Xfce Foundation Classes
Main Page | Index | Namespace List | Alphabetical List | Class List | File List

# Xfc::Gtk::RadioButton Class Reference

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

`#include <xfc/gtk/radiobutton.hh>`

Inheritance diagram for Xfc::Gtk::RadioButton:

List of all members.

## Signal Prototypes

- const GroupChangedSignalType group_changed_signal
    Group changed signal (see signal_group_changed()).

## Public Types

- typedef GSList Group
    The radio button group.

## Public Member Functions

Constructors

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

Accessors

- GtkRadioButton * gtk_radio_button () const
    Get a pointer to the GtkRadioButton 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.

Signal Proxies

- const GroupChangedSignalProxy signal_group_changed ()
    Connect to the group_changed_signal; emitted when the group of radio buttons that a radio button belongs to changes.

## Protected Member Functions

Constructors

- RadioButton (GtkRadioButton *radio_button, bool owns_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(const RadioButton *group, const char *label, bool use_underline = false);
        RadioButton(const RadioButton *group, const String& label, bool use_underline = false);

The group argument is 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 <xfc/main.hh>
        #include <xfc/ui.hh>
        #include <xfc/gtk/radiobutton.hh>
        #include <xfc/gtk/separator.hh>

        using namespace Xfc;

        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 = 0;
            radio_button = new Gtk::RadioButton(radio_button, "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->signal_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.signal_destroy().connect(slot(&Xfc::Main::quit));
            window.show();

            run();
            return 0;
        }

See also: the Button Widget HOWTOs and examples.

## Constructor & Destructor Documentation

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

  | Construct a new RadioButton from an existing GtkRadioButton. Parameters:
  | radio_button | A pointer to a GtkRadioButton.
  | owns_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).

Xfc::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.

Xfc::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, or null for the first button in a group.
To be of any practical value, a widget should then be packed into the radio button.

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

  | Constructs a new radio button and adds it to the same group as group. Parameters:
  | group | An existing radio button, or null to start a new group.
  | 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* Xfc::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 Xfc::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.

const GroupChangedSignalProxy Xfc::Gtk::RadioButton::signal_group_changed | ( |  | ) |

| Connect to the group_changed_signal; emitted when the group of radio buttons that a radio button belongs to changes. This can be when a radio button switches from being alone to being part of a group of 2 or more buttons, or vice-versa, and when a button is moved from one group of 2 or more buttons to a different one, but not when the composition of the group that a button belongs to changes.

## Member Data Documentation

const GroupChangedSignalType Xfc::Gtk::RadioButton::group_changed_signal`[static, protected]`

| Group changed signal (see signal_group_changed()). Calls a slot with the signature:
                 void function();

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

- radiobutton.hh

Xfce Foundation Classes

Copyright © 2004-2005 The XFC Development Team | XFC 4.3