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