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  = GtkToggleToolButton.html
27  * outPack = gtk
28  * outFile = ToggleToolButton
29  * strct   = GtkToggleToolButton
30  * realStrct=
31  * ctorStrct=GtkToolItem
32  * clss    = ToggleToolButton
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_toggle_tool_button_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * structWrap:
48  * module aliases:
49  * local aliases:
50  * overrides:
51  */
52 
53 module gtk.ToggleToolButton;
54 
55 public  import gtkc.gtktypes;
56 
57 private import gtkc.gtk;
58 private import glib.ConstructionException;
59 private import gobject.ObjectG;
60 
61 private import gobject.Signals;
62 public  import gtkc.gdktypes;
63 
64 private import glib.Str;
65 
66 
67 
68 private import gtk.ToolButton;
69 
70 /**
71  * A GtkToggleToolButton is a GtkToolItem that contains a toggle
72  * button.
73  *
74  * Use gtk_toggle_tool_button_new() to create a new
75  * GtkToggleToolButton.
76  */
77 public class ToggleToolButton : ToolButton
78 {
79 	
80 	/** the main Gtk struct */
81 	protected GtkToggleToolButton* gtkToggleToolButton;
82 	
83 	
84 	public GtkToggleToolButton* getToggleToolButtonStruct()
85 	{
86 		return gtkToggleToolButton;
87 	}
88 	
89 	
90 	/** the main Gtk struct as a void* */
91 	protected override void* getStruct()
92 	{
93 		return cast(void*)gtkToggleToolButton;
94 	}
95 	
96 	/**
97 	 * Sets our main struct and passes it to the parent class
98 	 */
99 	public this (GtkToggleToolButton* gtkToggleToolButton)
100 	{
101 		super(cast(GtkToolButton*)gtkToggleToolButton);
102 		this.gtkToggleToolButton = gtkToggleToolButton;
103 	}
104 	
105 	protected override void setStruct(GObject* obj)
106 	{
107 		super.setStruct(obj);
108 		gtkToggleToolButton = cast(GtkToggleToolButton*)obj;
109 	}
110 	
111 	/**
112 	 * Creates a new GtkToggleToolButton containing the image and text
113 	 * from a stock item.
114 	 */
115 	public this(StockID stockId)
116 	{
117 		this(StockDesc[stockId]);
118 	}
119 	
120 	/**
121 	 */
122 	int[string] connectedSignals;
123 	
124 	void delegate(ToggleToolButton)[] onToggledListeners;
125 	/**
126 	 * Emitted whenever the toggle tool button changes state.
127 	 * See Also
128 	 * GtkToolbar, GtkToolButton, GtkSeparatorToolItem
129 	 */
130 	void addOnToggled(void delegate(ToggleToolButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
131 	{
132 		if ( !("toggled" in connectedSignals) )
133 		{
134 			Signals.connectData(
135 			getStruct(),
136 			"toggled",
137 			cast(GCallback)&callBackToggled,
138 			cast(void*)this,
139 			null,
140 			connectFlags);
141 			connectedSignals["toggled"] = 1;
142 		}
143 		onToggledListeners ~= dlg;
144 	}
145 	extern(C) static void callBackToggled(GtkToggleToolButton* toggleToolButtonStruct, ToggleToolButton _toggleToolButton)
146 	{
147 		foreach ( void delegate(ToggleToolButton) dlg ; _toggleToolButton.onToggledListeners )
148 		{
149 			dlg(_toggleToolButton);
150 		}
151 	}
152 	
153 	
154 	/**
155 	 * Returns a new GtkToggleToolButton
156 	 * Since 2.4
157 	 * Throws: ConstructionException GTK+ fails to create the object.
158 	 */
159 	public this ()
160 	{
161 		// GtkToolItem * gtk_toggle_tool_button_new (void);
162 		auto p = gtk_toggle_tool_button_new();
163 		if(p is null)
164 		{
165 			throw new ConstructionException("null returned by gtk_toggle_tool_button_new()");
166 		}
167 		this(cast(GtkToggleToolButton*) p);
168 	}
169 	
170 	/**
171 	 * Warning
172 	 * gtk_toggle_tool_button_new_from_stock has been deprecated since version 3.10 and should not be used in newly-written code. Use gtk_toggle_tool_button_new() instead.
173 	 * Creates a new GtkToggleToolButton containing the image and text from a
174 	 * stock item. Some stock ids have preprocessor macros like GTK_STOCK_OK
175 	 * and GTK_STOCK_APPLY.
176 	 * It is an error if stock_id is not a name of a stock item.
177 	 * Since 2.4
178 	 * Params:
179 	 * stockId = the name of the stock item
180 	 * Throws: ConstructionException GTK+ fails to create the object.
181 	 */
182 	public this (string stockId)
183 	{
184 		// GtkToolItem * gtk_toggle_tool_button_new_from_stock  (const gchar *stock_id);
185 		auto p = gtk_toggle_tool_button_new_from_stock(Str.toStringz(stockId));
186 		if(p is null)
187 		{
188 			throw new ConstructionException("null returned by gtk_toggle_tool_button_new_from_stock(Str.toStringz(stockId))");
189 		}
190 		this(cast(GtkToggleToolButton*) p);
191 	}
192 	
193 	/**
194 	 * Sets the status of the toggle tool button. Set to TRUE if you
195 	 * want the GtkToggleButton to be 'pressed in', and FALSE to raise it.
196 	 * This action causes the toggled signal to be emitted.
197 	 * Since 2.4
198 	 * Params:
199 	 * isActive = whether button should be active
200 	 */
201 	public void setActive(int isActive)
202 	{
203 		// void gtk_toggle_tool_button_set_active (GtkToggleToolButton *button,  gboolean is_active);
204 		gtk_toggle_tool_button_set_active(gtkToggleToolButton, isActive);
205 	}
206 	
207 	/**
208 	 * Queries a GtkToggleToolButton and returns its current state.
209 	 * Returns TRUE if the toggle button is pressed in and FALSE if it is raised.
210 	 * Since 2.4
211 	 * Returns: TRUE if the toggle tool button is pressed in, FALSE if not
212 	 */
213 	public int getActive()
214 	{
215 		// gboolean gtk_toggle_tool_button_get_active (GtkToggleToolButton *button);
216 		return gtk_toggle_tool_button_get_active(gtkToggleToolButton);
217 	}
218 }