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