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  = GtkGrid.html
27  * outPack = gtk
28  * outFile = Grid
29  * strct   = GtkGrid
30  * realStrct=
31  * ctorStrct=
32  * clss    = Grid
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- OrientableIF
40  * prefixes:
41  * 	- gtk_grid_
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.Grid;
58 
59 public  import gtkc.gtktypes;
60 
61 private import gtkc.gtk;
62 private import glib.ConstructionException;
63 private import gobject.ObjectG;
64 
65 
66 private import gtk.Widget;
67 private import gtk.OrientableIF;
68 private import gtk.OrientableT;
69 
70 
71 
72 private import gtk.Container;
73 
74 /**
75  * GtkGrid is a container which arranges its child widgets in
76  * rows and columns. It is a very similar to GtkTable and GtkBox,
77  * but it consistently uses GtkWidget's "margin" and "expand"
78  * properties instead of custom child properties, and it fully supports
79  * height-for-width geometry management.
80  *
81  * Children are added using gtk_grid_attach(). They can span multiple
82  * rows or columns. It is also possible to add a child next to an
83  * existing child, using gtk_grid_attach_next_to(). The behaviour of
84  * GtkGrid when several children occupy the same grid cell is undefined.
85  *
86  * GtkGrid can be used like a GtkBox by just using gtk_container_add(),
87  * which will place children next to each other in the direction determined
88  * by the "orientation" property.
89  */
90 public class Grid : Container, OrientableIF
91 {
92 	
93 	/** the main Gtk struct */
94 	protected GtkGrid* gtkGrid;
95 	
96 	
97 	public GtkGrid* getGridStruct()
98 	{
99 		return gtkGrid;
100 	}
101 	
102 	
103 	/** the main Gtk struct as a void* */
104 	protected override void* getStruct()
105 	{
106 		return cast(void*)gtkGrid;
107 	}
108 	
109 	/**
110 	 * Sets our main struct and passes it to the parent class
111 	 */
112 	public this (GtkGrid* gtkGrid)
113 	{
114 		super(cast(GtkContainer*)gtkGrid);
115 		this.gtkGrid = gtkGrid;
116 	}
117 	
118 	protected override void setStruct(GObject* obj)
119 	{
120 		super.setStruct(obj);
121 		gtkGrid = cast(GtkGrid*)obj;
122 	}
123 	
124 	// add the Orientable capabilities
125 	mixin OrientableT!(GtkGrid);
126 	
127 	/**
128 	 */
129 	
130 	/**
131 	 * Creates a new grid widget.
132 	 * Throws: ConstructionException GTK+ fails to create the object.
133 	 */
134 	public this ()
135 	{
136 		// GtkWidget * gtk_grid_new (void);
137 		auto p = gtk_grid_new();
138 		if(p is null)
139 		{
140 			throw new ConstructionException("null returned by gtk_grid_new()");
141 		}
142 		this(cast(GtkGrid*) p);
143 	}
144 	
145 	/**
146 	 * Adds a widget to the grid.
147 	 * The position of child is determined by left and top. The
148 	 * number of 'cells' that child will occupy is determined by
149 	 * width and height.
150 	 * Params:
151 	 * child = the widget to add
152 	 * left = the column number to attach the left side of child to
153 	 * top = the row number to attach the top side of child to
154 	 * width = the number of columns that child will span
155 	 * height = the number of rows that child will span
156 	 */
157 	public void attach(Widget child, int left, int top, int width, int height)
158 	{
159 		// void gtk_grid_attach (GtkGrid *grid,  GtkWidget *child,  gint left,  gint top,  gint width,  gint height);
160 		gtk_grid_attach(gtkGrid, (child is null) ? null : child.getWidgetStruct(), left, top, width, height);
161 	}
162 	
163 	/**
164 	 * Adds a widget to the grid.
165 	 * The widget is placed next to sibling, on the side determined by
166 	 * side. When sibling is NULL, the widget is placed in row (for
167 	 * left or right placement) or column 0 (for top or bottom placement),
168 	 * at the end indicated by side.
169 	 * Attaching widgets labeled [1], [2], [3] with sibling == NULL and
170 	 * side == GTK_POS_LEFT yields a layout of [3][2][1].
171 	 * Params:
172 	 * child = the widget to add
173 	 * sibling = the child of grid that child will be placed
174 	 * next to, or NULL to place child at the beginning or end. [allow-none]
175 	 * side = the side of sibling that child is positioned next to
176 	 * width = the number of columns that child will span
177 	 * height = the number of rows that child will span
178 	 */
179 	public void attachNextTo(Widget child, Widget sibling, GtkPositionType side, int width, int height)
180 	{
181 		// void gtk_grid_attach_next_to (GtkGrid *grid,  GtkWidget *child,  GtkWidget *sibling,  GtkPositionType side,  gint width,  gint height);
182 		gtk_grid_attach_next_to(gtkGrid, (child is null) ? null : child.getWidgetStruct(), (sibling is null) ? null : sibling.getWidgetStruct(), side, width, height);
183 	}
184 	
185 	/**
186 	 * Gets the child of grid whose area covers the grid
187 	 * cell whose upper left corner is at left, top.
188 	 * Params:
189 	 * left = the left edge of the cell
190 	 * top = the top edge of the cell
191 	 * Returns: the child at the given position, or NULL. [transfer none] Since 3.2
192 	 */
193 	public Widget getChildAt(int left, int top)
194 	{
195 		// GtkWidget * gtk_grid_get_child_at (GtkGrid *grid,  gint left,  gint top);
196 		auto p = gtk_grid_get_child_at(gtkGrid, left, top);
197 		
198 		if(p is null)
199 		{
200 			return null;
201 		}
202 		
203 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
204 	}
205 	
206 	/**
207 	 * Inserts a row at the specified position.
208 	 * Children which are attached at or below this position
209 	 * are moved one row down. Children which span across this
210 	 * position are grown to span the new row.
211 	 * Params:
212 	 * position = the position to insert the row at
213 	 * Since 3.2
214 	 */
215 	public void insertRow(int position)
216 	{
217 		// void gtk_grid_insert_row (GtkGrid *grid,  gint position);
218 		gtk_grid_insert_row(gtkGrid, position);
219 	}
220 	
221 	/**
222 	 * Inserts a column at the specified position.
223 	 * Children which are attached at or to the right of this position
224 	 * are moved one column to the right. Children which span across this
225 	 * position are grown to span the new column.
226 	 * Params:
227 	 * position = the position to insert the column at
228 	 * Since 3.2
229 	 */
230 	public void insertColumn(int position)
231 	{
232 		// void gtk_grid_insert_column (GtkGrid *grid,  gint position);
233 		gtk_grid_insert_column(gtkGrid, position);
234 	}
235 	
236 	/**
237 	 * Removes a row from the grid.
238 	 * Children that are placed in this row are removed,
239 	 * spanning children that overlap this row have their
240 	 * height reduced by one, and children below the row
241 	 * are moved up.
242 	 * Params:
243 	 * position = the position of the row to remove
244 	 * Since 3.10
245 	 */
246 	public void removeRow(int position)
247 	{
248 		// void gtk_grid_remove_row (GtkGrid *grid,  gint position);
249 		gtk_grid_remove_row(gtkGrid, position);
250 	}
251 	
252 	/**
253 	 * Removes a column from the grid.
254 	 * Children that are placed in this column are removed,
255 	 * spanning children that overlap this column have their
256 	 * width reduced by one, and children after the column
257 	 * are moved to the left.
258 	 * Params:
259 	 * position = the position of the column to remove
260 	 * Since 3.10
261 	 */
262 	public void removeColumn(int position)
263 	{
264 		// void gtk_grid_remove_column (GtkGrid *grid,  gint position);
265 		gtk_grid_remove_column(gtkGrid, position);
266 	}
267 	
268 	/**
269 	 * Inserts a row or column at the specified position.
270 	 * The new row or column is placed next to sibling, on the side
271 	 * determined by side. If side is GTK_POS_TOP or GTK_POS_BOTTOM,
272 	 * a row is inserted. If side is GTK_POS_LEFT of GTK_POS_RIGHT,
273 	 * a column is inserted.
274 	 * Params:
275 	 * sibling = the child of grid that the new row or column will be
276 	 * placed next to
277 	 * side = the side of sibling that child is positioned next to
278 	 * Since 3.2
279 	 */
280 	public void insertNextTo(Widget sibling, GtkPositionType side)
281 	{
282 		// void gtk_grid_insert_next_to (GtkGrid *grid,  GtkWidget *sibling,  GtkPositionType side);
283 		gtk_grid_insert_next_to(gtkGrid, (sibling is null) ? null : sibling.getWidgetStruct(), side);
284 	}
285 	
286 	/**
287 	 * Sets whether all rows of grid will have the same height.
288 	 * Params:
289 	 * homogeneous = TRUE to make rows homogeneous
290 	 */
291 	public void setRowHomogeneous(int homogeneous)
292 	{
293 		// void gtk_grid_set_row_homogeneous (GtkGrid *grid,  gboolean homogeneous);
294 		gtk_grid_set_row_homogeneous(gtkGrid, homogeneous);
295 	}
296 	
297 	/**
298 	 * Returns whether all rows of grid have the same height.
299 	 * Returns: whether all rows of grid have the same height.
300 	 */
301 	public int getRowHomogeneous()
302 	{
303 		// gboolean gtk_grid_get_row_homogeneous (GtkGrid *grid);
304 		return gtk_grid_get_row_homogeneous(gtkGrid);
305 	}
306 	
307 	/**
308 	 * Sets the amount of space between rows of grid.
309 	 * Params:
310 	 * spacing = the amount of space to insert between rows
311 	 */
312 	public void setRowSpacing(uint spacing)
313 	{
314 		// void gtk_grid_set_row_spacing (GtkGrid *grid,  guint spacing);
315 		gtk_grid_set_row_spacing(gtkGrid, spacing);
316 	}
317 	
318 	/**
319 	 * Returns the amount of space between the rows of grid.
320 	 * Returns: the row spacing of grid
321 	 */
322 	public uint getRowSpacing()
323 	{
324 		// guint gtk_grid_get_row_spacing (GtkGrid *grid);
325 		return gtk_grid_get_row_spacing(gtkGrid);
326 	}
327 	
328 	/**
329 	 * Sets whether all columns of grid will have the same width.
330 	 * Params:
331 	 * homogeneous = TRUE to make columns homogeneous
332 	 */
333 	public void setColumnHomogeneous(int homogeneous)
334 	{
335 		// void gtk_grid_set_column_homogeneous (GtkGrid *grid,  gboolean homogeneous);
336 		gtk_grid_set_column_homogeneous(gtkGrid, homogeneous);
337 	}
338 	
339 	/**
340 	 * Returns whether all columns of grid have the same width.
341 	 * Returns: whether all columns of grid have the same width.
342 	 */
343 	public int getColumnHomogeneous()
344 	{
345 		// gboolean gtk_grid_get_column_homogeneous (GtkGrid *grid);
346 		return gtk_grid_get_column_homogeneous(gtkGrid);
347 	}
348 	
349 	/**
350 	 * Sets the amount of space between columns of grid.
351 	 * Params:
352 	 * spacing = the amount of space to insert between columns
353 	 */
354 	public void setColumnSpacing(uint spacing)
355 	{
356 		// void gtk_grid_set_column_spacing (GtkGrid *grid,  guint spacing);
357 		gtk_grid_set_column_spacing(gtkGrid, spacing);
358 	}
359 	
360 	/**
361 	 * Returns the amount of space between the columns of grid.
362 	 * Returns: the column spacing of grid
363 	 */
364 	public uint getColumnSpacing()
365 	{
366 		// guint gtk_grid_get_column_spacing (GtkGrid *grid);
367 		return gtk_grid_get_column_spacing(gtkGrid);
368 	}
369 	
370 	/**
371 	 * Returns which row defines the global baseline of grid.
372 	 * Returns: the row index defining the global baseline Since 3.10
373 	 */
374 	public int getBaselineRow()
375 	{
376 		// gint gtk_grid_get_baseline_row (GtkGrid *grid);
377 		return gtk_grid_get_baseline_row(gtkGrid);
378 	}
379 	
380 	/**
381 	 * Sets which row defines the global baseline for the entire grid.
382 	 * Each row in the grid can have its own local baseline, but only
383 	 * one of those is global, meaning it will be the baseline in the
384 	 * parent of the grid.
385 	 * Params:
386 	 * row = the row index
387 	 * Returns: the row index defining the global baseline Since 3.10
388 	 */
389 	public void setBaselineRow(int row)
390 	{
391 		// void gtk_grid_set_baseline_row (GtkGrid *grid,  gint row);
392 		gtk_grid_set_baseline_row(gtkGrid, row);
393 	}
394 	
395 	/**
396 	 * Returns the baseline position of row as set
397 	 * by gtk_grid_set_row_baseline_position() or the default value
398 	 * GTK_BASELINE_POSITION_CENTER.
399 	 * Params:
400 	 * row = a row index
401 	 * Returns: the baseline position of row Since 3.10
402 	 */
403 	public GtkBaselinePosition getRowBaselinePosition(int row)
404 	{
405 		// GtkBaselinePosition gtk_grid_get_row_baseline_position (GtkGrid *grid,  gint row);
406 		return gtk_grid_get_row_baseline_position(gtkGrid, row);
407 	}
408 	
409 	/**
410 	 * Sets how the baseline should be positioned on row of the
411 	 * grid, in case that row is assigned more space than is requested.
412 	 * Params:
413 	 * row = a row index
414 	 * pos = a GtkBaselinePosition
415 	 * Since 3.10
416 	 */
417 	public void setRowBaselinePosition(int row, GtkBaselinePosition pos)
418 	{
419 		// void gtk_grid_set_row_baseline_position (GtkGrid *grid,  gint row,  GtkBaselinePosition pos);
420 		gtk_grid_set_row_baseline_position(gtkGrid, row, pos);
421 	}
422 }