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  = GtkExpander.html
27  * outPack = gtk
28  * outFile = Expander
29  * strct   = GtkExpander
30  * realStrct=
31  * ctorStrct=
32  * clss    = Expander
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_expander_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * 	- gtk_expander_new
45  * 	- gtk_expander_new_with_mnemonic
46  * omit signals:
47  * imports:
48  * 	- glib.Str
49  * 	- gtk.Widget
50  * structWrap:
51  * 	- GtkWidget* -> Widget
52  * module aliases:
53  * local aliases:
54  * overrides:
55  */
56 
57 module gtk.Expander;
58 
59 public  import gtkc.gtktypes;
60 
61 private import gtkc.gtk;
62 private import glib.ConstructionException;
63 private import gobject.ObjectG;
64 
65 private import gobject.Signals;
66 public  import gtkc.gdktypes;
67 private import glib.Str;
68 private import gtk.Widget;
69 
70 
71 private import gtk.Bin;
72 
73 /**
74  * A GtkExpander allows the user to hide or show its child by clicking
75  * on an expander triangle similar to the triangles used in a GtkTreeView.
76  *
77  * Normally you use an expander as you would use any other descendant
78  * of GtkBin; you create the child widget and use gtk_container_add()
79  * to add it to the expander. When the expander is toggled, it will take
80  * care of showing and hiding the child automatically.
81  *
82  * Special Usage
83  *
84  * There are situations in which you may prefer to show and hide the
85  * expanded widget yourself, such as when you want to actually create
86  * the widget at expansion time. In this case, create a GtkExpander
87  * but do not add a child to it. The expander widget has an
88  * "expanded" property which can be used to monitor
89  * its expansion state. You should watch this property with a signal
90  * connection as follows:
91  *
92  * $(DDOC_COMMENT example)
93  *
94  * <hr>
95  *
96  * GtkExpander as GtkBuildable
97  *
98  * The GtkExpander implementation of the GtkBuildable interface
99  * supports placing a child in the label position by specifying
100  * "label" as the "type" attribute of a &lt;child&gt; element.
101  * A normal content child can be specified without specifying
102  * a &lt;child&gt; type attribute.
103  *
104  * $(DDOC_COMMENT example)
105  */
106 public class Expander : Bin
107 {
108 	
109 	/** the main Gtk struct */
110 	protected GtkExpander* gtkExpander;
111 	
112 	
113 	/** Get the main Gtk struct */
114 	public GtkExpander* getExpanderStruct()
115 	{
116 		return gtkExpander;
117 	}
118 	
119 	
120 	/** the main Gtk struct as a void* */
121 	protected override void* getStruct()
122 	{
123 		return cast(void*)gtkExpander;
124 	}
125 	
126 	/**
127 	 * Sets our main struct and passes it to the parent class
128 	 */
129 	public this (GtkExpander* gtkExpander)
130 	{
131 		super(cast(GtkBin*)gtkExpander);
132 		this.gtkExpander = gtkExpander;
133 	}
134 	
135 	protected override void setStruct(GObject* obj)
136 	{
137 		super.setStruct(obj);
138 		gtkExpander = cast(GtkExpander*)obj;
139 	}
140 	
141 	/**
142 	 * Creates a new expander using label as the text of the label.
143 	 * Since 2.4
144 	 * Params:
145 	 *  label = the text of the label
146 	 *  mnemonic = if true characters in label that are preceded by an underscore,
147 	 *  are underlined.
148 	 *  If you need a literal underscore character in a label, use '__' (two
149 	 *  underscores). The first underlined character represents a keyboard
150 	 *  accelerator called a mnemonic.
151 	 * Throws: ConstructionException GTK+ fails to create the object.
152 	 */
153 	public this (string label, bool mnemonic=true)
154 	{
155 		GtkExpander* p;
156 		
157 		if ( mnemonic )
158 		{
159 			// GtkWidget* gtk_expander_new_with_mnemonic (const gchar *label);
160 			p = cast(GtkExpander*)gtk_expander_new_with_mnemonic(Str.toStringz(label));
161 		}
162 		else
163 		{
164 			// GtkWidget* gtk_expander_new (const gchar *label);
165 			p = cast(GtkExpander*)gtk_expander_new(Str.toStringz(label));
166 		}
167 		
168 		if(p is null)
169 		{
170 			throw new ConstructionException("null returned by gtk_expander_new");
171 		}
172 		
173 		this(p);
174 	}
175 	
176 	/**
177 	 */
178 	int[string] connectedSignals;
179 	
180 	void delegate(Expander)[] onActivateListeners;
181 	/**
182 	 */
183 	void addOnActivate(void delegate(Expander) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
184 	{
185 		if ( !("activate" in connectedSignals) )
186 		{
187 			Signals.connectData(
188 			getStruct(),
189 			"activate",
190 			cast(GCallback)&callBackActivate,
191 			cast(void*)this,
192 			null,
193 			connectFlags);
194 			connectedSignals["activate"] = 1;
195 		}
196 		onActivateListeners ~= dlg;
197 	}
198 	extern(C) static void callBackActivate(GtkExpander* expanderStruct, Expander _expander)
199 	{
200 		foreach ( void delegate(Expander) dlg ; _expander.onActivateListeners )
201 		{
202 			dlg(_expander);
203 		}
204 	}
205 	
206 	
207 	/**
208 	 * Sets the state of the expander. Set to TRUE, if you want
209 	 * the child widget to be revealed, and FALSE if you want the
210 	 * child widget to be hidden.
211 	 * Since 2.4
212 	 * Params:
213 	 * expanded = whether the child widget is revealed
214 	 */
215 	public void setExpanded(int expanded)
216 	{
217 		// void gtk_expander_set_expanded (GtkExpander *expander,  gboolean expanded);
218 		gtk_expander_set_expanded(gtkExpander, expanded);
219 	}
220 	
221 	/**
222 	 * Queries a GtkExpander and returns its current state. Returns TRUE
223 	 * if the child widget is revealed.
224 	 * See gtk_expander_set_expanded().
225 	 * Since 2.4
226 	 * Returns: the current state of the expander
227 	 */
228 	public int getExpanded()
229 	{
230 		// gboolean gtk_expander_get_expanded (GtkExpander *expander);
231 		return gtk_expander_get_expanded(gtkExpander);
232 	}
233 	
234 	/**
235 	 * Sets the spacing field of expander, which is the number of
236 	 * pixels to place between expander and the child.
237 	 * Since 2.4
238 	 * Params:
239 	 * spacing = distance between the expander and child in pixels
240 	 */
241 	public void setSpacing(int spacing)
242 	{
243 		// void gtk_expander_set_spacing (GtkExpander *expander,  gint spacing);
244 		gtk_expander_set_spacing(gtkExpander, spacing);
245 	}
246 	
247 	/**
248 	 * Gets the value set by gtk_expander_set_spacing().
249 	 * Since 2.4
250 	 * Returns: spacing between the expander and child
251 	 */
252 	public int getSpacing()
253 	{
254 		// gint gtk_expander_get_spacing (GtkExpander *expander);
255 		return gtk_expander_get_spacing(gtkExpander);
256 	}
257 	
258 	/**
259 	 * Sets the text of the label of the expander to label.
260 	 * This will also clear any previously set labels.
261 	 * Since 2.4
262 	 * Params:
263 	 * label = a string. [allow-none]
264 	 */
265 	public void setLabel(string label)
266 	{
267 		// void gtk_expander_set_label (GtkExpander *expander,  const gchar *label);
268 		gtk_expander_set_label(gtkExpander, Str.toStringz(label));
269 	}
270 	
271 	/**
272 	 * Fetches the text from a label widget including any embedded
273 	 * underlines indicating mnemonics and Pango markup, as set by
274 	 * gtk_expander_set_label(). If the label text has not been set the
275 	 * return value will be NULL. This will be the case if you create an
276 	 * empty button with gtk_button_new() to use as a container.
277 	 * Note that this function behaved differently in versions prior to
278 	 * 2.14 and used to return the label text stripped of embedded
279 	 * underlines indicating mnemonics and Pango markup. This problem can
280 	 * be avoided by fetching the label text directly from the label
281 	 * widget.
282 	 * Since 2.4
283 	 * Returns: The text of the label widget. This string is owned by the widget and must not be modified or freed.
284 	 */
285 	public string getLabel()
286 	{
287 		// const gchar * gtk_expander_get_label (GtkExpander *expander);
288 		return Str.toString(gtk_expander_get_label(gtkExpander));
289 	}
290 	
291 	/**
292 	 * If true, an underline in the text of the expander label indicates
293 	 * the next character should be used for the mnemonic accelerator key.
294 	 * Since 2.4
295 	 * Params:
296 	 * useUnderline = TRUE if underlines in the text indicate mnemonics
297 	 */
298 	public void setUseUnderline(int useUnderline)
299 	{
300 		// void gtk_expander_set_use_underline (GtkExpander *expander,  gboolean use_underline);
301 		gtk_expander_set_use_underline(gtkExpander, useUnderline);
302 	}
303 	
304 	/**
305 	 * Returns whether an embedded underline in the expander label
306 	 * indicates a mnemonic. See gtk_expander_set_use_underline().
307 	 * Since 2.4
308 	 * Returns: TRUE if an embedded underline in the expander label indicates the mnemonic accelerator keys
309 	 */
310 	public int getUseUnderline()
311 	{
312 		// gboolean gtk_expander_get_use_underline (GtkExpander *expander);
313 		return gtk_expander_get_use_underline(gtkExpander);
314 	}
315 	
316 	/**
317 	 * Sets whether the text of the label contains markup in Pango's text markup
318 	 * language. See gtk_label_set_markup().
319 	 * Since 2.4
320 	 * Params:
321 	 * useMarkup = TRUE if the label's text should be parsed for markup
322 	 */
323 	public void setUseMarkup(int useMarkup)
324 	{
325 		// void gtk_expander_set_use_markup (GtkExpander *expander,  gboolean use_markup);
326 		gtk_expander_set_use_markup(gtkExpander, useMarkup);
327 	}
328 	
329 	/**
330 	 * Returns whether the label's text is interpreted as marked up with
331 	 * the Pango text markup
332 	 * language. See gtk_expander_set_use_markup().
333 	 * Since 2.4
334 	 * Returns: TRUE if the label's text will be parsed for markup
335 	 */
336 	public int getUseMarkup()
337 	{
338 		// gboolean gtk_expander_get_use_markup (GtkExpander *expander);
339 		return gtk_expander_get_use_markup(gtkExpander);
340 	}
341 	
342 	/**
343 	 * Set the label widget for the expander. This is the widget
344 	 * that will appear embedded alongside the expander arrow.
345 	 * Since 2.4
346 	 * Params:
347 	 * labelWidget = the new label widget. [allow-none]
348 	 */
349 	public void setLabelWidget(Widget labelWidget)
350 	{
351 		// void gtk_expander_set_label_widget (GtkExpander *expander,  GtkWidget *label_widget);
352 		gtk_expander_set_label_widget(gtkExpander, (labelWidget is null) ? null : labelWidget.getWidgetStruct());
353 	}
354 	
355 	/**
356 	 * Retrieves the label widget for the frame. See
357 	 * gtk_expander_set_label_widget().
358 	 * Since 2.4
359 	 * Returns: the label widget, or NULL if there is none. [transfer none]
360 	 */
361 	public Widget getLabelWidget()
362 	{
363 		// GtkWidget * gtk_expander_get_label_widget (GtkExpander *expander);
364 		auto p = gtk_expander_get_label_widget(gtkExpander);
365 		
366 		if(p is null)
367 		{
368 			return null;
369 		}
370 		
371 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
372 	}
373 	
374 	/**
375 	 * Sets whether the label widget should fill all available
376 	 * horizontal space allocated to expander.
377 	 * Since 2.22
378 	 * Params:
379 	 * labelFill = TRUE if the label should should fill
380 	 * all available horizontal space
381 	 */
382 	public void setLabelFill(int labelFill)
383 	{
384 		// void gtk_expander_set_label_fill (GtkExpander *expander,  gboolean label_fill);
385 		gtk_expander_set_label_fill(gtkExpander, labelFill);
386 	}
387 	
388 	/**
389 	 * Returns whether the label widget will fill all available
390 	 * horizontal space allocated to expander.
391 	 * Since 2.22
392 	 * Returns: TRUE if the label widget will fill all available horizontal space
393 	 */
394 	public int getLabelFill()
395 	{
396 		// gboolean gtk_expander_get_label_fill (GtkExpander *expander);
397 		return gtk_expander_get_label_fill(gtkExpander);
398 	}
399 	
400 	/**
401 	 * Sets whether the expander will resize the toplevel widget
402 	 * containing the expander upon resizing and collpasing.
403 	 * Params:
404 	 * resizeToplevel = whether to resize the toplevel
405 	 * Since 3.2
406 	 */
407 	public void setResizeToplevel(int resizeToplevel)
408 	{
409 		// void gtk_expander_set_resize_toplevel (GtkExpander *expander,  gboolean resize_toplevel);
410 		gtk_expander_set_resize_toplevel(gtkExpander, resizeToplevel);
411 	}
412 	
413 	/**
414 	 * Returns whether the expander will resize the toplevel widget
415 	 * containing the expander upon resizing and collpasing.
416 	 * Returns: the "resize toplevel" setting. Since 3.2
417 	 */
418 	public int getResizeToplevel()
419 	{
420 		// gboolean gtk_expander_get_resize_toplevel (GtkExpander *expander);
421 		return gtk_expander_get_resize_toplevel(gtkExpander);
422 	}
423 }