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



Applications, Top-Level Widgets, and Dialogs

Primitives, managers, and shells are the components Motif provides for building an interface. A developer assembles these components into the broadest units of the program: dialogs, top-level widgets, and the application itself.

One approach to this construction is to specify the connection between the core application and the user interface. The developer determines what information the application needs to obtain from and present to the user. From this assessment, the developer specifies a generic interface to the application and then implements a Motif version using particular combinations of widgets.

Another approach is to design the user interface from the application level down to specific widgets. The developer decides what the top-level components of the application should be and how they relate to each other. From this assessment, the developer designs a combination of widgets that presents the application clearly to the user and permits a graceful transition from one task to another. The developer can then finely adjust the visual appearance of the interface.

In practice, a developer is likely to use both the bottom-up and top-down approaches at different stages of the program design. The approaches converge at the level of the application.

Applications

The application is the highest level of abstraction of a Motif program. In one sense the application embodies the entire program. In another sense, the application is the primary widget in the program. The user may cause other widgets to appear, but the application is the focus of activity and is usually the first widget to appear when the user starts the program.

The widget that represents the application is commonly a MainWindow. For many applications, the essential operations should be available from the MenuBar at the top of the MainWindow. By browsing through the MenuBar, the user can quickly determine what general functions the application provides. The activation callbacks for the buttons in menus that are pulled down from the MenuBar initiate the general operations of the application. The Motif Style Guide contains requirements and recommendations for the contents of the application MenuBar and its PulldownMenus.

The MainWindow usually contains a large scrollable work area. Single-component applications usually perform most of their work using this region. Other applications may require more than one work area.

An ApplicationShell encloses the main widget of an application. The developer can use the Xt function XtAppCreateShell to create an ApplicationShell directly or can let Xt create the shell during a call to XtAppInitialize.

Usually a program has only one application, but sometimes a program is made up of multiple logical applications. In this case, the program may have more than one main window, each enveloped in a separate ApplicationShell. Multiple ApplicationShells are also required for applications which use multiple displays.

Top-Level Widgets

Although it is unusual for a program to have more than one logical application, it is more common for an application to require multiple top-level widgets. For example, a mail-processing program may consist of a component for reading mail and another for composing and sending it.

Each major component of an application may reside in a top-level widget. Each top-level widget must be enclosed in a TopLevelShell or an ApplicationShell. One approach is to have a single ApplicationShell for the application, with each TopLevelShell a popup child of the ApplicationShell. The program does not create a window for the ApplicationShell. Another approach is to designate one top-level widget the application, enclosed in an ApplicationShell, and make the other TopLevelShells popup children of the ApplicationShell. A popup child is one whose window is a child of the root window and whose geometry is not managed by its parent widget.

Multiple top-level widgets are discussed in more detail in Chapter 3.

Dialogs

Dialogs are transient components used to display information about the current state of the application or to obtain specific information from the user. A dialog widget is usually a BulletinBoard or one of its subclasses, enclosed in a DialogShell. The DialogShell is a popup child of another widget in the hierarchy. Its window is a child of the root window, but the user cannot iconify a dialog separately from the main application.

A dialog can be modal--that is, it can prevent other parts of the application from processing input while the dialog is active. It can also be modeless so that the user can interact with the rest of the application while the dialog is visible. Motif has convenience routines that create both the dialog widget and the DialogShell for several kinds of information.

Dialogs are discussed in more detail in Chapter 7.


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