### _________________________________________________________Xaw Plus

### The SimpleMenu Widget

Application Header file Class Header file Class Class Name Superclass | <X11/XawPlus/SimpleMenu.h> <X11/XawPlus/SimpleMenP.h> simpleMenuWidgetClass SimpleMenu OverrideShell

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.

### Differences between Xaw and XawPlus

In XawPlus the menus entries (the Sme objects) are drawn in a 3D styled menu window, supplied by this widget. For this feature SimpleMenu has some new resources described below.

### Resources

When creating a Simple widget instance, the following resources are retrieved from the argument list of XtSetValues() or XtVaSetValues() or from the resource database:

Name | Class | Type | Default Value
OBJECT: |  |  |
destroyCallback | Callback | Pointer | NULL
RECTANGLE: |  |  |
borderWidth height sensitive width x y | BorderWidth Height Sensitive Width Position Position | Dimension Dimension Boolean Dimension Position Position | 0 12 True 12 0 0
CORE: |  |  |
border background mappedWhenManaged | BorderColor Background MappedWhenManaged | Pixel Pixel Boolean | XtDefaultForeground grey75 True
SHELL: |  |  |
allowShellResize geometry overrideRedirect popdownCallback popupCallback saveUnder | AllowShellResize Geometry OverrideRedirect Callback Callback SaveUnder | Boolean String Boolean Callback Callback Boolean | True NULL see above see above see above True
SIMPLEMENU: |  |  |
backingStore menuOnScreen popupOnEntry cursor label labelClass rowHeight bottomMargin topMargin highlightColor shadowColor buttonBorderWidth | BackingStore MenuOnScreen PopupOnEntry Cursor Label LabelClass RowHeight VerticalMargins VerticalMargins Background Background Width | BackingStore Boolean Widget Cursor String Pointer Dimension Dimension Dimension Pixel Pixel Dimension | default True NULL None NULL (No label) smeBSBObjectClass Height of Font VerticalSpace VerticalSpace grey90 grey40 2

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 . 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.
geometry | If this resource is specified it will override the x, y, width and height of this widget. The format of this string is [<width>x<height>][{+ -} <xoffset> {+ -}<yoffset>].
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.
overrideRedirect | Determines the value of the override_redirect attribute of the SimpleMenu's window. The override_redirect attribute of a window determines whether or not a window manager may interpose itself between this window and the root window of the display. For more information see the Interclient Communications Conventions Manual.
popdownCallback, popupCallback | These callback functions are called by the Xt Intrinsics whenever the shell is popped up or down (See Xt for details).
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.
saveUnder | If this is True then save unders will be active on the menu's window.
highlightColor | This color is used for the highlighted part of the menu border.
shadowColor | This color is used for the shadowed part of the menu border.
buttonBorderWidth | The border width of the menu. The reason for the name is compatibility with the resource of the Simple widget.

### SimpleMenu Actions

The SimpleMenu widget supports the following actions:

- Switching the entry under the mouse pointer between the foreground and background colors with highlight and unhighlight
- Processing menu entry callbacks with notify

The following are the default translation bindings used by the SimpleMenu widget:

> <EnterWindow>: <LeaveWindow>: <BtnMotion>: <BtnUp>: | highlight() unhighlight() highlight() 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 Xt.

### 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 Xt. 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>: !Ctrl<Btn2Down>: | XawPositionSimpleMenu(xterm) MenuPopup(xterm) 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.

### Xaw Plus_________________________________________________________