### _________________________________________________________Xaw Plus

### The MenuButton Widget

Application Header file Class Header file Class Class Name Superclass | <X11/XawPlus/MenuButton.h> <X11/XawPlus/MenuButtonP.h> menuButtonWidgetClass MenuButton Command

The MenuButton widget is an rectangular area, that contains a text label or bitmap image. When the pointer cursor is on the button, the button becomes highlighted. This highlighting indicates that the button is ready for selection. When a pointer button is pressed, the MenuButton widget will pop up the menu that has been named in the menuName resource.

### Differences between Xaw and XawPlus

Since the 3D extensions of Simple are inserted, the MenuButton widget has the additional resources highlightColor, shadowColor and buttonBorderWidth. The default background color is now grey75. These three colors and the width of the button border are used to draw the shape of a button with an inherited method of the Simple class. Since XawPlus only supply rectangular buttons, the resources shapeStyle and cornerRoundPercent (inherited from the Command widget class) lost their meaning.

The bitmap and leftBitmap resources now also provide support of XPM styled pixmaps. These resources are inherited from the Label widget class. Look there for a description of this new feature.

Since Command provides tooltips, this feature is also available in MenuButton. If a help text and useHelp is set in the resources, a help window is popped up afer 1.2 seconds when the mouse pointer stay over the widgets window.

### Resources

When creating a MenuButton 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
SIMPLE: |  |  |
cursor cursorName pointerColor pointerColorBackground insensitiveBorder international highlightColor shadowColor buttonBorderWidth | Cursor Cursor Foreground Background Insensitive International Background Background Width | Cursor String Pixel Pixel Pixmap Boolean Pixel Pixel Dimension | None NULL XtDefaultForeground XtDefaultBackground NULL False grey90 grey40 2
LABEL: |  |  |
font fontset encoding foreground internalHeight internalWidth justify resize truncateLabel truncLeftSide label leftBitmap leftClipMask bitmap clipMask | Font FontSet Encoding Foreground Height Width Justify Resize Truncate Truncate Label LeftBitmap LeftBitmap Pixmap Pixmap | XFontStruct* FontSet unsigned char Pixel Dimension Dimension XtJustify Boolean Boolean Boolean String Bitmap ClipMask Bitmap ClipMask | XtDefaultFont XtDefaultFontSet XawTextEncoding8bit XtDefaultForeground 2 4 XtJustifyCenter True True False NULL None None None None
COMMAND: |  |  |
helpText helpBackground useHelp highlightThickness highlightMode callback translations accelerators ancestorSensitive | Label Background Boolean Thickness Boolean Callback Translations Accelerators AncestorSensitive | String Pixel Boolean Dimension Boolean XtCallbackList TranslationTable AcceleratorTable Boolean | NULL LightGoldenrodYellow True 2 True NULL see doc or source NULL True
MENUBUTTON: |  |  |
menuName | MenuName | String | "menu"

menuName | The name of a popup shell to popup as a menu. The MenuButton will search for this name using XtNameToWidget starting with itself as the reference widget. If it is unsuccessful it will continue up the widget tree using each of its ancestors as the reference widget. If it is still unsuccessful it will print a warning message and give up. When the menu is found it will be popped up exclusive and spring_loaded. The MenuButton widget does not copy the value of this resource into newly allocated memory. The application programmer must pass the resource value in nonvolatile memory.

### MenuButton Actions

The MenuButton widget supports the following actions:

- Switching the button's interior between raised and sunken button shape with set,
  unset and reset.
- Processing application callbacks with notify
- Switching the internal border between highlighted and unhighlighted states with
  highlight and unhighlight.
- Popping up a menu with PopupMenu

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

> <EnterWindow> <LeaveWindow> <BtnDown> | highlight() reset() reset(), PopupMenu()

The full list of actions supported by MenuButton is:

highlight() | Displays the interior of the button in the raised style, if highlightMode is set to True. If not, the button is always displayed in the raised style. In this case highlight() has no meaning. Since XawPlus 2.0 the conditions WhenUnset and Always are not longer supported.
unhighlight() | Displays a flat border if highlightMode is set to True. If not, the button is displayed in the raised style. In this case unhighlight() has no meaning.
set() | Enters the set state, in which notify is possible. This action causes the button to display its interior in the sunken button style.
unset() | Cancels the set state and displays the interior of the button in the raised button style
reset() | Cancels any set or highlight and displays the interior of the toggle in the flat style if highlightMode is set to True. If not, the toggle is displayed in the raised style.
notify() | When the button is in the set state this action calls all functions in the callback list named by the callback resource. The value of the call_data argument passed to these functions is undefined.
PopupMenu() | Pops up the menu specified by the menuName resource.

The MenuButton widget does not place a server grab on itself. Instead, PopupMenu is registered as a grab action. As a result, clients which popup menus without using XtMenuPopup or MenuPopup or PopupMenu in translations will fail to have a grab active. They should make a call to XtRegisterGrabAction on the appropriate action in the application initialization routine, or use a different translation.

### Xaw Plus_________________________________________________________