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 #include "gtklayout.h"
35 #include "gdkconfig.h"
37 #include "gtkprivate.h"
39 #include "gtkmarshalers.h"
40 #include "gtkscrollable.h"
43 typedef struct _GtkLayoutChild GtkLayoutChild;
45 struct _GtkLayoutPrivate
51 GtkAdjustment *hadjustment;
52 GtkAdjustment *vadjustment;
54 /* GtkScrollablePolicy needs to be checked when
55 * driving the scrollable adjustment values */
56 guint hscroll_policy : 1;
57 guint vscroll_policy : 1;
61 GdkVisibilityState visibility;
62 GdkWindow *bin_window;
72 struct _GtkLayoutChild {
94 static void gtk_layout_get_property (GObject *object,
98 static void gtk_layout_set_property (GObject *object,
102 static void gtk_layout_finalize (GObject *object);
103 static void gtk_layout_realize (GtkWidget *widget);
104 static void gtk_layout_unrealize (GtkWidget *widget);
105 static void gtk_layout_map (GtkWidget *widget);
106 static void gtk_layout_get_preferred_width (GtkWidget *widget,
109 static void gtk_layout_get_preferred_height (GtkWidget *widget,
112 static void gtk_layout_size_allocate (GtkWidget *widget,
113 GtkAllocation *allocation);
114 static gint gtk_layout_draw (GtkWidget *widget,
116 static void gtk_layout_add (GtkContainer *container,
118 static void gtk_layout_remove (GtkContainer *container,
120 static void gtk_layout_forall (GtkContainer *container,
121 gboolean include_internals,
122 GtkCallback callback,
123 gpointer callback_data);
124 static void gtk_layout_set_child_property (GtkContainer *container,
129 static void gtk_layout_get_child_property (GtkContainer *container,
134 static void gtk_layout_allocate_child (GtkLayout *layout,
135 GtkLayoutChild *child);
136 static void gtk_layout_adjustment_changed (GtkAdjustment *adjustment,
138 static void gtk_layout_style_set (GtkWidget *widget,
139 GtkStyle *old_style);
141 static void gtk_layout_set_hadjustment_values (GtkLayout *layout);
142 static void gtk_layout_set_vadjustment_values (GtkLayout *layout);
144 G_DEFINE_TYPE_WITH_CODE (GtkLayout, gtk_layout, GTK_TYPE_CONTAINER,
145 G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL))
151 * @hadjustment: (allow-none): horizontal scroll adjustment, or %NULL
152 * @vadjustment: (allow-none): vertical scroll adjustment, or %NULL
154 * Creates a new #GtkLayout. Unless you have a specific adjustment
155 * you'd like the layout to use for scrolling, pass %NULL for
156 * @hadjustment and @vadjustment.
158 * Return value: a new #GtkLayout
162 gtk_layout_new (GtkAdjustment *hadjustment,
163 GtkAdjustment *vadjustment)
167 layout = g_object_new (GTK_TYPE_LAYOUT,
168 "hadjustment", hadjustment,
169 "vadjustment", vadjustment,
172 return GTK_WIDGET (layout);
176 * gtk_layout_get_bin_window:
177 * @layout: a #GtkLayout
179 * Retrieve the bin window of the layout used for drawing operations.
181 * Return value: (transfer none): a #GdkWindow
186 gtk_layout_get_bin_window (GtkLayout *layout)
188 g_return_val_if_fail (GTK_IS_LAYOUT (layout), NULL);
190 return layout->priv->bin_window;
194 * gtk_layout_get_hadjustment:
195 * @layout: a #GtkLayout
197 * This function should only be called after the layout has been
198 * placed in a #GtkScrolledWindow or otherwise configured for
199 * scrolling. It returns the #GtkAdjustment used for communication
200 * between the horizontal scrollbar and @layout.
202 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
204 * Return value: (transfer none): horizontal scroll adjustment
206 * Deprecated: 3.0: Use gtk_scrollable_get_hadjustment()
209 gtk_layout_get_hadjustment (GtkLayout *layout)
211 g_return_val_if_fail (GTK_IS_LAYOUT (layout), NULL);
213 return layout->priv->hadjustment;
216 * gtk_layout_get_vadjustment:
217 * @layout: a #GtkLayout
219 * This function should only be called after the layout has been
220 * placed in a #GtkScrolledWindow or otherwise configured for
221 * scrolling. It returns the #GtkAdjustment used for communication
222 * between the vertical scrollbar and @layout.
224 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
226 * Return value: (transfer none): vertical scroll adjustment
228 * Deprecated: 3.0: Use gtk_scrollable_get_vadjustment()
231 gtk_layout_get_vadjustment (GtkLayout *layout)
233 g_return_val_if_fail (GTK_IS_LAYOUT (layout), NULL);
235 return layout->priv->vadjustment;
239 gtk_layout_set_hadjustment_values (GtkLayout *layout)
241 GtkLayoutPrivate *priv = layout->priv;
242 GtkAllocation allocation;
243 GtkAdjustment *adj = priv->hadjustment;
248 gtk_widget_get_allocation (GTK_WIDGET (layout), &allocation);
250 old_value = gtk_adjustment_get_value (adj);
251 new_upper = MAX (allocation.width, priv->width);
256 "page-size", (gdouble)allocation.width,
257 "step-increment", allocation.width * 0.1,
258 "page-increment", allocation.width * 0.9,
261 new_value = CLAMP (old_value, 0, new_upper - allocation.width);
262 if (new_value != old_value)
263 gtk_adjustment_set_value (adj, new_value);
267 gtk_layout_set_vadjustment_values (GtkLayout *layout)
269 GtkAllocation allocation;
270 GtkAdjustment *adj = layout->priv->vadjustment;
275 gtk_widget_get_allocation (GTK_WIDGET (layout), &allocation);
277 old_value = gtk_adjustment_get_value (adj);
278 new_upper = MAX (allocation.height, layout->priv->height);
283 "page-size", (gdouble)allocation.height,
284 "step-increment", allocation.height * 0.1,
285 "page-increment", allocation.height * 0.9,
288 new_value = CLAMP (old_value, 0, new_upper - allocation.height);
289 if (new_value != old_value)
290 gtk_adjustment_set_value (adj, new_value);
294 gtk_layout_finalize (GObject *object)
296 GtkLayout *layout = GTK_LAYOUT (object);
297 GtkLayoutPrivate *priv = layout->priv;
299 g_object_unref (priv->hadjustment);
300 g_object_unref (priv->vadjustment);
302 G_OBJECT_CLASS (gtk_layout_parent_class)->finalize (object);
306 * gtk_layout_set_hadjustment:
307 * @layout: a #GtkLayout
308 * @adjustment: (allow-none): new scroll adjustment
310 * Sets the horizontal scroll adjustment for the layout.
312 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
314 * Deprecated: 3.0: Use gtk_scrollable_set_hadjustment()
317 gtk_layout_set_hadjustment (GtkLayout *layout,
318 GtkAdjustment *adjustment)
320 GtkLayoutPrivate *priv;
322 g_return_if_fail (GTK_IS_LAYOUT (layout));
323 g_return_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment));
327 if (adjustment && priv->hadjustment == adjustment)
330 if (priv->hadjustment != NULL)
332 g_signal_handlers_disconnect_by_func (priv->hadjustment,
333 gtk_layout_adjustment_changed,
335 g_object_unref (priv->hadjustment);
338 if (adjustment == NULL)
339 adjustment = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
341 g_signal_connect (adjustment, "value-changed",
342 G_CALLBACK (gtk_layout_adjustment_changed), layout);
343 priv->hadjustment = g_object_ref_sink (adjustment);
344 gtk_layout_set_hadjustment_values (layout);
346 g_object_notify (G_OBJECT (layout), "hadjustment");
351 * gtk_layout_set_vadjustment:
352 * @layout: a #GtkLayout
353 * @adjustment: (allow-none): new scroll adjustment
355 * Sets the vertical scroll adjustment for the layout.
357 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
359 * Deprecated: 3.0: Use gtk_scrollable_set_vadjustment()
362 gtk_layout_set_vadjustment (GtkLayout *layout,
363 GtkAdjustment *adjustment)
365 GtkLayoutPrivate *priv;
367 g_return_if_fail (GTK_IS_LAYOUT (layout));
368 g_return_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment));
372 if (adjustment && priv->vadjustment == adjustment)
375 if (priv->vadjustment != NULL)
377 g_signal_handlers_disconnect_by_func (priv->vadjustment,
378 gtk_layout_adjustment_changed,
380 g_object_unref (priv->vadjustment);
383 if (adjustment == NULL)
384 adjustment = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
386 g_signal_connect (adjustment, "value-changed",
387 G_CALLBACK (gtk_layout_adjustment_changed), layout);
388 priv->vadjustment = g_object_ref_sink (adjustment);
389 gtk_layout_set_vadjustment_values (layout);
391 g_object_notify (G_OBJECT (layout), "vadjustment");
394 static GtkLayoutChild*
395 get_child (GtkLayout *layout,
398 GtkLayoutPrivate *priv = layout->priv;
401 children = priv->children;
404 GtkLayoutChild *child;
406 child = children->data;
407 children = children->next;
409 if (child->widget == widget)
418 * @layout: a #GtkLayout
419 * @child_widget: child widget
420 * @x: X position of child widget
421 * @y: Y position of child widget
423 * Adds @child_widget to @layout, at position (@x,@y).
424 * @layout becomes the new parent container of @child_widget.
428 gtk_layout_put (GtkLayout *layout,
429 GtkWidget *child_widget,
433 GtkLayoutPrivate *priv;
434 GtkLayoutChild *child;
436 g_return_if_fail (GTK_IS_LAYOUT (layout));
437 g_return_if_fail (GTK_IS_WIDGET (child_widget));
441 child = g_new (GtkLayoutChild, 1);
443 child->widget = child_widget;
447 priv->children = g_list_append (priv->children, child);
449 if (gtk_widget_get_realized (GTK_WIDGET (layout)))
450 gtk_widget_set_parent_window (child->widget, priv->bin_window);
452 gtk_widget_set_parent (child_widget, GTK_WIDGET (layout));
456 gtk_layout_move_internal (GtkLayout *layout,
463 GtkLayoutChild *child;
465 child = get_child (layout, widget);
469 gtk_widget_freeze_child_notify (widget);
474 gtk_widget_child_notify (widget, "x");
480 gtk_widget_child_notify (widget, "y");
483 gtk_widget_thaw_child_notify (widget);
485 if (gtk_widget_get_visible (widget) &&
486 gtk_widget_get_visible (GTK_WIDGET (layout)))
487 gtk_widget_queue_resize (widget);
492 * @layout: a #GtkLayout
493 * @child_widget: a current child of @layout
494 * @x: X position to move to
495 * @y: Y position to move to
497 * Moves a current child of @layout to a new position.
501 gtk_layout_move (GtkLayout *layout,
502 GtkWidget *child_widget,
506 g_return_if_fail (GTK_IS_LAYOUT (layout));
507 g_return_if_fail (GTK_IS_WIDGET (child_widget));
508 g_return_if_fail (gtk_widget_get_parent (child_widget) == GTK_WIDGET (layout));
510 gtk_layout_move_internal (layout, child_widget, TRUE, x, TRUE, y);
514 * gtk_layout_set_size:
515 * @layout: a #GtkLayout
516 * @width: width of entire scrollable area
517 * @height: height of entire scrollable area
519 * Sets the size of the scrollable area of the layout.
523 gtk_layout_set_size (GtkLayout *layout,
527 GtkLayoutPrivate *priv;
530 g_return_if_fail (GTK_IS_LAYOUT (layout));
533 widget = GTK_WIDGET (layout);
535 g_object_freeze_notify (G_OBJECT (layout));
536 if (width != priv->width)
539 g_object_notify (G_OBJECT (layout), "width");
541 if (height != priv->height)
543 priv->height = height;
544 g_object_notify (G_OBJECT (layout), "height");
546 g_object_thaw_notify (G_OBJECT (layout));
548 if (gtk_widget_get_realized (widget))
550 GtkAllocation allocation;
552 gtk_widget_get_allocation (widget, &allocation);
553 width = MAX (width, allocation.width);
554 height = MAX (height, allocation.height);
555 gdk_window_resize (priv->bin_window, width, height);
558 gtk_layout_set_hadjustment_values (layout);
559 gtk_layout_set_vadjustment_values (layout);
563 * gtk_layout_get_size:
564 * @layout: a #GtkLayout
565 * @width: (allow-none): location to store the width set on @layout, or %NULL
566 * @height: (allow-none): location to store the height set on @layout, or %NULL
568 * Gets the size that has been set on the layout, and that determines
569 * the total extents of the layout's scrollbar area. See
570 * gtk_layout_set_size ().
573 gtk_layout_get_size (GtkLayout *layout,
577 GtkLayoutPrivate *priv;
579 g_return_if_fail (GTK_IS_LAYOUT (layout));
584 *width = priv->width;
586 *height = priv->height;
589 /* Basic Object handling procedures
592 gtk_layout_class_init (GtkLayoutClass *class)
594 GObjectClass *gobject_class;
595 GtkWidgetClass *widget_class;
596 GtkContainerClass *container_class;
598 gobject_class = (GObjectClass*) class;
599 widget_class = (GtkWidgetClass*) class;
600 container_class = (GtkContainerClass*) class;
602 gobject_class->set_property = gtk_layout_set_property;
603 gobject_class->get_property = gtk_layout_get_property;
604 gobject_class->finalize = gtk_layout_finalize;
606 container_class->set_child_property = gtk_layout_set_child_property;
607 container_class->get_child_property = gtk_layout_get_child_property;
609 gtk_container_class_install_child_property (container_class,
611 g_param_spec_int ("x",
613 P_("X position of child widget"),
617 GTK_PARAM_READWRITE));
619 gtk_container_class_install_child_property (container_class,
621 g_param_spec_int ("y",
623 P_("Y position of child widget"),
627 GTK_PARAM_READWRITE));
629 /* Scrollable interface */
630 g_object_class_override_property (gobject_class, PROP_HADJUSTMENT, "hadjustment");
631 g_object_class_override_property (gobject_class, PROP_VADJUSTMENT, "vadjustment");
632 g_object_class_override_property (gobject_class, PROP_HSCROLL_POLICY, "hscroll-policy");
633 g_object_class_override_property (gobject_class, PROP_VSCROLL_POLICY, "vscroll-policy");
635 g_object_class_install_property (gobject_class,
637 g_param_spec_uint ("width",
639 P_("The width of the layout"),
643 GTK_PARAM_READWRITE));
644 g_object_class_install_property (gobject_class,
646 g_param_spec_uint ("height",
648 P_("The height of the layout"),
652 GTK_PARAM_READWRITE));
653 widget_class->realize = gtk_layout_realize;
654 widget_class->unrealize = gtk_layout_unrealize;
655 widget_class->map = gtk_layout_map;
656 widget_class->get_preferred_width = gtk_layout_get_preferred_width;
657 widget_class->get_preferred_height = gtk_layout_get_preferred_height;
658 widget_class->size_allocate = gtk_layout_size_allocate;
659 widget_class->draw = gtk_layout_draw;
660 widget_class->style_set = gtk_layout_style_set;
662 container_class->add = gtk_layout_add;
663 container_class->remove = gtk_layout_remove;
664 container_class->forall = gtk_layout_forall;
666 g_type_class_add_private (class, sizeof (GtkLayoutPrivate));
670 gtk_layout_get_property (GObject *object,
675 GtkLayout *layout = GTK_LAYOUT (object);
676 GtkLayoutPrivate *priv = layout->priv;
680 case PROP_HADJUSTMENT:
681 g_value_set_object (value, priv->hadjustment);
683 case PROP_VADJUSTMENT:
684 g_value_set_object (value, priv->vadjustment);
686 case PROP_HSCROLL_POLICY:
687 g_value_set_enum (value, priv->hscroll_policy);
689 case PROP_VSCROLL_POLICY:
690 g_value_set_enum (value, priv->vscroll_policy);
693 g_value_set_uint (value, priv->width);
696 g_value_set_uint (value, priv->height);
699 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
705 gtk_layout_set_property (GObject *object,
710 GtkLayout *layout = GTK_LAYOUT (object);
711 GtkLayoutPrivate *priv = layout->priv;
715 case PROP_HADJUSTMENT:
716 gtk_layout_set_hadjustment (layout,
717 (GtkAdjustment*) g_value_get_object (value));
719 case PROP_VADJUSTMENT:
720 gtk_layout_set_vadjustment (layout,
721 (GtkAdjustment*) g_value_get_object (value));
723 case PROP_HSCROLL_POLICY:
724 priv->hscroll_policy = g_value_get_enum (value);
725 gtk_widget_queue_resize (GTK_WIDGET (layout));
727 case PROP_VSCROLL_POLICY:
728 priv->vscroll_policy = g_value_get_enum (value);
729 gtk_widget_queue_resize (GTK_WIDGET (layout));
732 gtk_layout_set_size (layout, g_value_get_uint (value),
736 gtk_layout_set_size (layout, priv->width,
737 g_value_get_uint (value));
740 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
746 gtk_layout_set_child_property (GtkContainer *container,
755 gtk_layout_move_internal (GTK_LAYOUT (container),
757 TRUE, g_value_get_int (value),
761 gtk_layout_move_internal (GTK_LAYOUT (container),
764 TRUE, g_value_get_int (value));
767 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
773 gtk_layout_get_child_property (GtkContainer *container,
779 GtkLayoutChild *layout_child;
781 layout_child = get_child (GTK_LAYOUT (container), child);
786 g_value_set_int (value, layout_child->x);
789 g_value_set_int (value, layout_child->y);
792 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
798 gtk_layout_init (GtkLayout *layout)
800 GtkLayoutPrivate *priv;
802 layout->priv = G_TYPE_INSTANCE_GET_PRIVATE (layout,
807 priv->children = NULL;
812 priv->hadjustment = NULL;
813 priv->vadjustment = NULL;
815 priv->bin_window = NULL;
819 priv->visibility = GDK_VISIBILITY_PARTIAL;
821 priv->freeze_count = 0;
828 gtk_layout_realize (GtkWidget *widget)
830 GtkLayout *layout = GTK_LAYOUT (widget);
831 GtkLayoutPrivate *priv = layout->priv;
832 GtkAllocation allocation;
834 GdkWindowAttr attributes;
836 gint attributes_mask;
838 gtk_widget_set_realized (widget, TRUE);
840 gtk_widget_get_allocation (widget, &allocation);
842 attributes.window_type = GDK_WINDOW_CHILD;
843 attributes.x = allocation.x;
844 attributes.y = allocation.y;
845 attributes.width = allocation.width;
846 attributes.height = allocation.height;
847 attributes.wclass = GDK_INPUT_OUTPUT;
848 attributes.visual = gtk_widget_get_visual (widget);
849 attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK;
851 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
853 window = gdk_window_new (gtk_widget_get_parent_window (widget),
854 &attributes, attributes_mask);
855 gtk_widget_set_window (widget, window);
856 gdk_window_set_user_data (window, widget);
858 gtk_widget_get_allocation (widget, &allocation);
860 attributes.x = - priv->hadjustment->value,
861 attributes.y = - priv->vadjustment->value;
862 attributes.width = MAX (priv->width, allocation.width);
863 attributes.height = MAX (priv->height, allocation.height);
864 attributes.event_mask = GDK_EXPOSURE_MASK | GDK_SCROLL_MASK |
865 gtk_widget_get_events (widget);
867 priv->bin_window = gdk_window_new (window,
868 &attributes, attributes_mask);
869 gdk_window_set_user_data (priv->bin_window, widget);
871 gtk_widget_style_attach (widget);
872 gtk_style_set_background (gtk_widget_get_style (widget), priv->bin_window, GTK_STATE_NORMAL);
874 tmp_list = priv->children;
877 GtkLayoutChild *child = tmp_list->data;
878 tmp_list = tmp_list->next;
880 gtk_widget_set_parent_window (child->widget, priv->bin_window);
885 gtk_layout_style_set (GtkWidget *widget,
888 GtkLayoutPrivate *priv;
890 GTK_WIDGET_CLASS (gtk_layout_parent_class)->style_set (widget, old_style);
892 if (gtk_widget_get_realized (widget))
894 priv = GTK_LAYOUT (widget)->priv;
895 gtk_style_set_background (gtk_widget_get_style (widget), priv->bin_window, GTK_STATE_NORMAL);
900 gtk_layout_map (GtkWidget *widget)
902 GtkLayout *layout = GTK_LAYOUT (widget);
903 GtkLayoutPrivate *priv = layout->priv;
906 gtk_widget_set_mapped (widget, TRUE);
908 tmp_list = priv->children;
911 GtkLayoutChild *child = tmp_list->data;
912 tmp_list = tmp_list->next;
914 if (gtk_widget_get_visible (child->widget))
916 if (!gtk_widget_get_mapped (child->widget))
917 gtk_widget_map (child->widget);
921 gdk_window_show (priv->bin_window);
922 gdk_window_show (gtk_widget_get_window (widget));
926 gtk_layout_unrealize (GtkWidget *widget)
928 GtkLayout *layout = GTK_LAYOUT (widget);
929 GtkLayoutPrivate *priv = layout->priv;
931 gdk_window_set_user_data (priv->bin_window, NULL);
932 gdk_window_destroy (priv->bin_window);
933 priv->bin_window = NULL;
935 GTK_WIDGET_CLASS (gtk_layout_parent_class)->unrealize (widget);
939 gtk_layout_get_preferred_width (GtkWidget *widget,
943 *minimum = *natural = 0;
947 gtk_layout_get_preferred_height (GtkWidget *widget,
951 *minimum = *natural = 0;
955 gtk_layout_size_allocate (GtkWidget *widget,
956 GtkAllocation *allocation)
958 GtkLayout *layout = GTK_LAYOUT (widget);
959 GtkLayoutPrivate *priv = layout->priv;
962 gtk_widget_set_allocation (widget, allocation);
964 tmp_list = priv->children;
968 GtkLayoutChild *child = tmp_list->data;
969 tmp_list = tmp_list->next;
971 gtk_layout_allocate_child (layout, child);
974 if (gtk_widget_get_realized (widget))
976 gdk_window_move_resize (gtk_widget_get_window (widget),
977 allocation->x, allocation->y,
978 allocation->width, allocation->height);
980 gdk_window_resize (priv->bin_window,
981 MAX (priv->width, allocation->width),
982 MAX (priv->height, allocation->height));
985 gtk_layout_set_hadjustment_values (layout);
986 gtk_layout_set_vadjustment_values (layout);
990 gtk_layout_draw (GtkWidget *widget,
993 GtkLayout *layout = GTK_LAYOUT (widget);
994 GtkLayoutPrivate *priv = layout->priv;
996 if (gtk_cairo_should_draw_window (cr, priv->bin_window))
997 GTK_WIDGET_CLASS (gtk_layout_parent_class)->draw (widget, cr);
1002 /* Container methods
1005 gtk_layout_add (GtkContainer *container,
1008 gtk_layout_put (GTK_LAYOUT (container), widget, 0, 0);
1012 gtk_layout_remove (GtkContainer *container,
1015 GtkLayout *layout = GTK_LAYOUT (container);
1016 GtkLayoutPrivate *priv = layout->priv;
1018 GtkLayoutChild *child = NULL;
1020 tmp_list = priv->children;
1023 child = tmp_list->data;
1024 if (child->widget == widget)
1026 tmp_list = tmp_list->next;
1031 gtk_widget_unparent (widget);
1033 priv->children = g_list_remove_link (priv->children, tmp_list);
1034 g_list_free_1 (tmp_list);
1040 gtk_layout_forall (GtkContainer *container,
1041 gboolean include_internals,
1042 GtkCallback callback,
1043 gpointer callback_data)
1045 GtkLayout *layout = GTK_LAYOUT (container);
1046 GtkLayoutPrivate *priv = layout->priv;
1047 GtkLayoutChild *child;
1050 tmp_list = priv->children;
1053 child = tmp_list->data;
1054 tmp_list = tmp_list->next;
1056 (* callback) (child->widget, callback_data);
1060 /* Operations on children
1064 gtk_layout_allocate_child (GtkLayout *layout,
1065 GtkLayoutChild *child)
1067 GtkAllocation allocation;
1068 GtkRequisition requisition;
1070 allocation.x = child->x;
1071 allocation.y = child->y;
1073 gtk_widget_get_preferred_size (child->widget, &requisition, NULL);
1074 allocation.width = requisition.width;
1075 allocation.height = requisition.height;
1077 gtk_widget_size_allocate (child->widget, &allocation);
1083 gtk_layout_adjustment_changed (GtkAdjustment *adjustment,
1086 GtkLayoutPrivate *priv = layout->priv;
1088 if (priv->freeze_count)
1091 if (gtk_widget_get_realized (GTK_WIDGET (layout)))
1093 gdk_window_move (priv->bin_window,
1094 - priv->hadjustment->value,
1095 - priv->vadjustment->value);
1097 gdk_window_process_updates (priv->bin_window, TRUE);