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.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
27 #include "gtkviewport.h"
29 #include "gtkmarshalers.h"
39 static void gtk_viewport_class_init (GtkViewportClass *klass);
40 static void gtk_viewport_init (GtkViewport *viewport);
41 static void gtk_viewport_destroy (GtkObject *object);
42 static void gtk_viewport_set_property (GObject *object,
46 static void gtk_viewport_get_property (GObject *object,
50 static void gtk_viewport_set_scroll_adjustments (GtkViewport *viewport,
51 GtkAdjustment *hadjustment,
52 GtkAdjustment *vadjustment);
53 static void gtk_viewport_realize (GtkWidget *widget);
54 static void gtk_viewport_unrealize (GtkWidget *widget);
55 static void gtk_viewport_paint (GtkWidget *widget,
57 static gint gtk_viewport_expose (GtkWidget *widget,
58 GdkEventExpose *event);
59 static void gtk_viewport_add (GtkContainer *container,
61 static void gtk_viewport_size_request (GtkWidget *widget,
62 GtkRequisition *requisition);
63 static void gtk_viewport_size_allocate (GtkWidget *widget,
64 GtkAllocation *allocation);
65 static void gtk_viewport_adjustment_changed (GtkAdjustment *adjustment,
67 static void gtk_viewport_adjustment_value_changed (GtkAdjustment *adjustment,
69 static void gtk_viewport_style_set (GtkWidget *widget,
70 GtkStyle *previous_style);
72 static GtkBinClass *parent_class;
75 gtk_viewport_get_type (void)
77 static GType viewport_type = 0;
81 static const GTypeInfo viewport_info =
83 sizeof (GtkViewportClass),
85 NULL, /* base_finalize */
86 (GClassInitFunc) gtk_viewport_class_init,
87 NULL, /* class_finalize */
88 NULL, /* class_data */
91 (GInstanceInitFunc) gtk_viewport_init,
94 viewport_type = g_type_register_static (GTK_TYPE_BIN, "GtkViewport",
102 gtk_viewport_class_init (GtkViewportClass *class)
104 GtkObjectClass *object_class;
105 GObjectClass *gobject_class;
106 GtkWidgetClass *widget_class;
107 GtkContainerClass *container_class;
109 object_class = (GtkObjectClass*) class;
110 gobject_class = G_OBJECT_CLASS (class);
111 widget_class = (GtkWidgetClass*) class;
112 container_class = (GtkContainerClass*) class;
114 parent_class = g_type_class_peek_parent (class);
116 gobject_class->set_property = gtk_viewport_set_property;
117 gobject_class->get_property = gtk_viewport_get_property;
118 object_class->destroy = gtk_viewport_destroy;
120 widget_class->realize = gtk_viewport_realize;
121 widget_class->unrealize = gtk_viewport_unrealize;
122 widget_class->expose_event = gtk_viewport_expose;
123 widget_class->size_request = gtk_viewport_size_request;
124 widget_class->size_allocate = gtk_viewport_size_allocate;
125 widget_class->style_set = gtk_viewport_style_set;
127 container_class->add = gtk_viewport_add;
129 class->set_scroll_adjustments = gtk_viewport_set_scroll_adjustments;
131 g_object_class_install_property (gobject_class,
133 g_param_spec_object ("hadjustment",
134 _("Horizontal adjustment"),
135 _("The GtkAdjustment that determines the values of the horizontal position for this viewport"),
139 g_object_class_install_property (gobject_class,
141 g_param_spec_object ("vadjustment",
142 _("Vertical adjustment"),
143 _("The GtkAdjustment that determines the values of the vertical position for this viewport"),
147 g_object_class_install_property (gobject_class,
149 g_param_spec_enum ("shadow_type",
151 _("Determines how the shadowed box around the viewport is drawn"),
152 GTK_TYPE_SHADOW_TYPE,
156 widget_class->set_scroll_adjustments_signal =
157 g_signal_new ("set_scroll_adjustments",
158 G_OBJECT_CLASS_TYPE (gobject_class),
159 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
160 G_STRUCT_OFFSET (GtkViewportClass, set_scroll_adjustments),
162 _gtk_marshal_VOID__OBJECT_OBJECT,
165 GTK_TYPE_ADJUSTMENT);
169 gtk_viewport_set_property (GObject *object,
174 GtkViewport *viewport;
176 viewport = GTK_VIEWPORT (object);
180 case PROP_HADJUSTMENT:
181 gtk_viewport_set_hadjustment (viewport, g_value_get_object (value));
183 case PROP_VADJUSTMENT:
184 gtk_viewport_set_vadjustment (viewport, g_value_get_object (value));
186 case PROP_SHADOW_TYPE:
187 gtk_viewport_set_shadow_type (viewport, g_value_get_enum (value));
190 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
196 gtk_viewport_get_property (GObject *object,
201 GtkViewport *viewport;
203 viewport = GTK_VIEWPORT (object);
207 case PROP_HADJUSTMENT:
208 g_value_set_object (value, viewport->hadjustment);
210 case PROP_VADJUSTMENT:
211 g_value_set_object (value, viewport->vadjustment);
213 case PROP_SHADOW_TYPE:
214 g_value_set_enum (value, viewport->shadow_type);
217 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
223 gtk_viewport_init (GtkViewport *viewport)
225 GTK_WIDGET_UNSET_FLAGS (viewport, GTK_NO_WINDOW);
227 gtk_widget_set_redraw_on_allocate (GTK_WIDGET (viewport), FALSE);
228 gtk_container_set_resize_mode (GTK_CONTAINER (viewport), GTK_RESIZE_QUEUE);
230 viewport->shadow_type = GTK_SHADOW_IN;
231 viewport->view_window = NULL;
232 viewport->bin_window = NULL;
233 viewport->hadjustment = NULL;
234 viewport->vadjustment = NULL;
239 * @hadjustment: horizontal adjustment.
240 * @vadjustment: vertical adjustment.
241 * @returns: a new #GtkViewport.
243 * Creates a new #GtkViewport with the given adjustments.
247 gtk_viewport_new (GtkAdjustment *hadjustment,
248 GtkAdjustment *vadjustment)
252 viewport = gtk_widget_new (GTK_TYPE_VIEWPORT,
253 "hadjustment", hadjustment,
254 "vadjustment", vadjustment,
261 gtk_viewport_destroy (GtkObject *object)
263 GtkViewport *viewport = GTK_VIEWPORT (object);
265 if (viewport->hadjustment)
267 g_signal_handlers_disconnect_by_func (viewport->hadjustment,
268 gtk_viewport_adjustment_changed,
270 g_signal_handlers_disconnect_by_func (viewport->hadjustment,
271 gtk_viewport_adjustment_value_changed,
273 g_object_unref (viewport->hadjustment);
274 viewport->hadjustment = NULL;
276 if (viewport->vadjustment)
278 g_signal_handlers_disconnect_by_func (viewport->vadjustment,
279 gtk_viewport_adjustment_changed,
281 g_signal_handlers_disconnect_by_func (viewport->vadjustment,
282 gtk_viewport_adjustment_value_changed,
284 g_object_unref (viewport->vadjustment);
285 viewport->vadjustment = NULL;
288 GTK_OBJECT_CLASS (parent_class)->destroy (object);
292 * gtk_viewport_get_hadjustment:
293 * @viewport: a #GtkViewport.
295 * Returns the horizontal adjustment of the viewport.
297 * Return value: the horizontal adjustment of @viewport.
300 gtk_viewport_get_hadjustment (GtkViewport *viewport)
302 g_return_val_if_fail (GTK_IS_VIEWPORT (viewport), NULL);
304 if (!viewport->hadjustment)
305 gtk_viewport_set_hadjustment (viewport, NULL);
307 return viewport->hadjustment;
311 * gtk_viewport_get_vadjustment:
312 * @viewport: a #GtkViewport.
314 * Returns the vertical adjustment of the viewport.
316 * Return value: the vertical adjustment of @viewport.
319 gtk_viewport_get_vadjustment (GtkViewport *viewport)
321 g_return_val_if_fail (GTK_IS_VIEWPORT (viewport), NULL);
323 if (!viewport->vadjustment)
324 gtk_viewport_set_vadjustment (viewport, NULL);
326 return viewport->vadjustment;
330 * gtk_viewport_set_hadjustment:
331 * @viewport: a #GtkViewport.
332 * @adjustment: a #GtkAdjustment.
334 * Sets the horizontal adjustment of the viewport.
337 gtk_viewport_set_hadjustment (GtkViewport *viewport,
338 GtkAdjustment *adjustment)
340 g_return_if_fail (GTK_IS_VIEWPORT (viewport));
342 g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
344 if (viewport->hadjustment && viewport->hadjustment != adjustment)
346 g_signal_handlers_disconnect_by_func (viewport->hadjustment,
347 gtk_viewport_adjustment_changed,
349 g_signal_handlers_disconnect_by_func (viewport->hadjustment,
350 gtk_viewport_adjustment_value_changed,
352 g_object_unref (viewport->hadjustment);
353 viewport->hadjustment = NULL;
357 adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0,
360 if (viewport->hadjustment != adjustment)
362 viewport->hadjustment = adjustment;
363 g_object_ref (viewport->hadjustment);
364 gtk_object_sink (GTK_OBJECT (viewport->hadjustment));
366 g_signal_connect (adjustment, "changed",
367 G_CALLBACK (gtk_viewport_adjustment_changed),
369 g_signal_connect (adjustment, "value_changed",
370 G_CALLBACK (gtk_viewport_adjustment_value_changed),
373 gtk_viewport_adjustment_changed (adjustment, viewport);
376 g_object_notify (G_OBJECT (viewport), "hadjustment");
380 * gtk_viewport_set_vadjustment:
381 * @viewport: a #GtkViewport.
382 * @adjustment: a #GtkAdjustment.
384 * Sets the vertical adjustment of the viewport.
387 gtk_viewport_set_vadjustment (GtkViewport *viewport,
388 GtkAdjustment *adjustment)
390 g_return_if_fail (GTK_IS_VIEWPORT (viewport));
392 g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
394 if (viewport->vadjustment && viewport->vadjustment != adjustment)
396 g_signal_handlers_disconnect_by_func (viewport->vadjustment,
397 gtk_viewport_adjustment_changed,
399 g_signal_handlers_disconnect_by_func (viewport->vadjustment,
400 gtk_viewport_adjustment_value_changed,
402 g_object_unref (viewport->vadjustment);
403 viewport->vadjustment = NULL;
407 adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0,
410 if (viewport->vadjustment != adjustment)
412 viewport->vadjustment = adjustment;
413 g_object_ref (viewport->vadjustment);
414 gtk_object_sink (GTK_OBJECT (viewport->vadjustment));
416 g_signal_connect (adjustment, "changed",
417 G_CALLBACK (gtk_viewport_adjustment_changed),
419 g_signal_connect (adjustment, "value_changed",
420 G_CALLBACK (gtk_viewport_adjustment_value_changed),
423 gtk_viewport_adjustment_changed (adjustment, viewport);
426 g_object_notify (G_OBJECT (viewport), "vadjustment");
430 gtk_viewport_set_scroll_adjustments (GtkViewport *viewport,
431 GtkAdjustment *hadjustment,
432 GtkAdjustment *vadjustment)
434 if (viewport->hadjustment != hadjustment)
435 gtk_viewport_set_hadjustment (viewport, hadjustment);
436 if (viewport->vadjustment != vadjustment)
437 gtk_viewport_set_vadjustment (viewport, vadjustment);
441 * gtk_viewport_set_shadow_type:
442 * @viewport: a #GtkViewport.
443 * @type: the new shadow type.
445 * Sets the shadow type of the viewport.
448 gtk_viewport_set_shadow_type (GtkViewport *viewport,
451 g_return_if_fail (GTK_IS_VIEWPORT (viewport));
453 if ((GtkShadowType) viewport->shadow_type != type)
455 viewport->shadow_type = type;
457 if (GTK_WIDGET_VISIBLE (viewport))
459 gtk_widget_size_allocate (GTK_WIDGET (viewport), &(GTK_WIDGET (viewport)->allocation));
460 gtk_widget_queue_draw (GTK_WIDGET (viewport));
463 g_object_notify (G_OBJECT (viewport), "shadow_type");
468 * gtk_viewport_get_shadow_type:
469 * @viewport: a #GtkViewport
471 * Gets the shadow type of the #GtkViewport. See
472 * gtk_viewport_set_shadow_type().
474 * Return value: the shadow type
477 gtk_viewport_get_shadow_type (GtkViewport *viewport)
479 g_return_val_if_fail (GTK_IS_VIEWPORT (viewport), GTK_SHADOW_NONE);
481 return viewport->shadow_type;
485 gtk_viewport_realize (GtkWidget *widget)
488 GtkViewport *viewport;
489 GdkWindowAttr attributes;
490 gint attributes_mask;
494 border_width = GTK_CONTAINER (widget)->border_width;
496 bin = GTK_BIN (widget);
497 viewport = GTK_VIEWPORT (widget);
498 GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
500 attributes.x = widget->allocation.x + border_width;
501 attributes.y = widget->allocation.y + border_width;
502 attributes.width = widget->allocation.width - border_width * 2;
503 attributes.height = widget->allocation.height - border_width * 2;
504 attributes.window_type = GDK_WINDOW_CHILD;
505 attributes.wclass = GDK_INPUT_OUTPUT;
506 attributes.visual = gtk_widget_get_visual (widget);
507 attributes.colormap = gtk_widget_get_colormap (widget);
509 event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
510 /* We select on button_press_mask so that button 4-5 scrolls are trapped.
512 attributes.event_mask = event_mask | GDK_BUTTON_PRESS_MASK;
514 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
516 widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
517 &attributes, attributes_mask);
518 gdk_window_set_user_data (widget->window, viewport);
520 if (viewport->shadow_type != GTK_SHADOW_NONE)
522 attributes.x = widget->style->xthickness;
523 attributes.y = widget->style->ythickness;
531 attributes.width = MAX (1, (gint)widget->allocation.width - attributes.x * 2 - border_width * 2);
532 attributes.height = MAX (1, (gint)widget->allocation.height - attributes.y * 2 - border_width * 2);
533 attributes.event_mask = 0;
535 viewport->view_window = gdk_window_new (widget->window, &attributes, attributes_mask);
536 gdk_window_set_user_data (viewport->view_window, viewport);
543 attributes.width = viewport->hadjustment->upper;
544 attributes.height = viewport->vadjustment->upper;
547 attributes.event_mask = event_mask;
549 viewport->bin_window = gdk_window_new (viewport->view_window, &attributes, attributes_mask);
550 gdk_window_set_user_data (viewport->bin_window, viewport);
553 gtk_widget_set_parent_window (bin->child, viewport->bin_window);
555 widget->style = gtk_style_attach (widget->style, widget->window);
556 gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
557 gtk_style_set_background (widget->style, viewport->bin_window, GTK_STATE_NORMAL);
559 gtk_paint_flat_box(widget->style, viewport->bin_window, GTK_STATE_NORMAL,
561 NULL, widget, "viewportbin",
564 gdk_window_show (viewport->bin_window);
565 gdk_window_show (viewport->view_window);
569 gtk_viewport_unrealize (GtkWidget *widget)
571 GtkViewport *viewport = GTK_VIEWPORT (widget);
573 gdk_window_set_user_data (viewport->view_window, NULL);
574 gdk_window_destroy (viewport->view_window);
575 viewport->view_window = NULL;
577 gdk_window_set_user_data (viewport->bin_window, NULL);
578 gdk_window_destroy (viewport->bin_window);
579 viewport->bin_window = NULL;
581 if (GTK_WIDGET_CLASS (parent_class)->unrealize)
582 (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
586 gtk_viewport_paint (GtkWidget *widget,
589 GtkViewport *viewport;
591 g_return_if_fail (GTK_IS_VIEWPORT (widget));
592 g_return_if_fail (area != NULL);
594 if (GTK_WIDGET_DRAWABLE (widget))
596 viewport = GTK_VIEWPORT (widget);
598 gtk_paint_shadow (widget->style, widget->window,
599 GTK_STATE_NORMAL, viewport->shadow_type,
600 NULL, widget, "viewport",
606 gtk_viewport_expose (GtkWidget *widget,
607 GdkEventExpose *event)
609 GtkViewport *viewport;
612 if (GTK_WIDGET_DRAWABLE (widget))
614 viewport = GTK_VIEWPORT (widget);
615 bin = GTK_BIN (widget);
617 if (event->window == widget->window)
618 gtk_viewport_paint (widget, &event->area);
619 else if (event->window == viewport->bin_window)
621 gtk_paint_flat_box(widget->style, viewport->bin_window,
622 GTK_STATE_NORMAL, GTK_SHADOW_NONE,
623 &event->area, widget, "viewportbin",
626 (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event);
636 gtk_viewport_add (GtkContainer *container,
641 g_return_if_fail (GTK_IS_WIDGET (child));
643 bin = GTK_BIN (container);
644 g_return_if_fail (bin->child == NULL);
646 gtk_widget_set_parent_window (child, GTK_VIEWPORT (bin)->bin_window);
648 GTK_CONTAINER_CLASS (parent_class)->add (container, child);
652 gtk_viewport_size_request (GtkWidget *widget,
653 GtkRequisition *requisition)
655 GtkViewport *viewport;
657 GtkRequisition child_requisition;
659 viewport = GTK_VIEWPORT (widget);
660 bin = GTK_BIN (widget);
662 requisition->width = (GTK_CONTAINER (widget)->border_width +
663 GTK_WIDGET (widget)->style->xthickness) * 2;
665 requisition->height = (GTK_CONTAINER (widget)->border_width * 2 +
666 GTK_WIDGET (widget)->style->ythickness) * 2;
668 if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
670 gtk_widget_size_request (bin->child, &child_requisition);
671 requisition->width += child_requisition.width;
672 requisition->height += child_requisition.height;
677 gtk_viewport_size_allocate (GtkWidget *widget,
678 GtkAllocation *allocation)
680 GtkViewport *viewport = GTK_VIEWPORT (widget);
681 GtkBin *bin = GTK_BIN (widget);
682 GtkAllocation child_allocation;
684 gint border_width = GTK_CONTAINER (widget)->border_width;
686 /* demand creation */
687 if (!viewport->hadjustment)
688 gtk_viewport_set_hadjustment (viewport, NULL);
689 if (!viewport->vadjustment)
690 gtk_viewport_set_vadjustment (viewport, NULL);
692 /* If our size changed, and we have a shadow, queue a redraw on widget->window to
693 * redraw the shadow correctly.
695 if (GTK_WIDGET_MAPPED (widget) &&
696 viewport->shadow_type != GTK_SHADOW_NONE &&
697 (widget->allocation.width != allocation->width ||
698 widget->allocation.height != allocation->height))
699 gdk_window_invalidate_rect (widget->window, NULL, FALSE);
701 widget->allocation = *allocation;
703 child_allocation.x = 0;
704 child_allocation.y = 0;
706 if (viewport->shadow_type != GTK_SHADOW_NONE)
708 child_allocation.x = widget->style->xthickness;
709 child_allocation.y = widget->style->ythickness;
712 child_allocation.width = MAX (1, allocation->width - child_allocation.x * 2 - border_width * 2);
713 child_allocation.height = MAX (1, allocation->height - child_allocation.y * 2 - border_width * 2);
715 if (GTK_WIDGET_REALIZED (widget))
717 gdk_window_move_resize (widget->window,
718 allocation->x + border_width,
719 allocation->y + border_width,
720 allocation->width - border_width * 2,
721 allocation->height - border_width * 2);
723 gdk_window_move_resize (viewport->view_window,
726 child_allocation.width,
727 child_allocation.height);
730 viewport->hadjustment->page_size = child_allocation.width;
731 viewport->hadjustment->step_increment = child_allocation.width * 0.1;
732 viewport->hadjustment->page_increment = child_allocation.width * 0.9;
734 viewport->vadjustment->page_size = child_allocation.height;
735 viewport->vadjustment->step_increment = child_allocation.height * 0.1;
736 viewport->vadjustment->page_increment = child_allocation.height * 0.9;
738 hval = viewport->hadjustment->value;
739 vval = viewport->vadjustment->value;
741 if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
743 GtkRequisition child_requisition;
744 gtk_widget_get_child_requisition (bin->child, &child_requisition);
746 viewport->hadjustment->lower = 0;
747 viewport->hadjustment->upper = MAX (child_requisition.width,
748 child_allocation.width);
750 hval = CLAMP (hval, 0,
751 viewport->hadjustment->upper -
752 viewport->hadjustment->page_size);
754 viewport->vadjustment->lower = 0;
755 viewport->vadjustment->upper = MAX (child_requisition.height,
756 child_allocation.height);
758 vval = CLAMP (vval, 0,
759 viewport->vadjustment->upper -
760 viewport->vadjustment->page_size);
763 if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
765 child_allocation.x = 0;
766 child_allocation.y = 0;
768 child_allocation.width = viewport->hadjustment->upper;
769 child_allocation.height = viewport->vadjustment->upper;
771 if (GTK_WIDGET_REALIZED (widget))
772 gdk_window_resize (viewport->bin_window,
773 child_allocation.width,
774 child_allocation.height);
776 child_allocation.x = 0;
777 child_allocation.y = 0;
778 gtk_widget_size_allocate (bin->child, &child_allocation);
781 gtk_adjustment_changed (viewport->hadjustment);
782 gtk_adjustment_changed (viewport->vadjustment);
783 if (viewport->hadjustment->value != hval)
785 viewport->hadjustment->value = hval;
786 gtk_adjustment_value_changed (viewport->hadjustment);
788 if (viewport->vadjustment->value != vval)
790 viewport->vadjustment->value = vval;
791 gtk_adjustment_value_changed (viewport->vadjustment);
796 gtk_viewport_adjustment_changed (GtkAdjustment *adjustment,
799 GtkViewport *viewport;
801 g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
802 g_return_if_fail (GTK_IS_VIEWPORT (data));
804 viewport = GTK_VIEWPORT (data);
808 gtk_viewport_adjustment_value_changed (GtkAdjustment *adjustment,
811 GtkViewport *viewport;
813 GtkAllocation child_allocation;
815 g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
816 g_return_if_fail (GTK_IS_VIEWPORT (data));
818 viewport = GTK_VIEWPORT (data);
819 bin = GTK_BIN (data);
821 if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
823 child_allocation.x = 0;
824 child_allocation.y = 0;
826 if (viewport->hadjustment->lower != (viewport->hadjustment->upper -
827 viewport->hadjustment->page_size))
828 child_allocation.x = viewport->hadjustment->lower - viewport->hadjustment->value;
830 if (viewport->vadjustment->lower != (viewport->vadjustment->upper -
831 viewport->vadjustment->page_size))
832 child_allocation.y = viewport->vadjustment->lower - viewport->vadjustment->value;
834 if (GTK_WIDGET_REALIZED (viewport))
836 gdk_window_move (viewport->bin_window,
840 gdk_window_process_updates (viewport->bin_window, TRUE);
846 gtk_viewport_style_set (GtkWidget *widget,
847 GtkStyle *previous_style)
849 GtkViewport *viewport;
851 if (GTK_WIDGET_REALIZED (widget) &&
852 !GTK_WIDGET_NO_WINDOW (widget))
854 viewport = GTK_VIEWPORT (widget);
856 gtk_style_set_background (widget->style, viewport->bin_window, GTK_STATE_NORMAL);
857 gtk_style_set_background (widget->style, widget->window, widget->state);