there would be no way to insert a tab character.) To traverse the tab groups in reverse, the SHIFT key is used with the
TAB key. Keyboard traversal wraps from the last item to the first item, both within a tab group and between tab
groups.
Although keyboard traversal is not completely controlled by manager widgets, they do play a pivotal role in
implementing it. A manager widget is typically initialized as a tab group; its primitive widget children are members of
the tab group. The Text and List widgets are exceptions to this rule. These widgets are set up as their own tab groups,
so that keyboard traversal can be used to move among the text in a Text widget or the items in a List widget. Within a
tab group, there is no sense of a manager−within−manager structure. The widget hierarchy is flattened out so that it
appears to the user that all of the controls in a window are at the same level.
Keyboard traversal only works if each widget in an interface cooperates. If a PushButton has the keyboard focus and
the user presses the TAB key, the internals of the PushButton widget are responsible for directing the focus to the next
tab group. Manager widgets play a key role in keyboard traversal because they are responsible for the keyboard events
that take place within gadgets. If an event occurs within a PushButton gadget, its manager parent is responsible for
directing the input focus to the next tab group.
Although the whole process of keyboard traversal may seem complex and difficult, it is automated by the Motif
toolkit and does not require application intervention. However, the toolkit does provide mechanisms that allow you to
control keyboard navigation. There are resources that allow you to specify widgets that are tab groups, widgets that
are in tab groups, and widgets that do not participate in keyboard navigation. There are also functions that allow you
to specify explicitly the direction of keyboard traversal. Fortunately, such fine−tuning is rarely necessary.
4.4 Putting Together a Complete Application
Managers and primitive widgets provide the basic tools with which you can build a graphical user interface from the
ground up. Motif also provides several components that address the large−scale organization of an application. The
specialized MainWindow manager widget is intended to be used as the organizing frame for an application. Motif also
provides different types of menus and dialog boxes that can be used to organize application functionality.
Since an application is always used in conjuction with a window manager, we need to discuss the role played by the
window manager. In the course of this discussion, we also need to take a closer look at shell widgets, since they
provide the communication link between an application and the window manager.
Both pixmaps and colors play an important role in a graphical user interface. Motif provides routines that cache
pixmaps so that they can be reused throughout an application. The three−dimensional appearance of Motif
components is implemented using a variety of color resources. It is important to understand these resources so that the
3D shadows are an effective part of the user interface.
4.4.1 The Main Window
Every application is different. A word processor, paint program, or spreadsheet typically has a single main work area,
with controls taking on a peripheral role, perhaps in PulldownMenus. More sophisticated programs, on the other hand,
may have several main work areas. For example, an electronic mail program may have a work area in which the user
reviews and selects from a list of incoming messages, another where she reads and responds to messages, and yet
another where she issues commands to organize, delete, or otherwise affect groups of messages. Still other
applications, such as data−entry programs, don't really have a separate work area. The work area is really just a
collection of controls, such as CheckBoxes and text entry areas, that are filled in by the user.
4 Overview of the Motif Toolkit4.4 Putting Together a Complete Application
59
It is quite conceivable that an application could provide multiple windows for performing different tasks. For
example, an order entry program might use one window for looking up a customer record, another for checking stock
on hand, and yet another for entering the current order. Motif allows for the creation of multiple top−level application
windows, as well as transient dialog boxes that ask for additional information or confirmation before carrying out a
command.
Nonetheless, every application has at least one main window. The main window is the most visible window in an
application. It is the first window the user sees and also the place where the user interacts with most application
functionality. No matter how small or large an application may be, there needs to be a focal point that ties it all
together. As a program grows more complex, the main window may grow more abstract and perform fewer functions,
but it always exists. In a sophisticated application, the main window is transformed into a hub where the user starts,
finishes, and returns again and again as she goes from one function to the next.
The Motif Style Guide suggests a particular layout for the main window. Applications should use this layout unless
they have a compelling reason not to. The recommended layout is shown in the figure.
Recommended layout for a main window
A main window should have a menu bar across the top, with the work area immediately below it. The work area
usually contains the main interface object of the application. For example, a paint or draw application might provide a
DrawingArea widget as a canvas, an electronic mail application might provide a ScrolledList of message summaries
from which the user can make selections, and a Text editor might place a Text widget in the work area. An application
work area might require a custom widget or a non−widget−based X window instead.
The work area can have both horizontal and vertical scrollbars allowing the user to view its entire contents if they are
too large to be displayed all at once. The main window can also contain an optional command area below the work
area, where the user can enter typed commands. This area is most helpful for porting character−based applications to a
Motif GUI, but it can be useful for other applications as well. At the bottom of the main window is an optional
message area. This area should be used for status and informational messages only, not for error messages or any
other type of message that requires a response from the user.
4 Overview of the Motif Toolkit4.4 Putting Together a Complete Application
60
Get Volume 6A: Motif Programming Manual now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.