|
NAMEXmtMenu - easy-to-create menus.SYNOPSIS
DESCRIPTIONThe XmtMenu widget is a subclass of the XmRowColumn widget designed to make it easier to create menus and systems of menus. A Menu widget takes an array of XmtMenuItem structures on its XmtNitems resource and automatically creates the items (push buttons, toggle buttons, cascade buttons, labels, and separators) described by those structures. There is a resource converter that parses an intuitive menu description grammar and converts it to an array of these XmtMenuItem structures. XmtMenuItem structures, whether statically initialized in C or created by the resource converter, can specify other arrays of menu structures which describe the contents of sub-menus. The Menu widget will automatically create Menu widget children to display each of these sub-menus. Thus, it is possible to create an entire pulldown menu system by creating only the menu bar, and letting the Menu widget do the rest.The Menu widget has four constructor functions, each with somewhat different behavior. XmtCreateMenubar() creates a Menu widget configured as a menubar. XmtCreateMenuPane() creates a menu pane in a menu shell widget (it may share the menu shell with other panes). The resulting pane can be attached to any cascade button. XmtCreatePopupMenu() creates a menu shell and a menu pane to pop up in that shell, and registers an event handler to pop up the menu appropriately. XmtCreateOptionMenu() creates an XmOption Menu and a menu pane to pop up in it. This last constructor is less useful than the others; option menus are generally better handled by the XmtChooser widget. RESOURCES XmtMenu inherits the resources of the XmRowColumn class, and defines the following new resources:
Describing Menus The Menu widget creates a menu bar or menu pane described by an array of XmtMenuItem structures on the XmtNitems resource. This array may be specified from a resource file using the resource converter described in the next section, or it may be statically initialized from C code. The XmtMenuItems structure and related types are defined as follows in <Xmt/Menu.h>. See Chapter 22, Easy Menu Creation, for a complete explanation of how to initialize each of the fields of the structure. /* * This structure defines a single menu item. Initialize an array of * them in order to define a menubar or menu pane. */ typedef struct _XmtMenuItem {
} XmtMenuItem; /* These are the possible types of menu items */ typedef enum {
} XmtMenuItemType; /* These are flags for menu items. Add these to the type */
Note that the XmtMenuItem structure has both public fields which may be initialized, and private fields which are used internally by the Menu widget and should set or read by the programmer. The fields in an XmtMenuItems structure are arranged in most-commonly-used to least-commonly used order, so that for most menu items you need only initialize the first few fields you care about, and leave the others uninitialized. If your array of structures is declared static, then uninitialized fields will contain NULL, which is their proper value. The XmtMenu Grammar The Xmt library provides a String-to-XmtMenuItems converter for use with the Menu widget. If you register this converter by calling XmtRegisterMenuItemsConverter(), then you can specify the contents of a menubar or any of its menu panes with a single string resource in a resource file. The XmtMenu grammar was designed to be easily readable and intuitive. A BNF definition of the syntax appears below. Items within single quotes are terminal symbols of the grammar-keywords or punctuation that should appear exactly as shown. Items in italics are non-terminals-items that are defined elsewhere in the grammar, or which are implicitly defined. Items within curly braces are repeated zero or more times and items within square brackets are optional. Note that the grammar is case-sensitive and that all keywords begin with a capital letter. This means that keywords will not conflict with item or submenu names, which, by convention, begin with a lowercase letter. This summary of the grammar is provided here for reference. See Chapter 20, Easy Menu Creation for a semantic explanation of each of the syntactical elements of the grammar, and for examples menu descriptions that use the grammar.
CALLBACKS The Menu widget defines no new callback lists of its own. It does allow callback procedures and XtCallbackLists to be specified and registered on the menu item children it automatically creates, however. TRANSLATIONS The Menu widget inherits its translations from the XmRow Column widget class and does not add any new translations of its own. ACTIONS The Menu widget defines no new action procedures. SEE ALSOChapter 20, Easy Menu Creation,XmtCreateMenuPane(), XmtCreateMenubar(), XmtCreateOptionMenu(), XmtCreatePopupMenu(), XmtMenuActivateProcedure(), XmtMenuGetMenuItem(), XmtMenuInactivateProcedure(), XmtMenuItemGetState(), XmtMenuItemGetSubmenu(), XmtMenuItemGetWidget(), XmtMenuItemSetSensitivity(), XmtMenuItemSetState().
Visit the GSP FreeBSD Man Page Interface. |