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