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 public class Stack : Container
51 {
52 	/** the main Gtk struct */
53 	protected GtkStack* gtkStack;
54 
55 	/** Get the main Gtk struct */
56 	public GtkStack* getStackStruct()
57 	{
58 		return gtkStack;
59 	}
60 
61 	/** the main Gtk struct as a void* */
62 	protected override void* getStruct()
63 	{
64 		return cast(void*)gtkStack;
65 	}
66 
67 	protected override void setStruct(GObject* obj)
68 	{
69 		gtkStack = cast(GtkStack*)obj;
70 		super.setStruct(obj);
71 	}
72 
73 	/**
74 	 * Sets our main struct and passes it to the parent class.
75 	 */
76 	public this (GtkStack* gtkStack, bool ownedRef = false)
77 	{
78 		this.gtkStack = gtkStack;
79 		super(cast(GtkContainer*)gtkStack, ownedRef);
80 	}
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 	 * Return: 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 	 * Return: 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 	 * Return: 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 	 * Return: 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 the amount of time (in milliseconds) that
196 	 * transitions between pages in @stack will take.
197 	 *
198 	 * Return: the transition duration
199 	 *
200 	 * Since: 3.10
201 	 */
202 	public uint getTransitionDuration()
203 	{
204 		return gtk_stack_get_transition_duration(gtkStack);
205 	}
206 
207 	/**
208 	 * Returns whether the @stack is currently in a transition from one page to
209 	 * another.
210 	 *
211 	 * Return: %TRUE if the transition is currently running, %FALSE otherwise.
212 	 *
213 	 * Since: 3.12
214 	 */
215 	public bool getTransitionRunning()
216 	{
217 		return gtk_stack_get_transition_running(gtkStack) != 0;
218 	}
219 
220 	/**
221 	 * Gets the type of animation that will be used
222 	 * for transitions between pages in @stack.
223 	 *
224 	 * Return: the current transition type of @stack
225 	 *
226 	 * Since: 3.10
227 	 */
228 	public GtkStackTransitionType getTransitionType()
229 	{
230 		return gtk_stack_get_transition_type(gtkStack);
231 	}
232 
233 	/**
234 	 * Gets whether @stack is vertically homogeneous.
235 	 * See gtk_stack_set_vhomogeneous().
236 	 *
237 	 * Return: whether @stack is vertically homogeneous.
238 	 *
239 	 * Since: 3.16
240 	 */
241 	public bool getVhomogeneous()
242 	{
243 		return gtk_stack_get_vhomogeneous(gtkStack) != 0;
244 	}
245 
246 	/**
247 	 * Gets the currently visible child of @stack, or %NULL if
248 	 * there are no visible children.
249 	 *
250 	 * Return: the visible child of the #GtkStack
251 	 *
252 	 * Since: 3.10
253 	 */
254 	public Widget getVisibleChild()
255 	{
256 		auto p = gtk_stack_get_visible_child(gtkStack);
257 		
258 		if(p is null)
259 		{
260 			return null;
261 		}
262 		
263 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
264 	}
265 
266 	/**
267 	 * Returns the name of the currently visible child of @stack, or
268 	 * %NULL if there is no visible child.
269 	 *
270 	 * Return: the name of the visible child of the #GtkStack
271 	 *
272 	 * Since: 3.10
273 	 */
274 	public string getVisibleChildName()
275 	{
276 		return Str.toString(gtk_stack_get_visible_child_name(gtkStack));
277 	}
278 
279 	/**
280 	 * Sets the #GtkStack to be horizontally homogeneous or not.
281 	 * If it is homogeneous, the #GtkStack will request the same
282 	 * width for all its children. If it isn't, the stack
283 	 * may change width when a different child becomes visible.
284 	 *
285 	 * Params:
286 	 *     hhomogeneous = %TRUE to make @stack horizontally homogeneous
287 	 *
288 	 * Since: 3.16
289 	 */
290 	public void setHhomogeneous(bool hhomogeneous)
291 	{
292 		gtk_stack_set_hhomogeneous(gtkStack, hhomogeneous);
293 	}
294 
295 	/**
296 	 * Sets the #GtkStack to be homogeneous or not. If it
297 	 * is homogeneous, the #GtkStack will request the same
298 	 * size for all its children. If it isn't, the stack
299 	 * may change size when a different child becomes visible.
300 	 *
301 	 * Since 3.16, homogeneity can be controlled separately
302 	 * for horizontal and vertical size, with the
303 	 * #GtkStack:hhomogeneous and #GtkStack:vhomogeneous.
304 	 *
305 	 * Params:
306 	 *     homogeneous = %TRUE to make @stack homogeneous
307 	 *
308 	 * Since: 3.10
309 	 */
310 	public void setHomogeneous(bool homogeneous)
311 	{
312 		gtk_stack_set_homogeneous(gtkStack, homogeneous);
313 	}
314 
315 	/**
316 	 * Sets the duration that transitions between pages in @stack
317 	 * will take.
318 	 *
319 	 * Params:
320 	 *     duration = the new duration, in milliseconds
321 	 *
322 	 * Since: 3.10
323 	 */
324 	public void setTransitionDuration(uint duration)
325 	{
326 		gtk_stack_set_transition_duration(gtkStack, duration);
327 	}
328 
329 	/**
330 	 * Sets the type of animation that will be used for
331 	 * transitions between pages in @stack. Available
332 	 * types include various kinds of fades and slides.
333 	 *
334 	 * The transition type can be changed without problems
335 	 * at runtime, so it is possible to change the animation
336 	 * based on the page that is about to become current.
337 	 *
338 	 * Params:
339 	 *     transition = the new transition type
340 	 *
341 	 * Since: 3.10
342 	 */
343 	public void setTransitionType(GtkStackTransitionType transition)
344 	{
345 		gtk_stack_set_transition_type(gtkStack, transition);
346 	}
347 
348 	/**
349 	 * Sets the #GtkStack to be vertically homogeneous or not.
350 	 * If it is homogeneous, the #GtkStack will request the same
351 	 * height for all its children. If it isn't, the stack
352 	 * may change height when a different child becomes visible.
353 	 *
354 	 * Params:
355 	 *     vhomogeneous = %TRUE to make @stack vertically homogeneous
356 	 *
357 	 * Since: 3.16
358 	 */
359 	public void setVhomogeneous(bool vhomogeneous)
360 	{
361 		gtk_stack_set_vhomogeneous(gtkStack, vhomogeneous);
362 	}
363 
364 	/**
365 	 * Makes @child the visible child of @stack.
366 	 *
367 	 * If @child is different from the currently
368 	 * visible child, the transition between the
369 	 * two will be animated with the current
370 	 * transition type of @stack.
371 	 *
372 	 * Note that the @child widget has to be visible itself
373 	 * (see gtk_widget_show()) in order to become the visible
374 	 * child of @stack.
375 	 *
376 	 * Params:
377 	 *     child = a child of @stack
378 	 *
379 	 * Since: 3.10
380 	 */
381 	public void setVisibleChild(Widget child)
382 	{
383 		gtk_stack_set_visible_child(gtkStack, (child is null) ? null : child.getWidgetStruct());
384 	}
385 
386 	/**
387 	 * Makes the child with the given name visible.
388 	 *
389 	 * Note that the child widget has to be visible itself
390 	 * (see gtk_widget_show()) in order to become the visible
391 	 * child of @stack.
392 	 *
393 	 * Params:
394 	 *     name = the name of the child to make visible
395 	 *     transition = the transition type to use
396 	 *
397 	 * Since: 3.10
398 	 */
399 	public void setVisibleChildFull(string name, GtkStackTransitionType transition)
400 	{
401 		gtk_stack_set_visible_child_full(gtkStack, Str.toStringz(name), transition);
402 	}
403 
404 	/**
405 	 * Makes the child with the given name visible.
406 	 *
407 	 * If @child is different from the currently
408 	 * visible child, the transition between the
409 	 * two will be animated with the current
410 	 * transition type of @stack.
411 	 *
412 	 * Note that the child widget has to be visible itself
413 	 * (see gtk_widget_show()) in order to become the visible
414 	 * child of @stack.
415 	 *
416 	 * Params:
417 	 *     name = the name of the child to make visible
418 	 *
419 	 * Since: 3.10
420 	 */
421 	public void setVisibleChildName(string name)
422 	{
423 		gtk_stack_set_visible_child_name(gtkStack, Str.toStringz(name));
424 	}
425 }