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