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;
55 gint min_display_width;
56 gint min_display_height;
60 GdkVisibilityState visibility;
61 GdkWindow *bin_window;
71 struct _GtkLayoutChild {
81 PROP_MIN_DISPLAY_WIDTH,
82 PROP_MIN_DISPLAY_HEIGHT,
93 static void gtk_layout_get_property (GObject *object,
97 static void gtk_layout_set_property (GObject *object,
101 static void gtk_layout_finalize (GObject *object);
102 static void gtk_layout_realize (GtkWidget *widget);
103 static void gtk_layout_unrealize (GtkWidget *widget);
104 static void gtk_layout_map (GtkWidget *widget);
105 static void gtk_layout_size_request (GtkWidget *widget,
106 GtkRequisition *requisition);
107 static void gtk_layout_size_allocate (GtkWidget *widget,
108 GtkAllocation *allocation);
109 static gint gtk_layout_draw (GtkWidget *widget,
111 static void gtk_layout_add (GtkContainer *container,
113 static void gtk_layout_remove (GtkContainer *container,
115 static void gtk_layout_forall (GtkContainer *container,
116 gboolean include_internals,
117 GtkCallback callback,
118 gpointer callback_data);
119 static void gtk_layout_set_child_property (GtkContainer *container,
124 static void gtk_layout_get_child_property (GtkContainer *container,
129 static void gtk_layout_allocate_child (GtkLayout *layout,
130 GtkLayoutChild *child);
131 static void gtk_layout_adjustment_changed (GtkAdjustment *adjustment,
133 static void gtk_layout_style_set (GtkWidget *widget,
134 GtkStyle *old_style);
136 static void gtk_layout_set_hadjustment_values (GtkLayout *layout);
137 static void gtk_layout_set_vadjustment_values (GtkLayout *layout);
139 G_DEFINE_TYPE_WITH_CODE (GtkLayout, gtk_layout, GTK_TYPE_CONTAINER,
140 G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL))
146 * @hadjustment: (allow-none): horizontal scroll adjustment, or %NULL
147 * @vadjustment: (allow-none): vertical scroll adjustment, or %NULL
149 * Creates a new #GtkLayout. Unless you have a specific adjustment
150 * you'd like the layout to use for scrolling, pass %NULL for
151 * @hadjustment and @vadjustment.
153 * Return value: a new #GtkLayout
157 gtk_layout_new (GtkAdjustment *hadjustment,
158 GtkAdjustment *vadjustment)
162 layout = g_object_new (GTK_TYPE_LAYOUT,
163 "hadjustment", hadjustment,
164 "vadjustment", vadjustment,
167 return GTK_WIDGET (layout);
171 * gtk_layout_get_bin_window:
172 * @layout: a #GtkLayout
174 * Retrieve the bin window of the layout used for drawing operations.
176 * Return value: (transfer none): a #GdkWindow
181 gtk_layout_get_bin_window (GtkLayout *layout)
183 g_return_val_if_fail (GTK_IS_LAYOUT (layout), NULL);
185 return layout->priv->bin_window;
189 * gtk_layout_get_hadjustment:
190 * @layout: a #GtkLayout
192 * This function should only be called after the layout has been
193 * placed in a #GtkScrolledWindow or otherwise configured for
194 * scrolling. It returns the #GtkAdjustment used for communication
195 * between the horizontal scrollbar and @layout.
197 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
199 * Return value: (transfer none): horizontal scroll adjustment
201 * Deprecated: 3.0: Use gtk_scrollable_get_hadjustment()
204 gtk_layout_get_hadjustment (GtkLayout *layout)
206 g_return_val_if_fail (GTK_IS_LAYOUT (layout), NULL);
208 return layout->priv->hadjustment;
211 * gtk_layout_get_vadjustment:
212 * @layout: a #GtkLayout
214 * This function should only be called after the layout has been
215 * placed in a #GtkScrolledWindow or otherwise configured for
216 * scrolling. It returns the #GtkAdjustment used for communication
217 * between the vertical scrollbar and @layout.
219 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
221 * Return value: (transfer none): vertical scroll adjustment
223 * Deprecated: 3.0: Use gtk_scrollable_get_vadjustment()
226 gtk_layout_get_vadjustment (GtkLayout *layout)
228 g_return_val_if_fail (GTK_IS_LAYOUT (layout), NULL);
230 return layout->priv->vadjustment;
234 gtk_layout_set_hadjustment_values (GtkLayout *layout)
236 GtkLayoutPrivate *priv = layout->priv;
237 GtkAllocation allocation;
238 GtkAdjustment *adj = priv->hadjustment;
243 gtk_widget_get_allocation (GTK_WIDGET (layout), &allocation);
245 old_value = gtk_adjustment_get_value (adj);
246 new_upper = MAX (allocation.width, priv->width);
251 "page-size", (gdouble)allocation.width,
252 "step-increment", allocation.width * 0.1,
253 "page-increment", allocation.width * 0.9,
256 new_value = CLAMP (old_value, 0, new_upper - allocation.width);
257 if (new_value != old_value)
258 gtk_adjustment_set_value (adj, new_value);
262 gtk_layout_set_vadjustment_values (GtkLayout *layout)
264 GtkAllocation allocation;
265 GtkAdjustment *adj = layout->priv->vadjustment;
270 gtk_widget_get_allocation (GTK_WIDGET (layout), &allocation);
272 old_value = gtk_adjustment_get_value (adj);
273 new_upper = MAX (allocation.height, layout->priv->height);
278 "page-size", (gdouble)allocation.height,
279 "step-increment", allocation.height * 0.1,
280 "page-increment", allocation.height * 0.9,
283 new_value = CLAMP (old_value, 0, new_upper - allocation.height);
284 if (new_value != old_value)
285 gtk_adjustment_set_value (adj, new_value);
289 gtk_layout_finalize (GObject *object)
291 GtkLayout *layout = GTK_LAYOUT (object);
292 GtkLayoutPrivate *priv = layout->priv;
294 g_object_unref (priv->hadjustment);
295 g_object_unref (priv->vadjustment);
297 G_OBJECT_CLASS (gtk_layout_parent_class)->finalize (object);
301 * gtk_layout_set_hadjustment:
302 * @layout: a #GtkLayout
303 * @adjustment: (allow-none): new scroll adjustment
305 * Sets the horizontal scroll adjustment for the layout.
307 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
309 * Deprecated: 3.0: Use gtk_scrollable_set_hadjustment()
312 gtk_layout_set_hadjustment (GtkLayout *layout,
313 GtkAdjustment *adjustment)
315 GtkLayoutPrivate *priv;
317 g_return_if_fail (GTK_IS_LAYOUT (layout));
318 g_return_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment));
322 if (adjustment && priv->hadjustment == adjustment)
325 if (priv->hadjustment != NULL)
327 g_signal_handlers_disconnect_by_func (priv->hadjustment,
328 gtk_layout_adjustment_changed,
330 g_object_unref (priv->hadjustment);
333 if (adjustment == NULL)
334 adjustment = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
336 g_signal_connect (adjustment, "value-changed",
337 G_CALLBACK (gtk_layout_adjustment_changed), layout);
338 priv->hadjustment = g_object_ref_sink (adjustment);
339 gtk_layout_set_hadjustment_values (layout);
341 g_object_notify (G_OBJECT (layout), "hadjustment");
346 * gtk_layout_set_vadjustment:
347 * @layout: a #GtkLayout
348 * @adjustment: (allow-none): new scroll adjustment
350 * Sets the vertical scroll adjustment for the layout.
352 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
354 * Deprecated: 3.0: Use gtk_scrollable_set_vadjustment()
357 gtk_layout_set_vadjustment (GtkLayout *layout,
358 GtkAdjustment *adjustment)
360 GtkLayoutPrivate *priv;
362 g_return_if_fail (GTK_IS_LAYOUT (layout));
363 g_return_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment));
367 if (adjustment && priv->vadjustment == adjustment)
370 if (priv->vadjustment != NULL)
372 g_signal_handlers_disconnect_by_func (priv->vadjustment,
373 gtk_layout_adjustment_changed,
375 g_object_unref (priv->vadjustment);
378 if (adjustment == NULL)
379 adjustment = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
381 g_signal_connect (adjustment, "value-changed",
382 G_CALLBACK (gtk_layout_adjustment_changed), layout);
383 priv->vadjustment = g_object_ref_sink (adjustment);
384 gtk_layout_set_vadjustment_values (layout);
386 g_object_notify (G_OBJECT (layout), "vadjustment");
389 static GtkLayoutChild*
390 get_child (GtkLayout *layout,
393 GtkLayoutPrivate *priv = layout->priv;
396 children = priv->children;
399 GtkLayoutChild *child;
401 child = children->data;
402 children = children->next;
404 if (child->widget == widget)
413 * @layout: a #GtkLayout
414 * @child_widget: child widget
415 * @x: X position of child widget
416 * @y: Y position of child widget
418 * Adds @child_widget to @layout, at position (@x,@y).
419 * @layout becomes the new parent container of @child_widget.
423 gtk_layout_put (GtkLayout *layout,
424 GtkWidget *child_widget,
428 GtkLayoutPrivate *priv;
429 GtkLayoutChild *child;
431 g_return_if_fail (GTK_IS_LAYOUT (layout));
432 g_return_if_fail (GTK_IS_WIDGET (child_widget));
436 child = g_new (GtkLayoutChild, 1);
438 child->widget = child_widget;
442 priv->children = g_list_append (priv->children, child);
444 if (gtk_widget_get_realized (GTK_WIDGET (layout)))
445 gtk_widget_set_parent_window (child->widget, priv->bin_window);
447 gtk_widget_set_parent (child_widget, GTK_WIDGET (layout));
451 gtk_layout_move_internal (GtkLayout *layout,
458 GtkLayoutChild *child;
460 child = get_child (layout, widget);
464 gtk_widget_freeze_child_notify (widget);
469 gtk_widget_child_notify (widget, "x");
475 gtk_widget_child_notify (widget, "y");
478 gtk_widget_thaw_child_notify (widget);
480 if (gtk_widget_get_visible (widget) &&
481 gtk_widget_get_visible (GTK_WIDGET (layout)))
482 gtk_widget_queue_resize (widget);
487 * @layout: a #GtkLayout
488 * @child_widget: a current child of @layout
489 * @x: X position to move to
490 * @y: Y position to move to
492 * Moves a current child of @layout to a new position.
496 gtk_layout_move (GtkLayout *layout,
497 GtkWidget *child_widget,
501 g_return_if_fail (GTK_IS_LAYOUT (layout));
502 g_return_if_fail (GTK_IS_WIDGET (child_widget));
503 g_return_if_fail (gtk_widget_get_parent (child_widget) == GTK_WIDGET (layout));
505 gtk_layout_move_internal (layout, child_widget, TRUE, x, TRUE, y);
509 * gtk_layout_set_size:
510 * @layout: a #GtkLayout
511 * @width: width of entire scrollable area
512 * @height: height of entire scrollable area
514 * Sets the size of the scrollable area of the layout.
518 gtk_layout_set_size (GtkLayout *layout,
522 GtkLayoutPrivate *priv;
525 g_return_if_fail (GTK_IS_LAYOUT (layout));
528 widget = GTK_WIDGET (layout);
530 g_object_freeze_notify (G_OBJECT (layout));
531 if (width != priv->width)
534 g_object_notify (G_OBJECT (layout), "width");
536 if (height != priv->height)
538 priv->height = height;
539 g_object_notify (G_OBJECT (layout), "height");
541 g_object_thaw_notify (G_OBJECT (layout));
543 if (gtk_widget_get_realized (widget))
545 GtkAllocation allocation;
547 gtk_widget_get_allocation (widget, &allocation);
548 width = MAX (width, allocation.width);
549 height = MAX (height, allocation.height);
550 gdk_window_resize (priv->bin_window, width, height);
553 gtk_layout_set_hadjustment_values (layout);
554 gtk_layout_set_vadjustment_values (layout);
558 * gtk_layout_get_size:
559 * @layout: a #GtkLayout
560 * @width: (allow-none): location to store the width set on @layout, or %NULL
561 * @height: (allow-none): location to store the height set on @layout, or %NULL
563 * Gets the size that has been set on the layout, and that determines
564 * the total extents of the layout's scrollbar area. See
565 * gtk_layout_set_size ().
568 gtk_layout_get_size (GtkLayout *layout,
572 GtkLayoutPrivate *priv;
574 g_return_if_fail (GTK_IS_LAYOUT (layout));
579 *width = priv->width;
581 *height = priv->height;
584 /* Basic Object handling procedures
587 gtk_layout_class_init (GtkLayoutClass *class)
589 GObjectClass *gobject_class;
590 GtkWidgetClass *widget_class;
591 GtkContainerClass *container_class;
593 gobject_class = (GObjectClass*) class;
594 widget_class = (GtkWidgetClass*) class;
595 container_class = (GtkContainerClass*) class;
597 gobject_class->set_property = gtk_layout_set_property;
598 gobject_class->get_property = gtk_layout_get_property;
599 gobject_class->finalize = gtk_layout_finalize;
601 container_class->set_child_property = gtk_layout_set_child_property;
602 container_class->get_child_property = gtk_layout_get_child_property;
604 gtk_container_class_install_child_property (container_class,
606 g_param_spec_int ("x",
608 P_("X position of child widget"),
612 GTK_PARAM_READWRITE));
614 gtk_container_class_install_child_property (container_class,
616 g_param_spec_int ("y",
618 P_("Y position of child widget"),
622 GTK_PARAM_READWRITE));
624 /* Scrollable interface */
625 g_object_class_override_property (gobject_class,
628 g_object_class_override_property (gobject_class,
631 g_object_class_override_property (gobject_class,
632 PROP_MIN_DISPLAY_WIDTH,
633 "min-display-width");
634 g_object_class_override_property (gobject_class,
635 PROP_MIN_DISPLAY_HEIGHT,
636 "min-display-height");
638 g_object_class_install_property (gobject_class,
640 g_param_spec_uint ("width",
642 P_("The width of the layout"),
646 GTK_PARAM_READWRITE));
647 g_object_class_install_property (gobject_class,
649 g_param_spec_uint ("height",
651 P_("The height of the layout"),
655 GTK_PARAM_READWRITE));
656 widget_class->realize = gtk_layout_realize;
657 widget_class->unrealize = gtk_layout_unrealize;
658 widget_class->map = gtk_layout_map;
659 widget_class->size_request = gtk_layout_size_request;
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_MIN_DISPLAY_WIDTH:
689 g_value_set_int (value, priv->min_display_width);
691 case PROP_MIN_DISPLAY_HEIGHT:
692 g_value_set_int (value, priv->min_display_height);
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_MIN_DISPLAY_WIDTH:
726 priv->min_display_width = g_value_get_int (value);
728 case PROP_MIN_DISPLAY_HEIGHT:
729 priv->min_display_height = g_value_get_int (value);
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;
814 priv->min_display_width = -1;
815 priv->min_display_height = -1;
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_size_request (GtkWidget *widget,
942 GtkRequisition *requisition)
944 requisition->width = 0;
945 requisition->height = 0;
949 gtk_layout_size_allocate (GtkWidget *widget,
950 GtkAllocation *allocation)
952 GtkLayout *layout = GTK_LAYOUT (widget);
953 GtkLayoutPrivate *priv = layout->priv;
956 gtk_widget_set_allocation (widget, allocation);
958 tmp_list = priv->children;
962 GtkLayoutChild *child = tmp_list->data;
963 tmp_list = tmp_list->next;
965 gtk_layout_allocate_child (layout, child);
968 if (gtk_widget_get_realized (widget))
970 gdk_window_move_resize (gtk_widget_get_window (widget),
971 allocation->x, allocation->y,
972 allocation->width, allocation->height);
974 gdk_window_resize (priv->bin_window,
975 MAX (priv->width, allocation->width),
976 MAX (priv->height, allocation->height));
979 gtk_layout_set_hadjustment_values (layout);
980 gtk_layout_set_vadjustment_values (layout);
984 gtk_layout_draw (GtkWidget *widget,
987 GtkLayout *layout = GTK_LAYOUT (widget);
988 GtkLayoutPrivate *priv = layout->priv;
990 if (gtk_cairo_should_draw_window (cr, priv->bin_window))
991 GTK_WIDGET_CLASS (gtk_layout_parent_class)->draw (widget, cr);
999 gtk_layout_add (GtkContainer *container,
1002 gtk_layout_put (GTK_LAYOUT (container), widget, 0, 0);
1006 gtk_layout_remove (GtkContainer *container,
1009 GtkLayout *layout = GTK_LAYOUT (container);
1010 GtkLayoutPrivate *priv = layout->priv;
1012 GtkLayoutChild *child = NULL;
1014 tmp_list = priv->children;
1017 child = tmp_list->data;
1018 if (child->widget == widget)
1020 tmp_list = tmp_list->next;
1025 gtk_widget_unparent (widget);
1027 priv->children = g_list_remove_link (priv->children, tmp_list);
1028 g_list_free_1 (tmp_list);
1034 gtk_layout_forall (GtkContainer *container,
1035 gboolean include_internals,
1036 GtkCallback callback,
1037 gpointer callback_data)
1039 GtkLayout *layout = GTK_LAYOUT (container);
1040 GtkLayoutPrivate *priv = layout->priv;
1041 GtkLayoutChild *child;
1044 tmp_list = priv->children;
1047 child = tmp_list->data;
1048 tmp_list = tmp_list->next;
1050 (* callback) (child->widget, callback_data);
1054 /* Operations on children
1058 gtk_layout_allocate_child (GtkLayout *layout,
1059 GtkLayoutChild *child)
1061 GtkAllocation allocation;
1062 GtkRequisition requisition;
1064 allocation.x = child->x;
1065 allocation.y = child->y;
1067 gtk_widget_get_preferred_size (child->widget, &requisition, NULL);
1068 allocation.width = requisition.width;
1069 allocation.height = requisition.height;
1071 gtk_widget_size_allocate (child->widget, &allocation);
1077 gtk_layout_adjustment_changed (GtkAdjustment *adjustment,
1080 GtkLayoutPrivate *priv = layout->priv;
1082 if (priv->freeze_count)
1085 if (gtk_widget_get_realized (GTK_WIDGET (layout)))
1087 gdk_window_move (priv->bin_window,
1088 - priv->hadjustment->value,
1089 - priv->vadjustment->value);
1091 gdk_window_process_updates (priv->bin_window, TRUE);