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