Dale Roberts Introduction to Visual Programming Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.

Slides:



Advertisements
Similar presentations
Chapter 16 Graphical User Interfaces John Keyser’s Modifications of Slides by Bjarne Stroustrup
Advertisements

Dale Roberts Introduction to Visual Programming Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
Lecture 2Slide 1 Event Driven Computing Basic Interaction Handling –Interactive programs - must pay attention to the user interface.
1 Chapter 7 Graphics and Event Handling. 2 Overview The java.awt and javax.swing packages and their subpackages support graphics and event handling. Many.
1 Chapter 1 Object-Oriented Programming. 2 OO programming and design Object-oriented programming and design can be contrasted with alternative programming.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Slides prepared by Rose Williams, Binghamton University Chapter 17 Swing I.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
1 Concurrent and Distributed Systems Introduction 8 lectures on concurrency control in centralised systems - interaction of components in main memory -
System Architecture Lecture 3 CSE 111 Spring /22/20151Copyright William E. Howden.
Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved.
Chapter 7 Improving the User Interface
Event-based Programming Roger Crawfis. Window-based programming Most modern desktop systems are window-based. Non-window based environment Window based.
Programming Paradigms Imperative programming Functional programming Logic programming Event-driven programming Object-oriented programming A programming.
Qt Igor November 8, 2002 Friday’s HENP Group Meeting.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 11 Slide 1 Architectural Design.
Lecture 7: Objects and Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
Software Construction Lecture 10 Frameworks
Welcome to CIS 083 ! Events CIS 068.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Lecture 5: Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 10Slide 1 Architectural Design l Establishing the overall structure of a software system.
Mr C Johnston ICT Teacher BTEC IT Unit 06 - Lesson 01 Introduction to Computer Programming.
FLTK Help Session By Richard Yu Gu CS 638 -Graphics Fall, 1999.
Computer Graphics I, Fall 2010 Input and Interaction.
C H A P T E R T E N Event-Driven Programming Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
Dale Roberts GUI Programming using Java - Event Handling Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
Dale Roberts GUI Programming using Java - Introduction Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 13 : Swing I King Fahd University of Petroleum & Minerals College of Computer Science.
Lecture 11: Exam Revision 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271  Coursework.
Python Programming Graphical User Interfaces Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
Computing Science 1P Lecture 17: Friday 23 rd February Simon Gay Department of Computing Science University of Glasgow 2006/07.
Object-Oriented Design Simple Program Design Third Edition A Step-by-Step Approach 11.
UHD::3320::CH121 DESIGN PHASE Chapter 12. UHD::3320::CH122 Design Phase Two Aspects –Actions which operate on data –Data on which actions operate Two.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Build-A-Button Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, October 8, 2003.
CITA 342 Section 2 Visual Programming. Allows the use of visual expressions (such as graphics, drawings, or animation) in the process of programming.
Program 2 due 02/01  Be sure to document your program  program level doc  your name  what the program does  each function  describe the arguments.
Programming in the Simple Raster Graphics Package (SRGP) Chapter 2.
GUIs Basic Concepts. GUI GUI : Graphical User Interface Window/Frame : a window on the screen Controls/Widgets : GUI components.
Dale Roberts Introduction to Visual Programming Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
Slide 1 Chapter 8 Architectural Design. Slide 2 Topics covered l System structuring l Control models l Modular decomposition l Domain-specific architectures.
12-Jun-16 Event loops. 2 Programming in prehistoric times Earliest programs were all “batch” processing There was no interaction with the user Input Output.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
1. 2 Qt Toolkit ● C++ toolkit for cross-platform GUI application development – GUI functions (GUI = graphical user interface) – Data access components,
Support for the Development of Interactive Systems
GUI Programming using Java - Key Events
GUI Design and Coding PPT By :Dr. R. Mall.
Introduction to Event-Driven Programming
Event loops 16-Jun-18.
Event Driven Programming Dick Steflik
CSC461 Lecture 8: Input Devices
Chap 7. Building Java Graphical User Interfaces
Graphical User Interfaces -- Introduction
Event Driven Programming
User Interface Software Look under the hood
Event loops.
GTK + Programming.
Event loops 17-Jan-19.
Event loops 17-Jan-19.
Event loops 8-Apr-19.
Tonga Institute of Higher Education
Event loops.
Event loops.
Event loops 19-Aug-19.
Presentation transcript:

Dale Roberts Introduction to Visual Programming Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science, School of Science, IUPUI Fall 2003

Dale Roberts Event Driven Processing Application Level Programming Uses widget sets and style guidelines to create application GUIs. Examples: Motif, MFC, Qt, GTK, etc. Graphical Systems Programmer Person who implements the widget sests and windowing systems above

Dale Roberts Programming Paradigms By now, you have been exposed to two programming paradigms: Functional Programming Object-oriented Programming Can you explain their differences in terms of: How to decompose a problem? How to express control?

Dale Roberts Functional Decomposition How do to decompose a problem? Top-down functional decomposition approach. Step-wise refinement Successive versions of algorithms written in pseudo-code Problem is divided into smaller subproblems Each “decomposition” is a function call. Keep decomposing until functions are close enough to target language to code. How do you express control? Each step is a function call. Flow of control statements are used within functions

Dale Roberts Object-Oriented Design How do to decompose a problem? Bottom-up building block approach. Identify objects needed to solve the problem. Create an Abstract Data Type implemented with objects Identify how values are represented in private data members. Define operations that act upon values as public member functions. Encapsulate implementation details within the class. How do you express control? Use UML to define relationships between classes. Flow-of-control between classes is relatively unstructured. Must still define a client that uses classes to solve a problem. Client is usually responsible for user-interaction, not classes. Stratifies application into presentation, processing, and data layers.

Dale Roberts Event-driven Programming Event-driven programming is the standard approach to creating graphical user interfaces (GUIs) An event-driven program is object-oriented Not a new programming “paradigm” Object-oriented programming was originally development to implement graphical objects within GUI operating systems However, top-level control is expressed differently The user is the top-level loop Think of Word, or a game program Every action in your program is a reaction to the user Decompose program in terms of “what will I do if the user does…” User inaction may trigger background actions (e.g. games)

Dale Roberts Detecting Asynchronous Events Polling Repeatedly read input devices in an infinite loop Interrupt-driven Hardware-triggered context-switching in response to user- events Event-driven Explicit event waiting Call-back functions (i.e. signals) in response to user events Qt uses event-driven processing.

Dale Roberts Method #1 Polling Interaction is governed by a simple loop: Loop forever: { read input respond to input } What limitations does this have? Does it have any advantages?

Dale Roberts Method #2 Interrupt-driven Processing Enable device, then proceed with “background” processing until an interrupt is received, at which point Save state (context-switch) Respond to input Restore state and go to step #2. What advantages/disadvantages does this have?

Dale Roberts Method #3: Event-driven Processing Interaction is once again governed by a loop: Loop forever: { if (event) then respond else do (one unit of) background processing or go to sleep (for one unit) }

Dale Roberts Event-driven Processing (cont) All major GUI packages (Motif, MGC, Qt, GTK, Java AWT, …) are event driven. Why? More portable than interrupt-driven. At the expense of what? More efficient than polling most do have polling commands Can rely on operating system to do time-slicing context-switching is very hardware/operating system specific.

Dale Roberts Events / Signals Any event-driven graphics package has devices that can signal events In old standards, this was limited to hardware devices In newer packages (e.g. Qt), any widget can signal events; the (hardware) mouse is the same as a (software) slider or button. Generally, the event tells you Which device/widget signaled the event Some “measure” giving the new state E.g., whether a mouse button was depressed or released Warning: old systems tend to use the term “events” while newer systems may call them signals (e.g. Qt)

Dale Roberts Call-back Functions / Slots A call-back function is an application-specific function called in response to an event In Qt, these are called “slots”, but this term is unique to Qt Generally, the “measure” of the event is passed as an argument The main loop of a GUI program is: Wait for an event Call the associated call-back function Return to the top of the loop

Dale Roberts GUI API Event Loops Loop forever: { if (input) then { find out which application receives the event; invoke the callback function; } else select one application with a background callback function; invoke background callback; }

Dale Roberts Pick Correlation The process of selecting which window (or application) an event belongs to is called pick correlation Pick correlation is usually object-oriented: Every window knows where its children are children send parents a message when they move, etc. The top-level window assigns events to children Child processes may handle the event through a call-back; or ask their children “is this yours”?

Dale Roberts Hiding the Main Loop Modern widget packages (like Qt) hide the main loop from the programmer. Programmers declare signals i.e. what events to respond to Programmers define slots i.e. how to respond to events Programmers connect signals to slots The main loop (wait for signal / call slot / loop) is part of the widget package Programmers call the main loop, but can’t alter it, other than through signals and slots

Dale Roberts Example: A Main Loop in Qt int main (int argc, char* argv[]) { QApplication app( argc, argv); QApplication app( argc, argv); GUI main( &app, &state) GUI main( &app, &state) app.setMainWidget( &main); app.setMainWidget( &main); main.Show(); main.Show(); return app.exec(); return app.exec();} Where’s the program? GUI is a widget. The GUI class defines signals and slots, and the GUI’s constructor connection them…

Dale Roberts What (really) are widgets? The objects in an object-oriented GUI are called widgets. Every widget: Knows its location (for pick correlation) Knows whether of not its visible Knows how to resize itself Knows how to redraw itself Knows its “children” widgets (if it’s a container) Has call-back functions (slots) for handling events (signals) Every window is a widget Not all widgets are windows

Dale Roberts Examples of widgets Text editing windows (canvases) Push buttons MenusSliders Radio buttons LED displays Borders

Dale Roberts Building a GUI Every application has a top-level widget In Qt, the top-level widget is called QApplication QApplication implements the main signal/slot loop QApplication is a widget but not a window QApplication in turn has a single top-level window Inside is a hierarchy of lesser widgets: frames, etc., for grouping and position widgets low-level widgets:buttons, pop-up menus, etc. Call-back functions (signals) are attached to implement responded to user actions Events are passed by the OS to the application’s top-level widget.

Dale Roberts Acknowledgements Some of the slides were originally written by J. Ross Beveridge, updated by Dale Roberts.