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