diff options
author | Tim Janik <timj@gtk.org> | 1999-01-18 19:42:59 +0000 |
---|---|---|
committer | Tim Janik <timj@src.gnome.org> | 1999-01-18 19:42:59 +0000 |
commit | 4ee10fdefa7343ffb5bfd5f4657fa421e2a51006 (patch) | |
tree | 9a4a7960c67c482a1cd3c52bf1d7a052258a5870 /gtk/gtkhscale.c | |
parent | 7709c1d12dd8fd4ba9409a4f5e7ea131317e396f (diff) | |
download | gtk+-4ee10fdefa7343ffb5bfd5f4657fa421e2a51006.tar.gz |
CLAMP digits into a meaningfull range (we need to stay below a certain
Mon Jan 18 18:53:08 1999 Tim Janik <timj@gtk.org>
* gtk/gtkscale.c (gtk_scale_set_digits): CLAMP digits into a
meaningfull range (we need to stay below a certain limit anyways
to avoid string buffer overflows).
* gtk/gtkvscale.c (gtk_vscale_pos_background): fixed up background
area calculations for GTK_POS_RIGHT and GTK_POS_BOTTOM.
* gtk/gtkhscale.c (gtk_hscale_pos_background): likewise.
(gtk_hscale_draw_value): safety CLAMP the value's x position for
GTK_POS_TOP and GTK_POS_BOTTOM, so we don't paint strings outside of
our allocation.
* gtk/gtkscale.c: implemented GtkScale::digits, GtkScale::draw_value
and GtkScale::value_pos arguments.
Diffstat (limited to 'gtk/gtkhscale.c')
-rw-r--r-- | gtk/gtkhscale.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/gtk/gtkhscale.c b/gtk/gtkhscale.c index 62513627f4..4e349fb085 100644 --- a/gtk/gtkhscale.c +++ b/gtk/gtkhscale.c @@ -455,14 +455,14 @@ gtk_hscale_pos_background (GtkHScale *hscale, *w -= twidth; break; case GTK_POS_RIGHT: - *x = tx; + *x += twidth; *w -= twidth; break; case GTK_POS_TOP: *h -= theight; break; case GTK_POS_BOTTOM: - *y = ty; + *y += theight; *h -= theight; break; } @@ -541,6 +541,8 @@ gtk_hscale_draw_value (GtkScale *scale) gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height); x += widget->allocation.x + (width - text_width) / 2; + x = CLAMP (x, widget->allocation.x, + widget->allocation.x + widget->allocation.width - text_width); y -= GTK_WIDGET (scale)->style->font->descent; break; case GTK_POS_BOTTOM: @@ -550,6 +552,8 @@ gtk_hscale_draw_value (GtkScale *scale) gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height); x += widget->allocation.x + (width - text_width) / 2; + x = CLAMP (x, widget->allocation.x, + widget->allocation.x + widget->allocation.width - text_width); y += height + GTK_WIDGET (scale)->style->font->ascent; break; } |