summaryrefslogtreecommitdiff
path: root/gtk/gtkscrolledwindow.c
diff options
context:
space:
mode:
authorLars Hamann <lars@gtk.org>1998-11-09 00:23:37 +0000
committerLars Hamann <lars@src.gnome.org>1998-11-09 00:23:37 +0000
commit6ef274c0ed992896a106bbf4ab416b197d38cb24 (patch)
treef68abe285a2f36b64da0febce1e59bac815ed952 /gtk/gtkscrolledwindow.c
parent3c07b7ebbd3d6ddb3dae9bdee185d14c6adaea56 (diff)
downloadgtk+-6ef274c0ed992896a106bbf4ab416b197d38cb24.tar.gz
new enum GtkCornerType added window_placement. new method to set
Mon Nov 9 00:39:20 1998 Lars Hamann <lars@gtk.org> * gtk/gtkenums.h : new enum GtkCornerType * gtk/gtkscrolledwindow.h (struct _GtkScrolledWindow): added window_placement. * gtk/gtkscrolledwindow.c (gtk_scrolled_window_set_placement): new method to set window_placement. (gtk_scrolled_window_viewport_allocate) (gtk_scrolled_window_size_allocate): few changes due to window_placement. * gtk/testgtk.c (remove_selection): fixed while loop.
Diffstat (limited to 'gtk/gtkscrolledwindow.c')
-rw-r--r--gtk/gtkscrolledwindow.c75
1 files changed, 58 insertions, 17 deletions
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 046e5eb472..f64f8d771e 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -201,6 +201,7 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
scrolled_window->vscrollbar = NULL;
scrolled_window->hscrollbar_policy = GTK_POLICY_ALWAYS;
scrolled_window->vscrollbar_policy = GTK_POLICY_ALWAYS;
+ scrolled_window->window_placement = GTK_CORNER_TOP_LEFT;
scrolled_window->autogenerated_viewport = FALSE;
}
@@ -289,6 +290,21 @@ gtk_scrolled_window_set_policy (GtkScrolledWindow *scrolled_window,
}
}
+void
+gtk_scrolled_window_set_placement (GtkScrolledWindow *scrolled_window,
+ GtkCornerType window_placement)
+{
+ g_return_if_fail (scrolled_window != NULL);
+ g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
+
+ if (scrolled_window->window_placement != window_placement)
+ {
+ scrolled_window->window_placement = window_placement;
+
+ if (GTK_WIDGET (scrolled_window)->parent)
+ gtk_widget_queue_resize (GTK_WIDGET (scrolled_window));
+ }
+}
static void
gtk_scrolled_window_destroy (GtkObject *object)
@@ -517,7 +533,14 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
gtk_widget_show (scrolled_window->hscrollbar);
child_allocation.x = viewport_allocation.x;
- child_allocation.y = viewport_allocation.y + viewport_allocation.height + SCROLLBAR_SPACING (scrolled_window);
+ if (scrolled_window->window_placement == GTK_CORNER_TOP_LEFT ||
+ scrolled_window->window_placement == GTK_CORNER_TOP_RIGHT)
+ child_allocation.y = (viewport_allocation.y +
+ viewport_allocation.height +
+ SCROLLBAR_SPACING (scrolled_window));
+ else
+ child_allocation.y = GTK_CONTAINER (scrolled_window)->border_width;
+
child_allocation.width = viewport_allocation.width;
child_allocation.height = scrolled_window->hscrollbar->requisition.height;
child_allocation.x += allocation->x;
@@ -525,18 +548,22 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (scrolled_window->hscrollbar, &child_allocation);
}
- else
- {
- if (GTK_WIDGET_VISIBLE (scrolled_window->hscrollbar))
- gtk_widget_hide (scrolled_window->hscrollbar);
- }
+ else if (GTK_WIDGET_VISIBLE (scrolled_window->hscrollbar))
+ gtk_widget_hide (scrolled_window->hscrollbar);
if (scrolled_window->vscrollbar_visible)
{
if (!GTK_WIDGET_VISIBLE (scrolled_window->vscrollbar))
gtk_widget_show (scrolled_window->vscrollbar);
- child_allocation.x = viewport_allocation.x + viewport_allocation.width + SCROLLBAR_SPACING (scrolled_window);
+ if (scrolled_window->window_placement == GTK_CORNER_TOP_LEFT ||
+ scrolled_window->window_placement == GTK_CORNER_BOTTOM_LEFT)
+ child_allocation.x = (viewport_allocation.x +
+ viewport_allocation.width +
+ SCROLLBAR_SPACING (scrolled_window));
+ else
+ child_allocation.x = GTK_CONTAINER (scrolled_window)->border_width;
+
child_allocation.y = viewport_allocation.y;
child_allocation.width = scrolled_window->vscrollbar->requisition.width;
child_allocation.height = viewport_allocation.height;
@@ -545,11 +572,8 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (scrolled_window->vscrollbar, &child_allocation);
}
- else
- {
- if (GTK_WIDGET_VISIBLE (scrolled_window->vscrollbar))
- gtk_widget_hide (scrolled_window->vscrollbar);
- }
+ else if (GTK_WIDGET_VISIBLE (scrolled_window->vscrollbar))
+ gtk_widget_hide (scrolled_window->vscrollbar);
}
static void
@@ -559,7 +583,6 @@ gtk_scrolled_window_add (GtkContainer *container,
GtkScrolledWindow *scrolled_window;
GtkArgInfo *info_hadj;
GtkArgInfo *info_vadj;
- GtkArg arg;
gchar *error;
g_return_if_fail (container != NULL);
@@ -694,11 +717,29 @@ gtk_scrolled_window_viewport_allocate (GtkWidget *widget,
allocation->height = MAX (1, widget->allocation.height - allocation->y * 2);
if (scrolled_window->vscrollbar_visible)
- allocation->width = MAX (1,
- allocation->width - (scrolled_window->vscrollbar->requisition.width + SCROLLBAR_SPACING (scrolled_window)));
+ {
+ if (scrolled_window->window_placement == GTK_CORNER_TOP_RIGHT ||
+ scrolled_window->window_placement == GTK_CORNER_BOTTOM_RIGHT)
+ allocation->x += (scrolled_window->vscrollbar->requisition.width +
+ SCROLLBAR_SPACING (scrolled_window));
+
+ allocation->width =
+ MAX (1, allocation->width -
+ (scrolled_window->vscrollbar->requisition.width +
+ SCROLLBAR_SPACING (scrolled_window)));
+ }
if (scrolled_window->hscrollbar_visible)
- allocation->height = MAX (1,
- allocation->height - (scrolled_window->hscrollbar->requisition.height + SCROLLBAR_SPACING (scrolled_window)));
+ {
+ if (scrolled_window->window_placement == GTK_CORNER_BOTTOM_LEFT ||
+ scrolled_window->window_placement == GTK_CORNER_BOTTOM_RIGHT)
+ allocation->y += (scrolled_window->hscrollbar->requisition.height +
+ SCROLLBAR_SPACING (scrolled_window));
+
+ allocation->height =
+ MAX (1, allocation->height -
+ (scrolled_window->hscrollbar->requisition.height +
+ SCROLLBAR_SPACING (scrolled_window)));
+ }
}
static void