Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/widget_ref/pttogglebutton.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/widget_ref/pttogglebutton.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/widget_ref/pttogglebutton.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/widget_ref/pttogglebutton.html on line 8

PtToggleButton

A toggle switch that's either off or on

Class hierarchy:

PtWidgetPtBasicPtLabelPtButtonPtToggleButton

For more information, see the diagram of the widget hierarchy.

PhAB icon:

PtToggleButton button in PhAB

Public header:

<photon/PtToggleButton.h>

Description:

A PtToggleButton widget is like a toggle switch, although it behaves like a button. It has on and off states, and pressing the button inverts the current state of the button.


PtToggleButton


Various button styles supported by PtToggleButton.

Creating toggle buttons

Toggle buttons inherit resources from PtLabel and PtButton; specify the label for toggle buttons the way you do for these classes.

A toggle button is displayed as a button with a label beside it. The button is either set or unset, and you can control its appearance with the Pt_ARG_INDICATOR_COLOR and Pt_ARG_INDICATOR_TYPE resources. You can set the position of the text relative to the button with the Pt_ARG_BALLOON_POSITION resource.

You can also set Pt_ARG_ARM_COLOR, which specifies the fill color for the button's interior when the button is set. This resource is used only if the value of Pt_ARG_ARM_FILL is Pt_TRUE. These resources are inherited from PtButton.

To determine whether or not the button is set, check the:

Grouping toggle buttons

A group can control how several toggle buttons behave together. If you place the toggle buttons in a group and make them mutually exclusive, they behave like the channel-selector buttons on a car radio: only one of the buttons can be set at any given time, and setting any button automatically unsets the button that's currently set.

To make a group of toggle buttons mutually exclusive, set the Pt_GROUP_EXCLUSIVE bit in the group's Pt_ARG_GROUP_FLAGS resource. For example:

PtSetArg (&argt[n], Pt_ARG_GROUP_FLAGS, Pt_TRUE,
          Pt_GROUP_EXCLUSIVE );
n++;
PtSetArg (&argt[n], Pt_ARG_GROUP_ORIENTATION,
          Pt_GROUP_VERTICAL, 0 ) ;
n++;
group = PtCreateWidget (PtGroup, parent, n, argt );

PtSetArg (&argt[0], Pt_ARG_TEXT_STRING,
          "Button 1", 0 ) ;
button1 = PtCreateWidget (PtToggleButton, group,
                           1, argt ) ;

PtSetArg (&argt[0], Pt_ARG_TEXT_STRING,
          "Button 2", 0 ) ;
button2 = PtCreateWidget (PtToggleButton, group,
                          1, argt ) ;

PtSetArg (&argt[0], Pt_ARG_TEXT_STRING,
          "Button 3", 0 ) ;
button3 = PtCreateWidget (PtToggleButton, group,
                          1, argt ) ;

PtRealizeWidget ( group ) ;

You can use the same callback for all the buttons, but how do you determine which one is selected? There are several ways:

New resources:

Resource C type Pt type Default
Pt_ARG_INDICATOR_COLOR PgColor_t Scalar Pg_WHITE
Pt_ARG_INDICATOR_TYPE unsigned char Scalar Pt_TOGGLE_CHECK

Pt_ARG_INDICATOR_COLOR

C type Pt type Default
PgColor_t Scalar Pg_WHITE

The fill color for the toggle button's indicator. See PgColor_t in the Photon Library Reference.

Pt_ARG_INDICATOR_TYPE

C type Pt type Default
unsigned char Scalar Pt_TOGGLE_CHECK

Determines how the indicator is drawn. Possible values:

Here's how these types look, both set and unset:

PtToggleButton

Inherited resources:

If the widget modifies an inherited resource, the “Default override” column indicates the new value. This modification affects any subclasses of the widget.

Resource Inherited from Default override
Pt_ARG_ACCEL_KEY PtLabel
Pt_ARG_ANCHOR_FLAGS PtWidget
Pt_ARG_ANCHOR_OFFSETS PtWidget
Pt_ARG_AREA PtWidget
Pt_ARG_ARM_COLOR PtButton
Pt_ARG_ARM_IMAGE PtButton
Pt_ARG_ARM_FILL PtButton
Pt_ARG_BALLOON_COLOR PtLabel
Pt_ARG_BALLOON_FILL_COLOR PtLabel
Pt_ARG_BALLOON_POSITION PtLabel
Pt_ARG_BALLOON_TEXT PtLabel
Pt_ARG_BANDWIDTH_THRESHOLD PtBasic Not used by this class.
Pt_ARG_BASIC_FLAGS PtBasic
Pt_ARG_BEVEL_WIDTH PtWidget 0
Pt_ARG_BITMAP_CURSOR PtWidget
Pt_ARG_BEVEL_COLOR PtBasic
Pt_ARG_BEVEL_CONTRAST PtBasic
Pt_ARG_COLOR PtBasic
Pt_ARG_CONTRAST PtBasic
Pt_ARG_CURSOR_COLOR PtWidget
Pt_ARG_CURSOR_TYPE PtWidget
Pt_ARG_DARK_BEVEL_COLOR PtBasic
Pt_ARG_DARK_FILL_COLOR PtBasic
Pt_ARG_DATA PtWidget
Pt_ARG_DIM PtWidget
Pt_ARG_EFLAGS PtWidget
Pt_ARG_EXTENT PtWidget
Pt_ARG_FILL_COLOR PtBasic
Pt_ARG_FILL_PATTERN PtBasic
Pt_ARG_FLAGS PtWidget |=Pt_SELECTABLE|
Pt_TOGGLE
Pt_ARG_GRID_LAYOUT_DATA PtWidget
Pt_ARG_HEIGHT PtWidget
Pt_ARG_HELP_TOPIC PtWidget
Pt_ARG_HIGHLIGHT_ROUNDNESS PtBasic
Pt_ARG_HORIZONTAL_ALIGNMENT PtLabel
Pt_ARG_INLINE_COLOR PtBasic
Pt_ARG_LABEL_BALLOON PtLabel
Pt_ARG_LABEL_FLAGS PtLabel
Pt_ARG_LABEL_IMAGE PtLabel Not used by this class.
Pt_ARG_LABEL_TYPE PtLabel Not used by this class.
Pt_ARG_LAYOUT_DATA PtWidget
Pt_ARG_LIGHT_BEVEL_COLOR PtBasic
Pt_ARG_LIGHT_FILL_COLOR PtBasic
Pt_ARG_LINE_SPACING PtLabel
Pt_ARG_MARGIN_BOTTOM PtLabel
Pt_ARG_MARGIN_HEIGHT PtBasic
Pt_ARG_MARGIN_LEFT PtLabel
Pt_ARG_MARGIN_RIGHT PtLabel
Pt_ARG_MARGIN_TOP PtLabel
Pt_ARG_MARGIN_WIDTH PtBasic
Pt_ARG_MAXIMUM_DIM PtWidget
Pt_ARG_MINIMUM_DIM PtWidget
Pt_ARG_OUTLINE_COLOR PtBasic
Pt_ARG_POINTER PtWidget
Pt_ARG_POS PtWidget
Pt_ARG_RESIZE_FLAGS PtWidget
Pt_ARG_ROW_LAYOUT_DATA PtWidget
Pt_ARG_SECONDARY_H_ALIGN PtLabel
Pt_ARG_SECONDARY_V_ALIGN PtLabel
Pt_ARG_STYLE PtBasic
Pt_ARG_TEXT_FONT PtLabel
Pt_ARG_TEXT_IMAGE_SPACING PtLabel
Pt_ARG_TEXT_STRING PtLabel
Pt_ARG_TRANS_PATTERN PtBasic
Pt_ARG_UNDERLINE_TYPE PtLabel
Pt_ARG_UNDERLINE1 PtLabel
Pt_ARG_UNDERLINE2 PtLabel
Pt_ARG_USER_DATA PtWidget
Pt_ARG_VERTICAL_ALIGNMENT PtLabel
Pt_ARG_WIDTH PtWidget
Pt_CB_ACTIVATE PtBasic
Pt_CB_ARM PtBasic
Pt_CB_BLOCKED PtWidget
Pt_CB_DESTROYED PtWidget
Pt_CB_DISARM PtBasic
Pt_CB_DND PtWidget
Pt_CB_FILTER PtWidget
Pt_CB_GOT_FOCUS PtBasic
Pt_CB_HOTKEY PtWidget
Pt_CB_IS_DESTROYED PtWidget
Pt_CB_LOST_FOCUS PtBasic
Pt_CB_MENU PtBasic
Pt_CB_OUTBOUND PtWidget
Pt_CB_RAW PtWidget
Pt_CB_REALIZED PtWidget
Pt_CB_REPEAT PtBasic
Pt_CB_UNREALIZED PtWidget

Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/widget_ref/pttogglebutton.html on line 1070

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/widget_ref/pttogglebutton.html on line 1070