summaryrefslogtreecommitdiff
path: root/gtk
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
parent3c07b7ebbd3d6ddb3dae9bdee185d14c6adaea56 (diff)
downloadgdk-pixbuf-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')
-rw-r--r--gtk/gtkenums.h9
-rw-r--r--gtk/gtkscrolledwindow.c75
-rw-r--r--gtk/gtkscrolledwindow.h4
-rw-r--r--gtk/testgtk.c5
4 files changed, 73 insertions, 20 deletions
diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h
index 38166455a..c914fc419 100644
--- a/gtk/gtkenums.h
+++ b/gtk/gtkenums.h
@@ -136,6 +136,15 @@ typedef enum
GTK_ORIENTATION_VERTICAL
} GtkOrientation;
+/* Placement type for scrolled window */
+typedef enum
+{
+ GTK_CORNER_TOP_LEFT,
+ GTK_CORNER_BOTTOM_LEFT,
+ GTK_CORNER_TOP_RIGHT,
+ GTK_CORNER_BOTTOM_RIGHT
+} GtkCornerType;
+
/* Packing types (for boxes) */
typedef enum
{
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 046e5eb47..f64f8d771 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
diff --git a/gtk/gtkscrolledwindow.h b/gtk/gtkscrolledwindow.h
index a29c7b2e9..20260f04a 100644
--- a/gtk/gtkscrolledwindow.h
+++ b/gtk/gtkscrolledwindow.h
@@ -53,6 +53,7 @@ struct _GtkScrolledWindow
guint vscrollbar_policy : 2;
guint hscrollbar_visible : 1;
guint vscrollbar_visible : 1;
+ guint window_placement : 2;
guint autogenerated_viewport : 1;
};
@@ -75,7 +76,8 @@ GtkAdjustment* gtk_scrolled_window_get_vadjustment (GtkScrolledWindow *scrolled_
void gtk_scrolled_window_set_policy (GtkScrolledWindow *scrolled_window,
GtkPolicyType hscrollbar_policy,
GtkPolicyType vscrollbar_policy);
-
+void gtk_scrolled_window_set_placement (GtkScrolledWindow *scrolled_window,
+ GtkCornerType window_placement);
#ifdef __cplusplus
}
diff --git a/gtk/testgtk.c b/gtk/testgtk.c
index 4c571f93b..fa3429e69 100644
--- a/gtk/testgtk.c
+++ b/gtk/testgtk.c
@@ -4319,6 +4319,8 @@ void remove_selection (GtkWidget *widget, GtkCTree *ctree)
while (selection)
{
work = selection->data;
+ selection = selection->next;
+
if (GTK_CTREE_ROW (work)->is_leaf)
pages--;
else
@@ -4343,7 +4345,6 @@ void remove_selection (GtkWidget *widget, GtkCTree *ctree)
}
gtk_ctree_remove_node (ctree, work);
- selection = GTK_CLIST (ctree)->selection;
}
if (new_sel)
@@ -4634,7 +4635,7 @@ void build_recursive (GtkCTree *ctree, gint cur_depth, gint depth,
pixmap1, mask1, pixmap2, mask2,
FALSE, FALSE);
- style = gtk_style_new();
+ style = gtk_style_new ();
switch (cur_depth % 3)
{
case 0: