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