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.Container; 26 27 private import cairo.Context; 28 private import glib.ListG; 29 private import glib.Str; 30 private import gobject.ObjectG; 31 private import gobject.ParamSpec; 32 private import gobject.Signals; 33 private import gobject.Value; 34 private import gtk.Adjustment; 35 private import gtk.Widget; 36 private import gtk.WidgetPath; 37 public import gtkc.gdktypes; 38 private import gtkc.gtk; 39 public import gtkc.gtktypes; 40 41 42 /** 43 * A GTK+ user interface is constructed by nesting widgets inside widgets. 44 * Container widgets are the inner nodes in the resulting tree of widgets: 45 * they contain other widgets. So, for example, you might have a #GtkWindow 46 * containing a #GtkFrame containing a #GtkLabel. If you wanted an image instead 47 * of a textual label inside the frame, you might replace the #GtkLabel widget 48 * with a #GtkImage widget. 49 * 50 * There are two major kinds of container widgets in GTK+. Both are subclasses 51 * of the abstract GtkContainer base class. 52 * 53 * The first type of container widget has a single child widget and derives 54 * from #GtkBin. These containers are decorators, which 55 * add some kind of functionality to the child. For example, a #GtkButton makes 56 * its child into a clickable button; a #GtkFrame draws a frame around its child 57 * and a #GtkWindow places its child widget inside a top-level window. 58 * 59 * The second type of container can have more than one child; its purpose is to 60 * manage layout. This means that these containers assign 61 * sizes and positions to their children. For example, a #GtkHBox arranges its 62 * children in a horizontal row, and a #GtkGrid arranges the widgets it contains 63 * in a two-dimensional grid. 64 * 65 * # Height for width geometry management 66 * 67 * GTK+ uses a height-for-width (and width-for-height) geometry management system. 68 * Height-for-width means that a widget can change how much vertical space it needs, 69 * depending on the amount of horizontal space that it is given (and similar for 70 * width-for-height). 71 * 72 * There are some things to keep in mind when implementing container widgets 73 * that make use of GTK+’s height for width geometry management system. First, 74 * it’s important to note that a container must prioritize one of its 75 * dimensions, that is to say that a widget or container can only have a 76 * #GtkSizeRequestMode that is %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH or 77 * %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT. However, every widget and container 78 * must be able to respond to the APIs for both dimensions, i.e. even if a 79 * widget has a request mode that is height-for-width, it is possible that 80 * its parent will request its sizes using the width-for-height APIs. 81 * 82 * To ensure that everything works properly, here are some guidelines to follow 83 * when implementing height-for-width (or width-for-height) containers. 84 * 85 * Each request mode involves 2 virtual methods. Height-for-width apis run 86 * through gtk_widget_get_preferred_width() and then through gtk_widget_get_preferred_height_for_width(). 87 * When handling requests in the opposite #GtkSizeRequestMode it is important that 88 * every widget request at least enough space to display all of its content at all times. 89 * 90 * When gtk_widget_get_preferred_height() is called on a container that is height-for-width, 91 * the container must return the height for its minimum width. This is easily achieved by 92 * simply calling the reverse apis implemented for itself as follows: 93 * 94 * |[<!-- language="C" --> 95 * static void 96 * foo_container_get_preferred_height (GtkWidget *widget, 97 * gint *min_height, 98 * gint *nat_height) 99 * { 100 * if (i_am_in_height_for_width_mode) 101 * { 102 * gint min_width; 103 * 104 * GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, 105 * &min_width, 106 * NULL); 107 * GTK_WIDGET_GET_CLASS (widget)->get_preferred_height_for_width 108 * (widget, 109 * min_width, 110 * min_height, 111 * nat_height); 112 * } 113 * else 114 * { 115 * ... many containers support both request modes, execute the 116 * real width-for-height request here by returning the 117 * collective heights of all widgets that are stacked 118 * vertically (or whatever is appropriate for this container) 119 * ... 120 * } 121 * } 122 * ]| 123 * 124 * Similarly, when gtk_widget_get_preferred_width_for_height() is called for a container or widget 125 * that is height-for-width, it then only needs to return the base minimum width like so: 126 * 127 * |[<!-- language="C" --> 128 * static void 129 * foo_container_get_preferred_width_for_height (GtkWidget *widget, 130 * gint for_height, 131 * gint *min_width, 132 * gint *nat_width) 133 * { 134 * if (i_am_in_height_for_width_mode) 135 * { 136 * GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, 137 * min_width, 138 * nat_width); 139 * } 140 * else 141 * { 142 * ... execute the real width-for-height request here based on 143 * the required width of the children collectively if the 144 * container were to be allocated the said height ... 145 * } 146 * } 147 * ]| 148 * 149 * Height for width requests are generally implemented in terms of a virtual allocation 150 * of widgets in the input orientation. Assuming an height-for-width request mode, a container 151 * would implement the get_preferred_height_for_width() virtual function by first calling 152 * gtk_widget_get_preferred_width() for each of its children. 153 * 154 * For each potential group of children that are lined up horizontally, the values returned by 155 * gtk_widget_get_preferred_width() should be collected in an array of #GtkRequestedSize structures. 156 * Any child spacing should be removed from the input @for_width and then the collective size should be 157 * allocated using the gtk_distribute_natural_allocation() convenience function. 158 * 159 * The container will then move on to request the preferred height for each child by using 160 * gtk_widget_get_preferred_height_for_width() and using the sizes stored in the #GtkRequestedSize array. 161 * 162 * To allocate a height-for-width container, it’s again important 163 * to consider that a container must prioritize one dimension over the other. So if 164 * a container is a height-for-width container it must first allocate all widgets horizontally 165 * using a #GtkRequestedSize array and gtk_distribute_natural_allocation() and then add any 166 * extra space (if and where appropriate) for the widget to expand. 167 * 168 * After adding all the expand space, the container assumes it was allocated sufficient 169 * height to fit all of its content. At this time, the container must use the total horizontal sizes 170 * of each widget to request the height-for-width of each of its children and store the requests in a 171 * #GtkRequestedSize array for any widgets that stack vertically (for tabular containers this can 172 * be generalized into the heights and widths of rows and columns). 173 * The vertical space must then again be distributed using gtk_distribute_natural_allocation() 174 * while this time considering the allocated height of the widget minus any vertical spacing 175 * that the container adds. Then vertical expand space should be added where appropriate and available 176 * and the container should go on to actually allocating the child widgets. 177 * 178 * See [GtkWidget’s geometry management section][geometry-management] 179 * to learn more about implementing height-for-width geometry management for widgets. 180 * 181 * # Child properties 182 * 183 * GtkContainer introduces child properties. 184 * These are object properties that are not specific 185 * to either the container or the contained widget, but rather to their relation. 186 * Typical examples of child properties are the position or pack-type of a widget 187 * which is contained in a #GtkBox. 188 * 189 * Use gtk_container_class_install_child_property() to install child properties 190 * for a container class and gtk_container_class_find_child_property() or 191 * gtk_container_class_list_child_properties() to get information about existing 192 * child properties. 193 * 194 * To set the value of a child property, use gtk_container_child_set_property(), 195 * gtk_container_child_set() or gtk_container_child_set_valist(). 196 * To obtain the value of a child property, use 197 * gtk_container_child_get_property(), gtk_container_child_get() or 198 * gtk_container_child_get_valist(). To emit notification about child property 199 * changes, use gtk_widget_child_notify(). 200 * 201 * # GtkContainer as GtkBuildable 202 * 203 * The GtkContainer implementation of the GtkBuildable interface supports 204 * a <packing> element for children, which can contain multiple <property> 205 * elements that specify child properties for the child. 206 * 207 * Since 2.16, child properties can also be marked as translatable using 208 * the same “translatable”, “comments” and “context” attributes that are used 209 * for regular properties. 210 * 211 * Since 3.16, containers can have a <focus-chain> element containing multiple 212 * <widget> elements, one for each child that should be added to the focus 213 * chain. The ”name” attribute gives the id of the widget. 214 * 215 * An example of these properties in UI definitions: 216 * |[ 217 * <object class="GtkBox"> 218 * <child> 219 * <object class="GtkEntry" id="entry1"/> 220 * <packing> 221 * <property name="pack-type">start</property> 222 * </packing> 223 * </child> 224 * <child> 225 * <object class="GtkEntry" id="entry2"/> 226 * </child> 227 * <focus-chain> 228 * <widget name="entry1"/> 229 * <widget name="entry2"/> 230 * </focus-chain> 231 * </object> 232 * ]| 233 */ 234 public class Container : Widget 235 { 236 /** the main Gtk struct */ 237 protected GtkContainer* gtkContainer; 238 239 /** Get the main Gtk struct */ 240 public GtkContainer* getContainerStruct() 241 { 242 return gtkContainer; 243 } 244 245 /** the main Gtk struct as a void* */ 246 protected override void* getStruct() 247 { 248 return cast(void*)gtkContainer; 249 } 250 251 protected override void setStruct(GObject* obj) 252 { 253 gtkContainer = cast(GtkContainer*)obj; 254 super.setStruct(obj); 255 } 256 257 /** 258 * Sets our main struct and passes it to the parent class. 259 */ 260 public this (GtkContainer* gtkContainer, bool ownedRef = false) 261 { 262 this.gtkContainer = gtkContainer; 263 super(cast(GtkWidget*)gtkContainer, ownedRef); 264 } 265 266 /** 267 * Removes all widgets from the container 268 */ 269 void removeAll() 270 { 271 GList* gList = gtk_container_get_children(getContainerStruct()); 272 if ( gList !is null ) 273 { 274 ListG children = new ListG(gList); 275 for ( int i=children.length()-1 ; i>=0 ; i-- ) 276 { 277 gtk_container_remove(getContainerStruct(), cast(GtkWidget*)children.nthData(i)); 278 } 279 } 280 } 281 282 /** 283 */ 284 285 /** */ 286 public static GType getType() 287 { 288 return gtk_container_get_type(); 289 } 290 291 /** 292 * Adds @widget to @container. Typically used for simple containers 293 * such as #GtkWindow, #GtkFrame, or #GtkButton; for more complicated 294 * layout containers such as #GtkBox or #GtkGrid, this function will 295 * pick default packing parameters that may not be correct. So 296 * consider functions such as gtk_box_pack_start() and 297 * gtk_grid_attach() as an alternative to gtk_container_add() in 298 * those cases. A widget may be added to only one container at a time; 299 * you can’t place the same widget inside two different containers. 300 * 301 * Note that some containers, such as #GtkScrolledWindow or #GtkListBox, 302 * may add intermediate children between the added widget and the 303 * container. 304 * 305 * Params: 306 * widget = a widget to be placed inside @container 307 */ 308 public void add(Widget widget) 309 { 310 gtk_container_add(gtkContainer, (widget is null) ? null : widget.getWidgetStruct()); 311 } 312 313 /** */ 314 public void checkResize() 315 { 316 gtk_container_check_resize(gtkContainer); 317 } 318 319 /** 320 * Gets the value of a child property for @child and @container. 321 * 322 * Params: 323 * child = a widget which is a child of @container 324 * propertyName = the name of the property to get 325 * value = a location to return the value 326 */ 327 public void childGetProperty(Widget child, string propertyName, Value value) 328 { 329 gtk_container_child_get_property(gtkContainer, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct()); 330 } 331 332 /** 333 * Gets the values of one or more child properties for @child and @container. 334 * 335 * Params: 336 * child = a widget which is a child of @container 337 * firstPropertyName = the name of the first property to get 338 * varArgs = return location for the first property, followed 339 * optionally by more name/return location pairs, followed by %NULL 340 */ 341 public void childGetValist(Widget child, string firstPropertyName, void* varArgs) 342 { 343 gtk_container_child_get_valist(gtkContainer, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(firstPropertyName), varArgs); 344 } 345 346 /** 347 * Emits a #GtkWidget::child-notify signal for the 348 * [child property][child-properties] 349 * @child_property on the child. 350 * 351 * This is an analogue of g_object_notify() for child properties. 352 * 353 * Also see gtk_widget_child_notify(). 354 * 355 * Params: 356 * child = the child widget 357 * childProperty = the name of a child property installed on 358 * the class of @container 359 * 360 * Since: 3.2 361 */ 362 public void childNotify(Widget child, string childProperty) 363 { 364 gtk_container_child_notify(gtkContainer, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(childProperty)); 365 } 366 367 /** 368 * Emits a #GtkWidget::child-notify signal for the 369 * [child property][child-properties] specified by 370 * @pspec on the child. 371 * 372 * This is an analogue of g_object_notify_by_pspec() for child properties. 373 * 374 * Params: 375 * child = the child widget 376 * pspec = the #GParamSpec of a child property instealled on 377 * the class of @container 378 * 379 * Since: 3.18 380 */ 381 public void childNotifyByPspec(Widget child, ParamSpec pspec) 382 { 383 gtk_container_child_notify_by_pspec(gtkContainer, (child is null) ? null : child.getWidgetStruct(), (pspec is null) ? null : pspec.getParamSpecStruct()); 384 } 385 386 /** 387 * Sets a child property for @child and @container. 388 * 389 * Params: 390 * child = a widget which is a child of @container 391 * propertyName = the name of the property to set 392 * value = the value to set the property to 393 */ 394 public void childSetProperty(Widget child, string propertyName, Value value) 395 { 396 gtk_container_child_set_property(gtkContainer, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct()); 397 } 398 399 /** 400 * Sets one or more child properties for @child and @container. 401 * 402 * Params: 403 * child = a widget which is a child of @container 404 * firstPropertyName = the name of the first property to set 405 * varArgs = a %NULL-terminated list of property names and values, starting 406 * with @first_prop_name 407 */ 408 public void childSetValist(Widget child, string firstPropertyName, void* varArgs) 409 { 410 gtk_container_child_set_valist(gtkContainer, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(firstPropertyName), varArgs); 411 } 412 413 /** 414 * Returns the type of the children supported by the container. 415 * 416 * Note that this may return %G_TYPE_NONE to indicate that no more 417 * children can be added, e.g. for a #GtkPaned which already has two 418 * children. 419 * 420 * Return: a #GType. 421 */ 422 public GType childType() 423 { 424 return gtk_container_child_type(gtkContainer); 425 } 426 427 /** 428 * Invokes @callback on each child of @container, including children 429 * that are considered “internal” (implementation details of the 430 * container). “Internal” children generally weren’t added by the user 431 * of the container, but were added by the container implementation 432 * itself. Most applications should use gtk_container_foreach(), 433 * rather than gtk_container_forall(). 434 * 435 * Params: 436 * callback = a callback 437 * callbackData = callback user data 438 */ 439 public void forall(GtkCallback callback, void* callbackData) 440 { 441 gtk_container_forall(gtkContainer, callback, callbackData); 442 } 443 444 /** 445 * Invokes @callback on each non-internal child of @container. See 446 * gtk_container_forall() for details on what constitutes an 447 * “internal” child. Most applications should use 448 * gtk_container_foreach(), rather than gtk_container_forall(). 449 * 450 * Params: 451 * callback = a callback 452 * callbackData = callback user data 453 */ 454 public void foreac(GtkCallback callback, void* callbackData) 455 { 456 gtk_container_foreach(gtkContainer, callback, callbackData); 457 } 458 459 /** 460 * Retrieves the border width of the container. See 461 * gtk_container_set_border_width(). 462 * 463 * Return: the current border width 464 */ 465 public uint getBorderWidth() 466 { 467 return gtk_container_get_border_width(gtkContainer); 468 } 469 470 /** 471 * Returns the container’s non-internal children. See 472 * gtk_container_forall() for details on what constitutes an "internal" child. 473 * 474 * Return: a newly-allocated list of the container’s non-internal children. 475 */ 476 public ListG getChildren() 477 { 478 auto p = gtk_container_get_children(gtkContainer); 479 480 if(p is null) 481 { 482 return null; 483 } 484 485 return new ListG(cast(GList*) p); 486 } 487 488 /** 489 * Retrieves the focus chain of the container, if one has been 490 * set explicitly. If no focus chain has been explicitly 491 * set, GTK+ computes the focus chain based on the positions 492 * of the children. In that case, GTK+ stores %NULL in 493 * @focusable_widgets and returns %FALSE. 494 * 495 * Params: 496 * focusableWidgets = location 497 * to store the focus chain of the 498 * container, or %NULL. You should free this list 499 * using g_list_free() when you are done with it, however 500 * no additional reference count is added to the 501 * individual widgets in the focus chain. 502 * 503 * Return: %TRUE if the focus chain of the container 504 * has been set explicitly. 505 */ 506 public bool getFocusChain(out ListG focusableWidgets) 507 { 508 GList* outfocusableWidgets = null; 509 510 auto p = gtk_container_get_focus_chain(gtkContainer, &outfocusableWidgets) != 0; 511 512 focusableWidgets = new ListG(outfocusableWidgets); 513 514 return p; 515 } 516 517 /** 518 * Returns the current focus child widget inside @container. This is not the 519 * currently focused widget. That can be obtained by calling 520 * gtk_window_get_focus(). 521 * 522 * Return: The child widget which will receive the 523 * focus inside @container when the @conatiner is focussed, 524 * or %NULL if none is set. 525 * 526 * Since: 2.14 527 */ 528 public Widget getFocusChild() 529 { 530 auto p = gtk_container_get_focus_child(gtkContainer); 531 532 if(p is null) 533 { 534 return null; 535 } 536 537 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 538 } 539 540 /** 541 * Retrieves the horizontal focus adjustment for the container. See 542 * gtk_container_set_focus_hadjustment (). 543 * 544 * Return: the horizontal focus adjustment, or %NULL if 545 * none has been set. 546 */ 547 public Adjustment getFocusHadjustment() 548 { 549 auto p = gtk_container_get_focus_hadjustment(gtkContainer); 550 551 if(p is null) 552 { 553 return null; 554 } 555 556 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 557 } 558 559 /** 560 * Retrieves the vertical focus adjustment for the container. See 561 * gtk_container_set_focus_vadjustment(). 562 * 563 * Return: the vertical focus adjustment, or %NULL if 564 * none has been set. 565 */ 566 public Adjustment getFocusVadjustment() 567 { 568 auto p = gtk_container_get_focus_vadjustment(gtkContainer); 569 570 if(p is null) 571 { 572 return null; 573 } 574 575 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 576 } 577 578 /** 579 * Returns a newly created widget path representing all the widget hierarchy 580 * from the toplevel down to and including @child. 581 * 582 * Params: 583 * child = a child of @container 584 * 585 * Return: A newly created #GtkWidgetPath 586 */ 587 public WidgetPath getPathForChild(Widget child) 588 { 589 auto p = gtk_container_get_path_for_child(gtkContainer, (child is null) ? null : child.getWidgetStruct()); 590 591 if(p is null) 592 { 593 return null; 594 } 595 596 return ObjectG.getDObject!(WidgetPath)(cast(GtkWidgetPath*) p); 597 } 598 599 /** 600 * Returns the resize mode for the container. See 601 * gtk_container_set_resize_mode (). 602 * 603 * Deprecated: Resize modes are deprecated. They aren’t necessary 604 * anymore since frame clocks and might introduce obscure bugs if 605 * used. 606 * 607 * Return: the current resize mode 608 */ 609 public GtkResizeMode getResizeMode() 610 { 611 return gtk_container_get_resize_mode(gtkContainer); 612 } 613 614 /** 615 * When a container receives a call to the draw function, it must send 616 * synthetic #GtkWidget::draw calls to all children that don’t have their 617 * own #GdkWindows. This function provides a convenient way of doing this. 618 * A container, when it receives a call to its #GtkWidget::draw function, 619 * calls gtk_container_propagate_draw() once for each child, passing in 620 * the @cr the container received. 621 * 622 * gtk_container_propagate_draw() takes care of translating the origin of @cr, 623 * and deciding whether the draw needs to be sent to the child. It is a 624 * convenient and optimized way of getting the same effect as calling 625 * gtk_widget_draw() on the child directly. 626 * 627 * In most cases, a container can simply either inherit the 628 * #GtkWidget::draw implementation from #GtkContainer, or do some drawing 629 * and then chain to the ::draw implementation from #GtkContainer. 630 * 631 * Params: 632 * child = a child of @container 633 * cr = Cairo context as passed to the container. If you want to use @cr 634 * in container’s draw function, consider using cairo_save() and 635 * cairo_restore() before calling this function. 636 */ 637 public void propagateDraw(Widget child, Context cr) 638 { 639 gtk_container_propagate_draw(gtkContainer, (child is null) ? null : child.getWidgetStruct(), (cr is null) ? null : cr.getContextStruct()); 640 } 641 642 /** 643 * Removes @widget from @container. @widget must be inside @container. 644 * Note that @container will own a reference to @widget, and that this 645 * may be the last reference held; so removing a widget from its 646 * container can destroy that widget. If you want to use @widget 647 * again, you need to add a reference to it while it’s not inside 648 * a container, using g_object_ref(). If you don’t want to use @widget 649 * again it’s usually more efficient to simply destroy it directly 650 * using gtk_widget_destroy() since this will remove it from the 651 * container and help break any circular reference count cycles. 652 * 653 * Params: 654 * widget = a current child of @container 655 */ 656 public void remove(Widget widget) 657 { 658 gtk_container_remove(gtkContainer, (widget is null) ? null : widget.getWidgetStruct()); 659 } 660 661 /** */ 662 public void resizeChildren() 663 { 664 gtk_container_resize_children(gtkContainer); 665 } 666 667 /** 668 * Sets the border width of the container. 669 * 670 * The border width of a container is the amount of space to leave 671 * around the outside of the container. The only exception to this is 672 * #GtkWindow; because toplevel windows can’t leave space outside, 673 * they leave the space inside. The border is added on all sides of 674 * the container. To add space to only one side, use a specific 675 * #GtkWidget:margin property on the child widget, for example 676 * #GtkWidget:margin-top. 677 * 678 * Params: 679 * borderWidth = amount of blank space to leave outside 680 * the container. Valid values are in the range 0-65535 pixels. 681 */ 682 public void setBorderWidth(uint borderWidth) 683 { 684 gtk_container_set_border_width(gtkContainer, borderWidth); 685 } 686 687 /** 688 * Sets a focus chain, overriding the one computed automatically by GTK+. 689 * 690 * In principle each widget in the chain should be a descendant of the 691 * container, but this is not enforced by this method, since it’s allowed 692 * to set the focus chain before you pack the widgets, or have a widget 693 * in the chain that isn’t always packed. The necessary checks are done 694 * when the focus chain is actually traversed. 695 * 696 * Params: 697 * focusableWidgets = the new focus chain 698 */ 699 public void setFocusChain(ListG focusableWidgets) 700 { 701 gtk_container_set_focus_chain(gtkContainer, (focusableWidgets is null) ? null : focusableWidgets.getListGStruct()); 702 } 703 704 /** 705 * Sets, or unsets if @child is %NULL, the focused child of @container. 706 * 707 * This function emits the GtkContainer::set_focus_child signal of 708 * @container. Implementations of #GtkContainer can override the 709 * default behaviour by overriding the class closure of this signal. 710 * 711 * This is function is mostly meant to be used by widgets. Applications can use 712 * gtk_widget_grab_focus() to manually set the focus to a specific widget. 713 * 714 * Params: 715 * child = a #GtkWidget, or %NULL 716 */ 717 public void setFocusChild(Widget child) 718 { 719 gtk_container_set_focus_child(gtkContainer, (child is null) ? null : child.getWidgetStruct()); 720 } 721 722 /** 723 * Hooks up an adjustment to focus handling in a container, so when a child 724 * of the container is focused, the adjustment is scrolled to show that 725 * widget. This function sets the horizontal alignment. 726 * See gtk_scrolled_window_get_hadjustment() for a typical way of obtaining 727 * the adjustment and gtk_container_set_focus_vadjustment() for setting 728 * the vertical adjustment. 729 * 730 * The adjustments have to be in pixel units and in the same coordinate 731 * system as the allocation for immediate children of the container. 732 * 733 * Params: 734 * adjustment = an adjustment which should be adjusted when the focus is 735 * moved among the descendents of @container 736 */ 737 public void setFocusHadjustment(Adjustment adjustment) 738 { 739 gtk_container_set_focus_hadjustment(gtkContainer, (adjustment is null) ? null : adjustment.getAdjustmentStruct()); 740 } 741 742 /** 743 * Hooks up an adjustment to focus handling in a container, so when a 744 * child of the container is focused, the adjustment is scrolled to 745 * show that widget. This function sets the vertical alignment. See 746 * gtk_scrolled_window_get_vadjustment() for a typical way of obtaining 747 * the adjustment and gtk_container_set_focus_hadjustment() for setting 748 * the horizontal adjustment. 749 * 750 * The adjustments have to be in pixel units and in the same coordinate 751 * system as the allocation for immediate children of the container. 752 * 753 * Params: 754 * adjustment = an adjustment which should be adjusted when the focus 755 * is moved among the descendents of @container 756 */ 757 public void setFocusVadjustment(Adjustment adjustment) 758 { 759 gtk_container_set_focus_vadjustment(gtkContainer, (adjustment is null) ? null : adjustment.getAdjustmentStruct()); 760 } 761 762 /** 763 * Sets the @reallocate_redraws flag of the container to the given value. 764 * 765 * Containers requesting reallocation redraws get automatically 766 * redrawn if any of their children changed allocation. 767 * 768 * Deprecated: Call gtk_widget_queue_draw() in your size_allocate handler. 769 * 770 * Params: 771 * needsRedraws = the new value for the container’s @reallocate_redraws flag 772 */ 773 public void setReallocateRedraws(bool needsRedraws) 774 { 775 gtk_container_set_reallocate_redraws(gtkContainer, needsRedraws); 776 } 777 778 /** 779 * Sets the resize mode for the container. 780 * 781 * The resize mode of a container determines whether a resize request 782 * will be passed to the container’s parent, queued for later execution 783 * or executed immediately. 784 * 785 * Deprecated: Resize modes are deprecated. They aren’t necessary 786 * anymore since frame clocks and might introduce obscure bugs if 787 * used. 788 * 789 * Params: 790 * resizeMode = the new resize mode 791 */ 792 public void setResizeMode(GtkResizeMode resizeMode) 793 { 794 gtk_container_set_resize_mode(gtkContainer, resizeMode); 795 } 796 797 /** 798 * Removes a focus chain explicitly set with gtk_container_set_focus_chain(). 799 */ 800 public void unsetFocusChain() 801 { 802 gtk_container_unset_focus_chain(gtkContainer); 803 } 804 805 int[string] connectedSignals; 806 807 void delegate(Widget, Container)[] onAddListeners; 808 /** */ 809 void addOnAdd(void delegate(Widget, Container) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 810 { 811 if ( "add" !in connectedSignals ) 812 { 813 Signals.connectData( 814 this, 815 "add", 816 cast(GCallback)&callBackAdd, 817 cast(void*)this, 818 null, 819 connectFlags); 820 connectedSignals["add"] = 1; 821 } 822 onAddListeners ~= dlg; 823 } 824 extern(C) static void callBackAdd(GtkContainer* containerStruct, GtkWidget* object, Container _container) 825 { 826 foreach ( void delegate(Widget, Container) dlg; _container.onAddListeners ) 827 { 828 dlg(ObjectG.getDObject!(Widget)(object), _container); 829 } 830 } 831 832 void delegate(Container)[] onCheckResizeListeners; 833 /** */ 834 void addOnCheckResize(void delegate(Container) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 835 { 836 if ( "check-resize" !in connectedSignals ) 837 { 838 Signals.connectData( 839 this, 840 "check-resize", 841 cast(GCallback)&callBackCheckResize, 842 cast(void*)this, 843 null, 844 connectFlags); 845 connectedSignals["check-resize"] = 1; 846 } 847 onCheckResizeListeners ~= dlg; 848 } 849 extern(C) static void callBackCheckResize(GtkContainer* containerStruct, Container _container) 850 { 851 foreach ( void delegate(Container) dlg; _container.onCheckResizeListeners ) 852 { 853 dlg(_container); 854 } 855 } 856 857 void delegate(Widget, Container)[] onRemoveListeners; 858 /** */ 859 void addOnRemove(void delegate(Widget, Container) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 860 { 861 if ( "remove" !in connectedSignals ) 862 { 863 Signals.connectData( 864 this, 865 "remove", 866 cast(GCallback)&callBackRemove, 867 cast(void*)this, 868 null, 869 connectFlags); 870 connectedSignals["remove"] = 1; 871 } 872 onRemoveListeners ~= dlg; 873 } 874 extern(C) static void callBackRemove(GtkContainer* containerStruct, GtkWidget* object, Container _container) 875 { 876 foreach ( void delegate(Widget, Container) dlg; _container.onRemoveListeners ) 877 { 878 dlg(ObjectG.getDObject!(Widget)(object), _container); 879 } 880 } 881 882 void delegate(Widget, Container)[] onSetFocusChildListeners; 883 /** */ 884 void addOnSetFocusChild(void delegate(Widget, Container) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 885 { 886 if ( "set-focus-child" !in connectedSignals ) 887 { 888 Signals.connectData( 889 this, 890 "set-focus-child", 891 cast(GCallback)&callBackSetFocusChild, 892 cast(void*)this, 893 null, 894 connectFlags); 895 connectedSignals["set-focus-child"] = 1; 896 } 897 onSetFocusChildListeners ~= dlg; 898 } 899 extern(C) static void callBackSetFocusChild(GtkContainer* containerStruct, GtkWidget* object, Container _container) 900 { 901 foreach ( void delegate(Widget, Container) dlg; _container.onSetFocusChildListeners ) 902 { 903 dlg(ObjectG.getDObject!(Widget)(object), _container); 904 } 905 } 906 }