1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
19 * GtkLayout: Widget for scrolling of arbitrary-sized areas.
21 * Copyright Owen Taylor, 1998
25 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
26 * file for a list of people on the GTK+ Team. See the ChangeLog
27 * files for a list of changes. These files are distributed with
28 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
33 #undef GTK_DISABLE_DEPRECATED
35 #include "gtklayout.h"
37 #include "gdkconfig.h"
39 #include "gtkprivate.h"
41 #include "gtkmarshalers.h"
42 #include "gtkscrollable.h"
45 typedef struct _GtkLayoutChild GtkLayoutChild;
47 struct _GtkLayoutPrivate
53 GtkAdjustment *hadjustment;
54 GtkAdjustment *vadjustment;
56 /* GtkScrollablePolicy needs to be checked when
57 * driving the scrollable adjustment values */
58 guint hscroll_policy : 1;
59 guint vscroll_policy : 1;
63 GdkVisibilityState visibility;
64 GdkWindow *bin_window;
74 struct _GtkLayoutChild {
96 static void gtk_layout_get_property (GObject *object,
100 static void gtk_layout_set_property (GObject *object,
104 static void gtk_layout_finalize (GObject *object);
105 static void gtk_layout_realize (GtkWidget *widget);
106 static void gtk_layout_unrealize (GtkWidget *widget);
107 static void gtk_layout_map (GtkWidget *widget);
108 static void gtk_layout_get_preferred_width (GtkWidget *widget,
111 static void gtk_layout_get_preferred_height (GtkWidget *widget,
114 static void gtk_layout_size_allocate (GtkWidget *widget,
115 GtkAllocation *allocation);
116 static gint gtk_layout_draw (GtkWidget *widget,
118 static void gtk_layout_add (GtkContainer *container,
120 static void gtk_layout_remove (GtkContainer *container,
122 static void gtk_layout_forall (GtkContainer *container,
123 gboolean include_internals,
124 GtkCallback callback,
125 gpointer callback_data);
126 static void gtk_layout_set_child_property (GtkContainer *container,
131 static void gtk_layout_get_child_property (GtkContainer *container,
136 static void gtk_layout_allocate_child (GtkLayout *layout,
137 GtkLayoutChild *child);
138 static void gtk_layout_adjustment_changed (GtkAdjustment *adjustment,
140 static void gtk_layout_style_set (GtkWidget *widget,
141 GtkStyle *old_style);
143 static void gtk_layout_set_hadjustment_values (GtkLayout *layout);
144 static void gtk_layout_set_vadjustment_values (GtkLayout *layout);
146 G_DEFINE_TYPE_WITH_CODE (GtkLayout, gtk_layout, GTK_TYPE_CONTAINER,
147 G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL))
153 * @hadjustment: (allow-none): horizontal scroll adjustment, or %NULL
154 * @vadjustment: (allow-none): vertical scroll adjustment, or %NULL
156 * Creates a new #GtkLayout. Unless you have a specific adjustment
157 * you'd like the layout to use for scrolling, pass %NULL for
158 * @hadjustment and @vadjustment.
160 * Return value: a new #GtkLayout
164 gtk_layout_new (GtkAdjustment *hadjustment,
165 GtkAdjustment *vadjustment)
169 layout = g_object_new (GTK_TYPE_LAYOUT,
170 "hadjustment", hadjustment,
171 "vadjustment", vadjustment,
174 return GTK_WIDGET (layout);
178 * gtk_layout_get_bin_window:
179 * @layout: a #GtkLayout
181 * Retrieve the bin window of the layout used for drawing operations.
183 * Return value: (transfer none): a #GdkWindow
188 gtk_layout_get_bin_window (GtkLayout *layout)
190 g_return_val_if_fail (GTK_IS_LAYOUT (layout), NULL);
192 return layout->priv->bin_window;
196 * gtk_layout_get_hadjustment:
197 * @layout: a #GtkLayout
199 * This function should only be called after the layout has been
200 * placed in a #GtkScrolledWindow or otherwise configured for
201 * scrolling. It returns the #GtkAdjustment used for communication
202 * between the horizontal scrollbar and @layout.
204 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
206 * Return value: (transfer none): horizontal scroll adjustment
208 * Deprecated: 3.0: Use gtk_scrollable_get_hadjustment()
211 gtk_layout_get_hadjustment (GtkLayout *layout)
213 g_return_val_if_fail (GTK_IS_LAYOUT (layout), NULL);
215 return layout->priv->hadjustment;
218 * gtk_layout_get_vadjustment:
219 * @layout: a #GtkLayout
221 * This function should only be called after the layout has been
222 * placed in a #GtkScrolledWindow or otherwise configured for
223 * scrolling. It returns the #GtkAdjustment used for communication
224 * between the vertical scrollbar and @layout.
226 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
228 * Return value: (transfer none): vertical scroll adjustment
230 * Deprecated: 3.0: Use gtk_scrollable_get_vadjustment()
233 gtk_layout_get_vadjustment (GtkLayout *layout)
235 g_return_val_if_fail (GTK_IS_LAYOUT (layout), NULL);
237 return layout->priv->vadjustment;
241 gtk_layout_set_hadjustment_values (GtkLayout *layout)
243 GtkLayoutPrivate *priv = layout->priv;
244 GtkAllocation allocation;
245 GtkAdjustment *adj = priv->hadjustment;
250 gtk_widget_get_allocation (GTK_WIDGET (layout), &allocation);
252 old_value = gtk_adjustment_get_value (adj);
253 new_upper = MAX (allocation.width, priv->width);
258 "page-size", (gdouble)allocation.width,
259 "step-increment", allocation.width * 0.1,
260 "page-increment", allocation.width * 0.9,
263 new_value = CLAMP (old_value, 0, new_upper - allocation.width);
264 if (new_value != old_value)
265 gtk_adjustment_set_value (adj, new_value);
269 gtk_layout_set_vadjustment_values (GtkLayout *layout)
271 GtkAllocation allocation;
272 GtkAdjustment *adj = layout->priv->vadjustment;
277 gtk_widget_get_allocation (GTK_WIDGET (layout), &allocation);
279 old_value = gtk_adjustment_get_value (adj);
280 new_upper = MAX (allocation.height, layout->priv->height);
285 "page-size", (gdouble)allocation.height,
286 "step-increment", allocation.height * 0.1,
287 "page-increment", allocation.height * 0.9,
290 new_value = CLAMP (old_value, 0, new_upper - allocation.height);
291 if (new_value != old_value)
292 gtk_adjustment_set_value (adj, new_value);
296 gtk_layout_finalize (GObject *object)
298 GtkLayout *layout = GTK_LAYOUT (object);
299 GtkLayoutPrivate *priv = layout->priv;
301 g_object_unref (priv->hadjustment);
302 g_object_unref (priv->vadjustment);
304 G_OBJECT_CLASS (gtk_layout_parent_class)->finalize (object);
308 * gtk_layout_set_hadjustment:
309 * @layout: a #GtkLayout
310 * @adjustment: (allow-none): new scroll adjustment
312 * Sets the horizontal scroll adjustment for the layout.
314 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
316 * Deprecated: 3.0: Use gtk_scrollable_set_hadjustment()
319 gtk_layout_set_hadjustment (GtkLayout *layout,
320 GtkAdjustment *adjustment)
322 GtkLayoutPrivate *priv;
324 g_return_if_fail (GTK_IS_LAYOUT (layout));
325 g_return_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment));
329 if (adjustment && priv->hadjustment == adjustment)
332 if (priv->hadjustment != NULL)
334 g_signal_handlers_disconnect_by_func (priv->hadjustment,
335 gtk_layout_adjustment_changed,
337 g_object_unref (priv->hadjustment);
340 if (adjustment == NULL)
341 adjustment = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
343 g_signal_connect (adjustment, "value-changed",
344 G_CALLBACK (gtk_layout_adjustment_changed), layout);
345 priv->hadjustment = g_object_ref_sink (adjustment);
346 gtk_layout_set_hadjustment_values (layout);
348 g_object_notify (G_OBJECT (layout), "hadjustment");
353 * gtk_layout_set_vadjustment:
354 * @layout: a #GtkLayout
355 * @adjustment: (allow-none): new scroll adjustment
357 * Sets the vertical scroll adjustment for the layout.
359 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
361 * Deprecated: 3.0: Use gtk_scrollable_set_vadjustment()
364 gtk_layout_set_vadjustment (GtkLayout *layout,
365 GtkAdjustment *adjustment)
367 GtkLayoutPrivate *priv;
369 g_return_if_fail (GTK_IS_LAYOUT (layout));
370 g_return_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment));
374 if (adjustment && priv->vadjustment == adjustment)
377 if (priv->vadjustment != NULL)
379 g_signal_handlers_disconnect_by_func (priv->vadjustment,
380 gtk_layout_adjustment_changed,
382 g_object_unref (priv->vadjustment);
385 if (adjustment == NULL)
386 adjustment = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
388 g_signal_connect (adjustment, "value-changed",
389 G_CALLBACK (gtk_layout_adjustment_changed), layout);
390 priv->vadjustment = g_object_ref_sink (adjustment);
391 gtk_layout_set_vadjustment_values (layout);
393 g_object_notify (G_OBJECT (layout), "vadjustment");
396 static GtkLayoutChild*
397 get_child (GtkLayout *layout,
400 GtkLayoutPrivate *priv = layout->priv;
403 children = priv->children;
406 GtkLayoutChild *child;
408 child = children->data;
409 children = children->next;
411 if (child->widget == widget)
420 * @layout: a #GtkLayout
421 * @child_widget: child widget
422 * @x: X position of child widget
423 * @y: Y position of child widget
425 * Adds @child_widget to @layout, at position (@x,@y).
426 * @layout becomes the new parent container of @child_widget.
430 gtk_layout_put (GtkLayout *layout,
431 GtkWidget *child_widget,
435 GtkLayoutPrivate *priv;
436 GtkLayoutChild *child;
438 g_return_if_fail (GTK_IS_LAYOUT (layout));
439 g_return_if_fail (GTK_IS_WIDGET (child_widget));
443 child = g_new (GtkLayoutChild, 1);
445 child->widget = child_widget;
449 priv->children = g_list_append (priv->children, child);
451 if (gtk_widget_get_realized (GTK_WIDGET (layout)))
452 gtk_widget_set_parent_window (child->widget, priv->bin_window);
454 gtk_widget_set_parent (child_widget, GTK_WIDGET (layout));
458 gtk_layout_move_internal (GtkLayout *layout,
465 GtkLayoutChild *child;
467 child = get_child (layout, widget);
471 gtk_widget_freeze_child_notify (widget);
476 gtk_widget_child_notify (widget, "x");
482 gtk_widget_child_notify (widget, "y");
485 gtk_widget_thaw_child_notify (widget);
487 if (gtk_widget_get_visible (widget) &&
488 gtk_widget_get_visible (GTK_WIDGET (layout)))
489 gtk_widget_queue_resize (widget);
494 * @layout: a #GtkLayout
495 * @child_widget: a current child of @layout
496 * @x: X position to move to
497 * @y: Y position to move to
499 * Moves a current child of @layout to a new position.
503 gtk_layout_move (GtkLayout *layout,
504 GtkWidget *child_widget,
508 g_return_if_fail (GTK_IS_LAYOUT (layout));
509 g_return_if_fail (GTK_IS_WIDGET (child_widget));
510 g_return_if_fail (gtk_widget_get_parent (child_widget) == GTK_WIDGET (layout));
512 gtk_layout_move_internal (layout, child_widget, TRUE, x, TRUE, y);
516 * gtk_layout_set_size:
517 * @layout: a #GtkLayout
518 * @width: width of entire scrollable area
519 * @height: height of entire scrollable area
521 * Sets the size of the scrollable area of the layout.
525 gtk_layout_set_size (GtkLayout *layout,
529 GtkLayoutPrivate *priv;
532 g_return_if_fail (GTK_IS_LAYOUT (layout));
535 widget = GTK_WIDGET (layout);
537 g_object_freeze_notify (G_OBJECT (layout));
538 if (width != priv->width)
541 g_object_notify (G_OBJECT (layout), "width");
543 if (height != priv->height)
545 priv->height = height;
546 g_object_notify (G_OBJECT (layout), "height");
548 g_object_thaw_notify (G_OBJECT (layout));
550 if (gtk_widget_get_realized (widget))
552 GtkAllocation allocation;
554 gtk_widget_get_allocation (widget, &allocation);
555 width = MAX (width, allocation.width);
556 height = MAX (height, allocation.height);
557 gdk_window_resize (priv->bin_window, width, height);
560 gtk_layout_set_hadjustment_values (layout);
561 gtk_layout_set_vadjustment_values (layout);
565 * gtk_layout_get_size:
566 * @layout: a #GtkLayout
567 * @width: (allow-none): location to store the width set on @layout, or %NULL
568 * @height: (allow-none): location to store the height set on @layout, or %NULL
570 * Gets the size that has been set on the layout, and that determines
571 * the total extents of the layout's scrollbar area. See
572 * gtk_layout_set_size ().
575 gtk_layout_get_size (GtkLayout *layout,
579 GtkLayoutPrivate *priv;
581 g_return_if_fail (GTK_IS_LAYOUT (layout));
586 *width = priv->width;
588 *height = priv->height;
591 /* Basic Object handling procedures
594 gtk_layout_class_init (GtkLayoutClass *class)
596 GObjectClass *gobject_class;
597 GtkWidgetClass *widget_class;
598 GtkContainerClass *container_class;
600 gobject_class = (GObjectClass*) class;
601 widget_class = (GtkWidgetClass*) class;
602 container_class = (GtkContainerClass*) class;
604 gobject_class->set_property = gtk_layout_set_property;
605 gobject_class->get_property = gtk_layout_get_property;
606 gobject_class->finalize = gtk_layout_finalize;
608 container_class->set_child_property = gtk_layout_set_child_property;
609 container_class->get_child_property = gtk_layout_get_child_property;
611 gtk_container_class_install_child_property (container_class,
613 g_param_spec_int ("x",
615 P_("X position of child widget"),
619 GTK_PARAM_READWRITE));
621 gtk_container_class_install_child_property (container_class,
623 g_param_spec_int ("y",
625 P_("Y position of child widget"),
629 GTK_PARAM_READWRITE));
631 /* Scrollable interface */
632 g_object_class_override_property (gobject_class, PROP_HADJUSTMENT, "hadjustment");
633 g_object_class_override_property (gobject_class, PROP_VADJUSTMENT, "vadjustment");
634 g_object_class_override_property (gobject_class, PROP_HSCROLL_POLICY, "hscroll-policy");
635 g_object_class_override_property (gobject_class, PROP_VSCROLL_POLICY, "vscroll-policy");
637 g_object_class_install_property (gobject_class,
639 g_param_spec_uint ("width",
641 P_("The width of the layout"),
645 GTK_PARAM_READWRITE));
646 g_object_class_install_property (gobject_class,
648 g_param_spec_uint ("height",
650 P_("The height of the layout"),
654 GTK_PARAM_READWRITE));
655 widget_class->realize = gtk_layout_realize;
656 widget_class->unrealize = gtk_layout_unrealize;
657 widget_class->map = gtk_layout_map;
658 widget_class->get_preferred_width = gtk_layout_get_preferred_width;
659 widget_class->get_preferred_height = gtk_layout_get_preferred_height;
660 widget_class->size_allocate = gtk_layout_size_allocate;
661 widget_class->draw = gtk_layout_draw;
662 widget_class->style_set = gtk_layout_style_set;
664 container_class->add = gtk_layout_add;
665 container_class->remove = gtk_layout_remove;
666 container_class->forall = gtk_layout_forall;
668 g_type_class_add_private (class, sizeof (GtkLayoutPrivate));
672 gtk_layout_get_property (GObject *object,
677 GtkLayout *layout = GTK_LAYOUT (object);
678 GtkLayoutPrivate *priv = layout->priv;
682 case PROP_HADJUSTMENT:
683 g_value_set_object (value, priv->hadjustment);
685 case PROP_VADJUSTMENT:
686 g_value_set_object (value, priv->vadjustment);
688 case PROP_HSCROLL_POLICY:
689 g_value_set_enum (value, priv->hscroll_policy);
691 case PROP_VSCROLL_POLICY:
692 g_value_set_enum (value, priv->vscroll_policy);
695 g_value_set_uint (value, priv->width);
698 g_value_set_uint (value, priv->height);
701 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
707 gtk_layout_set_property (GObject *object,
712 GtkLayout *layout = GTK_LAYOUT (object);
713 GtkLayoutPrivate *priv = layout->priv;
717 case PROP_HADJUSTMENT:
718 gtk_layout_set_hadjustment (layout,
719 (GtkAdjustment*) g_value_get_object (value));
721 case PROP_VADJUSTMENT:
722 gtk_layout_set_vadjustment (layout,
723 (GtkAdjustment*) g_value_get_object (value));
725 case PROP_HSCROLL_POLICY:
726 priv->hscroll_policy = g_value_get_enum (value);
727 gtk_widget_queue_resize (GTK_WIDGET (layout));
729 case PROP_VSCROLL_POLICY:
730 priv->vscroll_policy = g_value_get_enum (value);
731 gtk_widget_queue_resize (GTK_WIDGET (layout));
734 gtk_layout_set_size (layout, g_value_get_uint (value),
738 gtk_layout_set_size (layout, priv->width,
739 g_value_get_uint (value));
742 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
748 gtk_layout_set_child_property (GtkContainer *container,
757 gtk_layout_move_internal (GTK_LAYOUT (container),
759 TRUE, g_value_get_int (value),
763 gtk_layout_move_internal (GTK_LAYOUT (container),
766 TRUE, g_value_get_int (value));
769 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
775 gtk_layout_get_child_property (GtkContainer *container,
781 GtkLayoutChild *layout_child;
783 layout_child = get_child (GTK_LAYOUT (container), child);
788 g_value_set_int (value, layout_child->x);
791 g_value_set_int (value, layout_child->y);
794 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
800 gtk_layout_init (GtkLayout *layout)
802 GtkLayoutPrivate *priv;
804 layout->priv = G_TYPE_INSTANCE_GET_PRIVATE (layout,
809 priv->children = NULL;
814 priv->hadjustment = NULL;
815 priv->vadjustment = NULL;
817 priv->bin_window = NULL;
821 priv->visibility = GDK_VISIBILITY_PARTIAL;
823 priv->freeze_count = 0;
830 gtk_layout_realize (GtkWidget *widget)
832 GtkLayout *layout = GTK_LAYOUT (widget);
833 GtkLayoutPrivate *priv = layout->priv;
834 GtkAllocation allocation;
836 GdkWindowAttr attributes;
838 gint attributes_mask;
840 gtk_widget_set_realized (widget, TRUE);
842 gtk_widget_get_allocation (widget, &allocation);
844 attributes.window_type = GDK_WINDOW_CHILD;
845 attributes.x = allocation.x;
846 attributes.y = allocation.y;
847 attributes.width = allocation.width;
848 attributes.height = allocation.height;
849 attributes.wclass = GDK_INPUT_OUTPUT;
850 attributes.visual = gtk_widget_get_visual (widget);
851 attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK;
853 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
855 window = gdk_window_new (gtk_widget_get_parent_window (widget),
856 &attributes, attributes_mask);
857 gtk_widget_set_window (widget, window);
858 gdk_window_set_user_data (window, widget);
860 gtk_widget_get_allocation (widget, &allocation);
862 attributes.x = - priv->hadjustment->value,
863 attributes.y = - priv->vadjustment->value;
864 attributes.width = MAX (priv->width, allocation.width);
865 attributes.height = MAX (priv->height, allocation.height);
866 attributes.event_mask = GDK_EXPOSURE_MASK | GDK_SCROLL_MASK |
867 gtk_widget_get_events (widget);
869 priv->bin_window = gdk_window_new (window,
870 &attributes, attributes_mask);
871 gdk_window_set_user_data (priv->bin_window, widget);
873 gtk_widget_style_attach (widget);
874 gtk_style_set_background (gtk_widget_get_style (widget), priv->bin_window, GTK_STATE_NORMAL);
876 tmp_list = priv->children;
879 GtkLayoutChild *child = tmp_list->data;
880 tmp_list = tmp_list->next;
882 gtk_widget_set_parent_window (child->widget, priv->bin_window);
887 gtk_layout_style_set (GtkWidget *widget,
890 GtkLayoutPrivate *priv;
892 GTK_WIDGET_CLASS (gtk_layout_parent_class)->style_set (widget, old_style);
894 if (gtk_widget_get_realized (widget))
896 priv = GTK_LAYOUT (widget)->priv;
897 gtk_style_set_background (gtk_widget_get_style (widget), priv->bin_window, GTK_STATE_NORMAL);
902 gtk_layout_map (GtkWidget *widget)
904 GtkLayout *layout = GTK_LAYOUT (widget);
905 GtkLayoutPrivate *priv = layout->priv;
908 gtk_widget_set_mapped (widget, TRUE);
910 tmp_list = priv->children;
913 GtkLayoutChild *child = tmp_list->data;
914 tmp_list = tmp_list->next;
916 if (gtk_widget_get_visible (child->widget))
918 if (!gtk_widget_get_mapped (child->widget))
919 gtk_widget_map (child->widget);
923 gdk_window_show (priv->bin_window);
924 gdk_window_show (gtk_widget_get_window (widget));
928 gtk_layout_unrealize (GtkWidget *widget)
930 GtkLayout *layout = GTK_LAYOUT (widget);
931 GtkLayoutPrivate *priv = layout->priv;
933 gdk_window_set_user_data (priv->bin_window, NULL);
934 gdk_window_destroy (priv->bin_window);
935 priv->bin_window = NULL;
937 GTK_WIDGET_CLASS (gtk_layout_parent_class)->unrealize (widget);
941 gtk_layout_get_preferred_width (GtkWidget *widget,
945 *minimum = *natural = 0;
949 gtk_layout_get_preferred_height (GtkWidget *widget,
953 *minimum = *natural = 0;
957 gtk_layout_size_allocate (GtkWidget *widget,
958 GtkAllocation *allocation)
960 GtkLayout *layout = GTK_LAYOUT (widget);
961 GtkLayoutPrivate *priv = layout->priv;
964 gtk_widget_set_allocation (widget, allocation);
966 tmp_list = priv->children;
970 GtkLayoutChild *child = tmp_list->data;
971 tmp_list = tmp_list->next;
973 gtk_layout_allocate_child (layout, child);
976 if (gtk_widget_get_realized (widget))
978 gdk_window_move_resize (gtk_widget_get_window (widget),
979 allocation->x, allocation->y,
980 allocation->width, allocation->height);
982 gdk_window_resize (priv->bin_window,
983 MAX (priv->width, allocation->width),
984 MAX (priv->height, allocation->height));
987 gtk_layout_set_hadjustment_values (layout);
988 gtk_layout_set_vadjustment_values (layout);
992 gtk_layout_draw (GtkWidget *widget,
995 GtkLayout *layout = GTK_LAYOUT (widget);
996 GtkLayoutPrivate *priv = layout->priv;
998 if (gtk_cairo_should_draw_window (cr, priv->bin_window))
999 GTK_WIDGET_CLASS (gtk_layout_parent_class)->draw (widget, cr);
1004 /* Container methods
1007 gtk_layout_add (GtkContainer *container,
1010 gtk_layout_put (GTK_LAYOUT (container), widget, 0, 0);
1014 gtk_layout_remove (GtkContainer *container,
1017 GtkLayout *layout = GTK_LAYOUT (container);
1018 GtkLayoutPrivate *priv = layout->priv;
1020 GtkLayoutChild *child = NULL;
1022 tmp_list = priv->children;
1025 child = tmp_list->data;
1026 if (child->widget == widget)
1028 tmp_list = tmp_list->next;
1033 gtk_widget_unparent (widget);
1035 priv->children = g_list_remove_link (priv->children, tmp_list);
1036 g_list_free_1 (tmp_list);
1042 gtk_layout_forall (GtkContainer *container,
1043 gboolean include_internals,
1044 GtkCallback callback,
1045 gpointer callback_data)
1047 GtkLayout *layout = GTK_LAYOUT (container);
1048 GtkLayoutPrivate *priv = layout->priv;
1049 GtkLayoutChild *child;
1052 tmp_list = priv->children;
1055 child = tmp_list->data;
1056 tmp_list = tmp_list->next;
1058 (* callback) (child->widget, callback_data);
1062 /* Operations on children
1066 gtk_layout_allocate_child (GtkLayout *layout,
1067 GtkLayoutChild *child)
1069 GtkAllocation allocation;
1070 GtkRequisition requisition;
1072 allocation.x = child->x;
1073 allocation.y = child->y;
1075 gtk_widget_get_preferred_size (child->widget, &requisition, NULL);
1076 allocation.width = requisition.width;
1077 allocation.height = requisition.height;
1079 gtk_widget_size_allocate (child->widget, &allocation);
1085 gtk_layout_adjustment_changed (GtkAdjustment *adjustment,
1088 GtkLayoutPrivate *priv = layout->priv;
1090 if (priv->freeze_count)
1093 if (gtk_widget_get_realized (GTK_WIDGET (layout)))
1095 gdk_window_move (priv->bin_window,
1096 - priv->hadjustment->value,
1097 - priv->vadjustment->value);
1099 gdk_window_process_updates (priv->bin_window, TRUE);