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