diff options
author | Owen Taylor <owt1@cornell.edu> | 1998-04-08 05:41:40 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 1998-04-08 05:41:40 +0000 |
commit | 0d1eb423a1f4a3cea517830b665df8ee294a3d39 (patch) | |
tree | 878065b7187a370731c8dc42fc0c749c734b1d06 /gtk/gtkviewport.c | |
parent | 55f36bac3acbeb04115455b025c6d597abd92426 (diff) | |
download | gtk+-0d1eb423a1f4a3cea517830b665df8ee294a3d39.tar.gz |
Handle border width correctly on realize after allocate.
Wed Apr 8 01:33:58 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkviewport.c (gtk_viewport_realize): Handle border
width correctly on realize after allocate.
Diffstat (limited to 'gtk/gtkviewport.c')
-rw-r--r-- | gtk/gtkviewport.c | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c index 047b264e56..115f9aafe7 100644 --- a/gtk/gtkviewport.c +++ b/gtk/gtkviewport.c @@ -279,21 +279,23 @@ gtk_viewport_realize (GtkWidget *widget) GtkBin *bin; GtkViewport *viewport; GdkWindowAttr attributes; - GtkRequisition *child_requisition; gint attributes_mask; gint event_mask; + gint border_width; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_VIEWPORT (widget)); + border_width = GTK_CONTAINER (widget)->border_width; + bin = GTK_BIN (widget); viewport = GTK_VIEWPORT (widget); GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); - attributes.x = widget->allocation.x + GTK_CONTAINER (widget)->border_width; - attributes.y = widget->allocation.y + GTK_CONTAINER (widget)->border_width; - attributes.width = widget->allocation.width - GTK_CONTAINER (widget)->border_width * 2; - attributes.height = widget->allocation.height - GTK_CONTAINER (widget)->border_width * 2; + attributes.x = widget->allocation.x + border_width; + attributes.y = widget->allocation.y + border_width; + attributes.width = widget->allocation.width - border_width * 2; + attributes.height = widget->allocation.height - border_width * 2; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); @@ -308,10 +310,19 @@ gtk_viewport_realize (GtkWidget *widget) &attributes, attributes_mask); gdk_window_set_user_data (widget->window, viewport); - attributes.x += widget->style->klass->xthickness; - attributes.y += widget->style->klass->ythickness; - attributes.width -= widget->style->klass->xthickness * 2; - attributes.height -= widget->style->klass->ythickness * 2; + if (viewport->shadow_type != GTK_SHADOW_NONE) + { + attributes.x = widget->style->klass->xthickness; + attributes.y = widget->style->klass->ythickness; + } + else + { + attributes.x = 0; + 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.event_mask = 0; viewport->view_window = gdk_window_new (widget->window, &attributes, attributes_mask); @@ -319,19 +330,20 @@ gtk_viewport_realize (GtkWidget *widget) attributes.x = 0; attributes.y = 0; + + if (bin->child) + { + attributes.width = viewport->hadjustment->upper; + attributes.height = viewport->vadjustment->upper; + } + attributes.event_mask = event_mask; viewport->bin_window = gdk_window_new (viewport->view_window, &attributes, attributes_mask); gdk_window_set_user_data (viewport->bin_window, viewport); if (bin->child) - { - child_requisition = >K_WIDGET (GTK_BIN (viewport)->child)->requisition; - attributes.width = child_requisition->width; - attributes.height = child_requisition->height; - - gtk_widget_set_parent_window (bin->child, viewport->bin_window); - } + gtk_widget_set_parent_window (bin->child, viewport->bin_window); widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); |