Motif provides a widget, MainWindow, that serves as a template for the primary window of most applications. MainWindow is a subclass of ScrolledWindow. In addition to the viewport and ScrollBar components of the ScrolledWindow, MainWindow has an optional MenuBar, Command window, and Message window.
MainWindow lays out these components in a manner compliant with the Motif Style Guide specifications for the primary window of an application. The MenuBar, if present, spans the top of the MainWindow horizontally. By default, the Command window, if present, spans the MainWindow horizontally just below the MenuBar. The ScrolledWindow viewport and ScrollBars are below the Command window, and the Message window is below the ScrolledWindow viewport or horizontal ScrollBar. If the MainWindow resource XmNcommandWindowLocation is set to XmCOMMAND_BELOW_WORKSPACE at the time the MainWindow is created, the Command window is located below the ScrolledWindow viewport or horizontal ScrollBar.
If the MainWindow resource XmNshowSeparator is True, the MainWindow automatically creates up to three SeparatorGadgets to separate the components. The names of these automatically created SeparatorGadgets are "Separator1", "Separator2", and "Separator3". The application can retrieve the widget IDs of the SeparatorGadgets by using the functions XmMainWindowSep1, XmMainWindowSep2, and XmMainWindowSep3.
In addition to the ScrolledWindow resources that hold the widget IDs of the ScrollBars, scroll widget, and viewport widget, MainWindow has resources that hold the widget IDs of the other MainWindow components:
The value is the widget ID of the Command window. If a child is a Command widget and no Command window exists, MainWindow automatically sets the value of this resource to the child's widget ID.
The value is the widget ID of the MenuBar. If a child is a MenuBar and no MainWindow MenuBar exists, MainWindow automatically sets the value of this resource to the child's widget ID.
The value is the widget ID of the Message window. After creating the Message window, the application must use XtSetValues to set the value of this resource to the child's widget ID.
MainWindow has a convenience routine, XmMainWindowSetAreas, to establish both the MainWindow and the ScrolledWindow components. XmMainWindowSetAreas does not set the Message window; an application must use XtSetValues of XmNmessageWindow to set the Message window. An application that has no Message window and uses only standard components for the other MainWindow children may not need to call XmMainWindowSetAreas or XtSetValues for the component resources, but it is good practice to make these calls. If an application uses a Message window or has additional MainWindow children beyond the standard components, it must call XmMainWindowSetAreas and XtSetValues for XmNmessageWindow.
An application takes the following steps to use MainWindow:
For examples of using MainWindow with both automatic and application-defined scrolling policies, see the ScrolledWindow examples in the previous sections.