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