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.Box; 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 * The GtkBox widget organizes child widgets into a rectangular area. 39 * 40 * The rectangular area of a GtkBox is organized into either a single row 41 * or a single column of child widgets depending upon the orientation. 42 * Thus, all children of a GtkBox are allocated one dimension in common, 43 * which is the height of a row, or the width of a column. 44 * 45 * GtkBox uses a notion of packing. Packing refers 46 * to adding widgets with reference to a particular position in a 47 * #GtkContainer. For a GtkBox, there are two reference positions: the 48 * start and the end of the box. 49 * For a vertical #GtkBox, the start is defined as the top of the box and 50 * the end is defined as the bottom. For a horizontal #GtkBox the start 51 * is defined as the left side and the end is defined as the right side. 52 * 53 * Use repeated calls to gtk_box_pack_start() to pack widgets into a 54 * GtkBox from start to end. Use gtk_box_pack_end() to add widgets from 55 * end to start. You may intersperse these calls and add widgets from 56 * both ends of the same GtkBox. 57 * 58 * Because GtkBox is a #GtkContainer, you may also use gtk_container_add() 59 * to insert widgets into the box, and they will be packed with the default 60 * values for expand and fill child properties. Use gtk_container_remove() 61 * to remove widgets from the GtkBox. 62 * 63 * Use gtk_box_set_homogeneous() to specify whether or not all children 64 * of the GtkBox are forced to get the same amount of space. 65 * 66 * Use gtk_box_set_spacing() to determine how much space will be 67 * minimally placed between all children in the GtkBox. Note that 68 * spacing is added between the children, while 69 * padding added by gtk_box_pack_start() or gtk_box_pack_end() is added 70 * on either side of the widget it belongs to. 71 * 72 * Use gtk_box_reorder_child() to move a GtkBox child to a different 73 * place in the box. 74 * 75 * Use gtk_box_set_child_packing() to reset the expand, 76 * fill and padding child properties. 77 * Use gtk_box_query_child_packing() to query these fields. 78 * 79 * Note that a single-row or single-column #GtkGrid provides exactly 80 * the same functionality as #GtkBox. 81 * 82 * # CSS nodes 83 * 84 * GtkBox uses a single CSS node with name box. 85 * 86 * In horizontal orientation, the nodes of the children are always arranged 87 * from left to right. So :first-child will always select the leftmost child, 88 * regardless of text direction. 89 */ 90 public class Box : Container, OrientableIF 91 { 92 /** the main Gtk struct */ 93 protected GtkBox* gtkBox; 94 95 /** Get the main Gtk struct */ 96 public GtkBox* getBoxStruct() 97 { 98 return gtkBox; 99 } 100 101 /** the main Gtk struct as a void* */ 102 protected override void* getStruct() 103 { 104 return cast(void*)gtkBox; 105 } 106 107 protected override void setStruct(GObject* obj) 108 { 109 gtkBox = cast(GtkBox*)obj; 110 super.setStruct(obj); 111 } 112 113 /** 114 * Sets our main struct and passes it to the parent class. 115 */ 116 public this (GtkBox* gtkBox, bool ownedRef = false) 117 { 118 this.gtkBox = gtkBox; 119 super(cast(GtkContainer*)gtkBox, ownedRef); 120 } 121 122 // add the Orientable capabilities 123 mixin OrientableT!(GtkBox); 124 125 126 /** */ 127 public static GType getType() 128 { 129 return gtk_box_get_type(); 130 } 131 132 /** 133 * Creates a new #GtkBox. 134 * 135 * Params: 136 * orientation = the box’s orientation. 137 * spacing = the number of pixels to place by default between children. 138 * 139 * Return: a new #GtkBox. 140 * 141 * Since: 3.0 142 * 143 * Throws: ConstructionException GTK+ fails to create the object. 144 */ 145 public this(GtkOrientation orientation, int spacing) 146 { 147 auto p = gtk_box_new(orientation, spacing); 148 149 if(p is null) 150 { 151 throw new ConstructionException("null returned by new"); 152 } 153 154 this(cast(GtkBox*) p); 155 } 156 157 /** 158 * Gets the value set by gtk_box_set_baseline_position(). 159 * 160 * Return: the baseline position 161 * 162 * Since: 3.10 163 */ 164 public GtkBaselinePosition getBaselinePosition() 165 { 166 return gtk_box_get_baseline_position(gtkBox); 167 } 168 169 /** 170 * Retrieves the center widget of the box. 171 * 172 * Return: the center widget 173 * or %NULL in case no center widget is set. 174 * 175 * Since: 3.12 176 */ 177 public Widget getCenterWidget() 178 { 179 auto p = gtk_box_get_center_widget(gtkBox); 180 181 if(p is null) 182 { 183 return null; 184 } 185 186 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 187 } 188 189 /** 190 * Returns whether the box is homogeneous (all children are the 191 * same size). See gtk_box_set_homogeneous(). 192 * 193 * Return: %TRUE if the box is homogeneous. 194 */ 195 public bool getHomogeneous() 196 { 197 return gtk_box_get_homogeneous(gtkBox) != 0; 198 } 199 200 /** 201 * Gets the value set by gtk_box_set_spacing(). 202 * 203 * Return: spacing between children 204 */ 205 public int getSpacing() 206 { 207 return gtk_box_get_spacing(gtkBox); 208 } 209 210 /** 211 * Adds @child to @box, packed with reference to the end of @box. 212 * The @child is packed after (away from end of) any other child 213 * packed with reference to the end of @box. 214 * 215 * Params: 216 * child = the #GtkWidget to be added to @box 217 * expand = %TRUE if the new child is to be given extra space allocated 218 * to @box. The extra space will be divided evenly between all children 219 * of @box that use this option 220 * fill = %TRUE if space given to @child by the @expand option is 221 * actually allocated to @child, rather than just padding it. This 222 * parameter has no effect if @expand is set to %FALSE. A child is 223 * always allocated the full height of a horizontal #GtkBox and the full width 224 * of a vertical #GtkBox. This option affects the other dimension 225 * padding = extra space in pixels to put between this child and its 226 * neighbors, over and above the global amount specified by 227 * #GtkBox:spacing property. If @child is a widget at one of the 228 * reference ends of @box, then @padding pixels are also put between 229 * @child and the reference edge of @box 230 */ 231 public void packEnd(Widget child, bool expand, bool fill, uint padding) 232 { 233 gtk_box_pack_end(gtkBox, (child is null) ? null : child.getWidgetStruct(), expand, fill, padding); 234 } 235 236 /** 237 * Adds @child to @box, packed with reference to the start of @box. 238 * The @child is packed after any other child packed with reference 239 * to the start of @box. 240 * 241 * Params: 242 * child = the #GtkWidget to be added to @box 243 * expand = %TRUE if the new child is to be given extra space allocated 244 * to @box. The extra space will be divided evenly between all children 245 * that use this option 246 * fill = %TRUE if space given to @child by the @expand option is 247 * actually allocated to @child, rather than just padding it. This 248 * parameter has no effect if @expand is set to %FALSE. A child is 249 * always allocated the full height of a horizontal #GtkBox and the full width 250 * of a vertical #GtkBox. This option affects the other dimension 251 * padding = extra space in pixels to put between this child and its 252 * neighbors, over and above the global amount specified by 253 * #GtkBox:spacing property. If @child is a widget at one of the 254 * reference ends of @box, then @padding pixels are also put between 255 * @child and the reference edge of @box 256 */ 257 public void packStart(Widget child, bool expand, bool fill, uint padding) 258 { 259 gtk_box_pack_start(gtkBox, (child is null) ? null : child.getWidgetStruct(), expand, fill, padding); 260 } 261 262 /** 263 * Obtains information about how @child is packed into @box. 264 * 265 * Params: 266 * child = the #GtkWidget of the child to query 267 * expand = pointer to return location for expand child 268 * property 269 * fill = pointer to return location for fill child 270 * property 271 * padding = pointer to return location for padding 272 * child property 273 * packType = pointer to return location for pack-type 274 * child property 275 */ 276 public void queryChildPacking(Widget child, out bool expand, out bool fill, out uint padding, out GtkPackType packType) 277 { 278 int outexpand; 279 int outfill; 280 281 gtk_box_query_child_packing(gtkBox, (child is null) ? null : child.getWidgetStruct(), &outexpand, &outfill, &padding, &packType); 282 283 expand = (outexpand == 1); 284 fill = (outfill == 1); 285 } 286 287 /** 288 * Moves @child to a new @position in the list of @box children. 289 * The list contains widgets packed #GTK_PACK_START 290 * as well as widgets packed #GTK_PACK_END, in the order that these 291 * widgets were added to @box. 292 * 293 * A widget’s position in the @box children list determines where 294 * the widget is packed into @box. A child widget at some position 295 * in the list will be packed just after all other widgets of the 296 * same packing type that appear earlier in the list. 297 * 298 * Params: 299 * child = the #GtkWidget to move 300 * position = the new position for @child in the list of children 301 * of @box, starting from 0. If negative, indicates the end of 302 * the list 303 */ 304 public void reorderChild(Widget child, int position) 305 { 306 gtk_box_reorder_child(gtkBox, (child is null) ? null : child.getWidgetStruct(), position); 307 } 308 309 /** 310 * Sets the baseline position of a box. This affects 311 * only horizontal boxes with at least one baseline aligned 312 * child. If there is more vertical space available than requested, 313 * and the baseline is not allocated by the parent then 314 * @position is used to allocate the baseline wrt the 315 * extra space available. 316 * 317 * Params: 318 * position = a #GtkBaselinePosition 319 * 320 * Since: 3.10 321 */ 322 public void setBaselinePosition(GtkBaselinePosition position) 323 { 324 gtk_box_set_baseline_position(gtkBox, position); 325 } 326 327 /** 328 * Sets a center widget; that is a child widget that will be 329 * centered with respect to the full width of the box, even 330 * if the children at either side take up different amounts 331 * of space. 332 * 333 * Params: 334 * widget = the widget to center 335 * 336 * Since: 3.12 337 */ 338 public void setCenterWidget(Widget widget) 339 { 340 gtk_box_set_center_widget(gtkBox, (widget is null) ? null : widget.getWidgetStruct()); 341 } 342 343 /** 344 * Sets the way @child is packed into @box. 345 * 346 * Params: 347 * child = the #GtkWidget of the child to set 348 * expand = the new value of the expand child property 349 * fill = the new value of the fill child property 350 * padding = the new value of the padding child property 351 * packType = the new value of the pack-type child property 352 */ 353 public void setChildPacking(Widget child, bool expand, bool fill, uint padding, GtkPackType packType) 354 { 355 gtk_box_set_child_packing(gtkBox, (child is null) ? null : child.getWidgetStruct(), expand, fill, padding, packType); 356 } 357 358 /** 359 * Sets the #GtkBox:homogeneous property of @box, controlling 360 * whether or not all children of @box are given equal space 361 * in the box. 362 * 363 * Params: 364 * homogeneous = a boolean value, %TRUE to create equal allotments, 365 * %FALSE for variable allotments 366 */ 367 public void setHomogeneous(bool homogeneous) 368 { 369 gtk_box_set_homogeneous(gtkBox, homogeneous); 370 } 371 372 /** 373 * Sets the #GtkBox:spacing property of @box, which is the 374 * number of pixels to place between children of @box. 375 * 376 * Params: 377 * spacing = the number of pixels to put between children 378 */ 379 public void setSpacing(int spacing) 380 { 381 gtk_box_set_spacing(gtkBox, spacing); 382 } 383 }