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