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 = GtkTable.html 27 * outPack = gtk 28 * outFile = Table 29 * strct = GtkTable 30 * realStrct= 31 * ctorStrct= 32 * clss = Table 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_table_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * - gtk_table_new 45 * omit signals: 46 * imports: 47 * - gtk.Widget 48 * structWrap: 49 * - GtkWidget* -> Widget 50 * module aliases: 51 * local aliases: 52 * overrides: 53 */ 54 55 module gtk.Table; 56 57 public import gtkc.gtktypes; 58 59 private import gtkc.gtk; 60 private import glib.ConstructionException; 61 private import gobject.ObjectG; 62 63 private import gtk.Widget; 64 65 66 private import gtk.Container; 67 68 /** 69 * The GtkTable functions allow the programmer to arrange widgets in rows and 70 * columns, making it easy to align many widgets next to each other, 71 * horizontally and vertically. 72 * 73 * Tables are created with a call to gtk_table_new(), the size of which can 74 * later be changed with gtk_table_resize(). 75 * 76 * Widgets can be added to a table using gtk_table_attach() or the more 77 * convenient (but slightly less flexible) gtk_table_attach_defaults(). 78 * 79 * To alter the space next to a specific row, use gtk_table_set_row_spacing(), 80 * and for a column, gtk_table_set_col_spacing(). 81 * The gaps between all rows or columns can be changed by 82 * calling gtk_table_set_row_spacings() or gtk_table_set_col_spacings() 83 * respectively. Note that spacing is added between the 84 * children, while padding added by gtk_table_attach() is added on 85 * either side of the widget it belongs to. 86 * 87 * gtk_table_set_homogeneous(), can be used to set whether all cells in the 88 * table will resize themselves to the size of the largest widget in the table. 89 * 90 * Note 91 * 92 * GtkTable has been deprecated. Use GtkGrid instead. It provides the same 93 * capabilities as GtkTable for arranging widgets in a rectangular grid, but 94 * does support height-for-width geometry management. 95 */ 96 public class Table : Container 97 { 98 99 /** the main Gtk struct */ 100 protected GtkTable* gtkTable; 101 102 103 /** Get the main Gtk struct */ 104 public GtkTable* getTableStruct() 105 { 106 return gtkTable; 107 } 108 109 110 /** the main Gtk struct as a void* */ 111 protected override void* getStruct() 112 { 113 return cast(void*)gtkTable; 114 } 115 116 /** 117 * Sets our main struct and passes it to the parent class 118 */ 119 public this (GtkTable* gtkTable) 120 { 121 super(cast(GtkContainer*)gtkTable); 122 this.gtkTable = gtkTable; 123 } 124 125 protected override void setStruct(GObject* obj) 126 { 127 super.setStruct(obj); 128 gtkTable = cast(GtkTable*)obj; 129 } 130 131 int row; 132 int col; 133 int maxRows; 134 int maxCols; 135 136 public AttachOptions defaultXOption = AttachOptions.SHRINK; 137 public AttachOptions defaultYOption = AttachOptions.SHRINK; 138 139 /** 140 * Removes all children and resizes the table to 1,1 141 */ 142 override void removeAll() 143 { 144 super.removeAll(); 145 resize(1,1); 146 147 row = 0; 148 col = 0; 149 maxRows = 1; 150 maxCols = 1; 151 } 152 153 /** 154 * Used to create a new table widget. An initial size must be given by 155 * specifying how many rows and columns the table should have, although 156 * this can be changed later with gtk_table_resize(). rows and columns 157 * must both be in the range 0 .. 65535. 158 * Params: 159 * rows = The number of rows the new table should have. 160 * columns = The number of columns the new table should have. 161 * homogeneous = If set to TRUE, all table cells are resized to the size of the cell 162 * containing the largest widget. 163 * Throws: ConstructionException GTK+ fails to create the object. 164 */ 165 public this (uint rows, uint columns, int homogeneous) 166 { 167 // GtkWidget* gtk_table_new (guint rows, guint columns, gboolean homogeneous); 168 auto p = gtk_table_new(rows, columns, homogeneous); 169 170 if(p is null) 171 { 172 throw new ConstructionException("null returned by gtk_table_new"); 173 } 174 175 this(cast(GtkTable*) p); 176 177 row = 0; 178 col = 0; 179 maxRows = rows; 180 maxCols = columns; 181 } 182 183 184 /** 185 * Attach a new widget creating a new row if necessary 186 */ 187 void attach(Widget child) 188 { 189 attach(child, col, col + 1, row, row + 1, 190 defaultXOption, defaultYOption, 191 getDefaultColSpacing(), getDefaultRowSpacing()); 192 ++col; 193 if (col >= maxCols) 194 { 195 col = 0; 196 ++row; 197 } 198 } 199 200 /** 201 */ 202 203 /** 204 * Warning 205 * gtk_table_resize has been deprecated since version 3.4 and should not be used in newly-written code. GtkGrid resizes automatically. 206 * If you need to change a table's size after 207 * it has been created, this function allows you to do so. 208 * Params: 209 * rows = The new number of rows. 210 * columns = The new number of columns. 211 */ 212 public void resize(uint rows, uint columns) 213 { 214 // void gtk_table_resize (GtkTable *table, guint rows, guint columns); 215 gtk_table_resize(gtkTable, rows, columns); 216 } 217 218 /** 219 * Warning 220 * gtk_table_get_size has been deprecated since version 3.4 and should not be used in newly-written code. GtkGrid does not expose the number of columns and 221 * rows. 222 * Gets the number of rows and columns in the table. 223 * Since 2.22 224 * Params: 225 * rows = return location for the number of 226 * rows, or NULL. [out][allow-none] 227 * columns = return location for the number 228 * of columns, or NULL. [out][allow-none] 229 */ 230 public void getSize(out uint rows, out uint columns) 231 { 232 // void gtk_table_get_size (GtkTable *table, guint *rows, guint *columns); 233 gtk_table_get_size(gtkTable, &rows, &columns); 234 } 235 236 /** 237 * Warning 238 * gtk_table_attach has been deprecated since version 3.4 and should not be used in newly-written code. Use gtk_grid_attach() with GtkGrid. Note that the attach 239 * arguments differ between those two functions. 240 * Adds a widget to a table. The number of 'cells' that a widget will occupy is 241 * specified by left_attach, right_attach, top_attach and bottom_attach. 242 * These each represent the leftmost, rightmost, uppermost and lowest column 243 * and row numbers of the table. (Columns and rows are indexed from zero). 244 * To make a button occupy the lower right cell of a 2x2 table, use 245 * $(DDOC_COMMENT example) 246 * If you want to make the button span the entire bottom row, use left_attach == 0 and right_attach = 2 instead. 247 * Params: 248 * child = The widget to add. 249 * leftAttach = the column number to attach the left side of a child widget to. 250 * rightAttach = the column number to attach the right side of a child widget to. 251 * topAttach = the row number to attach the top of a child widget to. 252 * bottomAttach = the row number to attach the bottom of a child widget to. 253 * xoptions = Used to specify the properties of the child widget when the table is resized. 254 * yoptions = The same as xoptions, except this field determines behaviour of vertical resizing. 255 * xpadding = An integer value specifying the padding on the left and right of the widget being added to the table. 256 * ypadding = The amount of padding above and below the child widget. 257 */ 258 public void attach(Widget child, uint leftAttach, uint rightAttach, uint topAttach, uint bottomAttach, GtkAttachOptions xoptions, GtkAttachOptions yoptions, uint xpadding, uint ypadding) 259 { 260 // 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); 261 gtk_table_attach(gtkTable, (child is null) ? null : child.getWidgetStruct(), leftAttach, rightAttach, topAttach, bottomAttach, xoptions, yoptions, xpadding, ypadding); 262 } 263 264 /** 265 * Warning 266 * gtk_table_attach_defaults has been deprecated since version 3.4 and should not be used in newly-written code. Use gtk_grid_attach() with GtkGrid. Note that the attach 267 * arguments differ between those two functions. 268 * As there are many options associated with gtk_table_attach(), this convenience 269 * function provides the programmer with a means to add children to a table with 270 * identical padding and expansion options. The values used for the GtkAttachOptions 271 * are GTK_EXPAND | GTK_FILL, and the padding is set to 0. 272 * Params: 273 * widget = The child widget to add. 274 * leftAttach = The column number to attach the left side of the child widget to. 275 * rightAttach = The column number to attach the right side of the child widget to. 276 * topAttach = The row number to attach the top of the child widget to. 277 * bottomAttach = The row number to attach the bottom of the child widget to. 278 */ 279 public void attachDefaults(Widget widget, uint leftAttach, uint rightAttach, uint topAttach, uint bottomAttach) 280 { 281 // void gtk_table_attach_defaults (GtkTable *table, GtkWidget *widget, guint left_attach, guint right_attach, guint top_attach, guint bottom_attach); 282 gtk_table_attach_defaults(gtkTable, (widget is null) ? null : widget.getWidgetStruct(), leftAttach, rightAttach, topAttach, bottomAttach); 283 } 284 285 /** 286 * Warning 287 * gtk_table_set_row_spacing has been deprecated since version 3.4 and should not be used in newly-written code. Use gtk_widget_set_margin_top() and 288 * gtk_widget_set_margin_bottom() on the widgets contained in the row if 289 * you need this functionality. GtkGrid does not support per-row spacing. 290 * Changes the space between a given table row and the subsequent row. 291 * Params: 292 * row = row number whose spacing will be changed. 293 * spacing = number of pixels that the spacing should take up. 294 */ 295 public void setRowSpacing(uint row, uint spacing) 296 { 297 // void gtk_table_set_row_spacing (GtkTable *table, guint row, guint spacing); 298 gtk_table_set_row_spacing(gtkTable, row, spacing); 299 } 300 301 /** 302 * Warning 303 * gtk_table_set_col_spacing has been deprecated since version 3.4 and should not be used in newly-written code. Use gtk_widget_set_margin_left() and 304 * gtk_widget_set_margin_right() on the widgets contained in the row if 305 * you need this functionality. GtkGrid does not support per-row spacing. 306 * Alters the amount of space between a given table column and the following 307 * column. 308 * Params: 309 * column = the column whose spacing should be changed. 310 * spacing = number of pixels that the spacing should take up. 311 */ 312 public void setColSpacing(uint column, uint spacing) 313 { 314 // void gtk_table_set_col_spacing (GtkTable *table, guint column, guint spacing); 315 gtk_table_set_col_spacing(gtkTable, column, spacing); 316 } 317 318 /** 319 * Warning 320 * gtk_table_set_row_spacings has been deprecated since version 3.4 and should not be used in newly-written code. Use gtk_grid_set_row_spacing() with GtkGrid. 321 * Sets the space between every row in table equal to spacing. 322 * Params: 323 * spacing = the number of pixels of space to place between every row in the table. 324 */ 325 public void setRowSpacings(uint spacing) 326 { 327 // void gtk_table_set_row_spacings (GtkTable *table, guint spacing); 328 gtk_table_set_row_spacings(gtkTable, spacing); 329 } 330 331 /** 332 * Warning 333 * gtk_table_set_col_spacings has been deprecated since version 3.4 and should not be used in newly-written code. Use gtk_grid_set_column_spacing() with GtkGrid. 334 * Sets the space between every column in table equal to spacing. 335 * Params: 336 * spacing = the number of pixels of space to place between every column 337 * in the table. 338 */ 339 public void setColSpacings(uint spacing) 340 { 341 // void gtk_table_set_col_spacings (GtkTable *table, guint spacing); 342 gtk_table_set_col_spacings(gtkTable, spacing); 343 } 344 345 /** 346 * Warning 347 * gtk_table_set_homogeneous has been deprecated since version 3.4 and should not be used in newly-written code. Use gtk_grid_set_row_homogeneous() and 348 * gtk_grid_set_column_homogeneous() with GtkGrid. 349 * Changes the homogenous property of table cells, ie. whether all cells are 350 * an equal size or not. 351 * Params: 352 * homogeneous = Set to TRUE to ensure all table cells are the same size. Set 353 * to FALSE if this is not your desired behaviour. 354 */ 355 public void setHomogeneous(int homogeneous) 356 { 357 // void gtk_table_set_homogeneous (GtkTable *table, gboolean homogeneous); 358 gtk_table_set_homogeneous(gtkTable, homogeneous); 359 } 360 361 /** 362 * Warning 363 * gtk_table_get_default_row_spacing has been deprecated since version 3.4 and should not be used in newly-written code. Use gtk_grid_get_row_spacing() with GtkGrid. 364 * Gets the default row spacing for the table. This is 365 * the spacing that will be used for newly added rows. 366 * (See gtk_table_set_row_spacings()) 367 * Returns: the default row spacing 368 */ 369 public uint getDefaultRowSpacing() 370 { 371 // guint gtk_table_get_default_row_spacing (GtkTable *table); 372 return gtk_table_get_default_row_spacing(gtkTable); 373 } 374 375 /** 376 * Warning 377 * gtk_table_get_homogeneous has been deprecated since version 3.4 and should not be used in newly-written code. Use gtk_grid_get_row_homogeneous() and 378 * gtk_grid_get_column_homogeneous() with GtkGrid. 379 * Returns whether the table cells are all constrained to the same 380 * width and height. (See gtk_table_set_homogenous()) 381 * Returns: TRUE if the cells are all constrained to the same size 382 */ 383 public int getHomogeneous() 384 { 385 // gboolean gtk_table_get_homogeneous (GtkTable *table); 386 return gtk_table_get_homogeneous(gtkTable); 387 } 388 389 /** 390 * Warning 391 * gtk_table_get_row_spacing has been deprecated since version 3.4 and should not be used in newly-written code. GtkGrid does not offer a replacement for this 392 * functionality. 393 * Gets the amount of space between row row, and 394 * row row + 1. See gtk_table_set_row_spacing(). 395 * Params: 396 * row = a row in the table, 0 indicates the first row 397 * Returns: the row spacing 398 */ 399 public uint getRowSpacing(uint row) 400 { 401 // guint gtk_table_get_row_spacing (GtkTable *table, guint row); 402 return gtk_table_get_row_spacing(gtkTable, row); 403 } 404 405 /** 406 * Warning 407 * gtk_table_get_col_spacing has been deprecated since version 3.4 and should not be used in newly-written code. GtkGrid does not offer a replacement for this 408 * functionality. 409 * Gets the amount of space between column col, and 410 * column col + 1. See gtk_table_set_col_spacing(). 411 * Params: 412 * column = a column in the table, 0 indicates the first column 413 * Returns: the column spacing 414 */ 415 public uint getColSpacing(uint column) 416 { 417 // guint gtk_table_get_col_spacing (GtkTable *table, guint column); 418 return gtk_table_get_col_spacing(gtkTable, column); 419 } 420 421 /** 422 * Warning 423 * gtk_table_get_default_col_spacing has been deprecated since version 3.4 and should not be used in newly-written code. Use gtk_grid_get_column_spacing() with GtkGrid. 424 * Gets the default column spacing for the table. This is 425 * the spacing that will be used for newly added columns. 426 * (See gtk_table_set_col_spacings()) 427 * Returns: the default column spacing 428 */ 429 public uint getDefaultColSpacing() 430 { 431 // guint gtk_table_get_default_col_spacing (GtkTable *table); 432 return gtk_table_get_default_col_spacing(gtkTable); 433 } 434 }