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