1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = GtkCheckMenuItem.html 27 * outPack = gtk 28 * outFile = CheckMenuItem 29 * strct = GtkCheckMenuItem 30 * realStrct= 31 * ctorStrct= 32 * clss = CheckMenuItem 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_check_menu_item_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * - gtk_check_menu_item_new_with_label 45 * - gtk_check_menu_item_new_with_mnemonic 46 * omit signals: 47 * imports: 48 * - glib.Str 49 * structWrap: 50 * module aliases: 51 * local aliases: 52 * overrides: 53 */ 54 55 module gtk.CheckMenuItem; 56 57 public import gtkc.gtktypes; 58 59 private import gtkc.gtk; 60 private import glib.ConstructionException; 61 private import gobject.ObjectG; 62 63 private import gobject.Signals; 64 public import gtkc.gdktypes; 65 private import glib.Str; 66 67 68 private import gtk.MenuItem; 69 70 /** 71 * A GtkCheckMenuItem is a menu item that maintains the state of a boolean 72 * value in addition to a GtkMenuItem usual role in activating application 73 * code. 74 * 75 * A check box indicating the state of the boolean value is displayed 76 * at the left side of the GtkMenuItem. Activating the GtkMenuItem 77 * toggles the value. 78 */ 79 public class CheckMenuItem : MenuItem 80 { 81 82 /** the main Gtk struct */ 83 protected GtkCheckMenuItem* gtkCheckMenuItem; 84 85 86 /** Get the main Gtk struct */ 87 public GtkCheckMenuItem* getCheckMenuItemStruct() 88 { 89 return gtkCheckMenuItem; 90 } 91 92 93 /** the main Gtk struct as a void* */ 94 protected override void* getStruct() 95 { 96 return cast(void*)gtkCheckMenuItem; 97 } 98 99 /** 100 * Sets our main struct and passes it to the parent class 101 */ 102 public this (GtkCheckMenuItem* gtkCheckMenuItem) 103 { 104 super(cast(GtkMenuItem*)gtkCheckMenuItem); 105 this.gtkCheckMenuItem = gtkCheckMenuItem; 106 } 107 108 protected override void setStruct(GObject* obj) 109 { 110 super.setStruct(obj); 111 gtkCheckMenuItem = cast(GtkCheckMenuItem*)obj; 112 } 113 114 /** 115 * Creates a new GtkCheckMenuItem with a label. 116 * Params: 117 * label = the string to use for the label. 118 * mnemonic = if true the label 119 * will be created using gtk_label_new_with_mnemonic(), so underscores 120 * in label indicate the mnemonic for the menu item. 121 * Throws: ConstructionException GTK+ fails to create the object. 122 */ 123 public this (string label, bool mnemonic=true) 124 { 125 GtkCheckMenuItem* p; 126 127 if ( mnemonic ) 128 { 129 // GtkWidget* gtk_check_menu_item_new_with_mnemonic (const gchar *label); 130 p = cast(GtkCheckMenuItem*)gtk_check_menu_item_new_with_mnemonic(Str.toStringz(label)); 131 } 132 else 133 { 134 // GtkWidget* gtk_check_menu_item_new_with_label (const gchar *label); 135 p = cast(GtkCheckMenuItem*)gtk_check_menu_item_new_with_label(Str.toStringz(label)); 136 } 137 138 if(p is null) 139 { 140 throw new ConstructionException("null returned by gtk_check_menu_item_new_with_"); 141 } 142 143 this(p); 144 } 145 146 /** 147 */ 148 int[string] connectedSignals; 149 150 void delegate(CheckMenuItem)[] onToggledListeners; 151 /** 152 * This signal is emitted when the state of the check box is changed. 153 * A signal handler can use gtk_check_menu_item_get_active() 154 * to discover the new state. 155 */ 156 void addOnToggled(void delegate(CheckMenuItem) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 157 { 158 if ( !("toggled" in connectedSignals) ) 159 { 160 Signals.connectData( 161 getStruct(), 162 "toggled", 163 cast(GCallback)&callBackToggled, 164 cast(void*)this, 165 null, 166 connectFlags); 167 connectedSignals["toggled"] = 1; 168 } 169 onToggledListeners ~= dlg; 170 } 171 extern(C) static void callBackToggled(GtkCheckMenuItem* checkmenuitemStruct, CheckMenuItem _checkMenuItem) 172 { 173 foreach ( void delegate(CheckMenuItem) dlg ; _checkMenuItem.onToggledListeners ) 174 { 175 dlg(_checkMenuItem); 176 } 177 } 178 179 180 /** 181 * Creates a new GtkCheckMenuItem. 182 * Throws: ConstructionException GTK+ fails to create the object. 183 */ 184 public this () 185 { 186 // GtkWidget * gtk_check_menu_item_new (void); 187 auto p = gtk_check_menu_item_new(); 188 if(p is null) 189 { 190 throw new ConstructionException("null returned by gtk_check_menu_item_new()"); 191 } 192 this(cast(GtkCheckMenuItem*) p); 193 } 194 195 /** 196 * Returns whether the check menu item is active. See 197 * gtk_check_menu_item_set_active(). 198 * Returns: TRUE if the menu item is checked. 199 */ 200 public int getActive() 201 { 202 // gboolean gtk_check_menu_item_get_active (GtkCheckMenuItem *check_menu_item); 203 return gtk_check_menu_item_get_active(gtkCheckMenuItem); 204 } 205 206 /** 207 * Sets the active state of the menu item's check box. 208 * Params: 209 * isActive = boolean value indicating whether the check box is active. 210 */ 211 public void setActive(int isActive) 212 { 213 // void gtk_check_menu_item_set_active (GtkCheckMenuItem *check_menu_item, gboolean is_active); 214 gtk_check_menu_item_set_active(gtkCheckMenuItem, isActive); 215 } 216 217 /** 218 * Emits the "toggled" signal. 219 */ 220 public void toggled() 221 { 222 // void gtk_check_menu_item_toggled (GtkCheckMenuItem *check_menu_item); 223 gtk_check_menu_item_toggled(gtkCheckMenuItem); 224 } 225 226 /** 227 * Retrieves the value set by gtk_check_menu_item_set_inconsistent(). 228 * Returns: TRUE if inconsistent 229 */ 230 public int getInconsistent() 231 { 232 // gboolean gtk_check_menu_item_get_inconsistent (GtkCheckMenuItem *check_menu_item); 233 return gtk_check_menu_item_get_inconsistent(gtkCheckMenuItem); 234 } 235 236 /** 237 * If the user has selected a range of elements (such as some text or 238 * spreadsheet cells) that are affected by a boolean setting, and the 239 * current values in that range are inconsistent, you may want to 240 * display the check in an "in between" state. This function turns on 241 * "in between" display. Normally you would turn off the inconsistent 242 * state again if the user explicitly selects a setting. This has to be 243 * done manually, gtk_check_menu_item_set_inconsistent() only affects 244 * visual appearance, it doesn't affect the semantics of the widget. 245 * Params: 246 * setting = TRUE to display an "inconsistent" third state check 247 */ 248 public void setInconsistent(int setting) 249 { 250 // void gtk_check_menu_item_set_inconsistent (GtkCheckMenuItem *check_menu_item, gboolean setting); 251 gtk_check_menu_item_set_inconsistent(gtkCheckMenuItem, setting); 252 } 253 254 /** 255 * Sets whether check_menu_item is drawn like a GtkRadioMenuItem 256 * Since 2.4 257 * Params: 258 * drawAsRadio = whether check_menu_item is drawn like a GtkRadioMenuItem 259 */ 260 public void setDrawAsRadio(int drawAsRadio) 261 { 262 // void gtk_check_menu_item_set_draw_as_radio (GtkCheckMenuItem *check_menu_item, gboolean draw_as_radio); 263 gtk_check_menu_item_set_draw_as_radio(gtkCheckMenuItem, drawAsRadio); 264 } 265 266 /** 267 * Returns whether check_menu_item looks like a GtkRadioMenuItem 268 * Since 2.4 269 * Returns: Whether check_menu_item looks like a GtkRadioMenuItem 270 */ 271 public int getDrawAsRadio() 272 { 273 // gboolean gtk_check_menu_item_get_draw_as_radio (GtkCheckMenuItem *check_menu_item); 274 return gtk_check_menu_item_get_draw_as_radio(gtkCheckMenuItem); 275 } 276 }