Presentation is loading. Please wait.

Presentation is loading. Please wait.

Building X Window GUIs with Motif The X Window System: Architecture Applications Sample code Review function (as time permits) … Introduce what it’s like.

Similar presentations


Presentation on theme: "Building X Window GUIs with Motif The X Window System: Architecture Applications Sample code Review function (as time permits) … Introduce what it’s like."— Presentation transcript:

1 Building X Window GUIs with Motif The X Window System: Architecture Applications Sample code Review function (as time permits) … Introduce what it’s like to build Motif applications, not a comprehensive course... … No advice on HCI design

2 Two Simple Examples...

3 The X Window System Developed at MIT; supported by DEC Now an industry standard, controlled by the X Consortium, for developing portable GUIs Available on most UNIX systems Philosophy of device independence and freedom from any particular style … History?

4 X Windows Architecture Application (client) Display (server) Server handles all input and output Client requests action to a window Communications obey the X protocol The terms display and server are equivalent for X Server can be an X-station can also be remote Display is not just a single screen Keyboard and mouse are also handled by the server 1

5 X Windows Architecture Client Server request event response 2

6 Almost all client requests involve windows Window concept much as in other systems Hierarchical organisation Windows do not have to be visible all the time May be obscured Window - or an ancestor - may not be mapped X Windows Architecture 3

7 Device independence means a client need not be concerned with the hardware on the server The application designer determines the user interface style No specific “look and feel” No enforcement of any particular policy “Mechanisms” for generating a variety of styles 4

8 5 X Windows Architecture Application programs use three levels of interface, the lowest being Xlib. Commonest Xlib interface is in C Programs can be large and difficult Most programs use higher-level toolkits: X Toolkit - Intrinsics layer Widget set - e.g. Motif Window Managers - e.g. Mwm - clients that manipulate windows

9 Client Program Structure Application Xlib Motif Xt Intrinsics

10 Xlib and Toolkits Windows, Graphics, colour etc. “Designer” Widgets Widget basics and event processing

11 Example 1

12 Sample code - 1 : Creating PushButton Sample code - 2 : Setting colour Sample code - 3 : Application setup (1) Sample code - 4 : Application setup (2) Sample code - 5 : Callback code See XMotifCode.doc (pages 1-5) for:

13 Example 2

14 Sample code - 6 : Application setup Sample code - 7 : Set / Get Resources Programming Model : Basic functions Programming Model in Example 1 Recap - 1 : Widgets Motif Widgets : /usr/include/Xm Widget Resources See XMotifCode.doc (pages 6-12) for:

15 The X Resource Manager … enables users to customise applications, because the programmer does not (always) get the user interface appearance or behaviour right! The resource database comprises information about the resources used in the application. It can also hold application-level resources. The Resource Manager has type converters: e.g. String to Fontstruct

16 Matching Rules X11cases*fontList applies to all XmStrings X11cases*button.fontList applies to the PushButton(s) X11cases.topForm.container.button.fontList is explicit “Application programmers should avoid specifying widget resource values in the program except where absolutely necessary to ensure that the application works correctly” - Douglas Young.

17 Recap - 2 Widget Creation Destroy Managing (and Mapping) Callbacks and Event Handlers Also … XmStrings Colormaps

18 Managing Widgets Parents manage their children ! Size, location, mapping, input focus Examples used: XtVaCreateManagedWidget() Convenient but not always the best way XmRowColumn is a Manager widget, which will organise its children. Example 2 forces a rearrangement XtCreateWidget() & XtManageChild()

19 Callbacks and Event Handlers Event Handlers are procedures called when a specified event occurs within a widget. e.g. ButtonRelease Callbacks are procedures called when a specified condition occurs within a widget. e.g. PushButton activate Both receive clientData from the application; Callbacks also receive callData.

20 Processing clientData void quitCallback( Widget w, XtPointer clientData, XtPointer callData ) { AppCtl * ctl = (AppCtl *)clientData ;... Often need to access more than one item... Temptation is to use global variables. Better to encapsulate application variables. typedef struct _AppCtl { XtAppContext context ; Display *display ; Colormap colormap ; Widget top ; } AppCtl ;

21 Source code for the two examples: eg1.c eg2.c together with a Makefile, is available from the CM212 / CM304 web page Sample source code

22 Reading and Reference Books The X Window System Programming and Applications with Xt OSF/Motif Edition Douglas A Young, Prentice-Hall The O’Reilly Books … X Protocol Reference Manual: Volume 0 Xlib Programming Manual: Volume 1 Xlib Reference Manual: Volume 2 X Toolkit Intrinsics Programming Manual: Volume 4 X Toolkit Intrinsics Programming Manual, Motif Edition: Volume 4M X Toolkit Intrinsics Reference Manual: Volume 5 Motif Programming Manual: Volume 6A Motif Reference Manual: Volume 6B … and there are many others...


Download ppt "Building X Window GUIs with Motif The X Window System: Architecture Applications Sample code Review function (as time permits) … Introduce what it’s like."

Similar presentations


Ads by Google