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 * Conversion parameters: 26 * inFile = GtkContainer.html 27 * outPack = gtk 28 * outFile = Container 29 * strct = GtkContainer 30 * realStrct= 31 * ctorStrct= 32 * clss = Container 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_container_ 41 * - gtk_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - gtk.Adjustment 49 * - glib.ListG 50 * - gobject.Value 51 * - gobject.ParamSpec 52 * structWrap: 53 * - GList* -> ListG 54 * - GParamSpec* -> ParamSpec 55 * - GValue* -> Value 56 * - GtkAdjustment* -> Adjustment 57 * - GtkContainerClass* -> Container 58 * - GtkWidget* -> Widget 59 * module aliases: 60 * local aliases: 61 * overrides: 62 */ 63 64 module gtk.Container; 65 66 public import gtkc.gtktypes; 67 68 private import gtkc.gtk; 69 private import glib.ConstructionException; 70 private import gobject.ObjectG; 71 72 private import gobject.Signals; 73 public import gtkc.gdktypes; 74 75 private import glib.Str; 76 private import gtk.Adjustment; 77 private import glib.ListG; 78 private import gobject.Value; 79 private import gobject.ParamSpec; 80 81 82 83 private import gtk.Widget; 84 85 /** 86 * Description 87 * A GTK+ user interface is constructed by nesting widgets inside widgets. 88 * Container widgets are the inner nodes in the resulting tree of widgets: 89 * they contain other widgets. So, for example, you might have a GtkWindow 90 * containing a GtkFrame containing a GtkLabel. If you wanted an image instead 91 * of a textual label inside the frame, you might replace the GtkLabel widget 92 * with a GtkImage widget. 93 * There are two major kinds of container widgets in GTK+. Both are subclasses 94 * of the abstract GtkContainer base class. 95 * The first type of container widget has a single child widget and derives 96 * from GtkBin. These containers are decorators, which 97 * add some kind of functionality to the child. For example, a GtkButton makes 98 * its child into a clickable button; a GtkFrame draws a frame around its child 99 * and a GtkWindow places its child widget inside a top-level window. 100 * The second type of container can have more than one child; its purpose is to 101 * manage layout. This means that these containers assign 102 * sizes and positions to their children. For example, a GtkHBox arranges its 103 * children in a horizontal row, and a GtkTable arranges the widgets it contains 104 * in a two-dimensional grid. 105 * To fulfill its task, a layout container must negotiate the size requirements 106 * with its parent and its children. This negotiation is carried out in two 107 * phases, size requisition and size 108 * allocation. 109 * Size Requisition 110 * The size requisition of a widget is it's desired width and height. 111 * This is represented by a GtkRequisition. 112 * How a widget determines its desired size depends on the widget. 113 * A GtkLabel, for example, requests enough space to display all its text. 114 * Container widgets generally base their size request on the requisitions 115 * of their children. 116 * The size requisition phase of the widget layout process operates top-down. 117 * It starts at a top-level widget, typically a GtkWindow. The top-level widget 118 * asks its child for its size requisition by calling gtk_widget_size_request(). 119 * To determine its requisition, the child asks its own children for their 120 * requisitions and so on. Finally, the top-level widget will get a requisition 121 * back from its child. 122 * <hr> 123 * Size Allocation 124 * When the top-level widget has determined how much space its child would like 125 * to have, the second phase of the size negotiation, size allocation, begins. 126 * Depending on its configuration (see gtk_window_set_resizable()), the top-level 127 * widget may be able to expand in order to satisfy the size request or it may 128 * have to ignore the size request and keep its fixed size. It then tells its 129 * child widget how much space it gets by calling gtk_widget_size_allocate(). 130 * The child widget divides the space among its children and tells each child 131 * how much space it got, and so on. Under normal circumstances, a GtkWindow 132 * will always give its child the amount of space the child requested. 133 * A child's size allocation is represented by a GtkAllocation. This struct 134 * contains not only a width and height, but also a position (i.e. X and Y 135 * coordinates), so that containers can tell their children not only how much 136 * space they have gotten, but also where they are positioned inside the space 137 * available to the container. 138 * Widgets are required to honor the size allocation they receive; a size 139 * request is only a request, and widgets must be able to cope with any size. 140 * <hr> 141 * Child properties 142 * GtkContainer introduces child 143 * properties - these are object properties that are not specific 144 * to either the container or the contained widget, but rather to their relation. 145 * Typical examples of child properties are the position or pack-type of a widget 146 * which is contained in a GtkBox. 147 * Use gtk_container_class_install_child_property() to install child properties 148 * for a container class and gtk_container_class_find_child_property() or 149 * gtk_container_class_list_child_properties() to get information about existing 150 * child properties. 151 * To set the value of a child property, use gtk_container_child_set_property(), 152 * gtk_container_child_set() or gtk_container_child_set_valist(). 153 * To obtain the value of a child property, use 154 * gtk_container_child_get_property(), gtk_container_child_get() or 155 * gtk_container_child_get_valist(). To emit notification about child property 156 * changes, use gtk_widget_child_notify(). 157 * <hr> 158 * GtkContainer as GtkBuildable 159 * The GtkContainer implementation of the GtkBuildable interface 160 * supports a <packing> element for children, which can 161 * contain multiple <property> elements that specify 162 * child properties for the child. 163 * $(DDOC_COMMENT example) 164 * Since 2.16, child properties can also be marked as translatable using 165 * the same "translatable", "comments" and "context" attributes that are used 166 * for regular properties. 167 */ 168 public class Container : Widget 169 { 170 171 /** the main Gtk struct */ 172 protected GtkContainer* gtkContainer; 173 174 175 public GtkContainer* getContainerStruct() 176 { 177 return gtkContainer; 178 } 179 180 181 /** the main Gtk struct as a void* */ 182 protected override void* getStruct() 183 { 184 return cast(void*)gtkContainer; 185 } 186 187 /** 188 * Sets our main struct and passes it to the parent class 189 */ 190 public this (GtkContainer* gtkContainer) 191 { 192 super(cast(GtkWidget*)gtkContainer); 193 this.gtkContainer = gtkContainer; 194 } 195 196 protected override void setStruct(GObject* obj) 197 { 198 super.setStruct(obj); 199 gtkContainer = cast(GtkContainer*)obj; 200 } 201 202 /** 203 * Removes all widgets from the container 204 */ 205 void removeAll() 206 { 207 GList* gList = gtk_container_get_children(getContainerStruct()); 208 if ( gList !is null ) 209 { 210 ListG children = new ListG(gList); 211 for ( int i=children.length()-1 ; i>=0 ; i-- ) 212 { 213 gtk_container_remove(getContainerStruct(), cast(GtkWidget*)children.nthData(i)); 214 } 215 } 216 } 217 218 /** 219 */ 220 int[string] connectedSignals; 221 222 void delegate(Widget, Container)[] onAddListeners; 223 /** 224 */ 225 void addOnAdd(void delegate(Widget, Container) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 226 { 227 if ( !("add" in connectedSignals) ) 228 { 229 Signals.connectData( 230 getStruct(), 231 "add", 232 cast(GCallback)&callBackAdd, 233 cast(void*)this, 234 null, 235 connectFlags); 236 connectedSignals["add"] = 1; 237 } 238 onAddListeners ~= dlg; 239 } 240 extern(C) static void callBackAdd(GtkContainer* containerStruct, GtkWidget* widget, Container _container) 241 { 242 foreach ( void delegate(Widget, Container) dlg ; _container.onAddListeners ) 243 { 244 dlg(ObjectG.getDObject!(Widget)(widget), _container); 245 } 246 } 247 248 void delegate(Container)[] onCheckResizeListeners; 249 /** 250 */ 251 void addOnCheckResize(void delegate(Container) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 252 { 253 if ( !("check-resize" in connectedSignals) ) 254 { 255 Signals.connectData( 256 getStruct(), 257 "check-resize", 258 cast(GCallback)&callBackCheckResize, 259 cast(void*)this, 260 null, 261 connectFlags); 262 connectedSignals["check-resize"] = 1; 263 } 264 onCheckResizeListeners ~= dlg; 265 } 266 extern(C) static void callBackCheckResize(GtkContainer* containerStruct, Container _container) 267 { 268 foreach ( void delegate(Container) dlg ; _container.onCheckResizeListeners ) 269 { 270 dlg(_container); 271 } 272 } 273 274 void delegate(Widget, Container)[] onRemoveListeners; 275 /** 276 */ 277 void addOnRemove(void delegate(Widget, Container) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 278 { 279 if ( !("remove" in connectedSignals) ) 280 { 281 Signals.connectData( 282 getStruct(), 283 "remove", 284 cast(GCallback)&callBackRemove, 285 cast(void*)this, 286 null, 287 connectFlags); 288 connectedSignals["remove"] = 1; 289 } 290 onRemoveListeners ~= dlg; 291 } 292 extern(C) static void callBackRemove(GtkContainer* containerStruct, GtkWidget* widget, Container _container) 293 { 294 foreach ( void delegate(Widget, Container) dlg ; _container.onRemoveListeners ) 295 { 296 dlg(ObjectG.getDObject!(Widget)(widget), _container); 297 } 298 } 299 300 void delegate(Widget, Container)[] onSetFocusChildListeners; 301 /** 302 */ 303 void addOnSetFocusChild(void delegate(Widget, Container) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 304 { 305 if ( !("set-focus-child" in connectedSignals) ) 306 { 307 Signals.connectData( 308 getStruct(), 309 "set-focus-child", 310 cast(GCallback)&callBackSetFocusChild, 311 cast(void*)this, 312 null, 313 connectFlags); 314 connectedSignals["set-focus-child"] = 1; 315 } 316 onSetFocusChildListeners ~= dlg; 317 } 318 extern(C) static void callBackSetFocusChild(GtkContainer* containerStruct, GtkWidget* widget, Container _container) 319 { 320 foreach ( void delegate(Widget, Container) dlg ; _container.onSetFocusChildListeners ) 321 { 322 dlg(ObjectG.getDObject!(Widget)(widget), _container); 323 } 324 } 325 326 327 /** 328 * Adds widget to container. Typically used for simple containers 329 * such as GtkWindow, GtkFrame, or GtkButton; for more complicated 330 * layout containers such as GtkBox or GtkTable, this function will 331 * pick default packing parameters that may not be correct. So 332 * consider functions such as gtk_box_pack_start() and 333 * gtk_table_attach() as an alternative to gtk_container_add() in 334 * those cases. A widget may be added to only one container at a time; 335 * you can't place the same widget inside two different containers. 336 * Params: 337 * widget = a widget to be placed inside container 338 */ 339 public void add(Widget widget) 340 { 341 // void gtk_container_add (GtkContainer *container, GtkWidget *widget); 342 gtk_container_add(gtkContainer, (widget is null) ? null : widget.getWidgetStruct()); 343 } 344 345 /** 346 * Removes widget from container. widget must be inside container. 347 * Note that container will own a reference to widget, and that this 348 * may be the last reference held; so removing a widget from its 349 * container can destroy that widget. If you want to use widget 350 * again, you need to add a reference to it while it's not inside 351 * a container, using g_object_ref(). If you don't want to use widget 352 * again it's usually more efficient to simply destroy it directly 353 * using gtk_widget_destroy() since this will remove it from the 354 * container and help break any circular reference count cycles. 355 * Params: 356 * widget = a current child of container 357 */ 358 public void remove(Widget widget) 359 { 360 // void gtk_container_remove (GtkContainer *container, GtkWidget *widget); 361 gtk_container_remove(gtkContainer, (widget is null) ? null : widget.getWidgetStruct()); 362 } 363 364 /** 365 * Returns the resize mode for the container. See 366 * gtk_container_set_resize_mode(). 367 * Returns: the current resize mode 368 */ 369 public GtkResizeMode getResizeMode() 370 { 371 // GtkResizeMode gtk_container_get_resize_mode (GtkContainer *container); 372 return gtk_container_get_resize_mode(gtkContainer); 373 } 374 375 /** 376 * Sets the resize mode for the container. 377 * The resize mode of a container determines whether a resize request 378 * will be passed to the container's parent, queued for later execution 379 * or executed immediately. 380 * Params: 381 * resizeMode = the new resize mode 382 */ 383 public void setResizeMode(GtkResizeMode resizeMode) 384 { 385 // void gtk_container_set_resize_mode (GtkContainer *container, GtkResizeMode resize_mode); 386 gtk_container_set_resize_mode(gtkContainer, resizeMode); 387 } 388 389 /** 390 */ 391 public void checkResize() 392 { 393 // void gtk_container_check_resize (GtkContainer *container); 394 gtk_container_check_resize(gtkContainer); 395 } 396 397 /** 398 * Invokes callback on each non-internal child of container. See 399 * gtk_container_forall() for details on what constitutes an 400 * "internal" child. Most applications should use 401 * gtk_container_foreach(), rather than gtk_container_forall(). 402 * Params: 403 * callback = a callback. [scope call] 404 * callbackData = callback user data 405 */ 406 public void foreac(GtkCallback callback, void* callbackData) 407 { 408 // void gtk_container_foreach (GtkContainer *container, GtkCallback callback, gpointer callback_data); 409 gtk_container_foreach(gtkContainer, callback, callbackData); 410 } 411 412 /** 413 * Warning 414 * gtk_container_foreach_full is deprecated and should not be used in newly-written code. Use gtk_container_foreach() instead. 415 */ 416 public void foreachFull(GtkCallback callback, GtkCallbackMarshal marshal, void* callbackData, GDestroyNotify notify) 417 { 418 // void gtk_container_foreach_full (GtkContainer *container, GtkCallback callback, GtkCallbackMarshal marshal, gpointer callback_data, GDestroyNotify notify); 419 gtk_container_foreach_full(gtkContainer, callback, marshal, callbackData, notify); 420 } 421 422 /** 423 * Returns the container's non-internal children. See 424 * gtk_container_forall() for details on what constitutes an "internal" child. 425 * Returns: a newly-allocated list of the container's non-internal children. [element-type GtkWidget][transfer container] 426 */ 427 public ListG getChildren() 428 { 429 // GList * gtk_container_get_children (GtkContainer *container); 430 auto p = gtk_container_get_children(gtkContainer); 431 432 if(p is null) 433 { 434 return null; 435 } 436 437 return ObjectG.getDObject!(ListG)(cast(GList*) p); 438 } 439 440 /** 441 * Sets the reallocate_redraws flag of the container to the given value. 442 * Containers requesting reallocation redraws get automatically 443 * redrawn if any of their children changed allocation. 444 * Params: 445 * needsRedraws = the new value for the container's reallocate_redraws flag 446 */ 447 public void setReallocateRedraws(int needsRedraws) 448 { 449 // void gtk_container_set_reallocate_redraws (GtkContainer *container, gboolean needs_redraws); 450 gtk_container_set_reallocate_redraws(gtkContainer, needsRedraws); 451 } 452 453 /** 454 * Returns the current focus child widget inside container. This is not the 455 * currently focused widget. That can be obtained by calling 456 * gtk_window_get_focus(). 457 * Since 2.14 458 * Returns: The child widget which will receive the focus inside container when the conatiner is focussed, or NULL if none is set. [transfer none] 459 */ 460 public Widget getFocusChild() 461 { 462 // GtkWidget * gtk_container_get_focus_child (GtkContainer *container); 463 auto p = gtk_container_get_focus_child(gtkContainer); 464 465 if(p is null) 466 { 467 return null; 468 } 469 470 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 471 } 472 473 /** 474 * Sets, or unsets if child is NULL, the focused child of container. 475 * This function emits the GtkContainer::set_focus_child signal of 476 * container. Implementations of GtkContainer can override the 477 * default behaviour by overriding the class closure of this signal. 478 * This is function is mostly meant to be used by widgets. Applications can use 479 * gtk_widget_grab_focus() to manualy set the focus to a specific widget. 480 * Params: 481 * child = a GtkWidget, or NULL. [allow-none] 482 */ 483 public void setFocusChild(Widget child) 484 { 485 // void gtk_container_set_focus_child (GtkContainer *container, GtkWidget *child); 486 gtk_container_set_focus_child(gtkContainer, (child is null) ? null : child.getWidgetStruct()); 487 } 488 489 /** 490 * Retrieves the vertical focus adjustment for the container. See 491 * gtk_container_set_focus_vadjustment(). 492 * Returns: the vertical focus adjustment, or NULL if none has been set. [transfer none] 493 */ 494 public Adjustment getFocusVadjustment() 495 { 496 // GtkAdjustment * gtk_container_get_focus_vadjustment (GtkContainer *container); 497 auto p = gtk_container_get_focus_vadjustment(gtkContainer); 498 499 if(p is null) 500 { 501 return null; 502 } 503 504 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 505 } 506 507 /** 508 * Hooks up an adjustment to focus handling in a container, so when a 509 * child of the container is focused, the adjustment is scrolled to 510 * show that widget. This function sets the vertical alignment. See 511 * gtk_scrolled_window_get_vadjustment() for a typical way of obtaining 512 * the adjustment and gtk_container_set_focus_hadjustment() for setting 513 * the horizontal adjustment. 514 * The adjustments have to be in pixel units and in the same coordinate 515 * system as the allocation for immediate children of the container. 516 * Params: 517 * adjustment = an adjustment which should be adjusted when the focus 518 * is moved among the descendents of container 519 */ 520 public void setFocusVadjustment(Adjustment adjustment) 521 { 522 // void gtk_container_set_focus_vadjustment (GtkContainer *container, GtkAdjustment *adjustment); 523 gtk_container_set_focus_vadjustment(gtkContainer, (adjustment is null) ? null : adjustment.getAdjustmentStruct()); 524 } 525 526 /** 527 * Retrieves the horizontal focus adjustment for the container. See 528 * gtk_container_set_focus_hadjustment(). 529 * Returns: the horizontal focus adjustment, or NULL if none has been set. [transfer none] 530 */ 531 public Adjustment getFocusHadjustment() 532 { 533 // GtkAdjustment * gtk_container_get_focus_hadjustment (GtkContainer *container); 534 auto p = gtk_container_get_focus_hadjustment(gtkContainer); 535 536 if(p is null) 537 { 538 return null; 539 } 540 541 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 542 } 543 544 /** 545 * Hooks up an adjustment to focus handling in a container, so when a child 546 * of the container is focused, the adjustment is scrolled to show that 547 * widget. This function sets the horizontal alignment. 548 * See gtk_scrolled_window_get_hadjustment() for a typical way of obtaining 549 * the adjustment and gtk_container_set_focus_vadjustment() for setting 550 * the vertical adjustment. 551 * The adjustments have to be in pixel units and in the same coordinate 552 * system as the allocation for immediate children of the container. 553 * Params: 554 * adjustment = an adjustment which should be adjusted when the focus is 555 * moved among the descendents of container 556 */ 557 public void setFocusHadjustment(Adjustment adjustment) 558 { 559 // void gtk_container_set_focus_hadjustment (GtkContainer *container, GtkAdjustment *adjustment); 560 gtk_container_set_focus_hadjustment(gtkContainer, (adjustment is null) ? null : adjustment.getAdjustmentStruct()); 561 } 562 563 /** 564 */ 565 public void resizeChildren() 566 { 567 // void gtk_container_resize_children (GtkContainer *container); 568 gtk_container_resize_children(gtkContainer); 569 } 570 571 /** 572 * Returns the type of the children supported by the container. 573 * Note that this may return G_TYPE_NONE to indicate that no more 574 * children can be added, e.g. for a GtkPaned which already has two 575 * children. 576 * Returns: a GType. 577 */ 578 public GType childType() 579 { 580 // GType gtk_container_child_type (GtkContainer *container); 581 return gtk_container_child_type(gtkContainer); 582 } 583 584 /** 585 * Gets the value of a child property for child and container. 586 * Params: 587 * child = a widget which is a child of container 588 * propertyName = the name of the property to get 589 * value = a location to return the value 590 */ 591 public void childGetProperty(Widget child, string propertyName, Value value) 592 { 593 // void gtk_container_child_get_property (GtkContainer *container, GtkWidget *child, const gchar *property_name, GValue *value); 594 gtk_container_child_get_property(gtkContainer, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct()); 595 } 596 597 /** 598 * Sets a child property for child and container. 599 * Params: 600 * child = a widget which is a child of container 601 * propertyName = the name of the property to set 602 * value = the value to set the property to 603 */ 604 public void childSetProperty(Widget child, string propertyName, Value value) 605 { 606 // void gtk_container_child_set_property (GtkContainer *container, GtkWidget *child, const gchar *property_name, const GValue *value); 607 gtk_container_child_set_property(gtkContainer, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct()); 608 } 609 610 /** 611 * Gets the values of one or more child properties for child and container. 612 * Params: 613 * child = a widget which is a child of container 614 * firstPropertyName = the name of the first property to get 615 * varArgs = return location for the first property, followed 616 * optionally by more name/return location pairs, followed by NULL 617 */ 618 public void childGetValist(Widget child, string firstPropertyName, void* varArgs) 619 { 620 // void gtk_container_child_get_valist (GtkContainer *container, GtkWidget *child, const gchar *first_property_name, va_list var_args); 621 gtk_container_child_get_valist(gtkContainer, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(firstPropertyName), varArgs); 622 } 623 624 /** 625 * Sets one or more child properties for child and container. 626 * Params: 627 * child = a widget which is a child of container 628 * firstPropertyName = the name of the first property to set 629 * varArgs = a NULL-terminated list of property names and values, starting 630 * with first_prop_name 631 */ 632 public void childSetValist(Widget child, string firstPropertyName, void* varArgs) 633 { 634 // void gtk_container_child_set_valist (GtkContainer *container, GtkWidget *child, const gchar *first_property_name, va_list var_args); 635 gtk_container_child_set_valist(gtkContainer, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(firstPropertyName), varArgs); 636 } 637 638 /** 639 * Invokes callback on each child of container, including children 640 * that are considered "internal" (implementation details of the 641 * container). "Internal" children generally weren't added by the user 642 * of the container, but were added by the container implementation 643 * itself. Most applications should use gtk_container_foreach(), 644 * rather than gtk_container_forall(). 645 * Params: 646 * callback = a callback 647 * callbackData = callback user data 648 */ 649 public void forall(GtkCallback callback, void* callbackData) 650 { 651 // void gtk_container_forall (GtkContainer *container, GtkCallback callback, gpointer callback_data); 652 gtk_container_forall(gtkContainer, callback, callbackData); 653 } 654 655 /** 656 * Retrieves the border width of the container. See 657 * gtk_container_set_border_width(). 658 * Returns: the current border width 659 */ 660 public uint getBorderWidth() 661 { 662 // guint gtk_container_get_border_width (GtkContainer *container); 663 return gtk_container_get_border_width(gtkContainer); 664 } 665 666 /** 667 * Sets the border width of the container. 668 * The border width of a container is the amount of space to leave 669 * around the outside of the container. The only exception to this is 670 * GtkWindow; because toplevel windows can't leave space outside, 671 * they leave the space inside. The border is added on all sides of 672 * the container. To add space to only one side, one approach is to 673 * create a GtkAlignment widget, call gtk_widget_set_size_request() 674 * to give it a size, and place it on the side of the container as 675 * a spacer. 676 * Params: 677 * borderWidth = amount of blank space to leave outside 678 * the container. Valid values are in the range 0-65535 pixels. 679 */ 680 public void setBorderWidth(uint borderWidth) 681 { 682 // void gtk_container_set_border_width (GtkContainer *container, guint border_width); 683 gtk_container_set_border_width(gtkContainer, borderWidth); 684 } 685 686 /** 687 * When a container receives an expose event, it must send synthetic 688 * expose events to all children that don't have their own GdkWindows. 689 * This function provides a convenient way of doing this. A container, 690 * when it receives an expose event, calls gtk_container_propagate_expose() 691 * once for each child, passing in the event the container received. 692 * gtk_container_propagate_expose() takes care of deciding whether 693 * an expose event needs to be sent to the child, intersecting 694 * the event's area with the child area, and sending the event. 695 * In most cases, a container can simply either simply inherit the 696 * "expose" implementation from GtkContainer, or, do some drawing 697 * and then chain to the ::expose implementation from GtkContainer. 698 * Note that the ::expose-event signal has been replaced by a ::draw 699 * signal in GTK+ 3, and consequently, gtk_container_propagate_expose() 700 * has been replaced by gtk_container_propagate_draw(). 701 * The GTK+ 3 migration guide 702 * for hints on how to port from ::expose-event to ::draw. 703 * Params: 704 * child = a child of container 705 * event = a expose event sent to container 706 */ 707 public void propagateExpose(Widget child, GdkEventExpose* event) 708 { 709 // void gtk_container_propagate_expose (GtkContainer *container, GtkWidget *child, GdkEventExpose *event); 710 gtk_container_propagate_expose(gtkContainer, (child is null) ? null : child.getWidgetStruct(), event); 711 } 712 713 /** 714 * Retrieves the focus chain of the container, if one has been 715 * set explicitly. If no focus chain has been explicitly 716 * set, GTK+ computes the focus chain based on the positions 717 * of the children. In that case, GTK+ stores NULL in 718 * focusable_widgets and returns FALSE. 719 * Params: 720 * focusableWidgets = location 721 * to store the focus chain of the 722 * container, or NULL. You should free this list 723 * using g_list_free() when you are done with it, however 724 * no additional reference count is added to the 725 * individual widgets in the focus chain. [element-type GtkWidget][out][transfer container] 726 * Returns: TRUE if the focus chain of the container has been set explicitly. 727 */ 728 public int getFocusChain(out ListG focusableWidgets) 729 { 730 // gboolean gtk_container_get_focus_chain (GtkContainer *container, GList **focusable_widgets); 731 GList* outfocusableWidgets = null; 732 733 auto p = gtk_container_get_focus_chain(gtkContainer, &outfocusableWidgets); 734 735 focusableWidgets = ObjectG.getDObject!(ListG)(outfocusableWidgets); 736 return p; 737 } 738 739 /** 740 * Sets a focus chain, overriding the one computed automatically by GTK+. 741 * In principle each widget in the chain should be a descendant of the 742 * container, but this is not enforced by this method, since it's allowed 743 * to set the focus chain before you pack the widgets, or have a widget 744 * in the chain that isn't always packed. The necessary checks are done 745 * when the focus chain is actually traversed. 746 * Params: 747 * focusableWidgets = the new focus chain. [transfer none][element-type GtkWidget] 748 */ 749 public void setFocusChain(ListG focusableWidgets) 750 { 751 // void gtk_container_set_focus_chain (GtkContainer *container, GList *focusable_widgets); 752 gtk_container_set_focus_chain(gtkContainer, (focusableWidgets is null) ? null : focusableWidgets.getListGStruct()); 753 } 754 755 /** 756 * Removes a focus chain explicitly set with gtk_container_set_focus_chain(). 757 */ 758 public void unsetFocusChain() 759 { 760 // void gtk_container_unset_focus_chain (GtkContainer *container); 761 gtk_container_unset_focus_chain(gtkContainer); 762 } 763 764 /** 765 * Finds a child property of a container class by name. 766 * Params: 767 * cclass = a GtkContainerClass. [type GtkContainerClass] 768 * propertyName = the name of the child property to find 769 * Returns: the GParamSpec of the child property or NULL if class has no child property with that name. [transfer none] 770 */ 771 public static ParamSpec classFindChildProperty(GObjectClass* cclass, string propertyName) 772 { 773 // GParamSpec * gtk_container_class_find_child_property (GObjectClass *cclass, const gchar *property_name); 774 auto p = gtk_container_class_find_child_property(cclass, Str.toStringz(propertyName)); 775 776 if(p is null) 777 { 778 return null; 779 } 780 781 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p); 782 } 783 784 /** 785 * Installs a child property on a container class. 786 * Params: 787 * cclass = a GtkContainerClass 788 * propertyId = the id for the property 789 * pspec = the GParamSpec for the property 790 */ 791 public static void classInstallChildProperty(Container cclass, uint propertyId, ParamSpec pspec) 792 { 793 // void gtk_container_class_install_child_property (GtkContainerClass *cclass, guint property_id, GParamSpec *pspec); 794 gtk_container_class_install_child_property((cclass is null) ? null : cclass.getContainerStruct(), propertyId, (pspec is null) ? null : pspec.getParamSpecStruct()); 795 } 796 797 /** 798 * Returns all child properties of a container class. 799 * Params: 800 * cclass = a GtkContainerClass. [type GtkContainerClass] 801 * Returns: a newly allocated NULL-terminated array of GParamSpec*. The array must be freed with g_free(). [array length=n_properties][transfer container] 802 */ 803 public static ParamSpec[] classListChildProperties(GObjectClass* cclass) 804 { 805 // GParamSpec ** gtk_container_class_list_child_properties (GObjectClass *cclass, guint *n_properties); 806 uint nProperties; 807 auto p = gtk_container_class_list_child_properties(cclass, &nProperties); 808 809 if(p is null) 810 { 811 return null; 812 } 813 814 ParamSpec[] arr = new ParamSpec[nProperties]; 815 for(int i = 0; i < nProperties; i++) 816 { 817 arr[i] = ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p[i]); 818 } 819 820 return arr; 821 } 822 }