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 module gtk.Stack;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gtk.Container;
31 private import gtk.Widget;
32 private import gtk.c.functions;
33 public  import gtk.c.types;
34 public  import gtkc.gtktypes;
35 
36 
37 /**
38  * The GtkStack widget is a container which only shows
39  * one of its children at a time. In contrast to GtkNotebook,
40  * GtkStack does not provide a means for users to change the
41  * visible child. Instead, the #GtkStackSwitcher widget can be
42  * used with GtkStack to provide this functionality.
43  * 
44  * Transitions between pages can be animated as slides or
45  * fades. This can be controlled with gtk_stack_set_transition_type().
46  * These animations respect the #GtkSettings:gtk-enable-animations
47  * setting.
48  * 
49  * The GtkStack widget was added in GTK+ 3.10.
50  * 
51  * # CSS nodes
52  * 
53  * GtkStack has a single CSS node named stack.
54  */
55 public class Stack : Container
56 {
57 	/** the main Gtk struct */
58 	protected GtkStack* gtkStack;
59 
60 	/** Get the main Gtk struct */
61 	public GtkStack* getStackStruct(bool transferOwnership = false)
62 	{
63 		if (transferOwnership)
64 			ownedRef = false;
65 		return gtkStack;
66 	}
67 
68 	/** the main Gtk struct as a void* */
69 	protected override void* getStruct()
70 	{
71 		return cast(void*)gtkStack;
72 	}
73 
74 	protected override void setStruct(GObject* obj)
75 	{
76 		gtkStack = cast(GtkStack*)obj;
77 		super.setStruct(obj);
78 	}
79 
80 	/**
81 	 * Sets our main struct and passes it to the parent class.
82 	 */
83 	public this (GtkStack* gtkStack, bool ownedRef = false)
84 	{
85 		this.gtkStack = gtkStack;
86 		super(cast(GtkContainer*)gtkStack, ownedRef);
87 	}
88 
89 
90 	/** */
91 	public static GType getType()
92 	{
93 		return gtk_stack_get_type();
94 	}
95 
96 	/**
97 	 * Creates a new #GtkStack container.
98 	 *
99 	 * Returns: a new #GtkStack
100 	 *
101 	 * Since: 3.10
102 	 *
103 	 * Throws: ConstructionException GTK+ fails to create the object.
104 	 */
105 	public this()
106 	{
107 		auto p = gtk_stack_new();
108 
109 		if(p is null)
110 		{
111 			throw new ConstructionException("null returned by new");
112 		}
113 
114 		this(cast(GtkStack*) p);
115 	}
116 
117 	/**
118 	 * Adds a child to @stack.
119 	 * The child is identified by the @name.
120 	 *
121 	 * Params:
122 	 *     child = the widget to add
123 	 *     name = the name for @child
124 	 *
125 	 * Since: 3.10
126 	 */
127 	public void addNamed(Widget child, string name)
128 	{
129 		gtk_stack_add_named(gtkStack, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(name));
130 	}
131 
132 	/**
133 	 * Adds a child to @stack.
134 	 * The child is identified by the @name. The @title
135 	 * will be used by #GtkStackSwitcher to represent
136 	 * @child in a tab bar, so it should be short.
137 	 *
138 	 * Params:
139 	 *     child = the widget to add
140 	 *     name = the name for @child
141 	 *     title = a human-readable title for @child
142 	 *
143 	 * Since: 3.10
144 	 */
145 	public void addTitled(Widget child, string name, string title)
146 	{
147 		gtk_stack_add_titled(gtkStack, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(name), Str.toStringz(title));
148 	}
149 
150 	/**
151 	 * Finds the child of the #GtkStack with the name given as
152 	 * the argument. Returns %NULL if there is no child with this
153 	 * name.
154 	 *
155 	 * Params:
156 	 *     name = the name of the child to find
157 	 *
158 	 * Returns: the requested child of the #GtkStack
159 	 *
160 	 * Since: 3.12
161 	 */
162 	public Widget getChildByName(string name)
163 	{
164 		auto p = gtk_stack_get_child_by_name(gtkStack, Str.toStringz(name));
165 
166 		if(p is null)
167 		{
168 			return null;
169 		}
170 
171 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
172 	}
173 
174 	/**
175 	 * Gets whether @stack is horizontally homogeneous.
176 	 * See gtk_stack_set_hhomogeneous().
177 	 *
178 	 * Returns: whether @stack is horizontally homogeneous.
179 	 *
180 	 * Since: 3.16
181 	 */
182 	public bool getHhomogeneous()
183 	{
184 		return gtk_stack_get_hhomogeneous(gtkStack) != 0;
185 	}
186 
187 	/**
188 	 * Gets whether @stack is homogeneous.
189 	 * See gtk_stack_set_homogeneous().
190 	 *
191 	 * Returns: whether @stack is homogeneous.
192 	 *
193 	 * Since: 3.10
194 	 */
195 	public bool getHomogeneous()
196 	{
197 		return gtk_stack_get_homogeneous(gtkStack) != 0;
198 	}
199 
200 	/**
201 	 * Returns wether the #GtkStack is set up to interpolate between
202 	 * the sizes of children on page switch.
203 	 *
204 	 * Returns: %TRUE if child sizes are interpolated
205 	 *
206 	 * Since: 3.18
207 	 */
208 	public bool getInterpolateSize()
209 	{
210 		return gtk_stack_get_interpolate_size(gtkStack) != 0;
211 	}
212 
213 	/**
214 	 * Returns the amount of time (in milliseconds) that
215 	 * transitions between pages in @stack will take.
216 	 *
217 	 * Returns: the transition duration
218 	 *
219 	 * Since: 3.10
220 	 */
221 	public uint getTransitionDuration()
222 	{
223 		return gtk_stack_get_transition_duration(gtkStack);
224 	}
225 
226 	/**
227 	 * Returns whether the @stack is currently in a transition from one page to
228 	 * another.
229 	 *
230 	 * Returns: %TRUE if the transition is currently running, %FALSE otherwise.
231 	 *
232 	 * Since: 3.12
233 	 */
234 	public bool getTransitionRunning()
235 	{
236 		return gtk_stack_get_transition_running(gtkStack) != 0;
237 	}
238 
239 	/**
240 	 * Gets the type of animation that will be used
241 	 * for transitions between pages in @stack.
242 	 *
243 	 * Returns: the current transition type of @stack
244 	 *
245 	 * Since: 3.10
246 	 */
247 	public GtkStackTransitionType getTransitionType()
248 	{
249 		return gtk_stack_get_transition_type(gtkStack);
250 	}
251 
252 	/**
253 	 * Gets whether @stack is vertically homogeneous.
254 	 * See gtk_stack_set_vhomogeneous().
255 	 *
256 	 * Returns: whether @stack is vertically homogeneous.
257 	 *
258 	 * Since: 3.16
259 	 */
260 	public bool getVhomogeneous()
261 	{
262 		return gtk_stack_get_vhomogeneous(gtkStack) != 0;
263 	}
264 
265 	/**
266 	 * Gets the currently visible child of @stack, or %NULL if
267 	 * there are no visible children.
268 	 *
269 	 * Returns: the visible child of the #GtkStack
270 	 *
271 	 * Since: 3.10
272 	 */
273 	public Widget getVisibleChild()
274 	{
275 		auto p = gtk_stack_get_visible_child(gtkStack);
276 
277 		if(p is null)
278 		{
279 			return null;
280 		}
281 
282 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
283 	}
284 
285 	/**
286 	 * Returns the name of the currently visible child of @stack, or
287 	 * %NULL if there is no visible child.
288 	 *
289 	 * Returns: the name of the visible child of the #GtkStack
290 	 *
291 	 * Since: 3.10
292 	 */
293 	public string getVisibleChildName()
294 	{
295 		return Str.toString(gtk_stack_get_visible_child_name(gtkStack));
296 	}
297 
298 	/**
299 	 * Sets the #GtkStack to be horizontally homogeneous or not.
300 	 * If it is homogeneous, the #GtkStack will request the same
301 	 * width for all its children. If it isn't, the stack
302 	 * may change width when a different child becomes visible.
303 	 *
304 	 * Params:
305 	 *     hhomogeneous = %TRUE to make @stack horizontally homogeneous
306 	 *
307 	 * Since: 3.16
308 	 */
309 	public void setHhomogeneous(bool hhomogeneous)
310 	{
311 		gtk_stack_set_hhomogeneous(gtkStack, hhomogeneous);
312 	}
313 
314 	/**
315 	 * Sets the #GtkStack to be homogeneous or not. If it
316 	 * is homogeneous, the #GtkStack will request the same
317 	 * size for all its children. If it isn't, the stack
318 	 * may change size when a different child becomes visible.
319 	 *
320 	 * Since 3.16, homogeneity can be controlled separately
321 	 * for horizontal and vertical size, with the
322 	 * #GtkStack:hhomogeneous and #GtkStack:vhomogeneous.
323 	 *
324 	 * Params:
325 	 *     homogeneous = %TRUE to make @stack homogeneous
326 	 *
327 	 * Since: 3.10
328 	 */
329 	public void setHomogeneous(bool homogeneous)
330 	{
331 		gtk_stack_set_homogeneous(gtkStack, homogeneous);
332 	}
333 
334 	/**
335 	 * Sets whether or not @stack will interpolate its size when
336 	 * changing the visible child. If the #GtkStack:interpolate-size
337 	 * property is set to %TRUE, @stack will interpolate its size between
338 	 * the current one and the one it'll take after changing the
339 	 * visible child, according to the set transition duration.
340 	 *
341 	 * Params:
342 	 *     interpolateSize = the new value
343 	 *
344 	 * Since: 3.18
345 	 */
346 	public void setInterpolateSize(bool interpolateSize)
347 	{
348 		gtk_stack_set_interpolate_size(gtkStack, interpolateSize);
349 	}
350 
351 	/**
352 	 * Sets the duration that transitions between pages in @stack
353 	 * will take.
354 	 *
355 	 * Params:
356 	 *     duration = the new duration, in milliseconds
357 	 *
358 	 * Since: 3.10
359 	 */
360 	public void setTransitionDuration(uint duration)
361 	{
362 		gtk_stack_set_transition_duration(gtkStack, duration);
363 	}
364 
365 	/**
366 	 * Sets the type of animation that will be used for
367 	 * transitions between pages in @stack. Available
368 	 * types include various kinds of fades and slides.
369 	 *
370 	 * The transition type can be changed without problems
371 	 * at runtime, so it is possible to change the animation
372 	 * based on the page that is about to become current.
373 	 *
374 	 * Params:
375 	 *     transition = the new transition type
376 	 *
377 	 * Since: 3.10
378 	 */
379 	public void setTransitionType(GtkStackTransitionType transition)
380 	{
381 		gtk_stack_set_transition_type(gtkStack, transition);
382 	}
383 
384 	/**
385 	 * Sets the #GtkStack to be vertically homogeneous or not.
386 	 * If it is homogeneous, the #GtkStack will request the same
387 	 * height for all its children. If it isn't, the stack
388 	 * may change height when a different child becomes visible.
389 	 *
390 	 * Params:
391 	 *     vhomogeneous = %TRUE to make @stack vertically homogeneous
392 	 *
393 	 * Since: 3.16
394 	 */
395 	public void setVhomogeneous(bool vhomogeneous)
396 	{
397 		gtk_stack_set_vhomogeneous(gtkStack, vhomogeneous);
398 	}
399 
400 	/**
401 	 * Makes @child the visible child of @stack.
402 	 *
403 	 * If @child is different from the currently
404 	 * visible child, the transition between the
405 	 * two will be animated with the current
406 	 * transition type of @stack.
407 	 *
408 	 * Note that the @child widget has to be visible itself
409 	 * (see gtk_widget_show()) in order to become the visible
410 	 * child of @stack.
411 	 *
412 	 * Params:
413 	 *     child = a child of @stack
414 	 *
415 	 * Since: 3.10
416 	 */
417 	public void setVisibleChild(Widget child)
418 	{
419 		gtk_stack_set_visible_child(gtkStack, (child is null) ? null : child.getWidgetStruct());
420 	}
421 
422 	/**
423 	 * Makes the child with the given name visible.
424 	 *
425 	 * Note that the child widget has to be visible itself
426 	 * (see gtk_widget_show()) in order to become the visible
427 	 * child of @stack.
428 	 *
429 	 * Params:
430 	 *     name = the name of the child to make visible
431 	 *     transition = the transition type to use
432 	 *
433 	 * Since: 3.10
434 	 */
435 	public void setVisibleChildFull(string name, GtkStackTransitionType transition)
436 	{
437 		gtk_stack_set_visible_child_full(gtkStack, Str.toStringz(name), transition);
438 	}
439 
440 	/**
441 	 * Makes the child with the given name visible.
442 	 *
443 	 * If @child is different from the currently
444 	 * visible child, the transition between the
445 	 * two will be animated with the current
446 	 * transition type of @stack.
447 	 *
448 	 * Note that the child widget has to be visible itself
449 	 * (see gtk_widget_show()) in order to become the visible
450 	 * child of @stack.
451 	 *
452 	 * Params:
453 	 *     name = the name of the child to make visible
454 	 *
455 	 * Since: 3.10
456 	 */
457 	public void setVisibleChildName(string name)
458 	{
459 		gtk_stack_set_visible_child_name(gtkStack, Str.toStringz(name));
460 	}
461 }