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