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