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