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


A manager is a widget that usually contains children, either primitives or other managers. One responsibility of a manager is to position and shape its children so that the configuration of the children is appropriate for the manager's specialized purpose. Another responsibility is to determine whether a gadget child should process an input event and, if so, to dispatch the event to that child.

The XmManager Motif widget class is the superclass for all managers. XmManager is a subclass of Core. Like XmPrimitive, XmManager has resources to control colors or pixmaps used for the foreground, shadows, and highlighting rectangle. Most managers do not have shadows or highlighting rectangles, but gadget children inherit the related resources. Managers also have resources that control keyboard traversal, and they provide callbacks for processing user requests for help. In addition, they have translations and actions for dispatching input events to gadget children, usually to the child that is the current focus of keyboard events.

XmManager is not an instantiable widget class; it is used only as a subclass for other widgets. Motif has several specialized subclasses of managers, summarized in the following sections.


A Frame is a simple manager that surrounds a single child with a shadow and a margin. A Frame can also have another child that appears as a title for the Frame.

Frames are discussed in more detail in Chapter 8.


A Scale is a manager that functions as a control. It displays a value within a range and optionally allows the user to supply a new value. Its appearance and behavior are much like those of a ScrollBar without arrows. It also has a title and can display the current value next to the slider. If the application adds other children to a Scale, the Scale positions them evenly along the rectangular area that represents the range of values, and these children then act as tic marks or value labels.

Scales are discussed in more detail in Chapter 5.


A PanedWindow arranges its children vertically from top to bottom or horizontally, and forces them all to have the same width. Each child is a pane of the window. Between each pair of panes, PanedWindow inserts an optional Separator and a control called a sash. By manipulating a sash with the mouse or keyboard, the user can increase or decrease the height of the pane above. PanedWindow has resources to control the margins, the spacing between panes, and the appearance of the sashes. Each pane of a PanedWindow has resources specifying a maximum and minimum height and whether or not either the pane itself or the PanedWindow should be allowed to resize the pane without user intervention.

PanedWindow is discussed in more detail in Chapter 8.

ScrolledWindow and MainWindow

A ScrolledWindow manages a viewport and ScrollBars to implement a window onto a virtual scroll. The user can move the viewport to display different portions of the underlying scroll by using the ScrollBars or keyboard scrolling commands.

ScrolledWindow is capable of performing scrolling operations automatically. In this mode, the application creates the widget that represents the scroll as a child of the ScrolledWindow. The ScrolledWindow then creates a clipping window to act as the viewport, creates and manages the ScrollBars, and moves the viewport with respect to the scroll when the user issues a scrolling command.

ScrolledWindow can also allow the application to perform scrolling operations. In this mode, the application must create and manage the ScrollBars and must change the contents of the viewport in response to the user's scrolling commands.

List and Text widgets are often used as virtual scrolls. Motif has convenience routines to create List and Text widgets inside ScrolledWindows, and the resulting ScrolledList and ScrolledText widgets perform scrolling operations without intervention by the application.

MainWindow is a subclass of ScrolledWindow that is intended as the primary window in an application. In addition to a viewport and ScrollBars, MainWindow includes an optional MenuBar and an optional command window and message window.

The ScrolledWindow and MainWindow widgets are described in more detail in Chapter 8.


RowColumn implements both menus and nonmenu WorkAreas. Menus are widgets that allow the user to make choices among actions or states. Motif offers four basic kinds of menu:

  1. A MenuBar usually appears in the application's MainWindow and sometimes in other components. It most often consists of a row of CascadeButtons that, when activated, cause PulldownMenus to appear.

  2. A PopupMenu contains a set of choices that apply to a component of the application. The menu is not visible until the user takes an action that posts it. It can contain buttons that take action directly or CascadeButtons that cause PulldownMenus to appear.

  3. A PulldownMenu is associated with a CascadeButton in a MenuBar, a PopupMenu, or another PulldownMenu. The menu is not visible until the user posts it by activating the associated CascadeButton. Like a PopupMenu, a PulldownMenu can contain buttons that take action directly or CascadeButtons that cause other PulldownMenus to appear.

  4. An OptionMenu allows the user to choose among one set of choices, usually mutually exclusive attributes or states. It consists of a label, a CascadeButtonGadget whose label shows the currently selected option, and a PulldownMenu containing buttons that represent the set of options.

    One use for a nonmenu RowColumn WorkArea is to contain a set of ToggleButtons constituting a RadioBox or a CheckBox. When the user selects a ToggleButton, its state changes from on to off or from off to on. Another use is to lay out an arbitrary set of widgets in a row, column, or two-dimensional formation.

    RowColumn is discussed in more detail in Chapter 6.

  5. BulletinBoard, Form, MessageBox, SelectionBox

    Dialogs are container widgets that provide a means of communicating between the user and the application. A dialog widget usually asks a question or presents some information to the user. In some cases, the application is suspended until the user provides a response.

    The usual superclass for a dialog widget is XmBulletinBoard. The dialog widget can be either a BulletinBoard itself or one of its more specialized subclasses. BulletinBoard is a container with no automatically created children; it supplies general behavior needed by most dialogs. Its subclasses provide child widgets and specific behavior tailored to particular types of dialogs:

    1. A SelectionBox is a BulletinBoard subclass that allows the user to select a choice from a list. It usually contains a List, an editable text field displaying the choice, and three or four buttons for accepting or canceling the choice and seeking help.

    2. A FileSelectionBox is a specialized SelectionBox for choosing a file from a directory. It contains two text fields, one containing a file search pattern and the other containing the selected filename; two lists, one displaying filenames and the other displaying subdirectories; and a set of buttons.

    3. A Command is a specialized SelectionBox for entering a command. Its main components are a text field for editing the command and a list representing the command history.

    4. A MessageBox is a BulletinBoard subclass for displaying messages to the user. It usually contains a message symbol, a message label, and up to three buttons. Motif provides distinct symbols for several kinds of messages: errors, warnings, information, questions, and notifications that the application is busy.

    5. A TemplateDialog is a specialized MessageBox that allows the application to build a custom dialog with additional children, such as a MenuBar and added buttons.

    6. A Form is a BulletinBoard subclass that performs constraint-based geometry management. The children of a Form have resources that represent attachments to other children or to the Form, offsets from the attachments, and relative positions within the Form. The Form calculates the positions and sizes of its children based partly on these constraints. This layout function makes Form useful outside dialogs as well.

      Dialogs are discussed in more detail in Chapter 7.

    7. DrawingArea

      A DrawingArea is a manager suited for use as a canvas containing graphical objects. An application must interact with a DrawingArea at a somewhat lower level than with other Motif widgets, but a DrawingArea provides the application with more fine-grained information about events. DrawingArea has callbacks to notify the application when the widget is exposed or resized and when it receives keyboard or mouse input. An application generally must use Xlib routines to draw into the DrawingArea, and the application is responsible for updating the contents when necessary. The flexibility of a DrawingArea makes it a useful widget for implementing both graphical and text features not provided by other Motif widgets.

      DrawingArea is discussed in more detail in Chapter 15.


      A ComboBox widget combines the capabilities of a TextField widget and a List widget. It allows users to enter information via TextField and also provides a list of possible choices via List to complete the text entry field. The application provides an array of compound strings that will fill this list and can also set the number of items that are visible in the list. If there are more items in the list than are viewable (as defined by the value of the XmNvisibleItemCount resource), a vertical scrollbar appears that allows the user to scroll through the list. The list can be displayed at all times, or it can be dropped down by the user by clicking on the down arrow in a drop-down-style ComboBox.

      The TextField field in the ComboBox can be editable or non-editable. If the TextField field is editable, the user can type directly in the text field to enter a selection. If it is not editable, typing text may invoke a matching algorithm that will attempt to make a selection from the list using the characters typed by the user. In either case, list items can be selected using the keyboard and the mouse. When an item is selected, the item is displayed in reverse colors in the list and is displayed in the TextField field of the ComboBox.

      ComboBox is discussed in more detail in Chapter 6.

      Spin Boxes

      A SpinBox is a manager that functions as a control. It creates a pair of arrows that can be used to spin through a set of choices. The choices, which are usually related but mutually exclusive, are displayed consecutively one at a time in a single text field. Choices can be a range of numeric values or an ordered list of compound strings. The arrow buttons allow the user to advance or back up through the choices until the desired choice is displayed.

      SimpleSpinBox is a ready-to-use subclass of SpinBox. The text field for a SimpleSpinBox is created automatically.

      SpinBox and SimpleSpinBox are discussed in more detail in Chapter 6.


      A Container is a manager that accepts only widgets that are classes or subclasses of XmIconGadget as children. It arranges these children in different formats or views depending upon its resource settings, and allows selection and manipulation of the children.

      Container is discussed in more detail in Chapter 8.


      A Notebook is a manager that displays only one child at a time. Each child is assigned a page number in the Notebook and is displayed by user manipulation of tab buttons and page scrollers in the Notebook.

      Notebook is discussed in more detail in Chapter 8.

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