I've no idea here...
[gtkD.git] / src / gtk / RadioButton.d
blob9bf181860670424508429b41a2ab6a34d0a55b17
1 /*
2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkRadioButton.html
26 * outPack = gtk
27 * outFile = RadioButton
28 * strct = GtkRadioButton
29 * realStrct=
30 * ctorStrct=
31 * clss = RadioButton
32 * interf =
33 * class Code: Yes
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_radio_button_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * - gtk_radio_button_new_with_label
45 * - gtk_radio_button_new_with_mnemonic
46 * - gtk_radio_button_new_with_label_from_widget
47 * - gtk_radio_button_new_with_mnemonic_from_widget
48 * imports:
49 * - glib.Str
50 * - glib.ListSG
51 * structWrap:
52 * - GSList* -> ListSG
53 * local aliases:
56 module gtk.RadioButton;
58 private import gtk.gtktypes;
60 private import lib.gtk;
62 private import glib.Str;
63 private import glib.ListSG;
65 /**
66 * Description
67 * A single radio button performs the same basic function as a GtkCheckButton,
68 * as its position in the object hierarchy reflects. It is only when multiple
69 * radio buttons are grouped together that they become a different user
70 * interface component in their own right.
71 * Every radio button is a member of some group of radio buttons. When one is selected, all other
72 * radio buttons in the same group are deselected. A GtkRadioButton is one way
73 * of giving the user a choice from many options.
74 * Radio button widgets are created with gtk_radio_button_new(), passing NULL
75 * as the argument if this is the first radio button in a group. In subsequent
76 * calls, the group you wish to add this button to should be passed as an
77 * argument. Optionally, gtk_radio_button_new_with_label() can be used if you
78 * want a text label on the radio button.
79 * Alternatively, when adding widgets to an existing group of radio buttons,
80 * use gtk_radio_button_new_from_widget() with a GtkRadioButton that already
81 * has a group assigned to it. The convenience function
82 * gtk_radio_button_new_with_label_from_widget() is also provided.
83 * To retrieve the group a GtkRadioButton is assigned to, use
84 * gtk_radio_button_get_group().
85 * To remove a GtkRadioButton from one group and make it part of a new one, use gtk_radio_button_set_group().
86 * The group list does not need to be freed, as each GtkRadioButton will remove
87 * itself and its list item when it is destroyed.
88 * Example1.How to create a group of two radio buttons.
89 * void create_radio_buttons (void) {
90 * GtkWidget *window, *radio1, *radio2, *box, *entry;
91 * window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
92 * box = gtk_vbox_new (TRUE, 2);
93 * /+* Create a radio button with a GtkEntry widget +/
94 * radio1 = gtk_radio_button_new (NULL);
95 * entry = gtk_entry_new ();
96 * gtk_container_add (GTK_CONTAINER (radio1), entry);
97 * /+* Create a radio button with a label +/
98 * radio2 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1),
99 * "I'm the second radio button.");
100 * /+* Pack them into a box, then show all the widgets +/
101 * gtk_box_pack_start (GTK_BOX (box), radio1, TRUE, TRUE, 2);
102 * gtk_box_pack_start (GTK_BOX (box), radio2, TRUE, TRUE, 2);
103 * gtk_container_add (GTK_CONTAINER (window), box);
104 * gtk_widget_show_all (window);
105 * return;
107 * When an unselected button in the group is clicked the clicked button
108 * receives the "toggled" signal, as does the previously selected button.
109 * Inside the "toggled" handler, gtk_toggle_button_get_active() can be used
110 * to determine if the button has been selected or deselected.
112 private import gtk.CheckButton;
113 public class RadioButton : CheckButton
116 /** the main Gtk struct */
117 protected GtkRadioButton* gtkRadioButton;
120 public GtkRadioButton* getRadioButtonStruct()
122 return gtkRadioButton;
126 /** the main Gtk struct as a void* */
127 protected void* getStruct()
129 return cast(void*)gtkRadioButton;
133 * Sets our main struct and passes it to the parent class
135 public this (GtkRadioButton* gtkRadioButton)
137 super(cast(GtkCheckButton*)gtkRadioButton);
138 this.gtkRadioButton = gtkRadioButton;
142 * Creates a new GtkRadioButton with a text label.
143 * If mnemonic if true the label will be created using
144 * gtk_label_new_with_mnemonic(), so underscores in label indicate the
145 * mnemonic for the button.
146 * an existing radio button group, or NULL if you are creating a new
147 * group.
148 * label:
149 * the text label to display next to the radio button.
150 * Returns:
151 * a new radio button.
153 public this (ListSG group, char[] label, bit mnemonic=true)
155 if ( mnemonic )
157 // GtkWidget* gtk_radio_button_new_with_mnemonic (GSList *group, const gchar *label);
158 this(cast(GtkRadioButton*)gtk_radio_button_new_with_mnemonic(
159 group is null ? null : group.getListSGStruct(),
160 Str.toStringz(label))
163 else
165 // GtkWidget* gtk_radio_button_new_with_label (GSList *group, const gchar *label);
166 this(cast(GtkRadioButton*)gtk_radio_button_new_with_label(
167 group is null ? null : group.getListSGStruct(),
168 Str.toStringz(label))
174 * Creates a new GtkRadioButton with a text label, adding it to the same group
175 * as group.
176 * It mnemonic it true the label
177 * will be created using gtk_label_new_with_mnemonic(), so underscores
178 * in label indicate the mnemonic for the button.
179 * group:
180 * an existing GtkRadioButton.
181 * label:
182 * a text string to display next to the radio button.
183 * Returns:
184 * a new radio button.
186 public this (RadioButton radioButton, char[] label, bit mnemonic=true)
188 if ( mnemonic )
190 // GtkWidget* gtk_radio_button_new_with_mnemonic_from_widget (GtkRadioButton *group, const gchar *label);
191 this(cast(GtkRadioButton*)gtk_radio_button_new_with_mnemonic_from_widget(
192 radioButton.getRadioButtonStruct(),
193 Str.toStringz(label))
196 else
198 // GtkWidget* gtk_radio_button_new_with_label_from_widget (GtkRadioButton *group, const gchar *label);
199 this(cast(GtkRadioButton*)gtk_radio_button_new_with_label_from_widget(
200 radioButton.getRadioButtonStruct(),
201 Str.toStringz(label))
209 // imports for the signal processing
210 private import gobject.Signals;
211 private import gdk.gdktypes;
212 int[char[]] connectedSignals;
214 void delegate(RadioButton)[] onGroupChangedListeners;
215 void addOnGroupChanged(void delegate(RadioButton) dlg)
217 if ( !("group-changed" in connectedSignals) )
219 Signals.connectData(
220 getStruct(),
221 "group-changed",
222 cast(GCallback)&callBackGroupChanged,
223 this,
224 null,
225 cast(ConnectFlags)0);
226 connectedSignals["group-changed"] = 1;
228 onGroupChangedListeners ~= dlg;
230 extern(C) static void callBackGroupChanged(GtkRadioButton* styleStruct, RadioButton radioButton)
232 bit consumed = false;
234 foreach ( void delegate(RadioButton) dlg ; radioButton.onGroupChangedListeners )
236 dlg(radioButton);
239 return consumed;
245 * Creates a new GtkRadioButton. To be of any practical value, a widget should
246 * then be packed into the radio button.
247 * group:
248 * an existing radio button group, or NULL if you are creating a new group.
249 * Returns:
250 * a new radio button.
252 public this (ListSG group)
254 // GtkWidget* gtk_radio_button_new (GSList *group);
255 this(cast(GtkRadioButton*)gtk_radio_button_new((group is null) ? null : group.getListSGStruct()) );
259 * Creates a new GtkRadioButton, adding it to the same group as group. As
260 * with gtk_radio_button_new(), a widget should be packed into the radio button.
261 * group:
262 * an existing GtkRadioButton.
263 * Returns:
264 * a new radio button.
266 public this ()
268 // GtkWidget* gtk_radio_button_new_from_widget (GtkRadioButton *group);
269 this(cast(GtkRadioButton*)gtk_radio_button_new_from_widget(gtkRadioButton) );
278 * Sets a GtkRadioButton's group. It should be noted that this does not change
279 * the layout of your interface in any way, so if you are changing the group,
280 * it is likely you will need to re-arrange the user interface to reflect these
281 * changes.
282 * radio_button:
283 * a GtkRadioButton.
284 * group:
285 * an existing radio button group, such as one returned from
286 * gtk_radio_button_get_group().
288 public void setGroup(ListSG group)
290 // void gtk_radio_button_set_group (GtkRadioButton *radio_button, GSList *group);
291 gtk_radio_button_set_group(gtkRadioButton, (group is null) ? null : group.getListSGStruct());
295 * Retrieves the group assigned to a radio button.
296 * radio_button:
297 * a GtkRadioButton.
298 * Returns:
299 * a linked list containing all the radio buttons in the same group
300 * as radio_button.
301 * Property Details
302 * The "group" property
303 * "group" GtkRadioButton : Write
304 * Sets a new group for a radio button.
305 * Signal Details
306 * The "group-changed" signal
307 * void user_function (GtkRadioButton *style,
308 * gpointer user_data) : Run first
309 * Emitted when the group of radio buttons that a radio button belongs
310 * to changes. This is emitted when a radio button switches from
311 * being alone to being part of a group of 2 or more buttons, or
312 * vice-versa, and when a buttton is moved from one group of 2 or
313 * more buttons to a different one, but not when the composition
314 * of the group that a button belongs to changes.
315 * style:
316 * the object which received the signal
317 * user_data:
318 * user data set when the signal handler was connected.
319 * Since 2.4
320 * See Also
321 * GtkOptionMenu
322 * Another way of offering the user a single choice from
323 * many.
325 public ListSG getGroup()
327 // GSList* gtk_radio_button_get_group (GtkRadioButton *radio_button);
328 return new ListSG( gtk_radio_button_get_group(gtkRadioButton) );