16.2.3 Option Menus
An OptionMenu is similar to a PulldownMenu in that they are both associated with CascadeButtons. However, there
are also several major differences between the two types of menus. In an OptionMenu, the CascadeButton is not part
of a MenuBar. Instead, it is created as the child of a RowColumn widget that also contains a Label.
Another difference is that the menu pops up on top of the CascadeButton, instead of dropping down from it. The label
on the CascadeButton is one of the elements in the menu; the CascadeButton displays the current menu selection. The
Motif toolkit handles the management of the PulldownMenu for the OptionMenu, so its handle is not available to you,
nor does it need to be. Because of the design of the OptionMenu, it cannot have cascading menus.
the source code demonstrates the use of XmVaCreateSimpleOptionMenu(). The program uses a DrawingArea
again, but now the user selects the drawing style from an OptionMenu that is displayed above the DrawingArea.
/* simple_option.c −− demonstrate how to use a simple option menu.
* Display a drawing area. The user selects the drawing style from
* the option menu.
*/
#include <Xm/RowColumn.h>
#include <Xm/MainW.h>
#include <Xm/ScrolledW.h>
#include <Xm/DrawingA.h>
#include <Xm/PushB.h>
main(argc, argv)
int argc;
char *argv[];
{
XmString draw_shape, line, square, circle;
Widget toplevel, main_w, rc, sw, drawing_a, option_menu, pb;
void option_cb(), exit();
XtAppContext app;
XtSetLanguageProc (NULL, NULL, NULL); ...