gtkmm: Gtk::ToggleButton Class Reference

gtkmm 2.24.4

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | Related Functions

# Gtk::ToggleButton Class Reference
Widgets

A Gtk::ToggleButton will remain 'pressed-in' when clicked. More...

Inheritance diagram for Gtk::ToggleButton:
[legend]
Collaboration diagram for Gtk::ToggleButton:
[legend]

List of all members.

## Public Member Functions
virtual | ~ToggleButton ()
GtkToggleButton* | gobj ()
| Provides access to the underlying C GtkObject.
const GtkToggleButton* | gobj () const
| Provides access to the underlying C GtkObject.
| ToggleButton ()
| Create an empty toggle button.
| ToggleButton (const Glib::ustring& label, bool mnemonic=false)
| Create a toggle button with a label.
| ToggleButton (const StockID& stock_id)
| Creates a toggle button containing the image and text from a stock item.
void | set_mode (bool draw_indicator=true)
| Sets whether the button is displayed as a separate indicator and label.
bool | get_mode () const
| Retrieves whether the button is displayed as a separate indicator and label.
void | set_active (bool is_active=true)
bool | get_active () const
void | set_inconsistent (bool setting=true)
| If the user has selected a range of elements (such as some text or spreadsheet cells) that are affected by a toggle button, and the current values in that range are inconsistent, you may want to display the toggle in an "in between" state.
bool | get_inconsistent () const
| Gets the value set by set_inconsistent().
void | toggled ()
Glib::SignalProxy0< void > | signal_toggled ()
| Emitted whenever the toggle tool button changes state.
Glib::PropertyProxy< bool > | property_active ()
| If the toggle button should be pressed in or not.
Glib::PropertyProxy_ReadOnly < bool > | property_active () const
| If the toggle button should be pressed in or not.
Glib::PropertyProxy< bool > | property_inconsistent ()
| If the toggle button is in an 'in between' state.
Glib::PropertyProxy_ReadOnly < bool > | property_inconsistent () const
| If the toggle button is in an 'in between' state.
Glib::PropertyProxy< bool > | property_draw_indicator ()
| If the toggle part of the button is displayed.
Glib::PropertyProxy_ReadOnly < bool > | property_draw_indicator () const
| If the toggle part of the button is displayed.
## Protected Member Functions
virtual void | on_toggled ()
## Related Functions
(Note that these are not member functions.)
Gtk::ToggleButton* | wrap (GtkToggleButton* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

A Gtk::ToggleButton will remain 'pressed-in' when clicked.

Clicking again will cause the toggle button to return to it's normal state. The state of a Gtk::ToggleButton can be set specifically using set_active(), and retrieved using get_active(). To simply switch the state of a toggle button, use toggled().

## Constructor & Destructor Documentation

virtual Gtk::ToggleButton::~ToggleButton | ( |  | ) | `[virtual]`

Gtk::ToggleButton::ToggleButton | ( |  | ) |

Create an empty toggle button.

With an empty button, you can Gtk::Button::add() a widget such as a Gtk::Pixmap or Gtk::Box.

If you just wish to add a Gtk::Label, you may want to use the Gtk::ToggleButton(const Glib::ustring& label) constructor directly instead.

Gtk::ToggleButton::ToggleButton | ( | const Glib::ustring & | label,
|  | bool | mnemonic = `false`
| ) |  | `[explicit]`

Create a toggle button with a label.

You won't be able to add a widget to this button since it already contains a Gtk::Label

Gtk::ToggleButton::ToggleButton | ( | const StockID& | stock_id | ) | `[explicit]`

Creates a toggle button containing the image and text from a stock item.

Stock ids have identifiers like Gtk::Stock::OK and Gtk::Stock::APPLY.

Parameters:

  stock_id | The stock item.

## Member Function Documentation

bool Gtk::ToggleButton::get_active | ( |  | ) | const

bool Gtk::ToggleButton::get_inconsistent | ( |  | ) | const

Gets the value set by set_inconsistent().

Returns:
  `true` if the button is displayed as inconsistent, `false` otherwise.

bool Gtk::ToggleButton::get_mode | ( |  | ) | const

Retrieves whether the button is displayed as a separate indicator and label.

See set_mode().

Returns:
  `true` if the togglebutton is drawn as a separate indicator and label.

GtkToggleButton* Gtk::ToggleButton::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::Button.

Reimplemented in Gtk::CheckButton, and Gtk::RadioButton.

const GtkToggleButton* Gtk::ToggleButton::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::Button.

Reimplemented in Gtk::CheckButton, and Gtk::RadioButton.

virtual void Gtk::ToggleButton::on_toggled | ( |  | ) | `[protected, virtual]`

Glib::PropertyProxy_ReadOnly<bool> Gtk::ToggleButton::property_active | ( |  | ) | const

If the toggle button should be pressed in or not.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<bool> Gtk::ToggleButton::property_active | ( |  | ) |

If the toggle button should be pressed in or not.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<bool> Gtk::ToggleButton::property_draw_indicator | ( |  | ) | const

If the toggle part of the button is displayed.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<bool> Gtk::ToggleButton::property_draw_indicator | ( |  | ) |

If the toggle part of the button is displayed.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<bool> Gtk::ToggleButton::property_inconsistent | ( |  | ) | const

If the toggle button is in an 'in between' state.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<bool> Gtk::ToggleButton::property_inconsistent | ( |  | ) |

If the toggle button is in an 'in between' state.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

void Gtk::ToggleButton::set_active | ( | bool | is_active = `true` | ) |

void Gtk::ToggleButton::set_inconsistent | ( | bool | setting = `true` | ) |

If the user has selected a range of elements (such as some text or spreadsheet cells) that are affected by a toggle button, and the current values in that range are inconsistent, you may want to display the toggle in an "in between" state.

This function turns on "in between" display. Normally you would turn off the inconsistent state again if the user toggles the toggle button. This has to be done manually, set_inconsistent() only affects visual appearance, it doesn't affect the semantics of the button.

Parameters:

  setting | `true` if state is inconsistent.

void Gtk::ToggleButton::set_mode | ( | bool | draw_indicator = `true` | ) |

Sets whether the button is displayed as a separate indicator and label.

You can call this function on a checkbutton or a radiobutton with draw_indicator = `false` to make the button look like a normal button

This function only affects instances of classes like Gtk::CheckButton and Gtk::RadioButton that derive from Gtk::ToggleButton, not instances of Gtk::ToggleButton itself.

Parameters:

  draw_indicator | If `true`, draw the button as a separate indicator and label; if `false`, draw the button like a normal button.

Glib::SignalProxy0< void > Gtk::ToggleButton::signal_toggled | ( |  | ) |

Emitted whenever the toggle tool button changes state.

Prototype:
  `void on_my_toggled()`

void Gtk::ToggleButton::toggled | ( |  | ) |

## Friends And Related Function Documentation

Gtk::ToggleButton* wrap | ( | GtkToggleButton * | object,
|  | bool | take_copy = `false`
| ) |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.

The documentation for this class was generated from the following file:

- gtkmm/togglebutton.h