
XtRealizeWidget (toplevel);
XtAppMainLoop (app);
}
The code follows the steps that we just outlined. The MenuBar is created as a child of the MainWindow, and the
PulldownMenu is created as a child of the MenuBar. The CascadeButton acts as the File title item in the MenuBar, so
it is also created as the child of the MenuBar. Both the menu title and the PulldownMenu are children of the MenuBar.
The CascadeButton sets its XmNsubMenuId resource to the PulldownMenu so that when the button is selected, it
knows which PulldownMenu to display. When you create a PulldownMenu using the simple menu creation routine, it
sets this resource behind the scenes.
We also set the label of the CascadeButton using the XmNlabelString resource. This value is a compound string,
just as in the simple creation function. If we had not set the label directly, the name of the widget itself would appear
as the label, and we could override it with a specification in a resource file. Since we are not using the simple creation
routine, we can choose whether or not we hard−code the label for the CascadeButton. After we create the items in the
menu, we manage the MenuBar using XtManageChild(). The output of the source code both before and after the
PulldownMenu is posted, is shown in the figure.
Output of file_menu.c
16.3.1 Menu Titles
The titles in a MenuBar are actually the labels of the CascadeButtons. The labels can be specified ...