Next | Prev | Up | Top | Contents | Index

Buttons

Motif provides several different types of buttons, some of which are shown below.


xmPushButton

This moat script creates a standard push button:

#! /usr/sgitcl/bin/moat 
xtAppInitialize
xmMainWindow .main managed
xmPushButton .main.button managed -labelString "Push me"
. realizeWidget
. mainLoop

Figure 4-1 : xmPushButton This is a regular button, displaying a text or pixmap label, surrounded by a beveled shadow. Clicking the button changes shadows to give the impression that the button has been pushed. When the button is released, it reverts to its normal appearance. When focus is gained, for instance by tabbing, the button appears brighter (if it is sensitive). The default push buttons of a dialog can be specified by setting -showAsDefault to true, in which case an additional border is drawn using Motif margin resources:

#! /usr/sgitcl/bin/moat 
xtAppInitialize
xmMainWindow .main managed
xmPushButton .main.b managed -labelString "Push me" -showAsDefault true
. realizeWidget
. mainLoop

Figure 4-2 : xmPushButton as Default Table 4-24 lists the resources for xmPushButton.

xmPushButton Resources
Resource NameDefault ValueType or Legal Values
-armColorcomputedColor
-armPixmap3nonePixmap
-defaultButtonShadowThickness0Dimension
-fillOnArmTrueBoolean
-multiClick multiclick_discard, multiclick_keep
-showAsDefault0Dimension


xmArrowButton

This button contains an arrow, whose direction is given by the -arrowDirection resource.

#! /usr/sgitcl/bin/moat 
xtAppInitialize
xmBulletinBoard .top managed -width 110 -height 110
xmArrowButton .top.up managed -x 40 -y 10 -width 30 -height 30
xmArrowButton .top.left managed -x 10 -y 40 \
    -width 30 -height 30 -arrowDirection arrow_left
xmArrowButton .top.right managed -x 70 -y 40 \
    -width 30 -height 30 -arrowDirection arrow_right
xmArrowButton .top.down managed -x 40 -y 70 \
    -width 30 -height 30 -arrowDirection arrow_down
. realizeWidget
. mainLoop

Figure 4-3 : xmArrowButton Table 4-25 lists the resources for xmArrowButton.

xmArrowButton Resources
Resource NameDefault ValueType or Legal Values
-arrowDirection arrow_uparrow_up
arrow_down
arrow_left
arrow_right


xmToggleButton

This button displays a state in an on/off indicator. Usually, a toggle button consists of a square or diamond indicator with an associated label. The square or diamond is filled or empty to indicate whether the button is selected or unselected.

#! /usr/sgitcl/bin/moat 
xtAppInitialize
xmMainWindow .main managed
xmRowColumn .main.col managed -orientation vertical
xmToggleButton .main.col.one managed
xmToggleButton .main.col.two managed
xmToggleButton .main.col.three managed
. realizeWidget
. mainLoop

Figure 4-4 : xmToggleButton A set of buttons can be grouped into a manager with the -radioBehavior resource set to true, ensuring that only one of them can be selected at a given time. Radio buttons are represented with diamonds instead of squares.

#! /usr/sgitcl/bin/moat 
xtAppInitialize
xmMainWindow .main managed
xmRowColumn .main.col managed -orientation vertical -radioBehavior true
xmToggleButton .main.col.yes managed -set true
xmToggleButton .main.col.no managed
xmToggleButton .main.col.maybe managed
. realizeWidget
. mainLoop

Figure 4-5 : xmToggleButton with radioBehavior See the section "Manager Widgets" for more information about manager options. Table 4-26 lists the resources for xmToggleButton.

xmToggleButton Resources
Resource NameDefault ValueType or Legal Values
-fillOnSelectTrueBoolean
-indicatorOnTrueBoolean
-indicatorSizenoneDimension
-indicatorTypen_of_manyn_of_many
one_of_many
-selectColorcomputedColor
-selectInsensitivePixmapnonePixmap
-selectPixmapnonePixmap
-setFalseBoolean
-spacing4Dimension
-visibleWhenOffcomputedBoolean

Text widgets also inherit resources from the Core, Primitive, and Label classes, as shown in Table 4-27.

Button Widget Inherited Resources
Resource InheritedFrom Resource InheritedFrom
-accelerators (Core) -alignment (Label)
-backgroundPixmap (Core) -background (Core)
-borderColor (Core) -borderWidth (Core)
-bottomShadowColor (Primitive) -bottomShadowPixmap (Primitive)
-fontList (Label) -foreground (Primitive)
-height (Core) -highlightColor (Primitive)
-highlightOnEnter (Primitive) -highlightPixmap (Primitive)
-highlightThickness (Primitive) -labelPixmap (Label)
-labelString (Label) -labelType (Label)
-mappedWhenManaged (Core) -marginBottom (Label)
-marginHeight (Label) -marginLeft (Label)
-marginRight (Label) -marginRight (Label)
-marginTop (Label) -navigationType (Primitive)
-recomputeSize (Label) -sensitive (Core)
-shadowThickness (Primitive) -stringDirection (Label)
-topShadowColor (Primitive) topShadowPixmap (Primitive)
-translations (Core) -traversalOn (Primitive)
-unitType (Primitive) -width (Core)
-x (Core) -y (Core)

In addition to the usual helpCallback and destroyCallback, button widgets define additional methods, as listed in Table 4-28.

Button Widget Callbacks
Method name Why
armCallback Button pressed.
disarmCallback Button released, with the pointer still on it.
activateCallback Some event triggers the Activate function.

The toggle button also defines the %set callback substitution, which is replaced by the Boolean state of the button.


Next | Prev | Up | Top | Contents | Index