GFC Logo GFC Title Logo
Reference Manual
Main Page  |  Namespace List  |  Alphabetical List  |  Class List  |  File List

GFC::Gtk::RadioButton Class Reference

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

#include <gfc/gtk/radiobutton.hh>

Inheritance diagram for GFC::Gtk::RadioButton:

GFC::Gtk::CheckButton GFC::Gtk::ToggleButton GFC::Gtk::Button GFC::Gtk::Bin GFC::Gtk::Container GFC::Gtk::Widget GFC::Gtk::Object GFC::Atk::Implementor GFC::G::Object GFC::G::TypeInterface GFC::G::TypeInstance GFC::G::TypeInstance GFC::Trackable GFC::Trackable List of all members.

Signal Prototypes

Public Types

Public Member Functions

Constructors
Accessors
Methods
Signal Proxies

Protected Member Functions

Constructors

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 <gfc/main.hh>
    #include <gfc/ui.hh>
    #include <gfc/gtk/radiobutton.hh>
    #include <gfc/gtk/separator.hh>
   
    using namespace GFC;
   
    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->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(&GFC::Main::quit));
        window.show();
   
        run();
        return 0;
    }


Constructor & Destructor Documentation

GFC::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).

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

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

GFC::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* GFC::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 GFC::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 GFC::Gtk::RadioButton::sig_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 GFC::Gtk::RadioButton::group_changed_signal [static, protected]
 

Group changed signal (see sig_group_changed()).

Calls a slot with the signature:

             void function();


The documentation for this class was generated from the following file:
Generated on Tue Aug 24 00:34:41 2004 for GFC-UI by doxygen 1.3.8