1 /* GTK - The GTK+ 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/.
32 #include "gdkconfig.h"
34 #include "gtklayout.h"
35 #include "gtkprivate.h"
37 #include "gtkmarshalers.h"
40 typedef struct _GtkLayoutChild GtkLayoutChild;
42 struct _GtkLayoutChild {
62 static void gtk_layout_get_property (GObject *object,
66 static void gtk_layout_set_property (GObject *object,
70 static GObject *gtk_layout_constructor (GType type,
72 GObjectConstructParam *properties);
73 static void gtk_layout_finalize (GObject *object);
74 static void gtk_layout_realize (GtkWidget *widget);
75 static void gtk_layout_unrealize (GtkWidget *widget);
76 static void gtk_layout_map (GtkWidget *widget);
77 static void gtk_layout_size_request (GtkWidget *widget,
78 GtkRequisition *requisition);
79 static void gtk_layout_size_allocate (GtkWidget *widget,
80 GtkAllocation *allocation);
81 static gint gtk_layout_expose (GtkWidget *widget,
82 GdkEventExpose *event);
83 static void gtk_layout_add (GtkContainer *container,
85 static void gtk_layout_remove (GtkContainer *container,
87 static void gtk_layout_forall (GtkContainer *container,
88 gboolean include_internals,
90 gpointer callback_data);
91 static void gtk_layout_set_adjustments (GtkLayout *layout,
94 static void gtk_layout_set_child_property (GtkContainer *container,
99 static void gtk_layout_get_child_property (GtkContainer *container,
104 static void gtk_layout_allocate_child (GtkLayout *layout,
105 GtkLayoutChild *child);
106 static void gtk_layout_adjustment_changed (GtkAdjustment *adjustment,
108 static void gtk_layout_style_set (GtkWidget *widget,
109 GtkStyle *old_style);
111 static void gtk_layout_set_adjustment_upper (GtkAdjustment *adj,
113 gboolean always_emit_changed);
115 G_DEFINE_TYPE (GtkLayout, gtk_layout, GTK_TYPE_CONTAINER)
121 * @hadjustment: horizontal scroll adjustment, or %NULL
122 * @vadjustment: vertical scroll adjustment, or %NULL
124 * Creates a new #GtkLayout. Unless you have a specific adjustment
125 * you'd like the layout to use for scrolling, pass %NULL for
126 * @hadjustment and @vadjustment.
128 * Return value: a new #GtkLayout
132 gtk_layout_new (GtkAdjustment *hadjustment,
133 GtkAdjustment *vadjustment)
137 layout = g_object_new (GTK_TYPE_LAYOUT,
138 "hadjustment", hadjustment,
139 "vadjustment", vadjustment,
142 return GTK_WIDGET (layout);
146 * gtk_layout_get_bin_window:
147 * @layout: a #GtkLayout
149 * Retrieve the bin window of the layout used for drawing operations.
151 * Return value: a #GdkWindow
156 gtk_layout_get_bin_window (GtkLayout *layout)
158 g_return_val_if_fail (GTK_IS_LAYOUT (layout), NULL);
160 return layout->bin_window;
164 * gtk_layout_get_hadjustment:
165 * @layout: a #GtkLayout
167 * This function should only be called after the layout has been
168 * placed in a #GtkScrolledWindow or otherwise configured for
169 * scrolling. It returns the #GtkAdjustment used for communication
170 * between the horizontal scrollbar and @layout.
172 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
174 * Return value: horizontal scroll adjustment
177 gtk_layout_get_hadjustment (GtkLayout *layout)
179 g_return_val_if_fail (GTK_IS_LAYOUT (layout), NULL);
181 return layout->hadjustment;
184 * gtk_layout_get_vadjustment:
185 * @layout: a #GtkLayout
187 * This function should only be called after the layout has been
188 * placed in a #GtkScrolledWindow or otherwise configured for
189 * scrolling. It returns the #GtkAdjustment used for communication
190 * between the vertical scrollbar and @layout.
192 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
194 * Return value: vertical scroll adjustment
197 gtk_layout_get_vadjustment (GtkLayout *layout)
199 g_return_val_if_fail (GTK_IS_LAYOUT (layout), NULL);
201 return layout->vadjustment;
204 static GtkAdjustment *
205 new_default_adjustment (void)
207 return GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
211 gtk_layout_set_adjustments (GtkLayout *layout,
215 gboolean need_adjust = FALSE;
217 g_return_if_fail (GTK_IS_LAYOUT (layout));
220 g_return_if_fail (GTK_IS_ADJUSTMENT (hadj));
221 else if (layout->hadjustment)
222 hadj = new_default_adjustment ();
224 g_return_if_fail (GTK_IS_ADJUSTMENT (vadj));
225 else if (layout->vadjustment)
226 vadj = new_default_adjustment ();
228 if (layout->hadjustment && (layout->hadjustment != hadj))
230 g_signal_handlers_disconnect_by_func (layout->hadjustment,
231 gtk_layout_adjustment_changed,
233 g_object_unref (layout->hadjustment);
236 if (layout->vadjustment && (layout->vadjustment != vadj))
238 g_signal_handlers_disconnect_by_func (layout->vadjustment,
239 gtk_layout_adjustment_changed,
241 g_object_unref (layout->vadjustment);
244 if (layout->hadjustment != hadj)
246 layout->hadjustment = hadj;
247 g_object_ref_sink (layout->hadjustment);
248 gtk_layout_set_adjustment_upper (layout->hadjustment, layout->width, FALSE);
250 g_signal_connect (layout->hadjustment, "value_changed",
251 G_CALLBACK (gtk_layout_adjustment_changed),
256 if (layout->vadjustment != vadj)
258 layout->vadjustment = vadj;
259 g_object_ref_sink (layout->vadjustment);
260 gtk_layout_set_adjustment_upper (layout->vadjustment, layout->height, FALSE);
262 g_signal_connect (layout->vadjustment, "value_changed",
263 G_CALLBACK (gtk_layout_adjustment_changed),
268 /* vadj or hadj can be NULL while constructing; don't emit a signal
270 if (need_adjust && vadj && hadj)
271 gtk_layout_adjustment_changed (NULL, layout);
275 gtk_layout_finalize (GObject *object)
277 GtkLayout *layout = GTK_LAYOUT (object);
279 g_object_unref (layout->hadjustment);
280 g_object_unref (layout->vadjustment);
282 G_OBJECT_CLASS (gtk_layout_parent_class)->finalize (object);
286 * gtk_layout_set_hadjustment:
287 * @layout: a #GtkLayout
288 * @adjustment: new scroll adjustment
290 * Sets the horizontal scroll adjustment for the layout.
292 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
296 gtk_layout_set_hadjustment (GtkLayout *layout,
297 GtkAdjustment *adjustment)
299 g_return_if_fail (GTK_IS_LAYOUT (layout));
301 gtk_layout_set_adjustments (layout, adjustment, layout->vadjustment);
302 g_object_notify (G_OBJECT (layout), "hadjustment");
306 * gtk_layout_set_vadjustment:
307 * @layout: a #GtkLayout
308 * @adjustment: new scroll adjustment
310 * Sets the vertical scroll adjustment for the layout.
312 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
316 gtk_layout_set_vadjustment (GtkLayout *layout,
317 GtkAdjustment *adjustment)
319 g_return_if_fail (GTK_IS_LAYOUT (layout));
321 gtk_layout_set_adjustments (layout, layout->hadjustment, adjustment);
322 g_object_notify (G_OBJECT (layout), "vadjustment");
325 static GtkLayoutChild*
326 get_child (GtkLayout *layout,
331 children = layout->children;
334 GtkLayoutChild *child;
336 child = children->data;
337 children = children->next;
339 if (child->widget == widget)
348 * @layout: a #GtkLayout
349 * @child_widget: child widget
350 * @x: X position of child widget
351 * @y: Y position of child widget
353 * Adds @child_widget to @layout, at position (@x,@y).
354 * @layout becomes the new parent container of @child_widget.
358 gtk_layout_put (GtkLayout *layout,
359 GtkWidget *child_widget,
363 GtkLayoutChild *child;
365 g_return_if_fail (GTK_IS_LAYOUT (layout));
366 g_return_if_fail (GTK_IS_WIDGET (child_widget));
368 child = g_new (GtkLayoutChild, 1);
370 child->widget = child_widget;
374 layout->children = g_list_append (layout->children, child);
376 if (GTK_WIDGET_REALIZED (layout))
377 gtk_widget_set_parent_window (child->widget, layout->bin_window);
379 gtk_widget_set_parent (child_widget, GTK_WIDGET (layout));
383 gtk_layout_move_internal (GtkLayout *layout,
390 GtkLayoutChild *child;
392 child = get_child (layout, widget);
396 gtk_widget_freeze_child_notify (widget);
401 gtk_widget_child_notify (widget, "x");
407 gtk_widget_child_notify (widget, "y");
410 gtk_widget_thaw_child_notify (widget);
412 if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (layout))
413 gtk_widget_queue_resize (GTK_WIDGET (widget));
418 * @layout: a #GtkLayout
419 * @child_widget: a current child of @layout
420 * @x: X position to move to
421 * @y: Y position to move to
423 * Moves a current child of @layout to a new position.
427 gtk_layout_move (GtkLayout *layout,
428 GtkWidget *child_widget,
432 g_return_if_fail (GTK_IS_LAYOUT (layout));
433 g_return_if_fail (GTK_IS_WIDGET (child_widget));
434 g_return_if_fail (child_widget->parent == GTK_WIDGET (layout));
436 gtk_layout_move_internal (layout, child_widget, TRUE, x, TRUE, y);
440 gtk_layout_set_adjustment_upper (GtkAdjustment *adj,
442 gboolean always_emit_changed)
444 gboolean changed = FALSE;
445 gboolean value_changed = FALSE;
447 gdouble min = MAX (0., upper - adj->page_size);
449 if (upper != adj->upper)
455 if (adj->value > min)
458 value_changed = TRUE;
461 if (changed || always_emit_changed)
462 gtk_adjustment_changed (adj);
464 gtk_adjustment_value_changed (adj);
468 * gtk_layout_set_size:
469 * @layout: a #GtkLayout
470 * @width: width of entire scrollable area
471 * @height: height of entire scrollable area
473 * Sets the size of the scrollable area of the layout.
477 gtk_layout_set_size (GtkLayout *layout,
483 g_return_if_fail (GTK_IS_LAYOUT (layout));
485 widget = GTK_WIDGET (layout);
487 g_object_freeze_notify (G_OBJECT (layout));
488 if (width != layout->width)
490 layout->width = width;
491 g_object_notify (G_OBJECT (layout), "width");
493 if (height != layout->height)
495 layout->height = height;
496 g_object_notify (G_OBJECT (layout), "height");
498 g_object_thaw_notify (G_OBJECT (layout));
500 if (layout->hadjustment)
501 gtk_layout_set_adjustment_upper (layout->hadjustment, layout->width, FALSE);
502 if (layout->vadjustment)
503 gtk_layout_set_adjustment_upper (layout->vadjustment, layout->height, FALSE);
505 if (GTK_WIDGET_REALIZED (layout))
507 width = MAX (width, widget->allocation.width);
508 height = MAX (height, widget->allocation.height);
509 gdk_window_resize (layout->bin_window, width, height);
514 * gtk_layout_get_size:
515 * @layout: a #GtkLayout
516 * @width: location to store the width set on @layout, or %NULL
517 * @height: location to store the height set on @layout, or %NULL
519 * Gets the size that has been set on the layout, and that determines
520 * the total extents of the layout's scrollbar area. See
521 * gtk_layout_set_size ().
524 gtk_layout_get_size (GtkLayout *layout,
528 g_return_if_fail (GTK_IS_LAYOUT (layout));
531 *width = layout->width;
533 *height = layout->height;
538 * @layout: a #GtkLayout
540 * This is a deprecated function, it doesn't do anything useful.
543 gtk_layout_freeze (GtkLayout *layout)
545 g_return_if_fail (GTK_IS_LAYOUT (layout));
547 layout->freeze_count++;
552 * @layout: a #GtkLayout
554 * This is a deprecated function, it doesn't do anything useful.
557 gtk_layout_thaw (GtkLayout *layout)
559 g_return_if_fail (GTK_IS_LAYOUT (layout));
561 if (layout->freeze_count)
563 if (!(--layout->freeze_count))
565 gtk_widget_queue_draw (GTK_WIDGET (layout));
566 gdk_window_process_updates (GTK_WIDGET (layout)->window, TRUE);
572 /* Basic Object handling procedures
575 gtk_layout_class_init (GtkLayoutClass *class)
577 GObjectClass *gobject_class;
578 GtkWidgetClass *widget_class;
579 GtkContainerClass *container_class;
581 gobject_class = (GObjectClass*) class;
582 widget_class = (GtkWidgetClass*) class;
583 container_class = (GtkContainerClass*) class;
585 gobject_class->set_property = gtk_layout_set_property;
586 gobject_class->get_property = gtk_layout_get_property;
587 gobject_class->finalize = gtk_layout_finalize;
588 gobject_class->constructor = gtk_layout_constructor;
590 container_class->set_child_property = gtk_layout_set_child_property;
591 container_class->get_child_property = gtk_layout_get_child_property;
593 gtk_container_class_install_child_property (container_class,
595 g_param_spec_int ("x",
597 P_("X position of child widget"),
601 GTK_PARAM_READWRITE));
603 gtk_container_class_install_child_property (container_class,
605 g_param_spec_int ("y",
607 P_("Y position of child widget"),
611 GTK_PARAM_READWRITE));
613 g_object_class_install_property (gobject_class,
615 g_param_spec_object ("hadjustment",
616 P_("Horizontal adjustment"),
617 P_("The GtkAdjustment for the horizontal position"),
619 GTK_PARAM_READWRITE));
621 g_object_class_install_property (gobject_class,
623 g_param_spec_object ("vadjustment",
624 P_("Vertical adjustment"),
625 P_("The GtkAdjustment for the vertical position"),
627 GTK_PARAM_READWRITE));
629 g_object_class_install_property (gobject_class,
631 g_param_spec_uint ("width",
633 P_("The width of the layout"),
637 GTK_PARAM_READWRITE));
638 g_object_class_install_property (gobject_class,
640 g_param_spec_uint ("height",
642 P_("The height of the layout"),
646 GTK_PARAM_READWRITE));
647 widget_class->realize = gtk_layout_realize;
648 widget_class->unrealize = gtk_layout_unrealize;
649 widget_class->map = gtk_layout_map;
650 widget_class->size_request = gtk_layout_size_request;
651 widget_class->size_allocate = gtk_layout_size_allocate;
652 widget_class->expose_event = gtk_layout_expose;
653 widget_class->style_set = gtk_layout_style_set;
655 container_class->add = gtk_layout_add;
656 container_class->remove = gtk_layout_remove;
657 container_class->forall = gtk_layout_forall;
659 class->set_scroll_adjustments = gtk_layout_set_adjustments;
661 widget_class->set_scroll_adjustments_signal =
662 g_signal_new (I_("set_scroll_adjustments"),
663 G_OBJECT_CLASS_TYPE (gobject_class),
664 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
665 G_STRUCT_OFFSET (GtkLayoutClass, set_scroll_adjustments),
667 _gtk_marshal_VOID__OBJECT_OBJECT,
670 GTK_TYPE_ADJUSTMENT);
674 gtk_layout_get_property (GObject *object,
679 GtkLayout *layout = GTK_LAYOUT (object);
683 case PROP_HADJUSTMENT:
684 g_value_set_object (value, layout->hadjustment);
686 case PROP_VADJUSTMENT:
687 g_value_set_object (value, layout->vadjustment);
690 g_value_set_uint (value, layout->width);
693 g_value_set_uint (value, layout->height);
696 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
702 gtk_layout_set_property (GObject *object,
707 GtkLayout *layout = GTK_LAYOUT (object);
711 case PROP_HADJUSTMENT:
712 gtk_layout_set_hadjustment (layout,
713 (GtkAdjustment*) g_value_get_object (value));
715 case PROP_VADJUSTMENT:
716 gtk_layout_set_vadjustment (layout,
717 (GtkAdjustment*) g_value_get_object (value));
720 gtk_layout_set_size (layout, g_value_get_uint (value),
724 gtk_layout_set_size (layout, layout->width,
725 g_value_get_uint (value));
728 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
734 gtk_layout_set_child_property (GtkContainer *container,
743 gtk_layout_move_internal (GTK_LAYOUT (container),
745 TRUE, g_value_get_int (value),
749 gtk_layout_move_internal (GTK_LAYOUT (container),
752 TRUE, g_value_get_int (value));
755 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
761 gtk_layout_get_child_property (GtkContainer *container,
767 GtkLayoutChild *layout_child;
769 layout_child = get_child (GTK_LAYOUT (container), child);
774 g_value_set_int (value, layout_child->x);
777 g_value_set_int (value, layout_child->y);
780 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
786 gtk_layout_init (GtkLayout *layout)
788 layout->children = NULL;
791 layout->height = 100;
793 layout->hadjustment = NULL;
794 layout->vadjustment = NULL;
796 layout->bin_window = NULL;
798 layout->scroll_x = 0;
799 layout->scroll_y = 0;
800 layout->visibility = GDK_VISIBILITY_PARTIAL;
802 layout->freeze_count = 0;
806 gtk_layout_constructor (GType type,
808 GObjectConstructParam *properties)
812 GtkAdjustment *hadj, *vadj;
814 object = G_OBJECT_CLASS (gtk_layout_parent_class)->constructor (type,
818 layout = GTK_LAYOUT (object);
820 hadj = layout->hadjustment ? layout->hadjustment : new_default_adjustment ();
821 vadj = layout->vadjustment ? layout->vadjustment : new_default_adjustment ();
823 if (!layout->hadjustment || !layout->vadjustment)
824 gtk_layout_set_adjustments (layout, hadj, vadj);
833 gtk_layout_realize (GtkWidget *widget)
835 GtkLayout *layout = GTK_LAYOUT (widget);
837 GdkWindowAttr attributes;
838 gint attributes_mask;
840 GTK_WIDGET_SET_FLAGS (layout, GTK_REALIZED);
842 attributes.window_type = GDK_WINDOW_CHILD;
843 attributes.x = widget->allocation.x;
844 attributes.y = widget->allocation.y;
845 attributes.width = widget->allocation.width;
846 attributes.height = widget->allocation.height;
847 attributes.wclass = GDK_INPUT_OUTPUT;
848 attributes.visual = gtk_widget_get_visual (widget);
849 attributes.colormap = gtk_widget_get_colormap (widget);
850 attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK;
852 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
854 widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
855 &attributes, attributes_mask);
856 gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
857 gdk_window_set_user_data (widget->window, widget);
859 attributes.x = - layout->hadjustment->value,
860 attributes.y = - layout->vadjustment->value;
861 attributes.width = MAX (layout->width, widget->allocation.width);
862 attributes.height = MAX (layout->height, widget->allocation.height);
863 attributes.event_mask = GDK_EXPOSURE_MASK | GDK_SCROLL_MASK |
864 gtk_widget_get_events (widget);
866 layout->bin_window = gdk_window_new (widget->window,
867 &attributes, attributes_mask);
868 gdk_window_set_user_data (layout->bin_window, widget);
870 widget->style = gtk_style_attach (widget->style, widget->window);
871 gtk_style_set_background (widget->style, layout->bin_window, GTK_STATE_NORMAL);
873 tmp_list = layout->children;
876 GtkLayoutChild *child = tmp_list->data;
877 tmp_list = tmp_list->next;
879 gtk_widget_set_parent_window (child->widget, layout->bin_window);
884 gtk_layout_style_set (GtkWidget *widget, GtkStyle *old_style)
886 if (GTK_WIDGET_CLASS (gtk_layout_parent_class)->style_set)
887 (* GTK_WIDGET_CLASS (gtk_layout_parent_class)->style_set) (widget, old_style);
889 if (GTK_WIDGET_REALIZED (widget))
891 gtk_style_set_background (widget->style, GTK_LAYOUT (widget)->bin_window, GTK_STATE_NORMAL);
896 gtk_layout_map (GtkWidget *widget)
898 GtkLayout *layout = GTK_LAYOUT (widget);
901 GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
903 tmp_list = layout->children;
906 GtkLayoutChild *child = tmp_list->data;
907 tmp_list = tmp_list->next;
909 if (GTK_WIDGET_VISIBLE (child->widget))
911 if (!GTK_WIDGET_MAPPED (child->widget))
912 gtk_widget_map (child->widget);
916 gdk_window_show (layout->bin_window);
917 gdk_window_show (widget->window);
921 gtk_layout_unrealize (GtkWidget *widget)
923 GtkLayout *layout = GTK_LAYOUT (widget);
925 gdk_window_set_user_data (layout->bin_window, NULL);
926 gdk_window_destroy (layout->bin_window);
927 layout->bin_window = NULL;
929 if (GTK_WIDGET_CLASS (gtk_layout_parent_class)->unrealize)
930 (* GTK_WIDGET_CLASS (gtk_layout_parent_class)->unrealize) (widget);
934 gtk_layout_size_request (GtkWidget *widget,
935 GtkRequisition *requisition)
937 GtkLayout *layout = GTK_LAYOUT (widget);
940 requisition->width = 0;
941 requisition->height = 0;
943 tmp_list = layout->children;
947 GtkLayoutChild *child = tmp_list->data;
948 GtkRequisition child_requisition;
950 tmp_list = tmp_list->next;
952 gtk_widget_size_request (child->widget, &child_requisition);
957 gtk_layout_size_allocate (GtkWidget *widget,
958 GtkAllocation *allocation)
960 GtkLayout *layout = GTK_LAYOUT (widget);
963 widget->allocation = *allocation;
965 tmp_list = layout->children;
969 GtkLayoutChild *child = tmp_list->data;
970 tmp_list = tmp_list->next;
972 gtk_layout_allocate_child (layout, child);
975 if (GTK_WIDGET_REALIZED (widget))
977 gdk_window_move_resize (widget->window,
978 allocation->x, allocation->y,
979 allocation->width, allocation->height);
981 gdk_window_resize (layout->bin_window,
982 MAX (layout->width, allocation->width),
983 MAX (layout->height, allocation->height));
986 layout->hadjustment->page_size = allocation->width;
987 layout->hadjustment->page_increment = allocation->width * 0.9;
988 layout->hadjustment->lower = 0;
989 /* set_adjustment_upper() emits ::changed */
990 gtk_layout_set_adjustment_upper (layout->hadjustment, MAX (allocation->width, layout->width), TRUE);
992 layout->vadjustment->page_size = allocation->height;
993 layout->vadjustment->page_increment = allocation->height * 0.9;
994 layout->vadjustment->lower = 0;
995 layout->vadjustment->upper = MAX (allocation->height, layout->height);
996 gtk_layout_set_adjustment_upper (layout->vadjustment, MAX (allocation->height, layout->height), TRUE);
1000 gtk_layout_expose (GtkWidget *widget,
1001 GdkEventExpose *event)
1003 GtkLayout *layout = GTK_LAYOUT (widget);
1005 if (event->window != layout->bin_window)
1008 (* GTK_WIDGET_CLASS (gtk_layout_parent_class)->expose_event) (widget, event);
1013 /* Container methods
1016 gtk_layout_add (GtkContainer *container,
1019 gtk_layout_put (GTK_LAYOUT (container), widget, 0, 0);
1023 gtk_layout_remove (GtkContainer *container,
1026 GtkLayout *layout = GTK_LAYOUT (container);
1028 GtkLayoutChild *child = NULL;
1030 tmp_list = layout->children;
1033 child = tmp_list->data;
1034 if (child->widget == widget)
1036 tmp_list = tmp_list->next;
1041 gtk_widget_unparent (widget);
1043 layout->children = g_list_remove_link (layout->children, tmp_list);
1044 g_list_free_1 (tmp_list);
1050 gtk_layout_forall (GtkContainer *container,
1051 gboolean include_internals,
1052 GtkCallback callback,
1053 gpointer callback_data)
1055 GtkLayout *layout = GTK_LAYOUT (container);
1056 GtkLayoutChild *child;
1059 tmp_list = layout->children;
1062 child = tmp_list->data;
1063 tmp_list = tmp_list->next;
1065 (* callback) (child->widget, callback_data);
1069 /* Operations on children
1073 gtk_layout_allocate_child (GtkLayout *layout,
1074 GtkLayoutChild *child)
1076 GtkAllocation allocation;
1077 GtkRequisition requisition;
1079 allocation.x = child->x;
1080 allocation.y = child->y;
1081 gtk_widget_get_child_requisition (child->widget, &requisition);
1082 allocation.width = requisition.width;
1083 allocation.height = requisition.height;
1085 gtk_widget_size_allocate (child->widget, &allocation);
1091 gtk_layout_adjustment_changed (GtkAdjustment *adjustment,
1094 if (layout->freeze_count)
1097 if (GTK_WIDGET_REALIZED (layout))
1099 gdk_window_move (layout->bin_window,
1100 - layout->hadjustment->value,
1101 - layout->vadjustment->value);
1103 gdk_window_process_updates (layout->bin_window, TRUE);
1107 #define __GTK_LAYOUT_C__
1108 #include "gtkaliasdef.c"