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