WkImageToggleButton
WkImageToggleButtons have two states: on, and off. They call their valueChanged callback when their state changes. Image toggle buttons may have an image and/or text string for a label. The image and text labels may be layed out either vertically or horizontally. Different images and labels can be specified for the up state, the pressed state, the checked state and the disabled state.
Protocol
alignment: resourceValue
Sets the horizontal alignment for the widget's image.
check
Set the receiver's state to checked (true).
click
Programatically click the button.
drawPolicy: anInteger
Specifies the drawing policy used in rendering buttons. The drawing policy determines two things for a button:
1. how the button draws itself so it looks like a button;
2. how the button animates when pressed.
Default: XmFLATDRAWPOLICY (Flat)
Valid resource values:
XmSHADOWEDTWOSTATEDRAWPOLICY (Shadowed Two State) - Buttons are drawn with a 3D shadowed outline and exhibit a simple 2-state (OFF and ON) state rendering.
XmSHADOWEDTHREESTATEDRAWPOLICY (Shadowed Three State) - Buttons are drawn with a 3D shadowed outline and exhibit a 3-state (OFF, ON, and PRESSED) state rendering.
XmOUTLINEDRAWPOLICY (Outlined) - Buttons are drawn with a simple etched (non-shadowed) outline and exhibit a 2-state (OFF and ON) state rendering.
XmFLATDRAWPOLICY (Flat) - Buttons are drawn flat without a 3D shadow.
getState
Answer the state of the checkbox.
horizontalAlignment: anInteger
Specifies the horizontal alignment for the widget's image.
Default: XmALIGNMENTBEGINNING (Left)
Valid resource values:
XmALIGNMENTBEGINNING (Left) - Causes the center of the image to be horizontally aligned with the left edge of the widget's window.
XmALIGNMENTCENTER (Center) - Causes the center of the image to be horizontally aligned in the center of the widget's window.
XmALIGNMENTEND (Right) - Causes the center of the image to be horizontally aligned with the right edge of the widget's window.
image: anImage
Set the image of the receiver.
indicatorType: anInteger
Specifies if the indicator is a 1-of or N-of indicator.
Default: XmNOFMANY (N-of-Many)
Valid resource values:
XmNOFMANY (N-of-Many) - Causes the ToggleButton to act like a CheckBox
XmONEOFMANY (1-of-Many) - Causes the ToggleButton to act like a RadioButton
labelCheckedPixmap: anImage
Specifies the renderable object (pixmap) which draws on the face of the widget when it is checked.
labelCheckedString: aString
Specifies the renderable object (string) which draws on the face of the widget when it is checked.
labelInsensitivePixmap: anImage
Specifies the renderable object (image) which draws on the face of the widget when it is disabled.
labelInsensitiveString: aString
Specifies the renderable object (string) which draws on the face of the widget when it is disabled.
labelPressedPixmap: anImage
Specifies the renderable object (image) which draws on the face of the widget when it is pressed.
labelPressedString: aString
Specifies the renderable object (string) which draws on the face of the widget when it is pressed.
labelPixmap: anImage
Specifies the renderable object (image) which draws on the face of the widget.
labelString: aString
Specifies the renderable object (string) which draws on the face of the widget.
mnemonic: aCharacter
Provides the user with alternate means for selecting a button.
orientation: anInteger
Specifies whether the image and label are displayed vertically or horizontally.
Default: XmHORIZONTAL (Horizontal)
Valid resource values:
XmVERTICAL (Vertical) - Displays the image and label vertically.
XmHORIZONTAL (Horizontal) - Displays the image and label horizontally.
set: aBoolean
Displays the button in its selected state if set to true.
setState: newState notify: notify
Sets or changes the EwToggleButton's current state.
newState - Specifies a Boolean value that indicates whether the checkbox state is selected or unselected. If true, the button state is selected; if false, button state is unselected. notify - Indicates whether valueChangedCallback is it can be either true or false.
showAsDefault: anInteger
Specifies a shadow thickness for a second shadow to be drawn around the PushButton to visually mark it as a default button. When the resource is set to 0, the button appears as a normal button.
Default: 0 (Normal)
Valid resource values:
0 (Normal) - Causes the Button to look like a normal button
1 (Default) - Causes the Button to look like a default button
turnOff
Set the receiver's state to off (false).
turnOn
Set the receiver's state to on (true).
uncheck
Set the receiver's state to unchecked (false).
verticalAlignment: anInteger
Specifies the vertical alignment for the widget's image.
Default: XmALIGNMENTCENTER (Center)
Valid resource values:
XmALIGNMENTCENTER (Center) - Causes the center of the image to be vertically aligned in the center of the widget's window.
XmALIGNMENTTOP (Top) - Causes the top edge of the image to be vertically aligned with the top edge of the widget's window.
XmALIGNMENTBOTTOM (Bottom) - Causes the center of the image to be vertically aligned in the center of the widget's window.
Callbacks & Events
Arm Callback
These callbacks are triggered when the button is armed. Buttons are armed and appear pressed whenever the moused is pressed within the button and not yet released. If the mouse is moved outside of the button while still pressed, the button will be disarmed and appear unpressed. If the mouse is released while still in the button, the button is activated
Default Action Callback
These callbacks are triggered when the widget is double clicked.
Disarm Callback
These callbacks are triggered when the button is disarmed. Buttons are disarmed whenever the mouse is moved outside of the button after it has been armed. Moving the mouse back over the button while the mouse button is still down will cause the button to become rearmed.
Value Changed Callback
These callbacks are triggered when the checkbox value is changed.
Call data arguments:
set - a Boolean value indicating if the checkbox is toggle on (true) or off (false).
Editor
Border Width
Specifies the width of the border that surrounds the widget’s window on all four sides. The width is specified in pixels. A width of zero means that no border will show.
Border - Causes the widget to have a border.
No Border - Causes the widget to have no border.
Draw Policy
Specifies the drawing policy used in rendering buttons. The drawing policy determines two things for a button:
1. how the button draws itself so it looks like a button;
2. how the button animates when pressed.
Shadowed Two State - Buttons are drawn with a 3D shadowed outline and exhibit a simple 2-state (OFF and ON) state rendering.
Shadowed Three State - Buttons are drawn with a 3D shadowed outline and exhibit a 3-state (OFF, ON, and PRESSED) state rendering.
Outlined - Buttons are drawn with a simple etched (non-shadowed) outline and exhibit a 2-state (OFF and ON) state rendering.
Flat - Buttons are drawn flat without a 3D shadow.
Enabled
Determines whether a widget will react to input events. Disabled (insensitive) widgets do not react to input events.
Horizontal Alignment
Specifies the horizontal alignment for the widget's image.
Left - Causes the center of the image to be horizontally aligned with the left edge of the widget's window.
Center - Causes the center of the image to be horizontally aligned in the center of the widget's window.
Right - Causes the center of the image to be horizontally aligned with the right edge of the widget's window.
Label - Default
Specifies the default label string.
Label - Pressed
Specifies the label string when the widget is pressed.
Label - Disabled
Specifies the label string when the widget is disabled.
Label - Checked
Specifies the label string when the widget is checked.
Image - Default
Specifies the default label image.
Image - Pressed
Specifies the label image when the widget is pressed.
Image - Disabled
Specifies the label image when the widget is disabled.
Image - Checked
Specifies the label image when the widget is checked.
Mnemonic
Provides the user with alternate means for selecting a button.
Orientation
Specifies whether the image and label are displayed vertically or horizontally.
Vertical - Displays the image and label vertically.
Horizontal - Displays the image and label horizontally.
Set
Displays the button in its selected state if set to true.
Show As Default
Specifies a shadow thickness for a second shadow to be drawn around the PushButton to visually mark it as a default button. When the resource is set to 0, the button appears as a normal button.
Normal - Causes the Button to look like a normal button
Default - Causes the Button to look like a default button
Vertical Alignment
Specifies the vertical alignment for the widget's image.
Center - Causes the center of the image to be vertically aligned in the center of the widget's window.
Top - Causes the top edge of the image to be vertically aligned with the top edge of the widget's window.
Bottom - Causes the center of the image to be vertically aligned in the center of the widget's window.
Visible
Maps the widget (makes visible) as soon as it is both realized and managed, if set to True. If set to False, the client is responsible for mapping and unmapping the widget.
Example
The following example code creates a WkImageToggleButton where the image is composed of an icon (from a file) and a text label laid out vertically. This corresponds to the upper left image at the start of the WkImageToggleButton section.
aWkImageToggleButton := WkImageToggleButton
createWidget: 'aWkImageToggleButton'
parent: self form
argBlock: [:w | w
x: 52;
y: 44;
width: 136;
height: 80;
image: (WbLabeledImage stateDriven
image: (WbIcon fromFile: 'BALLOON.ICO')
label: 'Balloon';
orientation: XmVERTICAL;
yourself);
scale].
The next example code creates a WkImageToggleButton where the image is composed of an icon (from a file) and a text label laid out horizontally and the initial state has been set on. This corresponds to the lower right image at the start of the WkImageToggleButton section.
aWkImageToggleButton := WkImageToggleButton
createWidget: 'aWkImageToggleButton'
parent: self form
argBlock: [:w | w
x: 52;
y: 44;
width: 136;
height: 80;
image: (WbLabeledImage stateDriven
image: (WbIcon fromFile: 'BALLOON.ICO')
label: 'Balloon';
yourself);
orientation: XmHORIZONTAL;
set: true;
scale].