SimpleMenu widget


Application Header file <Xraw/SimpleMenu.h>
Class Header file <Xraw/SimpleMenuP.h>
Class simpleMenuWidgetClass
Class Name SimpleMenu
Superclass OvverideShell --> Shell --> Core

The SimpleMenu widget is a container for the menu entries. It is a direct subclass of shell, and is usually created with XtCreatePopupShell. This is the only part of the menu that actually contains a window. The SimpleMenu serves as the glue to bind the individual menu entries together into a menu.


New Resources

The resources associated with the SimpleMenu widget control aspects that will affect the entire menu.

Name Class Type Notes Default Value
backingStore BackingStore BackingStore see below
bottomMargin VerticalMargins Dimension 0
cursor Cursor Cursor None
label Label String NULL
labelClass LabelClass Pointer SmeBSBObjectClass
menuOnScreen MenuOnScreen Boolean True
popupOnEntry PopupOnEntry Widget A Label or first entry
rowHeight RowHeight Dimension 0
topMargin VerticalMargins Dimension 0
backingStore Determines what type of backing store will be used for the menu. Legal values for this resource are NotUseful, WhenMapped, and Always. These values are the backing-store integers defined in <X11/X.h>. If default is specified (the default behavior) the server will use whatever it thinks is appropriate.
bottomMargin
topMargin
The amount of space between the top or bottom of the menu and the menu entry closest to that edge.
cursor The shape of the mouse pointer whenever it is in this widget.
label This label will be placed at the top of the SimpleMenu, and may not be highlighted. The name of the label object is menuLabel. Using this name it is possible to modify the label's attributes through the resource database. When the label is created, the label is hard coded to the value of label, and justify is hard coded as XtJustifyCenter.
labelClass Specifies the type of Sme object created as the menu label.
menuOnScreen If the menu is automatically positioned under the cursor with the XawPositionSimpleMenu action, and this resource is True, then the menu will always be fully visible on the screen.
popupOnEntry The XawPositionSimpleMenu action will, by default, popup the SimpleMenu with its label (or first entry) directly under the pointer. To popup the menu under another entry, set this resource to the menu entry that should be under the pointer, when the menu is popped up. This allows the application to offer the user a default menu entry that can be selected with out moving the pointer.
rowHeight If this resources is zero (the default) then each menu entry will be given its desired height. If this resource has any other value then all menu entries will be forced to be rowHeight pixels high.


SimpleMenu Actions

The SimpleMenu widget supports the following actions:

The following are the default translation bindings used by the SimpleMenu widget:
	<EnterWindow>:	highlight()
	<LeaveWindow>:	unhighlight()
	<BtnMotion>:	highlight()
	<BtnUp>:	MenuPopdown() notify() unhighlight()
The user can pop down the menu without activating any of the callback functions by releasing the pointer button when no menu item is highlighted.

The full list of actions supported by SimpleMenu is:
highlight() Highlight the menu entry that is currently under the pointer. Only a item that is highlighted will be notified when the notify action is invoked. The look of a highlighted entry is determined by the menu entry.
unhighlight() Unhighlights the currently highlighted menu item, and returns it to its normal look.
notify() Notifies the menu entry that is currently highlighted that is has been selected. It is the responsibility of the menu entry to take the appropriate action.
MenuPopdown(menu) This action is defined in X Toolkit Intrinsics.


Positioning the SimpleMenu

If the SimpleMenu widget is to be used as a pulldown menu then the MenuButton widget, or some other outside means should be used to place the menu when it is popped up.

If popup menus are desired it will be necessary to add the XawPositionSimpleMenu and MenuPopup actions to the translation table of the widget that will be popping up the menu. The MenuPopup action is described in X Toolkit Intrinsics. XawPositionSimpleMenu is a global action procedure registered by the SimpleMenu widget when the first one is created or the convenience routine XawSimpleMenuAddGlobalActions is called.

Translation writers should be aware that Xt does not register grabs on ``don't care'' modifiers, and therefore the left hand side of the production should be written to exclude unspecified modifiers. For example these are the translations needed to popup some of xterm's menus:

	!Ctrl<Btn1Down>: XawPositionSimpleMenu(xterm) MenuPopup(xterm)
	!Ctrl<Btn2Down>: XawPositionSimpleMenu(modes) MenuPopup(modes)

XawPositionSimpleMenu(menu) The XawPositionSimpleMenu routine will search for the menu name passed to it using XtNameToWidget starting with the widget invoking the action as the reference widget. If it is unsuccessful it will continue up the widget tree using each of the invoking widget's ancestors as the reference widget. If it is still unsuccessful it will print a warning message and give up. XawPositionSimpleMenu will position the menu directly under the pointer cursor. The menu will be placed so that the pointer cursor is centered on the entry named by the popupOnEntry resource. If the menuOnScreen resource is True then the menu will always be fully visible on the screen.


Convenience routines

Registering the global action routines

The XawPositionSimpleMenu action routine may often be invoked before any menus have been created. This can occur when an application uses dynamic menu creation. In these cases an application will need to register this global action routine by calling XawSimpleMenuAddGlobalActions:

void XawSimpleMenuAddGlobalActions(app_con)
	XtAppContext app_con;
app_con Specifies the application context in which this action should be registered.

This function need only be called once per application and must be called before any widget that uses XawPositionSimpleMenu action is realized.


Getting and clearing the current menu entry

To get the currently highlighted menu entry use XawSimpleMenuGetActiveEntry:
Widget XawSimpleMenuGetActiveEntry(w)
	Widget w;
w Specifies the SimpleMenu widget.

This function returns the menu entry that is currently highlighted, or NULL if no entry is highlighted.

To clear the SimpleMenu widget's internal information about the currently highlighted menu entry use XawSimpleMenuClearActiveEntry:

Widget XawSimpleMenuClearActiveEntry(w)
	Widget w;
w Specifies the SimpleMenu widget.

This function unsets all internal references to the currently highlighted menu entry. It does not unhighlight or otherwise alter the appearance of the active entry. This function is primarily for use by implementors of menu entries.


[Xraw home] [Xraw widget class hierarchy]
Vladimir T. Romanovski
romsky@hp1.oea.ihep.su