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



Separating Interface from Application

A widely accepted principle of application design is that a core application should not rely on a specific user interface. Separating the application from the interface allows developers to work on the two components independently. It also allows the program to run with different interfaces without changes in the core application. This makes it easier to port the application to more than one interface and to experiment with different configurations of a single interface.

Many applications need to collect input from the user and to display output in some form. It may be easier to separate the core application from the user interface if the developer specifies a set of generic input and output routines along with any necessary data structures. If these generic interfaces have no dependence on specific user interfaces, they can be implemented in different ways for different interfaces without changing the core application. They form a module for communication between the core application and the interface.

The Motif implementation of the interface module consists of code to perform the following tasks:

  1. Initialize the Intrinsics

  2. Create the widget hierarchy

  3. Define callback procedures

  4. Make widgets visible

  5. Enter a loop that waits for and responds to user input

    These steps are explained in detail in Chapter 3.

    The User Interface Language (UIL) helps enforce the separation of the interface from the core application. With UIL, the developer defines widgets and their characteristics in a text file and then compiles the text file into a binary format. At run time, the application uses Motif Resource Manager (MRM) routines to retrieve the widget descriptions from the binary file, and MRM creates the widgets from these descriptions. The UIL file can also define data such as text strings and colors, and MRM can retrieve the data at run time.

    In this way, an application can remove the description of the widget hierarchy from the program code. In its source code, the application defines callback procedures and interacts with the widgets as if it were using the Motif toolkit alone. If the application has defined all the callback procedures it needs, a developer can change the widget hierarchy by editing and recompiling the UIL file without recompiling and relinking the source program.


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