1 / 22

Building X Window GUIs with Motif

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. Two Simple Examples. The X Window System.

nealrobert
Download Presentation

Building X Window GUIs with Motif

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 1 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

  5. X Windows Architecture 2 Client request response Server event

  6. X Windows Architecture 3 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

  7. X Windows Architecture 4 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

  8. X Windows Architecture 5 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 Motif Xt Intrinsics Xlib

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

  11. Example 1

  12. See XMotifCode.doc (pages 1-5) for: • 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

  13. Example 2

  14. See XMotifCode.doc (pages 6-12) for: • 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

  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. Sample source code Source code for the two examples: eg1.c eg2.c together with a Makefile, is available from the CM212 / CM304 web page

  22. Reading and Reference Books The X Window SystemProgramming 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 ...

More Related