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