alternative to assert
[gtkD.git] / gtkD / src / gtk / RadioMenuItem.d
blobddc0de08f7c713598e3b9b06989e550585943aea
1 /*
2 * This file is part of gtkD.
4 * gtkD 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 * gtkD 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 gtkD; 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 = GtkRadioMenuItem.html
26 * outPack = gtk
27 * outFile = RadioMenuItem
28 * strct = GtkRadioMenuItem
29 * realStrct=
30 * ctorStrct=
31 * clss = RadioMenuItem
32 * interf =
33 * class Code: Yes
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_radio_menu_item_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * - gtk_radio_menu_item_new_with_label
45 * - gtk_radio_menu_item_new_with_mnemonic
46 * - gtk_radio_menu_item_new_with_mnemonic_from_widget
47 * - gtk_radio_menu_item_new_with_label_from_widget
48 * imports:
49 * - glib.Str
50 * - glib.ListSG
51 * structWrap:
52 * - GSList* -> ListSG
53 * module aliases:
54 * local aliases:
57 module gtk.RadioMenuItem;
59 version(noAssert)
61 version(Tango)
63 import tango.io.Stdout; // use the tango loging?
67 private import gtkc.gtktypes;
69 private import gtkc.gtk;
72 private import glib.Str;
73 private import glib.ListSG;
78 /**
79 * Description
80 * A radio menu item is a check menu item that belongs to a group. At each
81 * instant exactly one of the radio menu items from a group is selected.
82 * The group list does not need to be freed, as each GtkRadioMenuItem will
83 * remove itself and its list item when it is destroyed.
84 * The correct way to create a group of radio menu items is approximatively
85 * this:
86 * Example3.How to create a group of radio menu items.
87 * GSList *group = NULL;
88 * GtkWidget *item;
89 * gint i;
90 * for (i = 0; i < 5; i++)
91 * {
92 * item = gtk_radio_menu_item_new_with_label (group, "This is an example");
93 * group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (item));
94 * if (i == 1)
95 * gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
96 * }
98 private import gtk.CheckMenuItem;
99 public class RadioMenuItem : CheckMenuItem
102 /** the main Gtk struct */
103 protected GtkRadioMenuItem* gtkRadioMenuItem;
106 public GtkRadioMenuItem* getRadioMenuItemStruct()
108 return gtkRadioMenuItem;
112 /** the main Gtk struct as a void* */
113 protected void* getStruct()
115 return cast(void*)gtkRadioMenuItem;
119 * Sets our main struct and passes it to the parent class
121 public this (GtkRadioMenuItem* gtkRadioMenuItem)
123 version(noAssert)
125 if ( gtkRadioMenuItem is null )
127 int zero = 0;
128 version(Tango)
130 Stdout("struct gtkRadioMenuItem is null on constructor").newline;
132 else
134 printf("struct gtkRadioMenuItem is null on constructor");
136 zero = zero / zero;
139 else
141 assert(gtkRadioMenuItem !is null, "struct gtkRadioMenuItem is null on constructor");
143 super(cast(GtkCheckMenuItem*)gtkRadioMenuItem);
144 this.gtkRadioMenuItem = gtkRadioMenuItem;
148 * Creates a new GtkRadioMenuItem whose child is a simple GtkLabel.
149 * The new GtkRadioMenuItem is added to the same group as group.
150 * If mnemonic is true the label will be
151 * created using gtk_label_new_with_mnemonic(), so underscores in label
152 * indicate the mnemonic for the menu item.
153 * group:
154 * an existing GtkRadioMenuItem
155 * label:
156 * the text for the label
157 * Returns:
158 * The new GtkRadioMenuItem
159 * Since 2.4
161 public this (RadioMenuItem radioMenuItem, char[] label, bool mnemonic=true)
163 if ( mnemonic )
165 // GtkWidget* gtk_radio_menu_item_new_with_mnemonic_from_widget (GtkRadioMenuItem *group, const gchar *label);
166 this(cast(GtkRadioMenuItem*)gtk_radio_menu_item_new_with_mnemonic_from_widget(
167 radioMenuItem.getRadioMenuItemStruct(), Str.toStringz(label)) );
169 else
171 // GtkWidget* gtk_radio_menu_item_new_with_label_from_widget (GtkRadioMenuItem *group, const gchar *label);
172 this(cast(GtkRadioMenuItem*)gtk_radio_menu_item_new_with_label_from_widget(
173 radioMenuItem.getRadioMenuItemStruct(), Str.toStringz(label)) );
178 * Creates a new GtkRadioMenuItem containing a label. T
179 * The new GtkRadioMenuItem is added to the same group as group.
180 * group:
181 * An existing GtkRadioMenuItem
182 * label:
183 * the text of the button, with an underscore in front of the
184 * mnemonic character
185 * Returns:
186 * The new GtkRadioMenuItem
187 * Since 2.4
189 public this (char[] label)
194 * Creates a new GtkRadioMenuItem whose child is a simple GtkLabel.
195 * If mnemonic is true the label
196 * will be created using gtk_label_new_with_mnemonic(), so underscores
197 * in label indicate the mnemonic for the menu item.
198 * group:
199 * the group to which the radio menu item is to be attached
200 * label:
201 * the text for the label
202 * Returns:
203 * a new GtkRadioMenuItem
205 public this (ListSG group, char[] label, bool mnemonic=true)
207 if ( mnemonic )
209 // GtkWidget* gtk_radio_menu_item_new_with_mnemonic (GSList *group, const gchar *label);
210 this(cast(GtkRadioMenuItem*)gtk_radio_menu_item_new_with_mnemonic(
211 group is null ? null : group.getListSGStruct(), Str.toStringz(label)) );
213 else
215 // GtkWidget* gtk_radio_menu_item_new_with_label (GSList *group, const gchar *label);
216 this(cast(GtkRadioMenuItem*)gtk_radio_menu_item_new_with_label(
217 group is null ? null : group.getListSGStruct(), Str.toStringz(label)) );
224 // imports for the signal processing
225 private import gobject.Signals;
226 private import gtkc.gdktypes;
227 int[char[]] connectedSignals;
229 void delegate(RadioMenuItem)[] onGroupChangedListeners;
230 void addOnGroupChanged(void delegate(RadioMenuItem) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
232 if ( !("group-changed" in connectedSignals) )
234 Signals.connectData(
235 getStruct(),
236 "group-changed",
237 cast(GCallback)&callBackGroupChanged,
238 cast(void*)this,
239 null,
240 connectFlags);
241 connectedSignals["group-changed"] = 1;
243 onGroupChangedListeners ~= dlg;
245 extern(C) static void callBackGroupChanged(GtkRadioMenuItem* radiomenuitemStruct, RadioMenuItem radioMenuItem)
247 bool consumed = false;
249 foreach ( void delegate(RadioMenuItem) dlg ; radioMenuItem.onGroupChangedListeners )
251 dlg(radioMenuItem);
254 return consumed;
260 * Creates a new GtkRadioMenuItem.
261 * group:
262 * the group to which the radio menu item is to be attached
263 * Returns:
264 * a new GtkRadioMenuItem
266 public this (ListSG group)
268 // GtkWidget* gtk_radio_menu_item_new (GSList *group);
269 this(cast(GtkRadioMenuItem*)gtk_radio_menu_item_new((group is null) ? null : group.getListSGStruct()) );
275 * Creates a new GtkRadioMenuItem adding it to the same group as group.
276 * group:
277 * An existing GtkRadioMenuItem
278 * Returns:
279 * The new GtkRadioMenuItem
280 * Since 2.4
282 public this ()
284 // GtkWidget* gtk_radio_menu_item_new_from_widget (GtkRadioMenuItem *group);
285 this(cast(GtkRadioMenuItem*)gtk_radio_menu_item_new_from_widget(gtkRadioMenuItem) );
292 * Sets the group of a radio menu item, or changes it.
293 * radio_menu_item:
294 * a GtkRadioMenuItem.
295 * group:
296 * the new group.
298 public void setGroup(ListSG group)
300 // void gtk_radio_menu_item_set_group (GtkRadioMenuItem *radio_menu_item, GSList *group);
301 gtk_radio_menu_item_set_group(gtkRadioMenuItem, (group is null) ? null : group.getListSGStruct());
305 * Returns the group to which the radio menu item belongs, as a GList of
306 * GtkRadioMenuItem. The list belongs to GTK+ and should not be freed.
307 * radio_menu_item:
308 * a GtkRadioMenuItem.
309 * Returns:
310 * the group of radio_menu_item.
311 * Property Details
312 * The "group" property
313 * "group" GtkRadioMenuItem : Write
314 * The radio menu item whose group this widget belongs to.
315 * Since 2.8
316 * Signal Details
317 * The "group-changed" signal
318 * void user_function (GtkRadioMenuItem *radiomenuitem,
319 * gpointer user_data) : Run First
320 * radiomenuitem:
321 * the object which received the signal.
322 * user_data:
323 * user data set when the signal handler was connected.
324 * See Also
325 * GtkMenuItem
326 * because a radio menu item is a menu item.
327 * GtkCheckMenuItem
328 * to know how to handle the check.
330 public ListSG getGroup()
332 // GSList* gtk_radio_menu_item_get_group (GtkRadioMenuItem *radio_menu_item);
333 return new ListSG( gtk_radio_menu_item_get_group(gtkRadioMenuItem) );