Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# Inti::Gtk::RadioButton Class Reference

A GtkRadioButton C++ wrapper class. More...

`#include <inti/gtk/radiobutton.h>`

Inheritance diagram for Inti::Gtk::RadioButton:

List of all members.

## Public Types

- typedef GSList Group
    The radio button group.

## Public Member Functions

Constructors

- RadioButton ()
    Construct a new radio button in a new group.
- RadioButton (Group *group)
    Construct a new radio button and add it to group.
- RadioButton (const RadioButton *group)
    Construct a new radio button, adding it to the same group as group.
- RadioButton (const String &label, bool use_underline=false)
    Construct a new radio button with a text label, in a new group.
- RadioButton (Group *group, const String &label, bool use_underline=false)
    Construct a new radio button with a text label and add it to group.
- RadioButton (const RadioButton *group, const String &label, bool use_underline=false)
    Construct a new radio button with a text label, adding it to the same group as group.
- virtual ~RadioButton ()
    Destructor.

Accessors

- GtkRadioButton * gtk_radio_button () const
    Get a pointer to the GtkRadioButton structure.
- GtkRadioButtonClass * gtk_radio_button_class () const
    Get a pointer to the GtkRadioButtonClass structure.
- operator GtkRadioButton * () const
    Conversion operator; safely converts a RadioButton to a GtkRadioButton pointer.
- Group * get_group () const
    Retrieves the group assigned to the radio button.

Methods

- void set_group (Group *group)
    Sets a radio button's group.

Property Proxies

- const GroupPropertyProxy prop_group ()
    The radio button whose group this widget belongs (RadioButton* : Read / Write).

## Protected Member Functions

Constructors

- RadioButton (GtkRadioButton *radio_button, bool reference=false)
    Construct a new RadioButton from an existing GtkRadioButton.

## Detailed Description

A GtkRadioButton C++ wrapper class.

A single radio button performs the same basic function as a CheckButton, as it's position in the object hierarchy reflects. It is only when multiple radio buttons are grouped together that they become a different user interface component in their own right.

Every radio button is a member of some group of radio buttons. When one is selected, all other radio buttons in the same group are deselected. A RadioButton is one way of giving the user a choice from many options.

The first radio button in a group is constructed with one of the constructors that doesn't have a group argument. These are:

        RadioButton();
        RadioButton(const String& label, bool use_underline = false);

Then subsequent radio buttons in the group are constructed with one of the constructors that requires a group. These are:

        RadioButton(Group *group);
        RadioButton(const RadioButton *group);
        RadioButton(Group *group, const String& label, bool use_underline = false);
        RadioButton(const RadioButton *group, const String& label, bool use_underline = false);

There are two types of group arguments. The first, Group, is a typedef for GSList and can be retrieved by calling get_group(). The second is just a pointer to a RadioButton that already has a group assigned to it. To remove a RadioButton from one group and make it part of a new one, use set_group().

Example: How to create a group of three radio buttons.

        #include <inti/main.h>
        #include <inti/core.h>
        #include <inti/gtk/radiobutton.h>
        #include <inti/gtk/separator.h>

        using namespace Inti;

        class RadioButtonWindow : public Gtk::Window
        {
        public:
            RadioButtonWindow();
        };

        RadioButtonWindow::RadioButtonWindow()
        {
            set_border_width(0);

            Gtk::VBox *box1 = new Gtk::VBox;
            add(*box1);
            box1->show();

            Gtk::VBox *box2 = new Gtk::VBox(false, 10);
            box2->set_border_width(10);
            box1->pack_start(*box2);
            box2->show();

            Gtk::RadioButton *radio_button = new Gtk::RadioButton("button1");
            box2->pack_start(*radio_button);
            radio_button->show();

            radio_button = new Gtk::RadioButton(radio_button, "button2");
            radio_button->set_active(true);
            box2->pack_start(*radio_button);
            radio_button->show();

            radio_button = new Gtk::RadioButton(radio_button, "button3");
            box2->pack_start(*radio_button);
            radio_button->show();

            Gtk::HSeparator *separator = new Gtk::HSeparator;
            box1->pack_start(*separator, false);
            separator->show();

            box2 = new Gtk::VBox(false, 10);
            box2->set_border_width(10);
            box1->pack_start(*box2, false);
            box2->show();

            Gtk::Button *button = new Gtk::Button("close");
            button->sig_clicked().connect(slot(this, &RadioButtonWindow::dispose));
            box2->pack_start(*button);
            button->set_flags(Gtk::CAN_DEFAULT);
            button->grab_default();
            button->show();
        }

        int main (int argc, char *argv[])
        {
            using namespace Main;

            init(&argc, &argv);

            RadioButtonWindow window;
            window.sig_destroy().connect(slot(&Inti::Main::quit));
            window.show();

            run();
            return 0;
        }

## Constructor & Destructor Documentation

Inti::Gtk::RadioButton::RadioButton | ( | GtkRadioButton * | radio_button,
|  | bool | reference = false
| ) | `[explicit, protected]`

Construct a new RadioButton from an existing GtkRadioButton.

Parameters:

  radio_button | A pointer to a GtkRadioButton.
  reference | Set false if the initial reference count is floating, set true if it's not.

The radio_button can be a newly created GtkRadioButton or an existing GtkRadioButton (see G::Object::Object).

Inti::Gtk::RadioButton::RadioButton | ( |  | ) |

| Construct a new radio button in a new group. To be of any practical value, a widget should then be packed into the radio button.

Inti::Gtk::RadioButton::RadioButton | ( | Group * | group | ) | `[explicit]`

Construct a new radio button and add it to group.

Parameters:

  group | An existing radio button group, or null if you are creating a new group.

To be of any practical value, a widget should then be packed into the radio button.

Inti::Gtk::RadioButton::RadioButton | ( | const RadioButton * | group | ) | `[explicit]`

Construct a new radio button, adding it to the same group as group.

Parameters:

  group | An existing radio button.

To be of any practical value, a widget should then be packed into the radio button.

Inti::Gtk::RadioButton::RadioButton | ( | const String & | label,
|  | bool | use_underline = false
| ) |

Construct a new radio button with a text label, in a new group.

Parameters:

  label | The text label to display next to the radio button.
  use_underline | Set true if label contains a mnemonic character.

Inti::Gtk::RadioButton::RadioButton | ( | Group * | group,
|  | const String & | label,
|  | bool | use_underline = false
| ) |

Construct a new radio button with a text label and add it to group.

Parameters:

  group | An existing radio button group, or null if you are creating a new group.
  label | The text label to display next to the radio button.
  use_underline | Set true if label contains a mnemonic character.

Inti::Gtk::RadioButton::RadioButton | ( | const RadioButton * | group,
|  | const String & | label,
|  | bool | use_underline = false
| ) |

Construct a new radio button with a text label, adding it to the same group as group.

Parameters:

  group | An existing radio button.
  label | The text label to display next to the radio button.
  use_underline | Set true if label contains a mnemonic character.

## Member Function Documentation

Group* Inti::Gtk::RadioButton::get_group | ( |  | ) | const

Retrieves the group assigned to the radio button.

Returns:
  A linked list containing all the radio buttons in the same group as this radio button.

void Inti::Gtk::RadioButton::set_group | ( | Group * | group | ) |

Sets a radio button's group.

Parameters:

  group | An existing radio button group, such as one returned from get_group().

It should be noted that this does not change the layout of your interface in any way, so if you are changing the group, it is likely you will need to re-arrange the user interface to reflect these changes.

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

- radiobutton.h

Main Page - Footer