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/.
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: (allow-none): horizontal scroll adjustment, or %NULL
122 * @vadjustment: (allow-none): 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: (allow-none): 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: (allow-none): 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_get_visible (widget) &&
413 gtk_widget_get_visible (GTK_WIDGET (layout)))
414 gtk_widget_queue_resize (widget);
419 * @layout: a #GtkLayout
420 * @child_widget: a current child of @layout
421 * @x: X position to move to
422 * @y: Y position to move to
424 * Moves a current child of @layout to a new position.
428 gtk_layout_move (GtkLayout *layout,
429 GtkWidget *child_widget,
433 g_return_if_fail (GTK_IS_LAYOUT (layout));
434 g_return_if_fail (GTK_IS_WIDGET (child_widget));
435 g_return_if_fail (child_widget->parent == GTK_WIDGET (layout));
437 gtk_layout_move_internal (layout, child_widget, TRUE, x, TRUE, y);
441 gtk_layout_set_adjustment_upper (GtkAdjustment *adj,
443 gboolean always_emit_changed)
445 gboolean changed = FALSE;
446 gboolean value_changed = FALSE;
448 gdouble min = MAX (0., upper - adj->page_size);
450 if (upper != adj->upper)
456 if (adj->value > min)
459 value_changed = TRUE;
462 if (changed || always_emit_changed)
463 gtk_adjustment_changed (adj);
465 gtk_adjustment_value_changed (adj);
469 * gtk_layout_set_size:
470 * @layout: a #GtkLayout
471 * @width: width of entire scrollable area
472 * @height: height of entire scrollable area
474 * Sets the size of the scrollable area of the layout.
478 gtk_layout_set_size (GtkLayout *layout,
484 g_return_if_fail (GTK_IS_LAYOUT (layout));
486 widget = GTK_WIDGET (layout);
488 g_object_freeze_notify (G_OBJECT (layout));
489 if (width != layout->width)
491 layout->width = width;
492 g_object_notify (G_OBJECT (layout), "width");
494 if (height != layout->height)
496 layout->height = height;
497 g_object_notify (G_OBJECT (layout), "height");
499 g_object_thaw_notify (G_OBJECT (layout));
501 if (layout->hadjustment)
502 gtk_layout_set_adjustment_upper (layout->hadjustment, layout->width, FALSE);
503 if (layout->vadjustment)
504 gtk_layout_set_adjustment_upper (layout->vadjustment, layout->height, FALSE);
506 if (GTK_WIDGET_REALIZED (layout))
508 width = MAX (width, widget->allocation.width);
509 height = MAX (height, widget->allocation.height);
510 gdk_window_resize (layout->bin_window, width, height);
515 * gtk_layout_get_size:
516 * @layout: a #GtkLayout
517 * @width: (allow-none): location to store the width set on @layout, or %NULL
518 * @height: (allow-none): location to store the height set on @layout, or %NULL
520 * Gets the size that has been set on the layout, and that determines
521 * the total extents of the layout's scrollbar area. See
522 * gtk_layout_set_size ().
525 gtk_layout_get_size (GtkLayout *layout,
529 g_return_if_fail (GTK_IS_LAYOUT (layout));
532 *width = layout->width;
534 *height = layout->height;
539 * @layout: a #GtkLayout
541 * This is a deprecated function, it doesn't do anything useful.
544 gtk_layout_freeze (GtkLayout *layout)
546 g_return_if_fail (GTK_IS_LAYOUT (layout));
548 layout->freeze_count++;
553 * @layout: a #GtkLayout
555 * This is a deprecated function, it doesn't do anything useful.
558 gtk_layout_thaw (GtkLayout *layout)
560 g_return_if_fail (GTK_IS_LAYOUT (layout));
562 if (layout->freeze_count)
564 if (!(--layout->freeze_count))
566 gtk_widget_queue_draw (GTK_WIDGET (layout));
567 gdk_window_process_updates (GTK_WIDGET (layout)->window, TRUE);
573 /* Basic Object handling procedures
576 gtk_layout_class_init (GtkLayoutClass *class)
578 GObjectClass *gobject_class;
579 GtkWidgetClass *widget_class;
580 GtkContainerClass *container_class;
582 gobject_class = (GObjectClass*) class;
583 widget_class = (GtkWidgetClass*) class;
584 container_class = (GtkContainerClass*) class;
586 gobject_class->set_property = gtk_layout_set_property;
587 gobject_class->get_property = gtk_layout_get_property;
588 gobject_class->finalize = gtk_layout_finalize;
589 gobject_class->constructor = gtk_layout_constructor;
591 container_class->set_child_property = gtk_layout_set_child_property;
592 container_class->get_child_property = gtk_layout_get_child_property;
594 gtk_container_class_install_child_property (container_class,
596 g_param_spec_int ("x",
598 P_("X position of child widget"),
602 GTK_PARAM_READWRITE));
604 gtk_container_class_install_child_property (container_class,
606 g_param_spec_int ("y",
608 P_("Y position of child widget"),
612 GTK_PARAM_READWRITE));
614 g_object_class_install_property (gobject_class,
616 g_param_spec_object ("hadjustment",
617 P_("Horizontal adjustment"),
618 P_("The GtkAdjustment for the horizontal position"),
620 GTK_PARAM_READWRITE));
622 g_object_class_install_property (gobject_class,
624 g_param_spec_object ("vadjustment",
625 P_("Vertical adjustment"),
626 P_("The GtkAdjustment for the vertical position"),
628 GTK_PARAM_READWRITE));
630 g_object_class_install_property (gobject_class,
632 g_param_spec_uint ("width",
634 P_("The width of the layout"),
638 GTK_PARAM_READWRITE));
639 g_object_class_install_property (gobject_class,
641 g_param_spec_uint ("height",
643 P_("The height of the layout"),
647 GTK_PARAM_READWRITE));
648 widget_class->realize = gtk_layout_realize;
649 widget_class->unrealize = gtk_layout_unrealize;
650 widget_class->map = gtk_layout_map;
651 widget_class->size_request = gtk_layout_size_request;
652 widget_class->size_allocate = gtk_layout_size_allocate;
653 widget_class->expose_event = gtk_layout_expose;
654 widget_class->style_set = gtk_layout_style_set;
656 container_class->add = gtk_layout_add;
657 container_class->remove = gtk_layout_remove;
658 container_class->forall = gtk_layout_forall;
660 class->set_scroll_adjustments = gtk_layout_set_adjustments;
663 * GtkLayout::set-scroll-adjustments
664 * @horizontal: the horizontal #GtkAdjustment
665 * @vertical: the vertical #GtkAdjustment
667 * Set the scroll adjustments for the layout. Usually scrolled containers
668 * like #GtkScrolledWindow will emit this signal to connect two instances
669 * of #GtkScrollbar to the scroll directions of the #GtkLayout.
671 widget_class->set_scroll_adjustments_signal =
672 g_signal_new (I_("set-scroll-adjustments"),
673 G_OBJECT_CLASS_TYPE (gobject_class),
674 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
675 G_STRUCT_OFFSET (GtkLayoutClass, set_scroll_adjustments),
677 _gtk_marshal_VOID__OBJECT_OBJECT,
680 GTK_TYPE_ADJUSTMENT);
684 gtk_layout_get_property (GObject *object,
689 GtkLayout *layout = GTK_LAYOUT (object);
693 case PROP_HADJUSTMENT:
694 g_value_set_object (value, layout->hadjustment);
696 case PROP_VADJUSTMENT:
697 g_value_set_object (value, layout->vadjustment);
700 g_value_set_uint (value, layout->width);
703 g_value_set_uint (value, layout->height);
706 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
712 gtk_layout_set_property (GObject *object,
717 GtkLayout *layout = GTK_LAYOUT (object);
721 case PROP_HADJUSTMENT:
722 gtk_layout_set_hadjustment (layout,
723 (GtkAdjustment*) g_value_get_object (value));
725 case PROP_VADJUSTMENT:
726 gtk_layout_set_vadjustment (layout,
727 (GtkAdjustment*) g_value_get_object (value));
730 gtk_layout_set_size (layout, g_value_get_uint (value),
734 gtk_layout_set_size (layout, layout->width,
735 g_value_get_uint (value));
738 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
744 gtk_layout_set_child_property (GtkContainer *container,
753 gtk_layout_move_internal (GTK_LAYOUT (container),
755 TRUE, g_value_get_int (value),
759 gtk_layout_move_internal (GTK_LAYOUT (container),
762 TRUE, g_value_get_int (value));
765 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
771 gtk_layout_get_child_property (GtkContainer *container,
777 GtkLayoutChild *layout_child;
779 layout_child = get_child (GTK_LAYOUT (container), child);
784 g_value_set_int (value, layout_child->x);
787 g_value_set_int (value, layout_child->y);
790 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
796 gtk_layout_init (GtkLayout *layout)
798 layout->children = NULL;
801 layout->height = 100;
803 layout->hadjustment = NULL;
804 layout->vadjustment = NULL;
806 layout->bin_window = NULL;
808 layout->scroll_x = 0;
809 layout->scroll_y = 0;
810 layout->visibility = GDK_VISIBILITY_PARTIAL;
812 layout->freeze_count = 0;
816 gtk_layout_constructor (GType type,
818 GObjectConstructParam *properties)
822 GtkAdjustment *hadj, *vadj;
824 object = G_OBJECT_CLASS (gtk_layout_parent_class)->constructor (type,
828 layout = GTK_LAYOUT (object);
830 hadj = layout->hadjustment ? layout->hadjustment : new_default_adjustment ();
831 vadj = layout->vadjustment ? layout->vadjustment : new_default_adjustment ();
833 if (!layout->hadjustment || !layout->vadjustment)
834 gtk_layout_set_adjustments (layout, hadj, vadj);
843 gtk_layout_realize (GtkWidget *widget)
845 GtkLayout *layout = GTK_LAYOUT (widget);
847 GdkWindowAttr attributes;
848 gint attributes_mask;
850 GTK_WIDGET_SET_FLAGS (layout, GTK_REALIZED);
852 attributes.window_type = GDK_WINDOW_CHILD;
853 attributes.x = widget->allocation.x;
854 attributes.y = widget->allocation.y;
855 attributes.width = widget->allocation.width;
856 attributes.height = widget->allocation.height;
857 attributes.wclass = GDK_INPUT_OUTPUT;
858 attributes.visual = gtk_widget_get_visual (widget);
859 attributes.colormap = gtk_widget_get_colormap (widget);
860 attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK;
862 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
864 widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
865 &attributes, attributes_mask);
866 gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
867 gdk_window_set_user_data (widget->window, widget);
869 attributes.x = - layout->hadjustment->value,
870 attributes.y = - layout->vadjustment->value;
871 attributes.width = MAX (layout->width, widget->allocation.width);
872 attributes.height = MAX (layout->height, widget->allocation.height);
873 attributes.event_mask = GDK_EXPOSURE_MASK | GDK_SCROLL_MASK |
874 gtk_widget_get_events (widget);
876 layout->bin_window = gdk_window_new (widget->window,
877 &attributes, attributes_mask);
878 gdk_window_set_user_data (layout->bin_window, widget);
880 widget->style = gtk_style_attach (widget->style, widget->window);
881 gtk_style_set_background (widget->style, layout->bin_window, GTK_STATE_NORMAL);
883 tmp_list = layout->children;
886 GtkLayoutChild *child = tmp_list->data;
887 tmp_list = tmp_list->next;
889 gtk_widget_set_parent_window (child->widget, layout->bin_window);
894 gtk_layout_style_set (GtkWidget *widget,
897 GTK_WIDGET_CLASS (gtk_layout_parent_class)->style_set (widget, old_style);
899 if (GTK_WIDGET_REALIZED (widget))
901 gtk_style_set_background (widget->style, GTK_LAYOUT (widget)->bin_window, GTK_STATE_NORMAL);
906 gtk_layout_map (GtkWidget *widget)
908 GtkLayout *layout = GTK_LAYOUT (widget);
911 GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
913 tmp_list = layout->children;
916 GtkLayoutChild *child = tmp_list->data;
917 tmp_list = tmp_list->next;
919 if (gtk_widget_get_visible (child->widget))
921 if (!GTK_WIDGET_MAPPED (child->widget))
922 gtk_widget_map (child->widget);
926 gdk_window_show (layout->bin_window);
927 gdk_window_show (widget->window);
931 gtk_layout_unrealize (GtkWidget *widget)
933 GtkLayout *layout = GTK_LAYOUT (widget);
935 gdk_window_set_user_data (layout->bin_window, NULL);
936 gdk_window_destroy (layout->bin_window);
937 layout->bin_window = NULL;
939 GTK_WIDGET_CLASS (gtk_layout_parent_class)->unrealize (widget);
943 gtk_layout_size_request (GtkWidget *widget,
944 GtkRequisition *requisition)
946 GtkLayout *layout = GTK_LAYOUT (widget);
949 requisition->width = 0;
950 requisition->height = 0;
952 tmp_list = layout->children;
956 GtkLayoutChild *child = tmp_list->data;
957 GtkRequisition child_requisition;
959 tmp_list = tmp_list->next;
961 gtk_widget_size_request (child->widget, &child_requisition);
966 gtk_layout_size_allocate (GtkWidget *widget,
967 GtkAllocation *allocation)
969 GtkLayout *layout = GTK_LAYOUT (widget);
972 widget->allocation = *allocation;
974 tmp_list = layout->children;
978 GtkLayoutChild *child = tmp_list->data;
979 tmp_list = tmp_list->next;
981 gtk_layout_allocate_child (layout, child);
984 if (GTK_WIDGET_REALIZED (widget))
986 gdk_window_move_resize (widget->window,
987 allocation->x, allocation->y,
988 allocation->width, allocation->height);
990 gdk_window_resize (layout->bin_window,
991 MAX (layout->width, allocation->width),
992 MAX (layout->height, allocation->height));
995 layout->hadjustment->page_size = allocation->width;
996 layout->hadjustment->page_increment = allocation->width * 0.9;
997 layout->hadjustment->lower = 0;
998 /* set_adjustment_upper() emits ::changed */
999 gtk_layout_set_adjustment_upper (layout->hadjustment, MAX (allocation->width, layout->width), TRUE);
1001 layout->vadjustment->page_size = allocation->height;
1002 layout->vadjustment->page_increment = allocation->height * 0.9;
1003 layout->vadjustment->lower = 0;
1004 layout->vadjustment->upper = MAX (allocation->height, layout->height);
1005 gtk_layout_set_adjustment_upper (layout->vadjustment, MAX (allocation->height, layout->height), TRUE);
1009 gtk_layout_expose (GtkWidget *widget,
1010 GdkEventExpose *event)
1012 GtkLayout *layout = GTK_LAYOUT (widget);
1014 if (event->window != layout->bin_window)
1017 GTK_WIDGET_CLASS (gtk_layout_parent_class)->expose_event (widget, event);
1022 /* Container methods
1025 gtk_layout_add (GtkContainer *container,
1028 gtk_layout_put (GTK_LAYOUT (container), widget, 0, 0);
1032 gtk_layout_remove (GtkContainer *container,
1035 GtkLayout *layout = GTK_LAYOUT (container);
1037 GtkLayoutChild *child = NULL;
1039 tmp_list = layout->children;
1042 child = tmp_list->data;
1043 if (child->widget == widget)
1045 tmp_list = tmp_list->next;
1050 gtk_widget_unparent (widget);
1052 layout->children = g_list_remove_link (layout->children, tmp_list);
1053 g_list_free_1 (tmp_list);
1059 gtk_layout_forall (GtkContainer *container,
1060 gboolean include_internals,
1061 GtkCallback callback,
1062 gpointer callback_data)
1064 GtkLayout *layout = GTK_LAYOUT (container);
1065 GtkLayoutChild *child;
1068 tmp_list = layout->children;
1071 child = tmp_list->data;
1072 tmp_list = tmp_list->next;
1074 (* callback) (child->widget, callback_data);
1078 /* Operations on children
1082 gtk_layout_allocate_child (GtkLayout *layout,
1083 GtkLayoutChild *child)
1085 GtkAllocation allocation;
1086 GtkRequisition requisition;
1088 allocation.x = child->x;
1089 allocation.y = child->y;
1090 gtk_widget_get_child_requisition (child->widget, &requisition);
1091 allocation.width = requisition.width;
1092 allocation.height = requisition.height;
1094 gtk_widget_size_allocate (child->widget, &allocation);
1100 gtk_layout_adjustment_changed (GtkAdjustment *adjustment,
1103 if (layout->freeze_count)
1106 if (GTK_WIDGET_REALIZED (layout))
1108 gdk_window_move (layout->bin_window,
1109 - layout->hadjustment->value,
1110 - layout->vadjustment->value);
1112 gdk_window_process_updates (layout->bin_window, TRUE);
1116 #define __GTK_LAYOUT_C__
1117 #include "gtkaliasdef.c"