GUI And Web Programming

3y ago
20 Views
2 Downloads
500.21 KB
34 Pages
Last View : 3d ago
Last Download : 3m ago
Upload by : Kaden Thurman
Transcription

GUI and Web ProgrammingCSE 403(based on a lecture by James Fogarty)

Event-based programming

Sequential Programs

Interacting with the user 1. Program takes control2. Program does something3. Program asks for user input4. User provides input

The user as a file 1. Program takes control2. Program does something3. Program asks for file input4. File provides inputThe user is abstracted as a file(named STDIN)

Event-driven Programming User can provide input at any time User actions generate eventsmouse click/scroll/move, hover, key press, resizeEvent type button/position target

Event Queues

Event Queues How many event queues are there in moderndesktop GUI environments? How can we tell without knowing theimplementation details? What are the implications?

Interactive Software Loop

dispatch event(e)Keyboard,mouse,touchpad,accelerometer

dispatch event(e) Handlers (callbacks) are installed to registerinterest in some event type Dispatch notifies all handlers Also known as Publish/Subscribe, Observer

Model-View-Controller (MVC) (See CSE 510 slides; p22-31)

GUI Toolkits Reduce time necessary to create a UI Ready-made UI elements, events Windows Forms, GTK, QT, Cocoa, Swing, Web pages! (more on this later)

Typically, in a GUI Toolkit Model backed by database, objects inmemory, files View/Controller is merged Visual output based on tree of UI elementsand their properties

Simple UI

Less-simple UI

Painting UI elements Each UI element (component) is responsible fordrawing itself and its children Typically event-basedvoid OnPaint(GraphicsContext g)//paint myselffor (child in this.children) {child.paint(g);}}

When to paint? The application does not decide! UI toolkits keep track of screen damage Toolkit will call paint() as necessary to fix“damage” to the bitmap Delegation of this greatly simplifies GUIs

How does damage happen? By external (transparent) events– Mouse cursor, hidden window, overlap By dirtying part of the UI component tree– Component.invalidate() will damage the areaoccupied by the component, causing later repaint.

Routing user input/damage For mouse input, known as hit testing– Maps from an active pixel to a UI element For keyboard input, focus management– The element in “focus” receives keyboard events Delegation strategies vary per framework

Web (client) Programming

HTML / CSS HTML hypertext markup language A language for structuring and marking updocuments in a semantic way Similar to LaTeX, PostScript

JavaScript Dynamically-typed scripting language Prototype-based object system Highly flexible and dynamic Transmitted only in source form

DOM / CSS DOM document object model The abstract syntax tree of HTML Large API interacting with document tree CSS cascading style sheets– Properties for DOM nodes based on pattern matching

HTML JavaScript DOM A GUI toolkit, with some catches DOM serves as model, view, and controller Event handlers written in JavaScript Visual output derived from DOM node props– No paint method!

Demo: Web page DOM as HTML ASTTree structureDOM node - visual outputCSS matches on DOM nodesAssembled from many piecesDamage recompute styles, layout

Demo: Web application User input generates eventsEvent handlers installed per DOM nodeIncremental repaint of “damaged” areaAssembled from many pieces dynamically

AJAX? Asynchronous JavaScript and XML Supports loading JavaScript asynchronously– As opposed to forcing script load– Event/callback based

JavaScript Libraries? jQuery, Prototype, Scriptaculous Advantages:– Remove a lot of boilerplate DOM code– Alternate, browser-consistent API Disadvantages:– Difficult to debug a large library– Difficult to reuse code that uses one library

Pros and cons of web applications Pros:– Nothing to install, just need conformant browser– Easier to configure dynamically– Effortless “software update” Cons:– HTML/JS/DOM not intended for stateful apps– Usually requires internet connection– Less control over user experience

Web (server) Programming Can be implemented in any language– Popular: PHP, Ruby, Java, Python, Perl Web application does not care who speaks– Load balancing, proxies, firewalls All communication via HTTP requests– GET, POST, (PUT, DELETE)– Static resources and application requests

Web (server) Programming Each request is handled in isolation– But application itself must be highly concurrent,parallel to serve many users Step 1: Decode user request Step 2: Do something Step 3: Send response to user

Web (server) programming Architecture and protocols still fluid As always, many frameworks exist to easeapplication development Deserves its own lecture but.– Probably best to go read the web!

Bonus: Research Research at all points touching the web:– Debugging– Domain-specific languages– Application architecture– Testing– Performance– Security– HCI

HTML JavaScript DOM A GUI toolkit, with some catches DOM serves as model, view, and controller Event handlers written in JavaScript Visual output derived from DOM node props –No paint method!

Related Documents:

layout and the components of the GUI Changes to this file are made in the Layout Editor - .m file - contains the code that controls the GUI You can program the callbacks in this file using the M-file Editor 28 Creating a GUI Typical stages of creating a GUI are: 1. Designing the GUI 2. Laying out the GUI - Using the Layout Editor 3.

In Java, GUI programming is object-oriented programming. This chapter covers the basics of GUI programming. The discussion will continue in Chap-ter 12 with more details and with more advanced techniques. 6.1 The Basic GUI Application There are two basic types of GUI program in Java: stand-alone applications and applets.

User Interface Programming in C#: Basics and Events Chris North CS 3724: HCI GUI Development: Goals 1. General GUI pro grammin concepts GUI components, layouts Event-based programming Graphics D irec tM a npul o,Am MVC architectures Data-driven UIs 2. C#, .NET Windows Forms Events, delegates GDI Threads .

Use the Discovery tool to find the FieldServer, and launch the Web GUI from the Discovery tool. 3.3.2 Using the Web Browser to launch FS-GUI: If the IP address is known, it can be typed directly into the web browser, and FS-GUI will launch. Ethernet Port .

Java GUI libraries Swing: the main Java GUI library – Benefits: Features; cross-platform compatibility; OO design – Paints GUI controls itself pixel-by-pixel Does not delegate to OS’s window system Abstract Windowing Toolkit (AWT): Sun's initial GUI library – Maps Java code to each operating system's real GUI system

No change in API which Apps refer to Apps can use API of each GUI-lib. Each GUI-lib has layer to adapt to PF Can have many different GUI-libs without change of PF. HMI Apps App FW Layer Service Layer AppLayer GUI-library GUI-lib PAL(*) ForAGL PF *PF Adaptation Layer HMI-Server (e.g.

GUI‐related classes are defined primarily in the java.awt and the javax.swingpackages The Abstract Windowing Toolkit(AWT) was the original Java GUI package The Swing package provides additional and more versatile components Both packages are needed to create a Java GUI‐based program SEEM 3460 3

the GUI toolkit for Tcl/Tk. Tcl (pronounced "tickle" and is an acronym for Tool Command Language) is a popular scripting language in the domains of embedded applications, testing, prototyping, and GUI development. Tk on the other hand is an open source, multiplatform widget toolkit that is used by many different languages for building GUI programs.