1 Lecture 10: Toolkits: Intrinsics, Callbacks, Resources, Widget hierarchies, Geometry management Brad Myers 05-830 Advanced User Interface Software.

Slides:



Advertisements
Similar presentations
1 Applets Programming Enabling Application Delivery Via the Web.
Advertisements

Introduction to Java 2 Programming
Java GUI building with the AWT. AWT (Abstract Window Toolkit) Present in all Java implementations Described in (almost) every Java textbook Adequate for.
Tk. Toolkit n Wish - windowing shell –touch fileName –chmod +x fileName –xedit fileName & –#!/usr/local/bin/wish n Widgets - eg Buttons, Labels, Frames.
Tk Widgets This material is best on several sources –Slides by Dr. Ernest J. Friedman-Hill –various Tcl/Tk books.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
Java Swing Toolkit Graphics The key to effectively using graphics in Java is understanding: –the basic components of the graphics library –the patterns.
Applets. The Applet Class public class MyApplet extends java.applet.Applet {... /** The no-arg constructor is called by the browser when the Web page.
Review of Java Applets Vijayan Sugumaran Decision and Information Sciences Oakland University.
Flowchart Start Input weight and height
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 16 Applets.
18-Jun-15 Applets. 2 An applet is a program that is typically embedded in a Web page and can be run from a browser You need special HTML in the Web page.
Swing CS-328 Dick Steflik John Margulies. Swing vs AWT AWT is Java’s original set of classes for building GUIs Uses peer components of the OS; heavyweight.
Chapter 14 Applets. 2 Knowledge Goals Understand the differing roles of applications and applets Understand how a browser operates Understand the role.
CS3157 Java UI Recitation. Material Covered: Overview of AWT components, Event Handling, creating applets, and sample UI. Not covered in recitation: Drawing,
28-Jun-15 Applets. 2 An applet is a program that is typically embedded in a Web page and can be run from a browser You need special HTML in the Web page.
The Composite Pattern.. Composite Pattern Intent –Compose objects into tree structures to represent part-whole hierarchies. –Composite lets clients treat.
Introduction To Form Builder
Object-Oriented Analysis and Design
A Simple Motif Widget The basic steps involved in creating and displaying this or any other Motif widget are essentially the same. This is a shell widget.
1 Standard Widget Toolkit. 2 SWT l a widget toolkit for Java developers l provides a portable API and tight integration with the underlying native OS.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L05 (Chapter 16) Applets.
Introduction to Java Swing “We are the sultans of swing” – Mark Knopfler.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
Java Programming Chapter 10 Graphical User Interfaces.
Applets, AWTS CompSci 230 Software Construction.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 16: Java Applets & AWT Fundamentals of Web Programming.
Software Construction Lecture 10 Frameworks
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 --
Applets Life Cycle Drawing and Event Handling Methods for UI Components Applet Capabilities Example.
FLTK Help Session By Richard Yu Gu CS 638 -Graphics Fall, 1999.
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
More on Hierarchies 1. When an object of a subclass is instantiated, is memory allocated for only the data members of the subclass or also for the members.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
SWING IF YOU GET LOST - IMPORTANT LINKS  Swing articles:
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
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.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
Lecture 10: Toolkits: Intrinsics, Callbacks, Resources, Widget hierarchies, Geometry management Brad Myers Advanced User Interface Software 1© 2013.
Dale Roberts Introduction to Visual Programming Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
1 Java Swing - Lecture 2 Components and Containment Boriana Koleva
1 Lecture 2: Overview of UI Software and Tools Brad Myers Advanced User Interface Software.
Java Applets: GUI Components, Events, Etc. Ralph Westfall June, 2010.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
Chapter 14 Applets and Advanced GUI  The Applet Class  The HTML Tag F Passing Parameters to Applets F Conversions Between Applications and Applets F.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
May 12, 1998CS102-01Lecture 7-3 Building GUIs in Java I CS Lecture 7-3 A picture's worth a thousand words.
Graphics Concepts CS 2302, Fall /17/20142 Drawing in Android.
Software Engineering Lecture 8 Object-Oriented Analysis.
9-Nov-97Tri-Ada '971 TASH An Alternative to the Windows API TRI-Ada ‘97 Terry J. Westley
Graphics Programming with Python. Many choices Python offers us several library choices:  Tkinter  WxPython  PyQt  PyGTK  Jython  And others...
Layout How multiple components are composed to build interfaces.
GUIs Basic Concepts. GUI GUI : Graphical User Interface Window/Frame : a window on the screen Controls/Widgets : GUI components.
Review_6 AWT, Swing, ActionListener, and Graphics.
Chapter 5 Introduction To Form Builder. Lesson A Objectives  Display Forms Builder forms in a Web browser  Use a data block form to view, insert, update,
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
Brad Myers Advanced User Interface Software, Spring, 2017
Lecture 6: Window Manager Input Models
Ellen Walker Hiram College
Chap 7. Building Java Graphical User Interfaces
GUI Using Python.
Graphical User Interfaces -- Introduction
User Interface Software Look under the hood
Distributed Computing, M. L. Liu
This Week: Tkinter for GUI Interfaces Some examples
Distributed Computing, M. L. Liu
Jim Fawcett CSE776 – Design Patterns Summer 2003
Presentation transcript:

1 Lecture 10: Toolkits: Intrinsics, Callbacks, Resources, Widget hierarchies, Geometry management Brad Myers Advanced User Interface Software

2 Widgets as objects Menus, buttons, scrollbars Refresh themselves and handle input, redraw if change In Motif and Tk each widget is at least one window Also Motif has "gadgets" which aren't windows In Amulet, widgets are not windows Decorative lines, labels and boxes also are "widgets“

3 Intrinsics How the widgets are implemented Motif -- "fake" object system out of C (same in Andrew) Tk -- Tcl language Amulet -- Prototype-instance object system, constraints, Opal graphics model, Interactors input model, command objects

4 Resources Every parameter of widgets in Motif Passed as a parameter to the create routine, set afterwards, or read from a configuration file Called "options" by Tk Amulet doesn't support having them in a file Each resource has a default value defined by the class In an X file = appl.widget1.resource: value appl.widget1.widget2.resource: value *.resource: value "sensitive" to grey-out "resizable" for windows

5 Callbacks In Motif, associate C procedures with widgets Many different callbacks for the same widget create, start, abort, finish, destroy,... Registered (set) at widget creation time, invoked at run time Are "resources" There are also "actions" which are internal to the widget and called by events. Not usually set by programmers Parameters: widget, client data, value In tk, associate tcl script with "events" in widgets or the widget action if it has one In Amulet, invoke Command Objects on "interactors" or widget finish, and call-back is the DO method.

6 Widget Hierarchies Motif-Primitive adds 3-D shadow (picture) Label adds string or pixmap display Push-button adds accepting input Composite is for geometry management Constraint = how size and position of children managed Manager = 3D shadows Shell = windows Inheritance down the parent or class hierarchy Java object hierarchy contains about 2300 classes and 1000 interfaces See the list for How many are for Swing and AWT?

7 Geometry Management Widgets don't set their own location. Widgets put into special group objects called "geometry managers" that perform the layout by setting the component's positions and size Used in Motif and tk Each widget negotiates with parent for more room when resize

8 Motif Geometry Management Motif RowColumn - add widgets and it lays them out Treats all children the same, so not for ScrollBars (picture) Form - generic constrained layout Put extra resources on the children widgets "For details, see the Motif Reference Manual, because the complete behavior of Form is quite complicated." Each edge can be constrained at a position or offset from an edge of the Form at an offset from an edge of another widget percent of the way across the Form (edge, not center) a percent calculated based on the initial position If wrong, widgets are on top of each other

9 Motif Geometry Management Two phases: bottom up requesting size, then top down setting size. All done before windows are allocated Unnecessary complexity: "XmCreateMenuBar actually creates a RowColumn widget, but with some special resource settings.... The Motif widget creation routines often have names that are different from the widgets they create." (picture of code)

10 TK Geometry Management All widgets must be in a geometry manager, or else not displayed Any widget with any geometry manager Layout depends on widget specified sizes programmer specifications, size of geometry manager itself Widgets must adjust themselves to the size given Geometry manager requests size recursively

11 TK Geometry, Cont. Placer - specific location for each widget Each widget treated independently Place "anchor" in absolute coords or as a % of way across then say which part of object is at the anchor n, ne, e, se,... center Packer - "constraint based" specify position of each widget in available space side left, right, top, bottom fill x, -fill y stretch widget to fill available space Text Canvas - mix graphics and widgets

12 Amulet geometry management Group can have the Am_LAYOUT slot set with a constraint that depends on other slots Sets positions of parts by side effect Default layout routines: Horizontal and Vertical layout, for lists or tables. Rest done by arbitrary constraints

13 Standard Motif Application 1. Include Motif and widget header files 2. Initialize the toolkit: XtAppInitialize reads resources, creates server connection, returns top-level screen pointer 3. Create the widgets and put them in composites ("parent") "manage" the widgets (except when pop-ups) 4. Register call-backs with the widgets 5. "Realize" the top level widget Causes geometry management to be invoked 6. Start the main loop: XtAppMainLoop

14 Simple Hello World Program in Amulet #include main (void) { Am_Initialize (); Am_Screen.Add_Part (Am_Window.Create ("window").Set (Am_WIDTH, 200).Set (Am_HEIGHT, 50).Add_Part (Am_Text.Create ("string").Set (Am_TEXT, "Hello World!"))); Am_Main_Event_Loop (); Am_Cleanup (); }

15 Goodbye-world Amulet program with button #include main (void) { Am_Initialize (); Am_Screen.Add_Part (Am_Window.Create ("window").Set (Am_WIDTH, 200).Set (Am_HEIGHT, 50).Set (Am_FILL_STYLE, Am_Amulet_Purple).Add_Part (Am_Button.Create ("button").Set_Part(Am_COMMAND, Am_Quit_No_Ask_Command.Create().Set (Am_LABEL, "Goodbye, world!")))); Am_Main_Event_Loop (); Am_Cleanup (); }

16 Goodbye-world Amulet program without button #include Am_Define_Method (Am_Object_Method, void, quit_method, (Am_Object)) { cerr << "It was nice knowing you.\n" << flush; Am_Exit_Main_Event_Loop(); } main (void) { Am_Object inter; Am_Initialize (); Am_Screen.Add_Part(Am_Window.Create ("window").Set (Am_WIDTH, 200).Set (Am_HEIGHT, 50).Add_Part(Am_Text.Create ("string").Set (Am_TEXT, "Goodbye World!").Add_Part(inter = Am_One_Shot_Interactor.Create()) ) ); inter.Get_Part(Am_COMMAND) Set (Am_DO_METHOD, quit_method); Am_Main_Event_Loop (); Am_Cleanup (); }

17 Minimal Hello-World in Java as Applet using AWT import java.applet.Applet; import java.awt.Label; public class AWTHelloWorld extends Applet { public void init () { super.init (); add ( new Label ( "Hello World!" ) ); }

18 Java and Swing Applets Hello World: AWT HelloWorld Applet Swing HelloWorld Applet Goodbye World: AWT GoodbyeWorld Applet Swing GoodbyeWorld Applet` Swing GoodbyeWorld Applet