alternative to assert
[gtkD.git] / src / gtk / Table.d
blob7365852f732d91d06ebbf814767ef733780e581d
1 /*
2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkTable.html
26 * outPack = gtk
27 * outFile = Table
28 * strct = GtkTable
29 * realStrct=
30 * ctorStrct=
31 * clss = Table
32 * interf =
33 * class Code: Yes
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_table_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * - gtk_table_new
45 * imports:
46 * - gtk.Widget
47 * structWrap:
48 * - GtkWidget* -> Widget
49 * local aliases:
52 module gtk.Table;
54 private import gtk.gtktypes;
56 private import lib.gtk;
58 private import gtk.Widget;
60 /**
61 * Description
62 * The GtkTable functions allow the programmer to arrange widgets in rows and
63 * columns, making it easy to align many widgets next to each other,
64 * horizontally and vertically.
65 * Tables are created with a call to gtk_table_new(), the size of which can
66 * later be changed with gtk_table_resize().
67 * Widgets can be added to a table using gtk_table_attach() or the more
68 * convenient (but slightly less flexible) gtk_table_attach_defaults().
69 * To alter the space next to a specific row, use gtk_table_set_row_spacing(),
70 * and for a column, gtk_table_set_col_spacing().
71 * The gaps between all rows or columns can be changed by calling
72 * gtk_table_set_row_spacings() or gtk_table_set_col_spacings() respectively.
73 * gtk_table_set_homogeneous(), can be used to set whether all cells in the
74 * table will resize themselves to the size of the largest widget in the table.
76 private import gtk.Container;
77 public class Table : Container
80 /** the main Gtk struct */
81 protected GtkTable* gtkTable;
84 public GtkTable* getTableStruct()
86 return gtkTable;
90 /** the main Gtk struct as a void* */
91 protected void* getStruct()
93 return cast(void*)gtkTable;
96 /**
97 * Sets our main struct and passes it to the parent class
99 public this (GtkTable* gtkTable)
101 super(cast(GtkContainer*)gtkTable);
102 this.gtkTable = gtkTable;
105 int row;
106 int col;
107 int maxRows;
108 int maxCols;
110 public AttachOptions defaultXOption = AttachOptions.SHRINK;
111 public AttachOptions defaultYOption = AttachOptions.SHRINK;
114 * Removes all children and resizes the table to 1,1
116 void removeAll()
118 super.removeAll();
119 resize(1,1);
123 * Used to create a new table widget. An initial size must be given by
124 * specifying how many rows and columns the table should have, although
125 * this can be changed later with gtk_table_resize(). rows and columns
126 * must both be in the range 0 .. 65535.
127 * rows:
128 * The number of rows the new table should have.
129 * columns:
130 * The number of columns the new table should have.
131 * homogeneous:
132 * If set to TRUE, all table cells are resized to the size of the cell
133 * containing the largest widget.
134 * Returns:
135 * A pointer to the the newly created table widget.
137 public this (uint rows, uint columns, int homogeneous)
139 // GtkWidget* gtk_table_new (guint rows, guint columns, gboolean homogeneous);
140 this(cast(GtkTable*)gtk_table_new(rows, columns, homogeneous) );
141 row = 0;
142 col = 0;
143 maxRows = rows;
144 maxCols = columns;
149 * Attach a new widget creating a new row if necessary
151 void attach(Widget child)
153 attach(child, col, col + 1, row, row + 1,
154 defaultXOption, defaultYOption,
155 getDefaultColSpacing(), getDefaultRowSpacing());
156 ++col;
157 if (col >= maxCols)
159 col = 0;
160 ++row;
173 * If you need to change a table's size after it has been created, this function allows you to do so.
174 * table:
175 * The GtkTable you wish to change the size of.
176 * rows:
177 * The new number of rows.
178 * columns:
179 * The new number of columns.
181 public void resize(uint rows, uint columns)
183 // void gtk_table_resize (GtkTable *table, guint rows, guint columns);
184 gtk_table_resize(gtkTable, rows, columns);
188 * Adds a widget to a table. The number of 'cells' that a widget will occupy is
189 * specified by left_attach, right_attach, top_attach and bottom_attach.
190 * These each represent the leftmost, rightmost, uppermost and lowest column
191 * and row numbers of the table. (Columns and rows are indexed from zero).
192 * table:
193 * The GtkTable to add a new widget to.
194 * child:
195 * The widget to add.
196 * left_attach:
197 * the column number to attach the left side of a child widget to.
198 * right_attach:
199 * the column number to attach the right side of a child widget to.
200 * top_attach:
201 * the row number to attach the top of a child widget to.
202 * bottom_attach:
203 * the row number to attach the bottom of a child widget to.
204 * xoptions:
205 * Used to specify the properties of the child widget when the table is resized.
206 * yoptions:
207 * The same as xoptions, except this field determines behaviour of vertical resizing.
208 * xpadding:
209 * An integer value specifying the padding on the left and right of the widget being added to the table.
210 * ypadding:
211 * The amount of padding above and below the child widget.
213 public void attach(Widget child, uint leftAttach, uint rightAttach, uint topAttach, uint bottomAttach, GtkAttachOptions xoptions, GtkAttachOptions yoptions, uint xpadding, uint ypadding)
215 // void gtk_table_attach (GtkTable *table, GtkWidget *child, guint left_attach, guint right_attach, guint top_attach, guint bottom_attach, GtkAttachOptions xoptions, GtkAttachOptions yoptions, guint xpadding, guint ypadding);
216 gtk_table_attach(gtkTable, (child is null) ? null : child.getWidgetStruct(), leftAttach, rightAttach, topAttach, bottomAttach, xoptions, yoptions, xpadding, ypadding);
220 * As there are many options associated with gtk_table_attach(), this convenience function provides the programmer with a means to add children to a table with identical padding and expansion options. The values used for the GtkAttachOptions are GTK_EXPAND | GTK_FILL, and the padding is set to 0.
221 * table:
222 * The table to add a new child widget to.
223 * widget:
224 * The child widget to add.
225 * left_attach:
226 * The column number to attach the left side of the child widget to.
227 * right_attach:
228 * The column number to attach the right side of the child widget to.
229 * top_attach:
230 * The row number to attach the top of the child widget to.
231 * bottom_attach:
232 * The row number to attach the bottom of the child widget to.
234 public void attachDefaults(Widget widget, uint leftAttach, uint rightAttach, uint topAttach, uint bottomAttach)
236 // void gtk_table_attach_defaults (GtkTable *table, GtkWidget *widget, guint left_attach, guint right_attach, guint top_attach, guint bottom_attach);
237 gtk_table_attach_defaults(gtkTable, (widget is null) ? null : widget.getWidgetStruct(), leftAttach, rightAttach, topAttach, bottomAttach);
241 * Changes the space between a given table row and the subsequent row.
242 * table:
243 * a GtkTable containing the row whose properties you wish to change.
244 * row:
245 * row number whose spacing will be changed.
246 * spacing:
247 * number of pixels that the spacing should take up.
249 public void setRowSpacing(uint row, uint spacing)
251 // void gtk_table_set_row_spacing (GtkTable *table, guint row, guint spacing);
252 gtk_table_set_row_spacing(gtkTable, row, spacing);
256 * Alters the amount of space between a given table column and the following
257 * column.
258 * table:
259 * a GtkTable.
260 * column:
261 * the column whose spacing should be changed.
262 * spacing:
263 * number of pixels that the spacing should take up.
265 public void setColSpacing(uint column, uint spacing)
267 // void gtk_table_set_col_spacing (GtkTable *table, guint column, guint spacing);
268 gtk_table_set_col_spacing(gtkTable, column, spacing);
272 * Sets the space between every row in table equal to spacing.
273 * table:
274 * a GtkTable.
275 * spacing:
276 * the number of pixels of space to place between every row in the table.
278 public void setRowSpacings(uint spacing)
280 // void gtk_table_set_row_spacings (GtkTable *table, guint spacing);
281 gtk_table_set_row_spacings(gtkTable, spacing);
285 * Sets the space between every column in table equal to spacing.
286 * table:
287 * a GtkTable.
288 * spacing:
289 * the number of pixels of space to place between every column in the table.
291 public void setColSpacings(uint spacing)
293 // void gtk_table_set_col_spacings (GtkTable *table, guint spacing);
294 gtk_table_set_col_spacings(gtkTable, spacing);
298 * Changes the homogenous property of table cells, ie. whether all cells are an equal size or not.
299 * table:
300 * The GtkTable you wish to set the homogeneous properties of.
301 * homogeneous:
302 * Set to TRUE to ensure all table cells are the same size. Set
303 * to FALSE if this is not your desired behaviour.
305 public void setHomogeneous(int homogeneous)
307 // void gtk_table_set_homogeneous (GtkTable *table, gboolean homogeneous);
308 gtk_table_set_homogeneous(gtkTable, homogeneous);
312 * Gets the default row spacing for the table. This is
313 * the spacing that will be used for newly added rows.
314 * (See gtk_table_set_row_spacings())
315 * table:
316 * a GtkTable
317 * Returns:
318 * value: the default row spacing
320 public uint getDefaultRowSpacing()
322 // guint gtk_table_get_default_row_spacing (GtkTable *table);
323 return gtk_table_get_default_row_spacing(gtkTable);
327 * Returns whether the table cells are all constrained to the same
328 * width and height. (See gtk_table_set_homogenous())
329 * table:
330 * a GtkTable
331 * Returns:
332 * TRUE if the cells are all constrained to the same size
334 public int getHomogeneous()
336 // gboolean gtk_table_get_homogeneous (GtkTable *table);
337 return gtk_table_get_homogeneous(gtkTable);
341 * Gets the amount of space between row row, and
342 * row row + 1. See gtk_table_set_row_spacing().
343 * table:
344 * a GtkTable
345 * row:
346 * a row in the table, 0 indicates the first row
347 * Returns:
348 * the row spacing
350 public uint getRowSpacing(uint row)
352 // guint gtk_table_get_row_spacing (GtkTable *table, guint row);
353 return gtk_table_get_row_spacing(gtkTable, row);
357 * Gets the amount of space between column col, and
358 * column col + 1. See gtk_table_set_col_spacing().
359 * table:
360 * a GtkTable
361 * column:
362 * a column in the table, 0 indicates the first column
363 * Returns:
364 * the column spacing
366 public uint getColSpacing(uint column)
368 // guint gtk_table_get_col_spacing (GtkTable *table, guint column);
369 return gtk_table_get_col_spacing(gtkTable, column);
373 * Gets the default column spacing for the table. This is
374 * the spacing that will be used for newly added columns.
375 * (See gtk_table_set_col_spacings())
376 * table:
377 * a GtkTable
378 * Returns:
379 * value: the default column spacing
380 * Property Details
381 * The "column-spacing" property
382 * "column-spacing" guint : Read / Write
383 * The amount of space between two consecutive columns.
384 * Default value: 0
386 public uint getDefaultColSpacing()
388 // guint gtk_table_get_default_col_spacing (GtkTable *table);
389 return gtk_table_get_default_col_spacing(gtkTable);