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 public static GType getType() 286 { 287 return gtk_container_get_type(); 288 } 289 290 /** 291 * Adds @widget to @container. Typically used for simple containers 292 * such as #GtkWindow, #GtkFrame, or #GtkButton; for more complicated 293 * layout containers such as #GtkBox or #GtkGrid, this function will 294 * pick default packing parameters that may not be correct. So 295 * consider functions such as gtk_box_pack_start() and 296 * gtk_grid_attach() as an alternative to gtk_container_add() in 297 * those cases. A widget may be added to only one container at a time; 298 * you can’t place the same widget inside two different containers. 299 * 300 * Note that some containers, such as #GtkScrolledWindow or #GtkListBox, 301 * may add intermediate children between the added widget and the 302 * container. 303 * 304 * Params: 305 * widget = a widget to be placed inside @container 306 */ 307 public void add(Widget widget) 308 { 309 gtk_container_add(gtkContainer, (widget is null) ? null : widget.getWidgetStruct()); 310 } 311 312 public void checkResize() 313 { 314 gtk_container_check_resize(gtkContainer); 315 } 316 317 /** 318 * Gets the value of a child property for @child and @container. 319 * 320 * Params: 321 * child = a widget which is a child of @container 322 * propertyName = the name of the property to get 323 * value = a location to return the value 324 */ 325 public void childGetProperty(Widget child, string propertyName, Value value) 326 { 327 gtk_container_child_get_property(gtkContainer, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct()); 328 } 329 330 /** 331 * Gets the values of one or more child properties for @child and @container. 332 * 333 * Params: 334 * child = a widget which is a child of @container 335 * firstPropertyName = the name of the first property to get 336 * varArgs = return location for the first property, followed 337 * optionally by more name/return location pairs, followed by %NULL 338 */ 339 public void childGetValist(Widget child, string firstPropertyName, void* varArgs) 340 { 341 gtk_container_child_get_valist(gtkContainer, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(firstPropertyName), varArgs); 342 } 343 344 /** 345 * Emits a #GtkWidget::child-notify signal for the 346 * [child property][child-properties] 347 * @child_property on the child. 348 * 349 * This is an analogue of g_object_notify() for child properties. 350 * 351 * Also see gtk_widget_child_notify(). 352 * 353 * Params: 354 * child = the child widget 355 * childProperty = the name of a child property installed on 356 * the class of @container 357 * 358 * Since: 3.2 359 */ 360 public void childNotify(Widget child, string childProperty) 361 { 362 gtk_container_child_notify(gtkContainer, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(childProperty)); 363 } 364 365 /** 366 * Emits a #GtkWidget::child-notify signal for the 367 * [child property][child-properties] specified by 368 * @pspec on the child. 369 * 370 * This is an analogue of g_object_notify_by_pspec() for child properties. 371 * 372 * Params: 373 * child = the child widget 374 * pspec = the #GParamSpec of a child property instealled on 375 * the class of @container 376 * 377 * Since: 3.18 378 */ 379 public void childNotifyByPspec(Widget child, ParamSpec pspec) 380 { 381 gtk_container_child_notify_by_pspec(gtkContainer, (child is null) ? null : child.getWidgetStruct(), (pspec is null) ? null : pspec.getParamSpecStruct()); 382 } 383 384 /** 385 * Sets a child property for @child and @container. 386 * 387 * Params: 388 * child = a widget which is a child of @container 389 * propertyName = the name of the property to set 390 * value = the value to set the property to 391 */ 392 public void childSetProperty(Widget child, string propertyName, Value value) 393 { 394 gtk_container_child_set_property(gtkContainer, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct()); 395 } 396 397 /** 398 * Sets one or more child properties for @child and @container. 399 * 400 * Params: 401 * child = a widget which is a child of @container 402 * firstPropertyName = the name of the first property to set 403 * varArgs = a %NULL-terminated list of property names and values, starting 404 * with @first_prop_name 405 */ 406 public void childSetValist(Widget child, string firstPropertyName, void* varArgs) 407 { 408 gtk_container_child_set_valist(gtkContainer, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(firstPropertyName), varArgs); 409 } 410 411 /** 412 * Returns the type of the children supported by the container. 413 * 414 * Note that this may return %G_TYPE_NONE to indicate that no more 415 * children can be added, e.g. for a #GtkPaned which already has two 416 * children. 417 * 418 * Return: a #GType. 419 */ 420 public GType childType() 421 { 422 return gtk_container_child_type(gtkContainer); 423 } 424 425 /** 426 * Invokes @callback on each child of @container, including children 427 * that are considered “internal” (implementation details of the 428 * container). “Internal” children generally weren’t added by the user 429 * of the container, but were added by the container implementation 430 * itself. Most applications should use gtk_container_foreach(), 431 * rather than gtk_container_forall(). 432 * 433 * Params: 434 * callback = a callback 435 * callbackData = callback user data 436 */ 437 public void forall(GtkCallback callback, void* callbackData) 438 { 439 gtk_container_forall(gtkContainer, callback, callbackData); 440 } 441 442 /** 443 * Invokes @callback on each non-internal child of @container. See 444 * gtk_container_forall() for details on what constitutes an 445 * “internal” child. Most applications should use 446 * gtk_container_foreach(), rather than gtk_container_forall(). 447 * 448 * Params: 449 * callback = a callback 450 * callbackData = callback user data 451 */ 452 public void foreac(GtkCallback callback, void* callbackData) 453 { 454 gtk_container_foreach(gtkContainer, callback, callbackData); 455 } 456 457 /** 458 * Retrieves the border width of the container. See 459 * gtk_container_set_border_width(). 460 * 461 * Return: the current border width 462 */ 463 public uint getBorderWidth() 464 { 465 return gtk_container_get_border_width(gtkContainer); 466 } 467 468 /** 469 * Returns the container’s non-internal children. See 470 * gtk_container_forall() for details on what constitutes an "internal" child. 471 * 472 * Return: a newly-allocated list of the container’s non-internal children. 473 */ 474 public ListG getChildren() 475 { 476 auto p = gtk_container_get_children(gtkContainer); 477 478 if(p is null) 479 { 480 return null; 481 } 482 483 return new ListG(cast(GList*) p); 484 } 485 486 /** 487 * Retrieves the focus chain of the container, if one has been 488 * set explicitly. If no focus chain has been explicitly 489 * set, GTK+ computes the focus chain based on the positions 490 * of the children. In that case, GTK+ stores %NULL in 491 * @focusable_widgets and returns %FALSE. 492 * 493 * Params: 494 * focusableWidgets = location 495 * to store the focus chain of the 496 * container, or %NULL. You should free this list 497 * using g_list_free() when you are done with it, however 498 * no additional reference count is added to the 499 * individual widgets in the focus chain. 500 * 501 * Return: %TRUE if the focus chain of the container 502 * has been set explicitly. 503 */ 504 public bool getFocusChain(out ListG focusableWidgets) 505 { 506 GList* outfocusableWidgets = null; 507 508 auto p = gtk_container_get_focus_chain(gtkContainer, &outfocusableWidgets) != 0; 509 510 focusableWidgets = new ListG(outfocusableWidgets); 511 512 return p; 513 } 514 515 /** 516 * Returns the current focus child widget inside @container. This is not the 517 * currently focused widget. That can be obtained by calling 518 * gtk_window_get_focus(). 519 * 520 * Return: The child widget which will receive the 521 * focus inside @container when the @conatiner is focussed, 522 * or %NULL if none is set. 523 * 524 * Since: 2.14 525 */ 526 public Widget getFocusChild() 527 { 528 auto p = gtk_container_get_focus_child(gtkContainer); 529 530 if(p is null) 531 { 532 return null; 533 } 534 535 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 536 } 537 538 /** 539 * Retrieves the horizontal focus adjustment for the container. See 540 * gtk_container_set_focus_hadjustment (). 541 * 542 * Return: the horizontal focus adjustment, or %NULL if 543 * none has been set. 544 */ 545 public Adjustment getFocusHadjustment() 546 { 547 auto p = gtk_container_get_focus_hadjustment(gtkContainer); 548 549 if(p is null) 550 { 551 return null; 552 } 553 554 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 555 } 556 557 /** 558 * Retrieves the vertical focus adjustment for the container. See 559 * gtk_container_set_focus_vadjustment(). 560 * 561 * Return: the vertical focus adjustment, or %NULL if 562 * none has been set. 563 */ 564 public Adjustment getFocusVadjustment() 565 { 566 auto p = gtk_container_get_focus_vadjustment(gtkContainer); 567 568 if(p is null) 569 { 570 return null; 571 } 572 573 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 574 } 575 576 /** 577 * Returns a newly created widget path representing all the widget hierarchy 578 * from the toplevel down to and including @child. 579 * 580 * Params: 581 * child = a child of @container 582 * 583 * Return: A newly created #GtkWidgetPath 584 */ 585 public WidgetPath getPathForChild(Widget child) 586 { 587 auto p = gtk_container_get_path_for_child(gtkContainer, (child is null) ? null : child.getWidgetStruct()); 588 589 if(p is null) 590 { 591 return null; 592 } 593 594 return ObjectG.getDObject!(WidgetPath)(cast(GtkWidgetPath*) p); 595 } 596 597 /** 598 * Returns the resize mode for the container. See 599 * gtk_container_set_resize_mode (). 600 * 601 * Deprecated: Resize modes are deprecated. They aren’t necessary 602 * anymore since frame clocks and might introduce obscure bugs if 603 * used. 604 * 605 * Return: the current resize mode 606 */ 607 public GtkResizeMode getResizeMode() 608 { 609 return gtk_container_get_resize_mode(gtkContainer); 610 } 611 612 /** 613 * When a container receives a call to the draw function, it must send 614 * synthetic #GtkWidget::draw calls to all children that don’t have their 615 * own #GdkWindows. This function provides a convenient way of doing this. 616 * A container, when it receives a call to its #GtkWidget::draw function, 617 * calls gtk_container_propagate_draw() once for each child, passing in 618 * the @cr the container received. 619 * 620 * gtk_container_propagate_draw() takes care of translating the origin of @cr, 621 * and deciding whether the draw needs to be sent to the child. It is a 622 * convenient and optimized way of getting the same effect as calling 623 * gtk_widget_draw() on the child directly. 624 * 625 * In most cases, a container can simply either inherit the 626 * #GtkWidget::draw implementation from #GtkContainer, or do some drawing 627 * and then chain to the ::draw implementation from #GtkContainer. 628 * 629 * Params: 630 * child = a child of @container 631 * cr = Cairo context as passed to the container. If you want to use @cr 632 * in container’s draw function, consider using cairo_save() and 633 * cairo_restore() before calling this function. 634 */ 635 public void propagateDraw(Widget child, Context cr) 636 { 637 gtk_container_propagate_draw(gtkContainer, (child is null) ? null : child.getWidgetStruct(), (cr is null) ? null : cr.getContextStruct()); 638 } 639 640 /** 641 * Removes @widget from @container. @widget must be inside @container. 642 * Note that @container will own a reference to @widget, and that this 643 * may be the last reference held; so removing a widget from its 644 * container can destroy that widget. If you want to use @widget 645 * again, you need to add a reference to it while it’s not inside 646 * a container, using g_object_ref(). If you don’t want to use @widget 647 * again it’s usually more efficient to simply destroy it directly 648 * using gtk_widget_destroy() since this will remove it from the 649 * container and help break any circular reference count cycles. 650 * 651 * Params: 652 * widget = a current child of @container 653 */ 654 public void remove(Widget widget) 655 { 656 gtk_container_remove(gtkContainer, (widget is null) ? null : widget.getWidgetStruct()); 657 } 658 659 public void resizeChildren() 660 { 661 gtk_container_resize_children(gtkContainer); 662 } 663 664 /** 665 * Sets the border width of the container. 666 * 667 * The border width of a container is the amount of space to leave 668 * around the outside of the container. The only exception to this is 669 * #GtkWindow; because toplevel windows can’t leave space outside, 670 * they leave the space inside. The border is added on all sides of 671 * the container. To add space to only one side, use a specific 672 * #GtkWidget:margin property on the child widget, for example 673 * #GtkWidget:margin-top. 674 * 675 * Params: 676 * borderWidth = amount of blank space to leave outside 677 * the container. Valid values are in the range 0-65535 pixels. 678 */ 679 public void setBorderWidth(uint borderWidth) 680 { 681 gtk_container_set_border_width(gtkContainer, borderWidth); 682 } 683 684 /** 685 * Sets a focus chain, overriding the one computed automatically by GTK+. 686 * 687 * In principle each widget in the chain should be a descendant of the 688 * container, but this is not enforced by this method, since it’s allowed 689 * to set the focus chain before you pack the widgets, or have a widget 690 * in the chain that isn’t always packed. The necessary checks are done 691 * when the focus chain is actually traversed. 692 * 693 * Params: 694 * focusableWidgets = the new focus chain 695 */ 696 public void setFocusChain(ListG focusableWidgets) 697 { 698 gtk_container_set_focus_chain(gtkContainer, (focusableWidgets is null) ? null : focusableWidgets.getListGStruct()); 699 } 700 701 /** 702 * Sets, or unsets if @child is %NULL, the focused child of @container. 703 * 704 * This function emits the GtkContainer::set_focus_child signal of 705 * @container. Implementations of #GtkContainer can override the 706 * default behaviour by overriding the class closure of this signal. 707 * 708 * This is function is mostly meant to be used by widgets. Applications can use 709 * gtk_widget_grab_focus() to manually set the focus to a specific widget. 710 * 711 * Params: 712 * child = a #GtkWidget, or %NULL 713 */ 714 public void setFocusChild(Widget child) 715 { 716 gtk_container_set_focus_child(gtkContainer, (child is null) ? null : child.getWidgetStruct()); 717 } 718 719 /** 720 * Hooks up an adjustment to focus handling in a container, so when a child 721 * of the container is focused, the adjustment is scrolled to show that 722 * widget. This function sets the horizontal alignment. 723 * See gtk_scrolled_window_get_hadjustment() for a typical way of obtaining 724 * the adjustment and gtk_container_set_focus_vadjustment() for setting 725 * the vertical adjustment. 726 * 727 * The adjustments have to be in pixel units and in the same coordinate 728 * system as the allocation for immediate children of the container. 729 * 730 * Params: 731 * adjustment = an adjustment which should be adjusted when the focus is 732 * moved among the descendents of @container 733 */ 734 public void setFocusHadjustment(Adjustment adjustment) 735 { 736 gtk_container_set_focus_hadjustment(gtkContainer, (adjustment is null) ? null : adjustment.getAdjustmentStruct()); 737 } 738 739 /** 740 * Hooks up an adjustment to focus handling in a container, so when a 741 * child of the container is focused, the adjustment is scrolled to 742 * show that widget. This function sets the vertical alignment. See 743 * gtk_scrolled_window_get_vadjustment() for a typical way of obtaining 744 * the adjustment and gtk_container_set_focus_hadjustment() for setting 745 * the horizontal adjustment. 746 * 747 * The adjustments have to be in pixel units and in the same coordinate 748 * system as the allocation for immediate children of the container. 749 * 750 * Params: 751 * adjustment = an adjustment which should be adjusted when the focus 752 * is moved among the descendents of @container 753 */ 754 public void setFocusVadjustment(Adjustment adjustment) 755 { 756 gtk_container_set_focus_vadjustment(gtkContainer, (adjustment is null) ? null : adjustment.getAdjustmentStruct()); 757 } 758 759 /** 760 * Sets the @reallocate_redraws flag of the container to the given value. 761 * 762 * Containers requesting reallocation redraws get automatically 763 * redrawn if any of their children changed allocation. 764 * 765 * Deprecated: Call gtk_widget_queue_draw() in your size_allocate handler. 766 * 767 * Params: 768 * needsRedraws = the new value for the container’s @reallocate_redraws flag 769 */ 770 public void setReallocateRedraws(bool needsRedraws) 771 { 772 gtk_container_set_reallocate_redraws(gtkContainer, needsRedraws); 773 } 774 775 /** 776 * Sets the resize mode for the container. 777 * 778 * The resize mode of a container determines whether a resize request 779 * will be passed to the container’s parent, queued for later execution 780 * or executed immediately. 781 * 782 * Deprecated: Resize modes are deprecated. They aren’t necessary 783 * anymore since frame clocks and might introduce obscure bugs if 784 * used. 785 * 786 * Params: 787 * resizeMode = the new resize mode 788 */ 789 public void setResizeMode(GtkResizeMode resizeMode) 790 { 791 gtk_container_set_resize_mode(gtkContainer, resizeMode); 792 } 793 794 /** 795 * Removes a focus chain explicitly set with gtk_container_set_focus_chain(). 796 */ 797 public void unsetFocusChain() 798 { 799 gtk_container_unset_focus_chain(gtkContainer); 800 } 801 802 int[string] connectedSignals; 803 804 void delegate(Widget, Container)[] onAddListeners; 805 void addOnAdd(void delegate(Widget, Container) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 806 { 807 if ( "add" !in connectedSignals ) 808 { 809 Signals.connectData( 810 this, 811 "add", 812 cast(GCallback)&callBackAdd, 813 cast(void*)this, 814 null, 815 connectFlags); 816 connectedSignals["add"] = 1; 817 } 818 onAddListeners ~= dlg; 819 } 820 extern(C) static void callBackAdd(GtkContainer* containerStruct, GtkWidget* object, Container _container) 821 { 822 foreach ( void delegate(Widget, Container) dlg; _container.onAddListeners ) 823 { 824 dlg(ObjectG.getDObject!(Widget)(object), _container); 825 } 826 } 827 828 void delegate(Container)[] onCheckResizeListeners; 829 void addOnCheckResize(void delegate(Container) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 830 { 831 if ( "check-resize" !in connectedSignals ) 832 { 833 Signals.connectData( 834 this, 835 "check-resize", 836 cast(GCallback)&callBackCheckResize, 837 cast(void*)this, 838 null, 839 connectFlags); 840 connectedSignals["check-resize"] = 1; 841 } 842 onCheckResizeListeners ~= dlg; 843 } 844 extern(C) static void callBackCheckResize(GtkContainer* containerStruct, Container _container) 845 { 846 foreach ( void delegate(Container) dlg; _container.onCheckResizeListeners ) 847 { 848 dlg(_container); 849 } 850 } 851 852 void delegate(Widget, Container)[] onRemoveListeners; 853 void addOnRemove(void delegate(Widget, Container) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 854 { 855 if ( "remove" !in connectedSignals ) 856 { 857 Signals.connectData( 858 this, 859 "remove", 860 cast(GCallback)&callBackRemove, 861 cast(void*)this, 862 null, 863 connectFlags); 864 connectedSignals["remove"] = 1; 865 } 866 onRemoveListeners ~= dlg; 867 } 868 extern(C) static void callBackRemove(GtkContainer* containerStruct, GtkWidget* object, Container _container) 869 { 870 foreach ( void delegate(Widget, Container) dlg; _container.onRemoveListeners ) 871 { 872 dlg(ObjectG.getDObject!(Widget)(object), _container); 873 } 874 } 875 876 void delegate(Widget, Container)[] onSetFocusChildListeners; 877 void addOnSetFocusChild(void delegate(Widget, Container) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 878 { 879 if ( "set-focus-child" !in connectedSignals ) 880 { 881 Signals.connectData( 882 this, 883 "set-focus-child", 884 cast(GCallback)&callBackSetFocusChild, 885 cast(void*)this, 886 null, 887 connectFlags); 888 connectedSignals["set-focus-child"] = 1; 889 } 890 onSetFocusChildListeners ~= dlg; 891 } 892 extern(C) static void callBackSetFocusChild(GtkContainer* containerStruct, GtkWidget* object, Container _container) 893 { 894 foreach ( void delegate(Widget, Container) dlg; _container.onSetFocusChildListeners ) 895 { 896 dlg(ObjectG.getDObject!(Widget)(object), _container); 897 } 898 } 899 }