Page: 1 2 3 4 5 6

Chapter 4


Menus

The Athena widget set provides support for single paned non-hierarchical pop and pulldown menus. Since menus are such a common user interface tool, support for them must be provided in even the most basic widget sets. In menuing as in other areas, the Athena Widget Set provides only basic functionality.

Menus in the Athena widget set are implemented as a menu container (the SimpleMenu widget) and a collection of objects that comprise the menu entries. The SimpleMenu widget is itself a direct subclass of the OverrideShell widget class, so no other shell is necessary when creating a menu. The managed children of a SimpleMenu must be subclasses of the Sme (Simple Menu Entry) object.

The Athena widget set provides three classes of Sme objects that may be used to build menus.

SmeThe base class of all menu entries. It may be used as a menu entry itself to provide blank space in a menu. "Sme" means "Simple Menu Entry."
SmeBSB This menu entry provides a selectable entry containing a text string. A bitmap may also be placed in the left and right margins. "BSB" means "Bitmap String Bitmap."
SmeLineThis menu entry provides an unselectable entry containing a separator line.

The SimpleMenu widget informs the window manager that it should ignore its window by setting the Override Redirect flag. This is the correct behavior for the press-drag-release style of menu operation. If click-move-click or "pinable"' menus are desired it is the responsibility of the application programmer, using the SimpleMenu resources, to inform the window manager of the menu.

To allow easy creation of pulldown menus, a MenuButton widget is also provided as part of the Athena widget set.

Home


4.1. Using the Menus

The default configuration for the menus is press-drag-release. The menus will typically be activated by clicking a pointer button while the pointer is over a MenuButton, causing the menu to appear in a fixed location relative to that button; this is a pulldown menu. Menus may also be activated when a specific pointer and/or key sequence is used anywhere in the application; this is a popup menu(e.g. clicking Ctrl-<pointer button 1> in the common application xterm). In this case the menu should be positioned under the cursor. Typically menus will be placed so the pointer cursor is on the first menu entry, or the last entry selected by the user.

The menu remains on the screen as long as the pointer button is held down. Moving the pointer will highlight different menu items. If the pointer leaves the menu, or moves over an entry that cannot be selected then no menu entry will highlighted. When the desired menu entry has been highlighted, releasing the pointer button removes the menu, and causes any mechanism associated with this entry to be invoked.

Home


4.2. SimpleMenu Widget

Application<X11/Xaw/SimpleMenu.h>
Class Header file<X11/Xaw/SimpleMenP.h>
ClasssimpleMenuWidgetClass
Class NameSimpleMenu
SuperclassOverrideShell

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

4.2.1. Resources

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

NameClassTypeNotesDefaull Value
acceleratorsAcceleratorsAcceleratorTableNULL
ancestorSensitiveAnsestorSensitiveBooleanDTrue
allowShellResizeAllowShellResizeBooleanTrue
backgroundBackgroundPixelXtDefaultBaekground
backgroundPixmapPixmapPixmapXtUnspecifiedPixmap
backingStorebackingStoreBackingStoresee below
borderColorBorderColorPixelXtDefaultForeground
borderPixmapPixmapPixmapXlUnspecifiedPixmap
borderWidthBorderWidthDimension1
bottomMarginverticalMarginsDimension0
childrenReadOnlyWidgetListRNULL
createPopupChildProcCreatePopupChildProcFunctionNULL
colormapColormapColormapParent's Colormap
cursorCursorCursorNone
depthDepthintCParent's Depth
destroyCallbackCallbackXtCallbackListNULL
geometryGeometryStringNULL
heightHeightDimensionEnough space to contain all entries
labelLabelStringNULL
labelClassLabelClassPointerSmeBSBObjeclClass
mappedWhenManagedMappedWhenManagedBooleanTrue
menuOnScreenMenuOnScreenBooleanTrue
numChildrenReadOnlyCardinalR0
overrideRedirectOverrideRedireclBooleanTrue
popdownCallbackCallbackXtCallbackListNULL
popupCallbackCallbackXtCallbackListNULL
popupOnEntryPopupOnEntryWidgetALabel or first entry
rowHeightRowHeightDimension0
saveUnderSaveUnderBooleanFalse
screenScreenScreenRParent's Screen
sensitiveSensitiveBooleanTrue
topMarginVertical MarginsDimension0
translationsTranslationsTranslationTableSee below
visualVisualVisualCopyFromParent
widthWidthDimensionWidth of widest entry
xPositionPosition0
yPositionPosition0

acceleratorsA list of event to action bindings to be executed by this widget, even though the event occurred in another widget. (See the X Toolkit Intrinsics-C Language Interface for details).
ancestorSensitiveThe sensitivity state of the ancestors of this widget. A widget is insensitive if either it or any of its ancestors is insensitive. This resource should not be changed with XtSetValues, although it may be queried.
backingStoreDetermines 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>. A converter is registered for this resource that will convert the following strings: notUseful, whenMapped, always, and default. If default is specified (the default behavior) the server will use whatever it thinks is appropriate.
backgroundA pixel value which indexes the widget's colormap to derive the background color of the widget's window.
backgroundPixmapThe background pixmap of this widget's window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the background color.
borderColorA pixel value which indexes the widget's colormap to derive the border color of the widget's window.
borderPixmapThe border pixmap of this widget's window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color.
borderWidthThe width of this widget's window border.
bottom Margin
topMarginThe amount of space between the top or bottom of the menu and the menu entry closest to that edge.
childrenA list of all this composite widget's current children.
colormapThe colormap that this widget will use.
cursorThe shape of the mouse pointer whenever it is in this widget.
depthThe depth of this widget's window.
destroyCallbackAll functions on this list are called when this widget is destroyed.
geometryIf this resource is specified it will override the x, y, width and height of this widget. The format of this string is [<width>x<heigh>][{+ -} <offset>{+ -} <yoffset>] .
height
widthThe height and width of this widget in pixels.
labelThis 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.
labelClassSpecifies the type of Sme object created as the menu label.
mappedWhenManagedIf this resource is True, then the widget's window will automatically be mapped by the Toolkit when it is realized and managed.
menuOnScreenIf 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.
numChildrenThe number of children in this composite widget.
overrideRedirectDetermines 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 Inter-Client Communications Conventions Manual.
PopdownCallback
popupCallbackThese callback functions are called by the Xt Intrinsics whenever the shell is popped up or down (See X Toolkit Intrinsics-C Language Interface for details).
popupOnEnlryThe 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.
rowHeightIf 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.
saveUnderIf this is True<>/b then save unders will be active on the menu's window.
screenThe screen on which this widget is displayed. This is not a settable resource.
sensitiveWhether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.
translationsThe event bindings associated with this widget.
x
y
The location of the upper left outside corner of this widget in its parent.

4.2.2. 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-C Language Interface.

4.2.3. 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-C Language Interface. 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.

4.2.4. Convenience Routines

4.2.4.1. 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:

voidXawSimpleMenuAddGlobalActions(app_con)
XtAppContext app_con;

app_conSpecifies 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.

4.2.4.2. Getting and Clearing the Current Menu Entry

To get the currently highlighted menu entry use XawSimpleMenuGetActiveEntry:

Widget XawSimpleMenuGetActiveEntry(w)
Widget w;

wSpecifies 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;

wSpecifies 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.

Home


4.3. SmeBSB Object

Application Header file<X11/Xaw/SmeBSB.h>
Class Header file<X11/Xaw/SmeBSBP.h>
ClasssmeBSBObjectClass
Class NameSmeBSB
SuperclassSme

The SmeBSB object is used to create a menu entry that contains a string, and optional bitmaps in its left and right margins. Since each menu entry is an independent object, the application is able to change the font, color, height, and other attributes of the menu entries, on an entry by entry basis. The format of the string may either be the encoding of the 8 bit font utilized, or in a multi-byte encoding for use with a fontSet.

4.3.1. Resources

The resources associated with the SmeBSB object are defined in this section, and affect only the single menu entry specified by this object.

NameClassTypeNotesDefault Value
ancestorSensitiveAncestorSensitiveBooleanDTrue
callbackCallbackCallbackNULL
destroyCallbackCallbackXtCallbackListNULL
fontFontXFontStructXtDefaultFont
fontSetFontSetXFontSetXtDefaultFontSet
foregroundForegroundPixelXtDefaultForeground
heightHeightDimensionAFont height + vertSpace
internationalInternationalBooleanCFalse
justifyJustifyJustifyXtjustifyLeft
labelLabelStringNULL
leftBitmapLeftBitmapPixmapXtUnspecifiedPixmap
leftMarginleftMarginDimension4
rightBitmapRightBitmapPixmapXtUnspecifiedPixmap
rightMarginrightMarginDimension4
sensitiveSensitiveBooleanTrue
vertSpaceVertSpaceint25
widthWidthDimensionATextWidth + margins

ancestorSensitiveThe sensitivity state of the ancestors of this widget. A widget is insensitive if either it or any of its ancestors is insensitive. This resource should not be changed with XtSetValues, although it may be queried.
callbackAll callback functions on this list are called when the SimpleMenu notifies this entry that the user has selected it.
destroyCallbackAll functions on this list are called when this widget is destroyed.
fontThe text font to use when displaying the label, when the international resource is false.
fontSetThe text font set to use when displaying the label, when the internatonal resource is true.
foregroundA pixel value which indexes the SimpleMenu's colormap to derive the foreground color of the menu entry's window. This color is also used to render all 1's in the left and right bitmaps.
height
widthThe height and width of this widget in pixels. Keep in mind that the SimpleMenu widget will force the width of all menu entries to be the width of the longest entry.
internationalThis is a boolean flag, only settable at widget creation time. A value of false signals the widget to use pre-R6 internationalization (specifically, the lack thereof), such as using fonts for displaying text, etc. A value of true directs the widget to act in an internationalized manner, such as utilizing font sets for displaying text, etc.
justifyHow the label is to be rendered between the left and right margins when the space is wider than the actual text. This resource may be specified with the values XtJustifyLeft, XtJustifyCenter, or XtJustifyRight. When specifying the justification from a resource file the values left, center, or right may be used.
labelThis is a the string that will be displayed in the menu entry. The exact location of this string within the bounds of the menu entry is controlled by the leftMargin, rightMargin, vertSpace, and justify resources.
leftBitmap
rightBitmapThis is a name of a bitmap to display in the left or right margin of the menu entry. All 1's in the bitmap will be rendered in the foreground color, and all 0's will be drawn in the background color of the SimpleMenu widget. It is the programmers' responsibility to make sure that the menu entry is tall enough, and the appropriate margin wide enough to accept the bitmap. If care is not taken the bitmap may extend into another menu entry, or into this entry's label.
leftMargin
rightMarginThis is the amount of space (in pixels) that will be left between the edge of the menu entry and the label string.
sensitiveWhether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.
vertSpaceThis is the amount of vertical padding, expressed as a percentage of the height of the font, that is to be placed around the label of a menu entry The label and bitmaps are always centered vertically within the menu. The default value for this resource (25) causes the default height to be 125% of the height of the font.

Home


4.4. SmeLine Object

Application Header file<X11/Xaw/SmeLine.h>
Class Header file<X11/Xaw/SmeLineP.h>
ClasssmeLineObjectClass
Class NameSmeLine
SuperclassSme

The SmeLine object is used to add a horizontal line or menu separator to a menu. Since each SmeLine is an independent object, the application is able to change the color, height, and other attributes of the SmeLine objects on an entry by entry basis. This object is not selectable, and will not highlight when the pointer cursor is over it.

4.4.1. Resources

The resources associated with the SmeLine object are defined in this section, and affect only the single menu entry specified by this object.

NameClassTypeNotesDefault Value
destroyCallbackCallbackXtCallbackListNULL
foregroundForegroundPixelXtDefaultForeground
heightHeightDimensionlineWldth
internationalInternationalBooleanCFalse
lineWidthLineWidthDimension1
stippleStipplePixmapXtUnspecifiedPixmap
widthWidthDimension1

destroyCallbackAll functions on this list are called when this widget is destroyed.
foregroundA pixel value which indexes the SimpleMenu's colormap to derive the foreground color used to draw the separator line.
height
widthThe height and width of this widget in pixels. Keep in mind that the SimpleMenu widget will force all menu items to be the width of the widget entry. Thus, setting the width is generally not very important.
internationalThis is a boolean flag, only settable at widget creation time. While not utilized in this widget, it can and should be checked by any subclasses that have behavior that should vary with locale.
lineWidthThe width of the horizontal line that is to be displayed.
stippleIf a bitmap is specified for this resource, the line will be stippled through it. This allows the menu separator to be rendered as something more exciting than just a line. For instance, if you define a stipple that is a chain link, then your menu separators will look like chains.

Home


4.5. Sme Object

Application Header file<X11/Xaw/Sme.h>
Class Header file<X11/Xaw/SmeP.h>
ClasssmeObjectClass
Class NameSme
SuperclassRectObj

The Sme object is the base class for all menu entries. While this object is mainly intended to be subclassed, it may be used in a menu to add blank space between menu entries.

4.5.1. Resources

The resources associated with the SmeLine object are defined in this section, and affect only the single menu entry specified by this object. There are no new resources added for this class, as it picks up all its resources from the RectObj class.

NameClassTypeNoetsDefault Value
ancestorSensitiveAncestorSensitiveBooleanTrue
callbackCallbackXtCallbackListNULL
destroyCallbackCallbackXtCallbackListNULL
heightHeightDimension0
internationalInternalionalBooleanCFalse
sensitiveSensitiveBooleanTrue
widthWidthDimension1

ancestorSensitiveThe sensitivity state of the ancestors of this widget. A widget is insensitive if either it or any of its ancestors is insensitive. This resource should not be changed with XtSetValues, although it may be queried.
destroyCallbackAll functions on this list are called when this widget is destroyed.
height
widthThe height and width of this widget in pixels. Keep in mind that the SimpleMenu widget will force all menu items to be the width of the widest entry.
internationalThis is a boolean flag, only settable at widget creation time. While not utilized in this widget, it can and should be checked by any subclasses that have behavior that should vary with locale.
sensitiveWhether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.

4.5.2. Subclassing the Sme Object

To Create a new Sme object class you will need to define three class methods. These methods allow the SimpleMenu to highlight and unhighlight the menu entry as the pointer cursor moves over it, as well as notify the entry when the user has selected it. All of these methods may be inherited from the Sme object, although the default semantics are not very interesting.

Highlight( )Called to put the menu entry into the highlighted state.
Unhighlight( )Called to return the widget to its normal (unhighlighted) state.
Notify( )Called when the user selects this menu entry.

Other then these methods, creating a new object is straight forward. Here is some information that may help you avoid some common mistakes.

1)Objects can be zero pixels high.
2)Objects draw on their parent's window, therefore the Drawing dimensions are different from those of widgets. For instance, y locations vary from y to y + height, not 0 to height.
3)XtSetValues calls may come from the application while the Sme is highlighted, and if the SetValues method returns True, will result in an expose event. The SimpleMenu may later call the menu entry's unhighlight procedure. However, due to the asynchronous nature of X, the expose event generated by XtSetValues will come after this unhighlight.
4)Remember that your subclass of the Sme does not own the window. Share the space with other menu entries, and refrain from drawing outside the subclass's own section of the menu.

Home


4.6. MenuButton Widget

Application Header file<X11/Xaw/MenuButton.h>
Class Header file<X11/Xaw/MenuButtonP.h>
ClassmenuButtonWidgetClass
Class NameMenuButton
SuperclassCommand

The MenuButton widget is an area, often rectangular, that displays a graphic. The graphic may be a text string containing multiple lines of characters in an 8 bit or 16 bit character set (to be displayed with a font), or in a multi-byte encoding (for use with a fontset). The graphic may also be a bitmap or pixmap.

When the pointer cursor is on a MenuButton widget, the MenuButton becomes highlighted by drawing a rectangle around its perimeter. This highlighting indicates that the MenuButton is ready for selection. When a pointer button is pressed, the MenuButton widget will pop up the menu named in the menuName resource.

4.6.1. Resources

When creating a MenuButton widget instance, the following resources are retrieved from the argument list or from the resource database:

NameClassTypeNotesDefault Value
acceleratorsAcceleratorsAcceleratorTableNULL
ancestorSensitiveAncestorSensitiveBooleanDTrue
backgroundBackgroundPixelXtDeafaultBackgtround
backgroundPixmapPixmapPixmapXtUnspecifiedPixmap
bitmapBitmapPixmapNone
borderColorBorderColorPixelXtDefaultForegrownd
borderPixmapPixmapPixmapXtUnspecifiedPixmap
borderWidthBorderWidthDimension1
callbackCallbackXtCallbackListNULL
colormapColormapColormapParent's Colormap
comerRowndPercentCornerRoundPcrcentDimension25
cursorCursorCursorNone
cursorNameCursorStringNone
depthDepthintCParent's Depth
destroyCallbackCallbackXtCallbackListNULL
encodingEncodingUnsignedCharXawTextEncoding8bi
fontFontXFontStructXtDefaultFont
fontSetFontSetXFontSetXtDefaultFontSet
foregroundForegroundPixelXtDefaultForegrownd
heightHeightDimensionAgraphic height + 2 * internalHeight
highlightThicknessThicknessDimensionA2 (0 if Shaped)
insensitiveBorderInsensitivePixmapGreyPixmap
internalHeightHeightDimension2
internalWidthWidthDimension4
internationalInternationalBooleanCFalse
justifyJustifyJustifyXtJustifyCenter (center)
labelLabelStringname of widget
leftBitmapLehtBitmapBitmapNone
mappedWhenManagedMappedWhenManagedBooleanTrue
menuNameMenuNameString"menu"
pointerColorForegroundPixelXtDefaultForegrownd
pointerColorBackgrowndBackgroundPixelXtDefaultBackgrownd
resizeResizeBooleanTrue
screenScreenScreenRParent's Screen
sensitiveSensitiveBooleanTrue
shapeStypeShapeStyleShapeStyleRectangle
translationsTranslationsTranslationTableSee below
widthWidthDimensionAgraphic width + 2 * internalWidth
xPositionPosition0
yPositionPosition0

acceleratorsA list of event to action bindings to be executed by this widget, even though the event occurred in another widget. (See the X Toolkit Intrinsics-C Language Interface for details).
ancestorSensitiveThe sensitivity state of the ancestors of this widget. A widget is insensitive if either it or any of its ancestors is insensitive. This resource should not be changed with XtSetValues, although it may be queried.
backgroundA pixel value which indexes the widget's colormap to derive the back ground color of the widget's window.
backgroundPixmapThe background pixmap of this widget's window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the background color.
bitmapA bitmap to display instead of the label. The default size of the widget will be just large enough to contain the bitmap and the widget's internal width and height. The resource for this resource constructs bit maps from the contents of files. (See section 2.5.3, Bitmap Conversion, for details.) If this bitmap is one bit deep then the 1's will be rendered in the fore ground color, and the 0's in the background color. If bitmap has a depth greater than one, it is copied directly into the window.
borderColorA pixel value which indexes the widget's colormap to derive the border color of the widget's window.
borderPixmapThe border pixmap of this widget's window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color.
borderWidthThe width of this widget's window border.
callbackA list of routines to be called when the notify acdon is invoked.
colormapThe colormap that this widget will use.
cornerRoundPercentWhen a ShapeStyle of roundedRectangle is used, this resource controls the radius of the rounded corner. The radius of the rounded corners is specified as a percentage of the length of the shortest side of the widget.
cursorThe image that will be displayed as the pointer cursor whenever it is in this widget. The use of this resource is deprecated in favor of cursorName.
cursorNameThe name of the symbol to use to represent the pointer cursor. This resource will override the cursor resource if both are specified. (See 2.5.1)
destroyCallbackAll functions on this list are called when this widget is destroyed.
fontThe text font to use when displaying the label, when the international resource is false.
fontSetThe text font set to use when displaying the label, when the international resource is true.
foregroundA pixel value which indexes the widget's colormap to derive the foreground color of the widget's window. This color is also used to render all l's in a bitmap one plane deep.
height
widthThe height and width of this widget in pixels.
highlightThicknessThe thickness of the rectangle that is used to highlight the internal border of this widget, alerting the user that it is ready to be selected. The default value is 2 pixels if the shapeStyle is rectangle, and 0 Pixels (no highlighting) otherwise.
insensitiveBorderThis pixmap will be titled into the widget's border if the widget becomes insensitive.
internalHeight
internalWidth
The minimum amount of space to leave between the graphic and the vertical and horizontal edges of the window.
internationalThis is a boolean flag, only settable at widget creation time. A value of false signals the widget to use pre-R6 internationalization (specifically, the lack thereof), such as using fonts for displaying text, etc. A value of true directs the widget to act in an internationalized manner, such as utilizing font sets for displaying text, etc.
justifySpecifies left, center, or right alignment of graphic within the widget. This resource may be specified with the values XtJustifyLeft, XtJustifyCenter, or XtJustifyRight. A converter is registered for this resource that will convert the following strings: left, right, and center. This resource only has noticeable effect when the width of the widget is larger than necessary to display the graphic. Note that when the graphic is a multi-line label, the longest line will obey this justification while shorter lines will be left-justified with the longest one.
labelSpecifies the text string to be displayed in the widget's window if no bit map is specified. The default is the name of this widget. Irregardless of the value of encoding or international, a single newline character ( 1 byte) will cause a line break.
mappedWhenManagedIf this resource is True, then the widget's window will automatically be mapped by the Toolkit when it is realized and managed.
menuNameThe 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 the search is unsuccessful the widget will continue up the widget tree using each of its ancestors as the reference widget passed to XtNameToWidget. If no widget of called menuName is found by this algorithm, the widget 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.
pointerColorA pixel value which indexes the widget's colormap to derive the fore ground color of the pointer symbol specified by the cursorName resource.
pointerColorBackgroundA pixel value which indexes the widget's colormap to derive the background color of the pointer symbol specified by the cursorName resource.
resizeSpecifies whether the widget should attempt to resize to its preferred dimensions whenever its resources are modified with XtSetValues. This attempt to resize may be denied by the parent of this widget. The parent is always free to resize the widget regardless of the state of this resource.
screenThe screen on which this widget is displayed. This is not a settable resource.
sensitiveWhether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.
shapeStyleNonrectangular widgets may be created using this resource. Nonrectangular widgets are supported only on a server that supports the Shape Extension. If nonrectangular widgets are specified for a server lacking this extension, the shape is ignored and the widgets will be rectangular. The following shapes are currently supported: XmuShapeRectangle, XmuShapeOval, XmuShapeEllipse, and XmuShapeRoundedRectangle. A converter is registered for this resource that will convert the following strings: rectangle, oval, ellipse, and roundedRectangle.
translationsThe event bindings associated with this widget.
x
yThe location of the upper left outside corner of this widget in its parent.

4.6.2. MenuButton Actions

The MenuButton widget supports the following actions:

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

<EnterWindow>:highlight( )
<LeaveWindow>:reset( )
<BtnDown>:reset( ) PopupMenu( )

4.6.3. MenuButton Actions

The full list of actions supported by MenuButton is:

highlight(condition)Displays the internal highlight border in the color (foreground or background ) that contrasts with the interior color of the Command widget. The conditions WhenUnset and Always are understood by this action procedure. If no argument is passed, WhenUnset is assumed.
unhighlight( )Displays the internal highlight border in the color (XtNforeground or background) that matches the interior color of the MenuButton widget.
set( )Enters the set state, in which notify is possible. This action causes the button to display its interior in the foreground color. The label or bitmap is displayed in the background color.
unset( )Cancels the set state and displays the interior of the button in the background color. The label or bitmap is displayed in the foreground color.
reset( )Cancels any set or highlight and displays the interior of the button in the background color, with the label displayed in the foreground color.
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 in these callback 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.

Home

Contents Previous Chapter Next Chapter