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