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.Box;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gtk.OrientableIF;
30 private import gtk.OrientableT;
31 private import gtk.Widget;
32 private import gtk.c.functions;
33 public  import gtk.c.types;
34 
35 
36 /**
37  * The `GtkBox` widget arranges child widgets into a single row or column.
38  * 
39  * ![An example GtkBox](box.png)
40  * 
41  * Whether it is a row or column depends on the value of its
42  * [property@Gtk.Orientable:orientation] property. Within the other
43  * dimension, all children are allocated the same size. Of course, the
44  * [property@Gtk.Widget:halign] and [property@Gtk.Widget:valign] properties
45  * can be used on the children to influence their allocation.
46  * 
47  * Use repeated calls to [method@Gtk.Box.append] to pack widgets into a
48  * `GtkBox` from start to end. Use [method@Gtk.Box.remove] to remove widgets
49  * from the `GtkBox`. [method@Gtk.Box.insert_child_after] can be used to add
50  * a child at a particular position.
51  * 
52  * Use [method@Gtk.Box.set_homogeneous] to specify whether or not all children
53  * of the `GtkBox` are forced to get the same amount of space.
54  * 
55  * Use [method@Gtk.Box.set_spacing] to determine how much space will be minimally
56  * placed between all children in the `GtkBox`. Note that spacing is added
57  * *between* the children.
58  * 
59  * Use [method@Gtk.Box.reorder_child_after] to move a child to a different
60  * place in the box.
61  * 
62  * # CSS nodes
63  * 
64  * `GtkBox` uses a single CSS node with name box.
65  * 
66  * # Accessibility
67  * 
68  * `GtkBox` uses the %GTK_ACCESSIBLE_ROLE_GROUP role.
69  */
70 public class Box : Widget, OrientableIF
71 {
72 	/** the main Gtk struct */
73 	protected GtkBox* gtkBox;
74 
75 	/** Get the main Gtk struct */
76 	public GtkBox* getBoxStruct(bool transferOwnership = false)
77 	{
78 		if (transferOwnership)
79 			ownedRef = false;
80 		return gtkBox;
81 	}
82 
83 	/** the main Gtk struct as a void* */
84 	protected override void* getStruct()
85 	{
86 		return cast(void*)gtkBox;
87 	}
88 
89 	/**
90 	 * Sets our main struct and passes it to the parent class.
91 	 */
92 	public this (GtkBox* gtkBox, bool ownedRef = false)
93 	{
94 		this.gtkBox = gtkBox;
95 		super(cast(GtkWidget*)gtkBox, ownedRef);
96 	}
97 
98 	// add the Orientable capabilities
99 	mixin OrientableT!(GtkBox);
100 
101 
102 	/** */
103 	public static GType getType()
104 	{
105 		return gtk_box_get_type();
106 	}
107 
108 	/**
109 	 * Creates a new `GtkBox`.
110 	 *
111 	 * Params:
112 	 *     orientation = the box’s orientation
113 	 *     spacing = the number of pixels to place by default between children
114 	 *
115 	 * Returns: a new `GtkBox`.
116 	 *
117 	 * Throws: ConstructionException GTK+ fails to create the object.
118 	 */
119 	public this(GtkOrientation orientation, int spacing)
120 	{
121 		auto __p = gtk_box_new(orientation, spacing);
122 
123 		if(__p is null)
124 		{
125 			throw new ConstructionException("null returned by new");
126 		}
127 
128 		this(cast(GtkBox*) __p);
129 	}
130 
131 	/**
132 	 * Adds @child as the last child to @box.
133 	 *
134 	 * Params:
135 	 *     child = the `GtkWidget` to append
136 	 */
137 	public void append(Widget child)
138 	{
139 		gtk_box_append(gtkBox, (child is null) ? null : child.getWidgetStruct());
140 	}
141 
142 	/**
143 	 * Gets the value set by gtk_box_set_baseline_position().
144 	 *
145 	 * Returns: the baseline position
146 	 */
147 	public GtkBaselinePosition getBaselinePosition()
148 	{
149 		return gtk_box_get_baseline_position(gtkBox);
150 	}
151 
152 	/**
153 	 * Returns whether the box is homogeneous (all children are the
154 	 * same size).
155 	 *
156 	 * Returns: %TRUE if the box is homogeneous.
157 	 */
158 	public bool getHomogeneous()
159 	{
160 		return gtk_box_get_homogeneous(gtkBox) != 0;
161 	}
162 
163 	/**
164 	 * Gets the value set by gtk_box_set_spacing().
165 	 *
166 	 * Returns: spacing between children
167 	 */
168 	public int getSpacing()
169 	{
170 		return gtk_box_get_spacing(gtkBox);
171 	}
172 
173 	/**
174 	 * Inserts @child in the position after @sibling in the list
175 	 * of @box children.
176 	 *
177 	 * If @sibling is %NULL, insert @child at the first position.
178 	 *
179 	 * Params:
180 	 *     child = the `GtkWidget` to insert
181 	 *     sibling = the sibling after which to insert @child
182 	 */
183 	public void insertChildAfter(Widget child, Widget sibling)
184 	{
185 		gtk_box_insert_child_after(gtkBox, (child is null) ? null : child.getWidgetStruct(), (sibling is null) ? null : sibling.getWidgetStruct());
186 	}
187 
188 	/**
189 	 * Adds @child as the first child to @box.
190 	 *
191 	 * Params:
192 	 *     child = the `GtkWidget` to prepend
193 	 */
194 	public void prepend(Widget child)
195 	{
196 		gtk_box_prepend(gtkBox, (child is null) ? null : child.getWidgetStruct());
197 	}
198 
199 	/**
200 	 * Removes a child widget from @box.
201 	 *
202 	 * The child must have been added before with
203 	 * [method@Gtk.Box.append], [method@Gtk.Box.prepend], or
204 	 * [method@Gtk.Box.insert_child_after].
205 	 *
206 	 * Params:
207 	 *     child = the child to remove
208 	 */
209 	public void remove(Widget child)
210 	{
211 		gtk_box_remove(gtkBox, (child is null) ? null : child.getWidgetStruct());
212 	}
213 
214 	/**
215 	 * Moves @child to the position after @sibling in the list
216 	 * of @box children.
217 	 *
218 	 * If @sibling is %NULL, move @child to the first position.
219 	 *
220 	 * Params:
221 	 *     child = the `GtkWidget` to move, must be a child of @box
222 	 *     sibling = the sibling to move @child after, or %NULL
223 	 */
224 	public void reorderChildAfter(Widget child, Widget sibling)
225 	{
226 		gtk_box_reorder_child_after(gtkBox, (child is null) ? null : child.getWidgetStruct(), (sibling is null) ? null : sibling.getWidgetStruct());
227 	}
228 
229 	/**
230 	 * Sets the baseline position of a box.
231 	 *
232 	 * This affects only horizontal boxes with at least one baseline
233 	 * aligned child. If there is more vertical space available than
234 	 * requested, and the baseline is not allocated by the parent then
235 	 * @position is used to allocate the baseline with respect to the
236 	 * extra space available.
237 	 *
238 	 * Params:
239 	 *     position = a `GtkBaselinePosition`
240 	 */
241 	public void setBaselinePosition(GtkBaselinePosition position)
242 	{
243 		gtk_box_set_baseline_position(gtkBox, position);
244 	}
245 
246 	/**
247 	 * Sets whether or not all children of @box are given equal space
248 	 * in the box.
249 	 *
250 	 * Params:
251 	 *     homogeneous = a boolean value, %TRUE to create equal allotments,
252 	 *         %FALSE for variable allotments
253 	 */
254 	public void setHomogeneous(bool homogeneous)
255 	{
256 		gtk_box_set_homogeneous(gtkBox, homogeneous);
257 	}
258 
259 	/**
260 	 * Sets the number of pixels to place between children of @box.
261 	 *
262 	 * Params:
263 	 *     spacing = the number of pixels to put between children
264 	 */
265 	public void setSpacing(int spacing)
266 	{
267 		gtk_box_set_spacing(gtkBox, spacing);
268 	}
269 }