XmToggleButton(Xm) UNIX System V
NAME
XmToggleButton - the ToggleButton widget class.
SYNOPSIS
#include <Xm/ToggleB.h>
DESCRIPTION
ToggleButton sets nontransitory state data within an
application. Usually this widget consists of an indicator
(square or diamond) with either text or a pixmap to its
right. However, it can also consist of just text or a
pixmap without the indicator.
The toggle graphics display a 1-of-many or N-of-many
selection state. When a toggle indicator is displayed, a
square indicator shows a N-of-many selection state and a
diamond indicator shows a 1-of-many selection state.
ToggleButton implies a selected or unselected state. In the
case of a label and an indicator, an empty indicator (square
or diamond shaped) indicates that ToggleButton is
unselected, and a filled indicator shows that it is
selected. In the case of a pixmap toggle, different pixmaps
are used to display the selected/unselected states.
Normally, mouse button 1 is used to arm and activate the
button. However, if the ToggleButton resides within a menu,
then the mouse button used is determined by the RowColumn
resources XmNrowColumnType and XmNwhichButton.
To accommodate the toggle indicator when created, Label's
resource XmNmarginLeft may be increased.
Classes
ToggleButton inherits behavior and resources from Core,
XmPrimitive, and XmLabel Classes.
The class pointer is xmToggleButtonWidgetClass.
The class name is XmToggleButton.
New Resources
The following table defines a set of widget resources used
by the programmer to specify data. The programmer can also
set the resource values for the inherited classes to set
attributes for this widget. To reference a resource by name
or by class in a .Xdefaults file, remove the XmN or XmC
prefix and use the remaining letters. To specify one of the
defined values for a resource in a .Xdefaults file, remove
the Xm prefix and use the remaining letters (in either lower
case or upper case, but include any underscores between
words). The codes in the access column indicate if the
given resource can be set at creation time (C), set by using
XtSetValues (S), retrieved by using XtGetValues (G), or is
not applicable (N/A).
XmToggleButton Resource Set
Name Class Type Default Access
________________________________________________________________________________________________
XmNarmCallback XmCArmCallback XtCallbackList NULL C
XmNdisarmCallback XmCDisarmCallback XtCallbackList NULL C
XmNfillOnSelect XmCFillOnSelect Boolean True CSG
XmNindicatorOn XmCIndicatorOn Boolean True CSG
XmNindicatorType XmCIndicatorType unsigned char XmN_OF_MANY CSG
XmNselectColor XmCSelectColor Pixel dynamic CSG
XmNselectInsensitivePixmap XmCSelectInsensitivePixmap Pixmap XmUNSPECIFIED_PIXMAP CSG
XmNselectPixmap XmCSelectPixmap Pixmap XmUNSPECIFIED_PIXMAP CSG
XmNset XmCSet Boolean False CSG
XmNspacing XmCSpacing short 4 CSG
XmNvalueChangedCallback XmCValueChangedCallback XtCallbackList NULL C
XmNvisibleWhenOff XmCVisibleWhenOff Boolean True CSG
XmNarmCallback
Specifies the list of callbacks that is called when the
ToggleButton is armed. To arm this widget, press the
active mouse button while the pointer is inside the
ToggleButton. For this callback, the reason is
XmCRARM.
XmNdisarmCallback
Specifies the list of callbacks that is called when
ToggleButton is disarmed. To disarm this widget, press
and release the active mouse button while the pointer
is inside the ToggleButton. This widget is also
disarmed when the user moves out of the widget and
releases the mouse button when the pointer is outside
the widget. For this callback, the reason is
XmCRDISARM.
XmNfillOnSelect
Fills the indicator with the color specified in
XmNselectColor and switches the top and bottom shadow
colors when set to True. Otherwise, it switches only
the top and bottom shadow colors.
XmNindicatorOn
Specifies that a toggle indicator is drawn to the left
of the toggle text or pixmap when set to True. When
set to False, no space is allocated for the indicator,
and it is not displayed. If XmNindicatorOn is True,
the indicator shadows are switched when the button is
selected or unselected, but, any shadows around the
entire widget are not switched. However, if
XmNindicatorOn is False, any shadows around the entire
widget are switched when the toggle is selected or
unselected.
XmNindicatorType
Specifies if the indicator is a 1-of or N-of indicator.
For the 1-of indicator, the value is XmONEOFMANY.
For the N-of indicator, the value is XmNOFMANY. The
N-of-many is a square-shaped indicator. The 1-of-many
is a diamond-shaped indicator. This resource only
specifies the visuals and does not enforce the
behavior. When the ToggleButton is in a RadioBox, the
parent forces this resource to XmONEOFMANY.
XmNselectColor
Allows the application to specify what color fills the
center of the square or diamond indicator when it is
set. If this color is the same as either the top or
bottom shadow color of the indicator, a one-pixel-wide
margin is left between the shadows and the fill;
otherwise, it is filled completely. This resource's
default for a color display is a color between the
background and bottom shadow color. For a monochrome
display, the default is set to the foreground color.
XmNselectInsensitivePixmap
Specifies a pixmap used as the button face when the
ToggleButton is selected and the button is insensitive
if the Label resource XmNlabelType is set to XmPIXMAP.
If the ToggleButton is unselected and the button is
insensitive, the pixmap in XmNlabelInsensitivePixmap is
used as the button face.
XmNselectPixmap
Specifies the pixmap to be used as the button face if
XmNlabelType is XmPIXMAP and the ToggleButton is
selected. When the ToggleButton is unselected, the
pixmap specified in Label's XmNlabelPixmap is used.
XmNset
Displays the button in its selected state if set to
True. This shows some conditions as active when a set
of buttons first appear.
XmNspacing
Specifies the amount of spacing between the toggle
indicator and the toggle label (text or pixmap).
XmNvalueChangedCallback
Specifies the list of callbacks that is called when the
ToggleButton value is changed. To change the value,
press and release the active mouse button while the
pointer is inside the ToggleButton. This action also
causes this widget to be disarmed. For this callback,
the reason is XmCRVALUECHANGED.
XmNvisibleWhenOff
Indicates that the toggle indicator is visible in the
unselected state when the Boolean value is True. When
the ToggleButton is in a menu, the RowColumn parent
forces this resource to False. When the ToggleButton
is in a RadioBox, the parent forces this resource to
True.
Inherited Resources
ToggleButton inherits behavior and resources from the
following superclasses. For a complete description of these
resources, refer to the man page for that superclass.
XmLabel Resource Set
Name Class Type Default Access
______________________________________________________________________________________________________
XmNaccelerator XmCAccelerator String NULL CSG
XmNacceleratorText XmCAcceleratorText XmString NULL CSG
XmNalignment XmCAlignment unsigned char XmALIGNMENT_CENTER CSG
XmNfontList XmCFontList XmFontList "Fixed" CSG
XmNlabelInsensitivePixmap XmCLabelInsensitivePixmap Pixmap XmUNSPECIFIED_PIXMAP CSG
XmNlabelPixmap XmCPixmap Pixmap XmUNSPECIFIED_PIXMAP CSG
XmNlabelString XmCXmString XmString NULL CSG
XmNlabelType XmCLabelType unsigned char XmSTRING CSG
XmNmarginBottom XmCMarginBottom short 0 CSG
XmNmarginHeight XmCMarginHeight short 2 CSG
XmNmarginLeft XmCMarginLeft short dynamic CSG
XmNmarginRight XmCMarginRight short 0 CSG
XmNmarginTop XmCMarginTop short 0 CSG
XmNmarginWidth XmCMarginWidth short 2 CSG
XmNmnemonic XmCMnemonic char `\0' CSG
XmNrecomputeSize XmCRecomputeSize Boolean True CSG
XmNstringDirection XmCStringDirection XmStringDirection XmSTRING_DIRECTION_L_TO_R CSG
XmPrimitive Resource Set
Name Class Type Default Access
______________________________________________________________________________________
XmNbottomShadowColor XmCForeground Pixel dynamic CSG
XmNbottomShadowPixmap XmCBottomShadowPixmap Pixmap XmUNSPECIFIED_PIXMAP CSG
XmNforeground XmCForeground Pixel dynamic CSG
XmNhelpCallback XmCCallback XtCallbackList NULL C
XmNhighlightColor XmCForeground Pixel Black CSG
XmNhighlightOnEnter XmCHighlightOnEnter Boolean False CSG
XmNhighlightPixmap XmCHighlightPixmap Pixmap dynamic CSG
XmNhighlightThickness XmCHighlightThickness short 0 CSG
XmNshadowThickness XmCShadowThickness short 0 CSG
XmNtopShadowColor XmCBackground Pixel dynamic CSG
XmNtopShadowPixmap XmCTopShadowPixmap Pixmap XmUNSPECIFIED_PIXMAP CSG
XmNtraversalOn XmCTraversalOn Boolean False CSG
XmNunitType XmCUnitType unsigned char XmPIXELS CSG
XmNuserData XmCUserData caddr_t NULL CSG
Core Resource Set
Name Class Type Default Access
____________________________________________________________________________________
XmNaccelerators XmCAccelerators XtTranslations NULL CSG
XmNancestorSensitive XmCSensitive Boolean True G
XmNbackground XmCBackground Pixel dynamic CSG
XmNbackgroundPixmap XmCPixmap Pixmap XmUNSPECIFIED_PIXMAP CSG
XmNborderColor XmCBorderColor Pixel Black CSG
XmNborderPixmap XmCPixmap Pixmap XmUNSPECIFIED_PIXMAP CSG
XmNborderWidth XmCBorderWidth Dimension 0 CSG
XmNcolormap XmCColormap Colormap XtCopyFromParent CG
XmNdepth XmCDepth int XtCopyFromParent CG
XmNdestroyCallback XmCCallback XtCallbackList NULL C
XmNheight XmCHeight Dimension 0 CSG
XmNmappedWhenManaged XmCMappedWhenManaged Boolean True CSG
XmNscreen XmCScreen Pointer XtCopyScreen CG
XmNsensitive XmCSensitive Boolean True CSG
XmNtranslations XmCTranslations XtTranslations NULL CSG
XmNwidth XmCWidth Dimension 0 CSG
XmNx XmCPosition Position 0 CSG
XmNy XmCPosition Position 0 CSG
Callback Information
The following structure is returned with each callback:
typedef struct
{
int reason;
XEvent * event;
Boolean set;
} XmToggleButtonCallbackStruct;
reason Indicates why the callback was invoked.
event Points to the XEvent that triggered the callback.
set Reflects the ToggleButton's current state when the
callback occurred, either True (selected) or False
(unselected).
Behavior
ToggleButton is associated with the default behavior unless
it is part of a menu system. In a menu system, the
RowColumn parent determines which mouse button is used.
Default Behavior
<Btn1Down>:
(if unset): This action arms the ToggleButton widget.
The indicator shadow is drawn so that the button looks
depressed, and the indicator fills with the color
specified in XmNselectColor. The callbacks for
XmNarmCallback are also called.
(if set): This action arms the ToggleButton widget.
The indicator shadow is drawn so that the button looks
raised, and the indicator fills with the background
color. The callbacks for XmNarmCallback are also
called.
<Btn1Up>:
(In Button):
(if unset): This action selects the ToggleButton
widget. Visually, it appears the same as when it is
armed. The callbacks for XmvalueChangedCallback are
called, followed by callbacks for XmdisarmCallback.
(if set): This action unselects the ToggleButton
widget. Visually, it appears the same as when it is
armed. The callbacks for XmvalueChangedCallback are
called, followed by callbacks for XmdisarmCallback.
(Outside Of Button):
If the button release occurs outside of the
ToggleButton, the callbacks for XmNdisarmCallback are
called.
<Leave Window>:
If the button is pressed and the cursor leaves the
widget, it visually reverts to its previous unpressed
state.
<Enter Window>:
If the button is pressed and the cursor leaves and
reenters the widget, it visually appears the same as
when the button was first armed.
Default PopupMenu System
<Btn3Down>:
This action disables keyboard traversal for the menu
and returns the user to drag mode, which is the mode in
which the menu is manipulated by using the mouse. This
action also causes the ToggleButton to be armed. A
shadow is drawn around the ToggleButton. The callbacks
for XmNarmCallback are also called.
<Btn3Up>:
(if unset): This action selects the ToggleButton
widget. The indicator shadow is drawn so that it looks
depressed, and the indicator fills with the color
specified in XmNselectColor. The menu is then unposted
and the callbacks for XmvalueChangedCallback are
called, followed by callbacks for XmdisarmCallback.
(if set): This action unselects the ToggleButton
widget. The indicator shadow is drawn so that it looks
raised, and the indicator fills with the background
color. The menu is then unposted and the callbacks for
XmvalueChangedCallback are called, followed by
callbacks for XmdisarmCallback.
<Leave Window>:
Pressing button 3 and moving the cursor out of the
widget's window erases the shadow around the
ToggleButton. This event is ignored if keyboard
traversal is enabled in the menu.
<Enter Window>:
Pressing button 3 and moving the cursor into the
widget's window draws a shadow around the ToggleButton.
This event is ignored if keyboard traversal is enabled
in the menu.
<Key>Return:
If keyboard traversal is enabled in the menu, this
event sets or unsets the ToggleButton.
(if unset): The ToggleButton gets set. The indicator
shadow is drawn so that looks depressed, and the
indicator fills with the color specified in
XmNselectColor.
(if set): The ToggleButton gets unset. The indicator
shadow is drawn so that it looks raised, and the
indicator fills with the background color.
For both set and unset cases, the menu is then unposted
and the callbacks for XmvalueChangedCallback are
called, followed by callbacks for XmdisarmCallback.
Default Pulldown Menu System and OptionMenu System
<Btn1Down>:
This action disables keyboard traversal for the menu
and returns the user to drag mode (the mode in which
the menu is manipulated using the mouse). This action
also arms the ToggleButton. A shadow is drawn around
the ToggleButton. The callbacks for XmNarmCallback are
also called.
<Btn1Up>:
(if unset): This action selects the ToggleButton. The
indicator shadow is drawn so that it looks depressed,
and the indicator fills with the color specified in
XmNselectColor. The menu then unposts, and the
callbacks for XmvalueChangedCallback are called,
followed by callbacks for XmdisarmCallback.
(if set): This action unselects the ToggleButton. The
indicator shadow is drawn so that it looks raised, and
the indicator fills with the background color. The
menu then unposts, and the callbacks for
XmvalueChangedCallback are called, followed by
callbacks for XmdisarmCallback.
<Leave Window>:
Pressing button one and moving the cursor out of the
widget's window erases the shadow around the
ToggleButton. This event is ignored if keyboard
traversal is enabled in the menu.
<Enter Window>:
Pressing button one and moving the cursor into the
widget's window draws a shadow around the ToggleButton.
This event is ignored if keyboard traversal is enabled
in the menu.
<Key>Return:
This event sets or unsets the ToggleButton if keyboard
traversal is enabled in the menu.
(if unset): The ToggleButton gets set. The indicator
shadow is drawn so that it looks depressed, and the
indicator fills with the color specified in
XmNselectColor.
(if set): The ToggleButton gets unset. The indicator
shadow is drawn so that it looks raised, and the
indicator fills with the background color.
For both set and unset cases, the menu then unposts,
and the callbacks for XmvalueChangedCallback are
called, followed by callbacks for XmdisarmCallback.
Default Translations
When not in a menu system, the following are the default translations:
<Btn1Down>: Arm()
<Btn1Up>: Select()
Disarm()
<Key>Return: ArmAndActivate()
<Key>space: ArmAndActivate()
<EnterWindow>: Enter()
<LeaveWindow>: Leave()
When in a menu system, the following are the default translations:
<BtnDown>: BtnDown()
<BtnUp>: BtnUp()
<EnterWindow>: Enter()
<LeaveWindow>: Leave()
<Key>Return: KeySelect()
<Key>Escape: MenuShellPopdownDone()
Keyboard Traversal
When in a menu system, the following translations are added
to ToggleButton.
<Unmap>: Unmap()
<FocusOut>: FocusOut()
<FocusIn>: FocusIn()
<Key>space: Noop()
<Key>Left: MenuTraverseLeft()
<Key>Right: MenuTraverseRight()
<Key>Up: MenuTraverseUp()
<Key>Down: MenuTraverseDown()
<Key>Home: Noop()
For information on keyboard traversal when not in a menu,
see the man page for XmPrimitive(Xm) and its sections on
behavior and default translations.
RELATED INFORMATION
Core(Xm), XmCreateToggleButton(Xm), XmLabel(Xm),
XmPrimitive(Xm), XmRowColumn(Xm),
XmToggleButtonGetState(Xm), and XmToggleButtonSetState(Xm).
(printed 2/14/90) XmToggleButton(Xm)