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