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 /** 111 * Sets our main struct and passes it to the parent class. 112 */ 113 public this (GtkBox* gtkBox, bool ownedRef = false) 114 { 115 this.gtkBox = gtkBox; 116 super(cast(GtkContainer*)gtkBox, ownedRef); 117 } 118 119 // add the Orientable capabilities 120 mixin OrientableT!(GtkBox); 121 122 123 /** */ 124 public static GType getType() 125 { 126 return gtk_box_get_type(); 127 } 128 129 /** 130 * Creates a new #GtkBox. 131 * 132 * Params: 133 * orientation = the box’s orientation. 134 * spacing = the number of pixels to place by default between children. 135 * 136 * Returns: a new #GtkBox. 137 * 138 * Since: 3.0 139 * 140 * Throws: ConstructionException GTK+ fails to create the object. 141 */ 142 public this(GtkOrientation orientation, int spacing) 143 { 144 auto p = gtk_box_new(orientation, spacing); 145 146 if(p is null) 147 { 148 throw new ConstructionException("null returned by new"); 149 } 150 151 this(cast(GtkBox*) p); 152 } 153 154 /** 155 * Gets the value set by gtk_box_set_baseline_position(). 156 * 157 * Returns: the baseline position 158 * 159 * Since: 3.10 160 */ 161 public GtkBaselinePosition getBaselinePosition() 162 { 163 return gtk_box_get_baseline_position(gtkBox); 164 } 165 166 /** 167 * Retrieves the center widget of the box. 168 * 169 * Returns: the center widget 170 * or %NULL in case no center widget is set. 171 * 172 * Since: 3.12 173 */ 174 public Widget getCenterWidget() 175 { 176 auto p = gtk_box_get_center_widget(gtkBox); 177 178 if(p is null) 179 { 180 return null; 181 } 182 183 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 184 } 185 186 /** 187 * Returns whether the box is homogeneous (all children are the 188 * same size). See gtk_box_set_homogeneous(). 189 * 190 * Returns: %TRUE if the box is homogeneous. 191 */ 192 public bool getHomogeneous() 193 { 194 return gtk_box_get_homogeneous(gtkBox) != 0; 195 } 196 197 /** 198 * Gets the value set by gtk_box_set_spacing(). 199 * 200 * Returns: spacing between children 201 */ 202 public int getSpacing() 203 { 204 return gtk_box_get_spacing(gtkBox); 205 } 206 207 /** 208 * Adds @child to @box, packed with reference to the end of @box. 209 * The @child is packed after (away from end of) any other child 210 * packed with reference to the end of @box. 211 * 212 * Params: 213 * child = the #GtkWidget to be added to @box 214 * expand = %TRUE if the new child is to be given extra space allocated 215 * to @box. The extra space will be divided evenly between all children 216 * of @box that use this option 217 * fill = %TRUE if space given to @child by the @expand option is 218 * actually allocated to @child, rather than just padding it. This 219 * parameter has no effect if @expand is set to %FALSE. A child is 220 * always allocated the full height of a horizontal #GtkBox and the full width 221 * of a vertical #GtkBox. This option affects the other dimension 222 * padding = extra space in pixels to put between this child and its 223 * neighbors, over and above the global amount specified by 224 * #GtkBox:spacing property. If @child is a widget at one of the 225 * reference ends of @box, then @padding pixels are also put between 226 * @child and the reference edge of @box 227 */ 228 public void packEnd(Widget child, bool expand, bool fill, uint padding) 229 { 230 gtk_box_pack_end(gtkBox, (child is null) ? null : child.getWidgetStruct(), expand, fill, padding); 231 } 232 233 /** 234 * Adds @child to @box, packed with reference to the start of @box. 235 * The @child is packed after any other child packed with reference 236 * to the start of @box. 237 * 238 * Params: 239 * child = the #GtkWidget to be added to @box 240 * expand = %TRUE if the new child is to be given extra space allocated 241 * to @box. The extra space will be divided evenly between all children 242 * that use this option 243 * fill = %TRUE if space given to @child by the @expand option is 244 * actually allocated to @child, rather than just padding it. This 245 * parameter has no effect if @expand is set to %FALSE. A child is 246 * always allocated the full height of a horizontal #GtkBox and the full width 247 * of a vertical #GtkBox. This option affects the other dimension 248 * padding = extra space in pixels to put between this child and its 249 * neighbors, over and above the global amount specified by 250 * #GtkBox:spacing property. If @child is a widget at one of the 251 * reference ends of @box, then @padding pixels are also put between 252 * @child and the reference edge of @box 253 */ 254 public void packStart(Widget child, bool expand, bool fill, uint padding) 255 { 256 gtk_box_pack_start(gtkBox, (child is null) ? null : child.getWidgetStruct(), expand, fill, padding); 257 } 258 259 /** 260 * Obtains information about how @child is packed into @box. 261 * 262 * Params: 263 * child = the #GtkWidget of the child to query 264 * expand = pointer to return location for expand child 265 * property 266 * fill = pointer to return location for fill child 267 * property 268 * padding = pointer to return location for padding 269 * child property 270 * packType = pointer to return location for pack-type 271 * child property 272 */ 273 public void queryChildPacking(Widget child, out bool expand, out bool fill, out uint padding, out GtkPackType packType) 274 { 275 int outexpand; 276 int outfill; 277 278 gtk_box_query_child_packing(gtkBox, (child is null) ? null : child.getWidgetStruct(), &outexpand, &outfill, &padding, &packType); 279 280 expand = (outexpand == 1); 281 fill = (outfill == 1); 282 } 283 284 /** 285 * Moves @child to a new @position in the list of @box children. 286 * The list contains widgets packed #GTK_PACK_START 287 * as well as widgets packed #GTK_PACK_END, in the order that these 288 * widgets were added to @box. 289 * 290 * A widget’s position in the @box children list determines where 291 * the widget is packed into @box. A child widget at some position 292 * in the list will be packed just after all other widgets of the 293 * same packing type that appear earlier in the list. 294 * 295 * Params: 296 * child = the #GtkWidget to move 297 * position = the new position for @child in the list of children 298 * of @box, starting from 0. If negative, indicates the end of 299 * the list 300 */ 301 public void reorderChild(Widget child, int position) 302 { 303 gtk_box_reorder_child(gtkBox, (child is null) ? null : child.getWidgetStruct(), position); 304 } 305 306 /** 307 * Sets the baseline position of a box. This affects 308 * only horizontal boxes with at least one baseline aligned 309 * child. If there is more vertical space available than requested, 310 * and the baseline is not allocated by the parent then 311 * @position is used to allocate the baseline wrt the 312 * extra space available. 313 * 314 * Params: 315 * position = a #GtkBaselinePosition 316 * 317 * Since: 3.10 318 */ 319 public void setBaselinePosition(GtkBaselinePosition position) 320 { 321 gtk_box_set_baseline_position(gtkBox, position); 322 } 323 324 /** 325 * Sets a center widget; that is a child widget that will be 326 * centered with respect to the full width of the box, even 327 * if the children at either side take up different amounts 328 * of space. 329 * 330 * Params: 331 * widget = the widget to center 332 * 333 * Since: 3.12 334 */ 335 public void setCenterWidget(Widget widget) 336 { 337 gtk_box_set_center_widget(gtkBox, (widget is null) ? null : widget.getWidgetStruct()); 338 } 339 340 /** 341 * Sets the way @child is packed into @box. 342 * 343 * Params: 344 * child = the #GtkWidget of the child to set 345 * expand = the new value of the expand child property 346 * fill = the new value of the fill child property 347 * padding = the new value of the padding child property 348 * packType = the new value of the pack-type child property 349 */ 350 public void setChildPacking(Widget child, bool expand, bool fill, uint padding, GtkPackType packType) 351 { 352 gtk_box_set_child_packing(gtkBox, (child is null) ? null : child.getWidgetStruct(), expand, fill, padding, packType); 353 } 354 355 /** 356 * Sets the #GtkBox:homogeneous property of @box, controlling 357 * whether or not all children of @box are given equal space 358 * in the box. 359 * 360 * Params: 361 * homogeneous = a boolean value, %TRUE to create equal allotments, 362 * %FALSE for variable allotments 363 */ 364 public void setHomogeneous(bool homogeneous) 365 { 366 gtk_box_set_homogeneous(gtkBox, homogeneous); 367 } 368 369 /** 370 * Sets the #GtkBox:spacing property of @box, which is the 371 * number of pixels to place between children of @box. 372 * 373 * Params: 374 * spacing = the number of pixels to put between children 375 */ 376 public void setSpacing(int spacing) 377 { 378 gtk_box_set_spacing(gtkBox, spacing); 379 } 380 }