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  * Conversion parameters:
26  * inFile  = GtkBox.html
27  * outPack = gtk
28  * outFile = Box
29  * strct   = GtkBox
30  * realStrct=
31  * ctorStrct=
32  * clss    = Box
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- OrientableIF
40  * prefixes:
41  * 	- gtk_box_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- gtk.Widget
48  * 	- gtk.OrientableIF
49  * 	- gtk.OrientableT
50  * structWrap:
51  * 	- GtkWidget* -> Widget
52  * module aliases:
53  * local aliases:
54  * overrides:
55  */
56 
57 module gtk.Box;
58 
59 public  import gtkc.gtktypes;
60 
61 private import gtkc.gtk;
62 private import glib.ConstructionException;
63 private import gobject.ObjectG;
64 
65 private import gtk.Widget;
66 private import gtk.OrientableIF;
67 private import gtk.OrientableT;
68 
69 
70 private import gtk.Container;
71 
72 /**
73  * The GtkBox widget organizes child widgets into a rectangular area.
74  *
75  * The rectangular area of a GtkBox is organized into either a single row
76  * or a single column of child widgets depending upon the orientation.
77  * Thus, all children of a GtkBox are allocated one dimension in common,
78  * which is the height of a row, or the width of a column.
79  *
80  * GtkBox uses a notion of packing. Packing refers
81  * to adding widgets with reference to a particular position in a
82  * GtkContainer. For a GtkBox, there are two reference positions: the
83  * start and the end of the box.
84  * For a vertical GtkBox, the start is defined as the top of the box and
85  * the end is defined as the bottom. For a horizontal GtkBox the start
86  * is defined as the left side and the end is defined as the right side.
87  *
88  * Use repeated calls to gtk_box_pack_start() to pack widgets into a
89  * GtkBox from start to end. Use gtk_box_pack_end() to add widgets from
90  * end to start. You may intersperse these calls and add widgets from
91  * both ends of the same GtkBox.
92  *
93  * Because GtkBox is a GtkContainer, you may also use gtk_container_add()
94  * to insert widgets into the box, and they will be packed with the default
95  * values for "expand" and "fill". Use gtk_container_remove()
96  * to remove widgets from the GtkBox.
97  *
98  * Use gtk_box_set_homogeneous() to specify whether or not all children
99  * of the GtkBox are forced to get the same amount of space.
100  *
101  * Use gtk_box_set_spacing() to determine how much space will be
102  * minimally placed between all children in the GtkBox. Note that
103  * spacing is added between the children, while
104  * padding added by gtk_box_pack_start() or gtk_box_pack_end() is added
105  * on either side of the widget it belongs to.
106  *
107  * Use gtk_box_reorder_child() to move a GtkBox child to a different
108  * place in the box.
109  *
110  * Use gtk_box_set_child_packing() to reset the "expand",
111  * "fill" and "padding" child properties.
112  * Use gtk_box_query_child_packing() to query these fields.
113  *
114  * Note
115  *
116  * Note that a single-row or single-column GtkGrid provides exactly
117  * the same functionality as GtkBox.
118  */
119 public class Box : Container, OrientableIF
120 {
121 	
122 	/** the main Gtk struct */
123 	protected GtkBox* gtkBox;
124 	
125 	
126 	/** Get the main Gtk struct */
127 	public GtkBox* getBoxStruct()
128 	{
129 		return gtkBox;
130 	}
131 	
132 	
133 	/** the main Gtk struct as a void* */
134 	protected override void* getStruct()
135 	{
136 		return cast(void*)gtkBox;
137 	}
138 	
139 	/**
140 	 * Sets our main struct and passes it to the parent class
141 	 */
142 	public this (GtkBox* gtkBox)
143 	{
144 		super(cast(GtkContainer*)gtkBox);
145 		this.gtkBox = gtkBox;
146 	}
147 	
148 	protected override void setStruct(GObject* obj)
149 	{
150 		super.setStruct(obj);
151 		gtkBox = cast(GtkBox*)obj;
152 	}
153 	
154 	// add the Orientable capabilities
155 	mixin OrientableT!(GtkBox);
156 	
157 	/**
158 	 */
159 	
160 	/**
161 	 * Creates a new GtkBox.
162 	 * Params:
163 	 * orientation = the box's orientation.
164 	 * spacing = the number of pixels to place by default between children.
165 	 * Throws: ConstructionException GTK+ fails to create the object.
166 	 */
167 	public this (GtkOrientation orientation, int spacing)
168 	{
169 		// GtkWidget * gtk_box_new (GtkOrientation orientation,  gint spacing);
170 		auto p = gtk_box_new(orientation, spacing);
171 		if(p is null)
172 		{
173 			throw new ConstructionException("null returned by gtk_box_new(orientation, spacing)");
174 		}
175 		this(cast(GtkBox*) p);
176 	}
177 	
178 	/**
179 	 * Adds child to box, packed with reference to the start of box.
180 	 * The child is packed after any other child packed with reference
181 	 * to the start of box.
182 	 * Params:
183 	 * child = the GtkWidget to be added to box
184 	 * expand = TRUE if the new child is to be given extra space allocated
185 	 * to box. The extra space will be divided evenly between all children
186 	 * that use this option
187 	 * fill = TRUE if space given to child by the expand option is
188 	 * actually allocated to child, rather than just padding it. This
189 	 * parameter has no effect if expand is set to FALSE. A child is
190 	 * always allocated the full height of a horizontal GtkBox and the full width
191 	 * of a vertical GtkBox. This option affects the other dimension
192 	 * padding = extra space in pixels to put between this child and its
193 	 * neighbors, over and above the global amount specified by
194 	 * "spacing" property. If child is a widget at one of the
195 	 * reference ends of box, then padding pixels are also put between
196 	 * child and the reference edge of box
197 	 */
198 	public void packStart(Widget child, int expand, int fill, uint padding)
199 	{
200 		// void gtk_box_pack_start (GtkBox *box,  GtkWidget *child,  gboolean expand,  gboolean fill,  guint padding);
201 		gtk_box_pack_start(gtkBox, (child is null) ? null : child.getWidgetStruct(), expand, fill, padding);
202 	}
203 	
204 	/**
205 	 * Adds child to box, packed with reference to the end of box.
206 	 * The child is packed after (away from end of) any other child
207 	 * packed with reference to the end of box.
208 	 * Params:
209 	 * child = the GtkWidget to be added to box
210 	 * expand = TRUE if the new child is to be given extra space allocated
211 	 * to box. The extra space will be divided evenly between all children
212 	 * of box that use this option
213 	 * fill = TRUE if space given to child by the expand option is
214 	 * actually allocated to child, rather than just padding it. This
215 	 * parameter has no effect if expand is set to FALSE. A child is
216 	 * always allocated the full height of a horizontal GtkBox and the full width
217 	 * of a vertical GtkBox. This option affects the other dimension
218 	 * padding = extra space in pixels to put between this child and its
219 	 * neighbors, over and above the global amount specified by
220 	 * "spacing" property. If child is a widget at one of the
221 	 * reference ends of box, then padding pixels are also put between
222 	 * child and the reference edge of box
223 	 */
224 	public void packEnd(Widget child, int expand, int fill, uint padding)
225 	{
226 		// void gtk_box_pack_end (GtkBox *box,  GtkWidget *child,  gboolean expand,  gboolean fill,  guint padding);
227 		gtk_box_pack_end(gtkBox, (child is null) ? null : child.getWidgetStruct(), expand, fill, padding);
228 	}
229 	
230 	/**
231 	 * Returns whether the box is homogeneous (all children are the
232 	 * same size). See gtk_box_set_homogeneous().
233 	 * Returns: TRUE if the box is homogeneous.
234 	 */
235 	public int getHomogeneous()
236 	{
237 		// gboolean gtk_box_get_homogeneous (GtkBox *box);
238 		return gtk_box_get_homogeneous(gtkBox);
239 	}
240 	
241 	/**
242 	 * Sets the "homogeneous" property of box, controlling
243 	 * whether or not all children of box are given equal space
244 	 * in the box.
245 	 * Params:
246 	 * homogeneous = a boolean value, TRUE to create equal allotments,
247 	 * FALSE for variable allotments
248 	 */
249 	public void setHomogeneous(int homogeneous)
250 	{
251 		// void gtk_box_set_homogeneous (GtkBox *box,  gboolean homogeneous);
252 		gtk_box_set_homogeneous(gtkBox, homogeneous);
253 	}
254 	
255 	/**
256 	 * Gets the value set by gtk_box_set_spacing().
257 	 * Returns: spacing between children
258 	 */
259 	public int getSpacing()
260 	{
261 		// gint gtk_box_get_spacing (GtkBox *box);
262 		return gtk_box_get_spacing(gtkBox);
263 	}
264 	
265 	/**
266 	 * Sets the "spacing" property of box, which is the
267 	 * number of pixels to place between children of box.
268 	 * Params:
269 	 * spacing = the number of pixels to put between children
270 	 */
271 	public void setSpacing(int spacing)
272 	{
273 		// void gtk_box_set_spacing (GtkBox *box,  gint spacing);
274 		gtk_box_set_spacing(gtkBox, spacing);
275 	}
276 	
277 	/**
278 	 * Moves child to a new position in the list of box children.
279 	 * The list is the children field of
280 	 * GtkBox, and contains both widgets packed GTK_PACK_START
281 	 * as well as widgets packed GTK_PACK_END, in the order that these
282 	 * widgets were added to box.
283 	 * A widget's position in the box children list determines where
284 	 * the widget is packed into box. A child widget at some position
285 	 * in the list will be packed just after all other widgets of the
286 	 * same packing type that appear earlier in the list.
287 	 * Params:
288 	 * child = the GtkWidget to move
289 	 * position = the new position for child in the list of children
290 	 * of box, starting from 0. If negative, indicates the end of
291 	 * the list
292 	 */
293 	public void reorderChild(Widget child, int position)
294 	{
295 		// void gtk_box_reorder_child (GtkBox *box,  GtkWidget *child,  gint position);
296 		gtk_box_reorder_child(gtkBox, (child is null) ? null : child.getWidgetStruct(), position);
297 	}
298 	
299 	/**
300 	 * Obtains information about how child is packed into box.
301 	 * Params:
302 	 * child = the GtkWidget of the child to query
303 	 * expand = pointer to return location for "expand" child
304 	 * property. [out]
305 	 * fill = pointer to return location for "fill" child
306 	 * property. [out]
307 	 * padding = pointer to return location for "padding"
308 	 * child property. [out]
309 	 * packType = pointer to return location for "pack-type"
310 	 * child property. [out]
311 	 */
312 	public void queryChildPacking(Widget child, out int expand, out int fill, out uint padding, out GtkPackType packType)
313 	{
314 		// void gtk_box_query_child_packing (GtkBox *box,  GtkWidget *child,  gboolean *expand,  gboolean *fill,  guint *padding,  GtkPackType *pack_type);
315 		gtk_box_query_child_packing(gtkBox, (child is null) ? null : child.getWidgetStruct(), &expand, &fill, &padding, &packType);
316 	}
317 	
318 	/**
319 	 * Sets the way child is packed into box.
320 	 * Params:
321 	 * child = the GtkWidget of the child to set
322 	 * expand = the new value of the "expand" child property
323 	 * fill = the new value of the "fill" child property
324 	 * padding = the new value of the "padding" child property
325 	 * packType = the new value of the "pack-type" child property
326 	 */
327 	public void setChildPacking(Widget child, int expand, int fill, uint padding, GtkPackType packType)
328 	{
329 		// void gtk_box_set_child_packing (GtkBox *box,  GtkWidget *child,  gboolean expand,  gboolean fill,  guint padding,  GtkPackType pack_type);
330 		gtk_box_set_child_packing(gtkBox, (child is null) ? null : child.getWidgetStruct(), expand, fill, padding, packType);
331 	}
332 	
333 	/**
334 	 * Gets the value set by gtk_box_set_baseline_position().
335 	 * Returns: the baseline position Since 3.10
336 	 */
337 	public GtkBaselinePosition getBaselinePosition()
338 	{
339 		// GtkBaselinePosition gtk_box_get_baseline_position (GtkBox *box);
340 		return gtk_box_get_baseline_position(gtkBox);
341 	}
342 	
343 	/**
344 	 * Sets the baseline position of a box. This affects
345 	 * only horizontal boxes with at least one baseline aligned
346 	 * child. If there is more vertical space availible than requested,
347 	 * and the baseline is not allocated by the parent then
348 	 * position is used to allocate the baseline wrt the
349 	 * extra space available.
350 	 * Params:
351 	 * position = a GtkBaselinePosition
352 	 * Since 3.10
353 	 */
354 	public void setBaselinePosition(GtkBaselinePosition position)
355 	{
356 		// void gtk_box_set_baseline_position (GtkBox *box,  GtkBaselinePosition position);
357 		gtk_box_set_baseline_position(gtkBox, position);
358 	}
359 }