[ Previous | Next | Contents | Glossary | Home | Search ]
Motif 2.1 Programmer's Guide

Chapter 4. Structure of a Program Using UIL and MRM

The User Interface Language (UIL) allows an application developer to separate the specification of particular widget hierarchies from the application source code. The application defines widgets and their characteristics in a text file, which the developer compiles into a User Interface Definition (UID) file in binary format. At run time the application, using Motif Resource Manager (MRM) routines, retrieves the widget descriptions from the binary file, and MRM creates the widgets from these descriptions. The application defines callback procedures and interacts with the widgets as if it were using the Motif toolkit alone.

UIL offers several advantages over toolkit-only applications:

  1. UIL enforces the separation of the user interface specification from the application.

  2. A developer can change the interface by editing and recompiling a text file without recompiling and relinking the application program.

  3. The UIL compiler generates warnings for errors that the developer otherwise would not discover until running the program, if then. For example, the UIL compiler checks the spelling of resource names.

  4. The toolkit may handle large databases more efficiently when they are represented as UID files rather than resource files.

    An application that uses UIL has two separate components: the UIL file and the application program.

    The UIL file consists mainly of definitions of the application's widget hierarchy. The declaration for each widget typically includes the following components:

    1. Widget type

    2. Widget children

    3. Initial resource values

    4. Declarations for callback procedures

      The UIL file can also define values for data such as compound strings, colors, and icons.

      The structure of the application program is similar to that of a toolkit-only program. The chief difference is that, instead of explicitly creating each widget, the program uses MRM routines to retrieve widget definitions from the UID file and to create the widgets themselves. The program might also use MRM routines to retrieve data values defined in the UIL file. An application program using UIL must take the following actions:

      1. Include the required header files

      2. Initialize the Intrinsics

      3. Initialize MRM

      4. Open the UID file

      5. Register the names of callback procedures and values of identifiers specified in the UID file

      6. Retrieve and create widgets and data defined in the UID file

      7. Close the UID file

      8. Define callback procedures

      9. Make the widgets visible

      10. Enter the event loop

      11. [ Previous | Next | Contents | Glossary | Home | Search ]