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