summaryrefslogtreecommitdiff
path: root/gtk/gtkrange.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2001-02-17 00:11:03 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-02-17 00:11:03 +0000
commit08add3cd503b3b891a0028b9b5400e271439c89f (patch)
tree1de50fc1006a3cc8c2c1de1b8742c200e7888840 /gtk/gtkrange.c
parentf139b1c9036128e5fef9bb0fea3a77d1afb8b8fe (diff)
downloadgdk-pixbuf-08add3cd503b3b891a0028b9b5400e271439c89f.tar.gz
convert the X coordinates so they're with respect to the line, rather than
2001-02-15 Havoc Pennington <hp@redhat.com> * gdk/gdkpango.c (gdk_pango_layout_line_get_clip_region): convert the X coordinates so they're with respect to the line, rather than with respect to the layout. * gtk/gtkalignment.c: Convert to new property API, patch from Lee Mallabone * gtk/testgtk.c (create_range_controls): add vscale tests, and inverted test * gtk/gtkrange.c (gtk_range_set_inverted): new function to fix #50806 * gtk/gtkentry.c (gtk_entry_get_text): add G_CONST_RETURN * gtk/gtktextiter.h (gtk_text_iter_is_last): rename gtk_text_iter_is_end * gtk/gtktextbuffer.h (gtk_text_buffer_get_last_iter): rename gtk_text_buffer_get_end_iter * gtk/testgtk.c (create_labels): Add test for selectable * gtk/gtkentry.c (gtk_entry_draw_text): Use new GDK API to draw the selection stuff. This code is kind of broken since it doesn't use the theme engine. * gdk/gdkpango.c (gdk_pango_layout_line_get_clip_region): fix infinite loop and y offset problem (gdk_draw_layout_line_with_colors): fix foreground color handling * gtk/gtklabel.h, gtk/gtklabel.c: Implement a "selectable" flag that makes the label selectable. * gtk/gtklabel.c (gtk_label_style_set): recreate the label's layout when the style is set, since fonts etc. could have changed.
Diffstat (limited to 'gtk/gtkrange.c')
-rw-r--r--gtk/gtkrange.c53
1 files changed, 49 insertions, 4 deletions
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 77e43d221..66c3bbf96 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -306,6 +306,29 @@ gtk_range_set_adjustment (GtkRange *range,
}
void
+gtk_range_set_inverted (GtkRange *range,
+ gboolean setting)
+{
+ g_return_if_fail (GTK_IS_RANGE (range));
+
+ setting = setting != FALSE;
+
+ if (setting != range->inverted)
+ {
+ range->inverted = setting;
+ gtk_widget_queue_resize (GTK_WIDGET (range));
+ }
+}
+
+gboolean
+gtk_range_get_inverted (GtkRange *range)
+{
+ g_return_val_if_fail (GTK_IS_RANGE (range), FALSE);
+
+ return range->inverted;
+}
+
+void
gtk_range_draw_background (GtkRange *range)
{
g_return_if_fail (range != NULL);
@@ -420,6 +443,19 @@ move_and_update_window (GdkWindow *window, gint x, gint y)
gdk_window_process_updates (parent, TRUE);
}
+static gboolean
+should_invert (GtkRange *range,
+ gboolean horizontal)
+{
+ if (horizontal)
+ return
+ (range->inverted && !range->flippable) ||
+ (range->inverted && range->flippable && gtk_widget_get_direction (GTK_WIDGET (range)) == GTK_TEXT_DIR_LTR) ||
+ (!range->inverted && range->flippable && gtk_widget_get_direction (GTK_WIDGET (range)) == GTK_TEXT_DIR_RTL);
+ else
+ return range->inverted;
+}
+
void
gtk_range_default_hslider_update (GtkRange *range)
{
@@ -455,7 +491,7 @@ gtk_range_default_hslider_update (GtkRange *range)
else if (x > right)
x = right;
- if (range->flippable && gtk_widget_get_direction (GTK_WIDGET (range)) == GTK_TEXT_DIR_RTL)
+ if (should_invert (range, TRUE))
x = right - (x - left);
move_and_update_window (range->slider, x, GTK_WIDGET (range)->style->ythickness);
@@ -497,6 +533,9 @@ gtk_range_default_vslider_update (GtkRange *range)
else if (y > bottom)
y = bottom;
+ if (should_invert (range, FALSE))
+ y = bottom - (y - top);
+
move_and_update_window (range->slider, GTK_WIDGET (range)->style->xthickness, y);
}
}
@@ -523,7 +562,7 @@ gtk_range_default_htrough_click (GtkRange *range,
gdk_window_get_size (range->slider, &slider_length, NULL);
right += slider_length;
- if (range->flippable && gtk_widget_get_direction (GTK_WIDGET (range)) == GTK_TEXT_DIR_RTL)
+ if (should_invert (range, TRUE))
x = (right - x) + left;
if ((x > left) && (y > ythickness))
@@ -571,7 +610,10 @@ gtk_range_default_vtrough_click (GtkRange *range,
gtk_range_trough_vdims (range, &top, &bottom);
gdk_window_get_size (range->slider, NULL, &slider_length);
bottom += slider_length;
-
+
+ if (should_invert (range, FALSE))
+ y = (bottom - y) + top;
+
if ((x > xthickness) && (y > top))
{
gdk_window_get_size (range->trough, &trough_width, &trough_height);
@@ -618,7 +660,7 @@ gtk_range_default_hmotion (GtkRange *range,
new_pos = slider_x + xdelta;
- if (range->flippable && gtk_widget_get_direction (GTK_WIDGET (range)) == GTK_TEXT_DIR_RTL)
+ if (should_invert (range, TRUE))
new_pos = (right - new_pos) + left;
if (new_pos < left)
@@ -686,6 +728,9 @@ gtk_range_default_vmotion (GtkRange *range,
new_pos = slider_y + ydelta;
+ if (should_invert (range, FALSE))
+ new_pos = (bottom - new_pos) + top;
+
if (new_pos < top)
new_pos = top;
else if (new_pos > bottom)