* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+
+/*
+ * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
#include "gtksignal.h"
#include "gtkviewport.h"
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
bin = GTK_BIN (widget);
- gdk_window_show (widget->window);
-
if (bin->child &&
GTK_WIDGET_VISIBLE (bin->child) &&
!GTK_WIDGET_MAPPED (bin->child))
gtk_widget_map (bin->child);
+
+ gdk_window_show (widget->window);
}
static void
attributes.colormap = gtk_widget_get_colormap (widget);
event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
- attributes.event_mask = event_mask;
+ /* We select on button_press_mask so that button 4-5 scrolls are trapped.
+ */
+ attributes.event_mask = event_mask | GDK_BUTTON_PRESS_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
attributes.y = 0;
}
- attributes.width = MAX (1, widget->allocation.width - attributes.x * 2 - border_width * 2);
- attributes.height = MAX (1, widget->allocation.height - attributes.y * 2 - border_width * 2);
+ attributes.width = MAX (1, (gint)widget->allocation.width - attributes.x * 2 - border_width * 2);
+ attributes.height = MAX (1, (gint)widget->allocation.height - attributes.y * 2 - border_width * 2);
attributes.event_mask = 0;
viewport->view_window = gdk_window_new (widget->window, &attributes, attributes_mask);
gtk_viewport_paint (widget, &tmp_area);
+ tmp_area.x += viewport->hadjustment->value - widget->style->klass->xthickness;
+ tmp_area.y += viewport->vadjustment->value - widget->style->klass->ythickness;
+
+ gtk_paint_flat_box(widget->style, viewport->bin_window,
+ GTK_STATE_NORMAL, GTK_SHADOW_NONE,
+ &tmp_area, widget, "viewportbin",
+ 0, 0, -1, -1);
+
if (bin->child)
{
- tmp_area.x += viewport->hadjustment->value - widget->style->klass->xthickness;
- tmp_area.y += viewport->vadjustment->value - widget->style->klass->ythickness;
-
if (gtk_widget_intersect (bin->child, &tmp_area, &child_area))
gtk_widget_draw (bin->child, &child_area);
}
if (event->window == widget->window)
gtk_viewport_paint (widget, &event->area);
+ else if (event->window == viewport->bin_window)
+ {
+ child_event = *event;
+
+ gtk_paint_flat_box(widget->style, viewport->bin_window,
+ GTK_STATE_NORMAL, GTK_SHADOW_NONE,
+ &event->area, widget, "viewportbin",
+ 0, 0, -1, -1);
+
+ if ((bin->child != NULL) &&
+ GTK_WIDGET_NO_WINDOW (bin->child) &&
+ gtk_widget_intersect (bin->child, &event->area, &child_event.area))
+ gtk_widget_event (bin->child, (GdkEvent*) &child_event);
+ }
+
- child_event = *event;
- if ((event->window == viewport->bin_window) &&
- (bin->child != NULL) &&
- GTK_WIDGET_NO_WINDOW (bin->child) &&
- gtk_widget_intersect (bin->child, &event->area, &child_event.area))
- gtk_widget_event (bin->child, (GdkEvent*) &child_event);
}
return FALSE;
{
GtkViewport *viewport;
GtkBin *bin;
+ GtkRequisition child_requisition;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_VIEWPORT (widget));
if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
{
- gtk_widget_size_request (bin->child, &bin->child->requisition);
- requisition->width += bin->child->requisition.width;
- requisition->height += bin->child->requisition.height;
+ gtk_widget_size_request (bin->child, &child_requisition);
+ requisition->width += child_requisition.width;
+ requisition->height += child_requisition.height;
}
}
child_allocation.y,
child_allocation.width,
child_allocation.height);
- gtk_paint_flat_box(widget->style, viewport->bin_window, GTK_STATE_NORMAL,
- GTK_SHADOW_NONE,
- NULL, widget, "viewportbin",
- 0, 0, -1, -1);
}
viewport->hadjustment->page_size = child_allocation.width;
if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
{
+ GtkRequisition child_requisition;
+ gtk_widget_get_child_requisition (bin->child, &child_requisition);
+
viewport->hadjustment->lower = 0;
- viewport->hadjustment->upper = MAX (bin->child->requisition.width,
+ viewport->hadjustment->upper = MAX (child_requisition.width,
child_allocation.width);
hval = CLAMP (hval, 0,
viewport->hadjustment->page_size);
viewport->vadjustment->lower = 0;
- viewport->vadjustment->upper = MAX (bin->child->requisition.height,
+ viewport->vadjustment->upper = MAX (child_requisition.height,
child_allocation.height);
vval = CLAMP (vval, 0,
child_allocation.width = viewport->hadjustment->upper;
child_allocation.height = viewport->vadjustment->upper;
- if (!GTK_WIDGET_REALIZED (widget))
- gtk_widget_realize (widget);
-
- gdk_window_resize (viewport->bin_window,
- child_allocation.width,
- child_allocation.height);
+ if (GTK_WIDGET_REALIZED (widget))
+ gdk_window_resize (viewport->bin_window,
+ child_allocation.width,
+ child_allocation.height);
child_allocation.x = 0;
child_allocation.y = 0;
GtkViewport *viewport;
GtkBin *bin;
GtkAllocation child_allocation;
- gint width, height;
g_return_if_fail (adjustment != NULL);
g_return_if_fail (data != NULL);
if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
{
- gdk_window_get_size (viewport->view_window, &width, &height);
-
child_allocation.x = 0;
child_allocation.y = 0;
gtk_style_set_background (widget->style, viewport->bin_window, GTK_STATE_NORMAL);
gtk_style_set_background (widget->style, widget->window, widget->state);
- gtk_paint_flat_box(widget->style, viewport->bin_window, GTK_STATE_NORMAL,
- GTK_SHADOW_NONE,
- NULL, widget, "viewportbin",
- 0, 0, -1, -1);
- if (GTK_WIDGET_DRAWABLE (widget))
- {
- gdk_window_clear (widget->window);
- gdk_window_clear (viewport->bin_window);
- }
}
}