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 = gtk-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 * - gtk_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * - gtk_check_menu_item_new_with_label 46 * - gtk_check_menu_item_new_with_mnemonic 47 * omit signals: 48 * imports: 49 * - glib.Str 50 * structWrap: 51 * module aliases: 52 * local aliases: 53 * overrides: 54 */ 55 56 module gtk.CheckMenuItem; 57 58 public import gtkc.gtktypes; 59 60 private import gtkc.gtk; 61 private import glib.ConstructionException; 62 private import gobject.ObjectG; 63 64 private import gobject.Signals; 65 public import gtkc.gdktypes; 66 67 private import glib.Str; 68 69 70 71 private import gtk.MenuItem; 72 73 /** 74 * Description 75 * A GtkCheckMenuItem is a menu item that maintains the state of a boolean 76 * value in addition to a GtkMenuItem's usual role in activating application 77 * code. 78 * A check box indicating the state of the boolean value is displayed 79 * at the left side of the GtkMenuItem. Activating the GtkMenuItem 80 * toggles the value. 81 */ 82 public class CheckMenuItem : MenuItem 83 { 84 85 /** the main Gtk struct */ 86 protected GtkCheckMenuItem* gtkCheckMenuItem; 87 88 89 public GtkCheckMenuItem* getCheckMenuItemStruct() 90 { 91 return gtkCheckMenuItem; 92 } 93 94 95 /** the main Gtk struct as a void* */ 96 protected override void* getStruct() 97 { 98 return cast(void*)gtkCheckMenuItem; 99 } 100 101 /** 102 * Sets our main struct and passes it to the parent class 103 */ 104 public this (GtkCheckMenuItem* gtkCheckMenuItem) 105 { 106 super(cast(GtkMenuItem*)gtkCheckMenuItem); 107 this.gtkCheckMenuItem = gtkCheckMenuItem; 108 } 109 110 protected override void setStruct(GObject* obj) 111 { 112 super.setStruct(obj); 113 gtkCheckMenuItem = cast(GtkCheckMenuItem*)obj; 114 } 115 116 /** 117 * Creates a new GtkCheckMenuItem with a label. 118 * Params: 119 * label = the string to use for the label. 120 * mnemonic = if true the label 121 * will be created using gtk_label_new_with_mnemonic(), so underscores 122 * in label indicate the mnemonic for the menu item. 123 * Throws: ConstructionException GTK+ fails to create the object. 124 */ 125 public this (string label, bool mnemonic=true) 126 { 127 GtkCheckMenuItem* p; 128 129 if ( mnemonic ) 130 { 131 // GtkWidget* gtk_check_menu_item_new_with_mnemonic (const gchar *label); 132 p = cast(GtkCheckMenuItem*)gtk_check_menu_item_new_with_mnemonic(Str.toStringz(label)); 133 } 134 else 135 { 136 // GtkWidget* gtk_check_menu_item_new_with_label (const gchar *label); 137 p = cast(GtkCheckMenuItem*)gtk_check_menu_item_new_with_label(Str.toStringz(label)); 138 } 139 140 if(p is null) 141 { 142 throw new ConstructionException("null returned by gtk_check_menu_item_new_with_"); 143 } 144 145 this(p); 146 } 147 148 /** 149 */ 150 int[string] connectedSignals; 151 152 void delegate(CheckMenuItem)[] onToggledListeners; 153 /** 154 * This signal is emitted when the state of the check box is changed. 155 * A signal handler can examine the active 156 * field of the GtkCheckMenuItem struct to discover the new state. 157 */ 158 void addOnToggled(void delegate(CheckMenuItem) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 159 { 160 if ( !("toggled" in connectedSignals) ) 161 { 162 Signals.connectData( 163 getStruct(), 164 "toggled", 165 cast(GCallback)&callBackToggled, 166 cast(void*)this, 167 null, 168 connectFlags); 169 connectedSignals["toggled"] = 1; 170 } 171 onToggledListeners ~= dlg; 172 } 173 extern(C) static void callBackToggled(GtkCheckMenuItem* checkmenuitemStruct, CheckMenuItem _checkMenuItem) 174 { 175 foreach ( void delegate(CheckMenuItem) dlg ; _checkMenuItem.onToggledListeners ) 176 { 177 dlg(_checkMenuItem); 178 } 179 } 180 181 182 /** 183 * Creates a new GtkCheckMenuItem. 184 * Throws: ConstructionException GTK+ fails to create the object. 185 */ 186 public this () 187 { 188 // GtkWidget * gtk_check_menu_item_new (void); 189 auto p = gtk_check_menu_item_new(); 190 if(p is null) 191 { 192 throw new ConstructionException("null returned by gtk_check_menu_item_new()"); 193 } 194 this(cast(GtkCheckMenuItem*) p); 195 } 196 197 /** 198 * Returns whether the check menu item is active. See 199 * gtk_check_menu_item_set_active(). 200 * Returns: TRUE if the menu item is checked. 201 */ 202 public int getActive() 203 { 204 // gboolean gtk_check_menu_item_get_active (GtkCheckMenuItem *check_menu_item); 205 return gtk_check_menu_item_get_active(gtkCheckMenuItem); 206 } 207 208 /** 209 * Sets the active state of the menu item's check box. 210 * Params: 211 * isActive = boolean value indicating whether the check box is active. 212 */ 213 public void setActive(int isActive) 214 { 215 // void gtk_check_menu_item_set_active (GtkCheckMenuItem *check_menu_item, gboolean is_active); 216 gtk_check_menu_item_set_active(gtkCheckMenuItem, isActive); 217 } 218 219 /** 220 * Warning 221 * gtk_check_menu_item_set_show_toggle is deprecated and should not be used in newly-written code. 222 * Controls whether the check box is shown at all times. 223 * Normally the check box is shown only when it is active or while the 224 * menu item is selected. 225 * Params: 226 * always = boolean value indicating whether to always show the check box. 227 */ 228 public void setShowToggle(int always) 229 { 230 // void gtk_check_menu_item_set_show_toggle (GtkCheckMenuItem *menu_item, gboolean always); 231 gtk_check_menu_item_set_show_toggle(gtkCheckMenuItem, always); 232 } 233 234 /** 235 * Emits the GtkCheckMenuItem::toggled signal. 236 */ 237 public void toggled() 238 { 239 // void gtk_check_menu_item_toggled (GtkCheckMenuItem *check_menu_item); 240 gtk_check_menu_item_toggled(gtkCheckMenuItem); 241 } 242 243 /** 244 * Retrieves the value set by gtk_check_menu_item_set_inconsistent(). 245 * Returns: TRUE if inconsistent 246 */ 247 public int getInconsistent() 248 { 249 // gboolean gtk_check_menu_item_get_inconsistent (GtkCheckMenuItem *check_menu_item); 250 return gtk_check_menu_item_get_inconsistent(gtkCheckMenuItem); 251 } 252 253 /** 254 * If the user has selected a range of elements (such as some text or 255 * spreadsheet cells) that are affected by a boolean setting, and the 256 * current values in that range are inconsistent, you may want to 257 * display the check in an "in between" state. This function turns on 258 * "in between" display. Normally you would turn off the inconsistent 259 * state again if the user explicitly selects a setting. This has to be 260 * done manually, gtk_check_menu_item_set_inconsistent() only affects 261 * visual appearance, it doesn't affect the semantics of the widget. 262 * Params: 263 * setting = TRUE to display an "inconsistent" third state check 264 */ 265 public void setInconsistent(int setting) 266 { 267 // void gtk_check_menu_item_set_inconsistent (GtkCheckMenuItem *check_menu_item, gboolean setting); 268 gtk_check_menu_item_set_inconsistent(gtkCheckMenuItem, setting); 269 } 270 271 /** 272 * Sets whether check_menu_item is drawn like a GtkRadioMenuItem 273 * Since 2.4 274 * Params: 275 * drawAsRadio = whether check_menu_item is drawn like a GtkRadioMenuItem 276 */ 277 public void setDrawAsRadio(int drawAsRadio) 278 { 279 // void gtk_check_menu_item_set_draw_as_radio (GtkCheckMenuItem *check_menu_item, gboolean draw_as_radio); 280 gtk_check_menu_item_set_draw_as_radio(gtkCheckMenuItem, drawAsRadio); 281 } 282 283 /** 284 * Returns whether check_menu_item looks like a GtkRadioMenuItem 285 * Since 2.4 286 * Returns: Whether check_menu_item looks like a GtkRadioMenuItem 287 */ 288 public int getDrawAsRadio() 289 { 290 // gboolean gtk_check_menu_item_get_draw_as_radio (GtkCheckMenuItem *check_menu_item); 291 return gtk_check_menu_item_get_draw_as_radio(gtkCheckMenuItem); 292 } 293 }