diff options
author | Gnome CVS User <gnomecvs@src.gnome.org> | 1997-11-25 07:15:41 +0000 |
---|---|---|
committer | Gnome CVS User <gnomecvs@src.gnome.org> | 1997-11-25 07:15:41 +0000 |
commit | 33b94315803c6a7c9fe3826f0d4b11a26392137a (patch) | |
tree | 48c12426b37871cf7863595503e27f0f3472e8d3 /gtk/gtkhruler.c | |
parent | c82e82dafc507469f48547702841f0946a888104 (diff) | |
download | gtk+-33b94315803c6a7c9fe3826f0d4b11a26392137a.tar.gz |
Mon Nov 24 1997 Jay Painter <jpaint@serv.net>
gtk-dairiki-971117-2.patch
gtk/gtkaspectframe.c (gtk_aspect_frame_size_allocate): When
computing new dimensions of the subwidget, round to nearest
integer rather than truncating.
Mon Nov 24 1997 Jay Painter <jpaint@serv.net>
gtk-dairiki-971117-1.patch
* gtk/gtkvruler.c (gtk_vruler_draw_ticks):
* gtk/gtkhruler.c (gtk_hruler_draw_ticks): Ensure that subticks
always are drawn when they should be (sometimes they were getting
drawn with zero length --- invisible). Also clear rectangle
behind text labels to ensure they don't touch or overlap ticks.
Mon Nov 24 1997 Jay Painter <jpaint@serv.net>
* gtk/gtkaspectframe.c (gtk_aspect_frame_set):
gtk-dairiki-971117-0.patch
Clear window when aspect ratio or alignment is changed.
Diffstat (limited to 'gtk/gtkhruler.c')
-rw-r--r-- | gtk/gtkhruler.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/gtk/gtkhruler.c b/gtk/gtkhruler.c index ab6e69199e..83f1c7a6e4 100644 --- a/gtk/gtkhruler.c +++ b/gtk/gtkhruler.c @@ -123,12 +123,13 @@ static void gtk_hruler_draw_ticks (GtkRuler *ruler) { GtkWidget *widget; - GdkGC *gc; + GdkGC *gc, *bg_gc; + GdkFont *font; gint i; gint width, height; gint xthickness; gint ythickness; - gint length; + gint length, ideal_length; gfloat subd_incr; gfloat step_incr; gfloat increment; @@ -147,9 +148,12 @@ gtk_hruler_draw_ticks (GtkRuler *ruler) widget = GTK_WIDGET (ruler); gc = widget->style->fg_gc[GTK_STATE_NORMAL]; + bg_gc = widget->style->bg_gc[GTK_STATE_NORMAL]; + font = widget->style->font; + xthickness = widget->style->klass->xthickness; ythickness = widget->style->klass->ythickness; - digit_height = widget->style->font->ascent; + digit_height = font->ascent; /* assume descent == 0? */ width = widget->allocation.width; height = widget->allocation.height - ythickness * 2; @@ -181,20 +185,21 @@ gtk_hruler_draw_ticks (GtkRuler *ruler) if (scale == MAXIMUM_SCALES) scale = MAXIMUM_SCALES - 1; - for (i = 0; i < MAXIMUM_SUBDIVIDE; i++) + length = 0; + for (i = MAXIMUM_SUBDIVIDE - 1; i >= 0; i--) { subd_incr = (gfloat) ruler->metric->ruler_scale[scale] / (gfloat) ruler->metric->subdivide[i]; step_incr = subd_incr * increment; if (step_incr <= MINIMUM_INCR) - break; + continue; start = floor ((ruler->lower / ruler->metric->pixels_per_unit) / subd_incr) * subd_incr; end = ceil ((ruler->upper / ruler->metric->pixels_per_unit) / subd_incr) * subd_incr; - length = height / (i + 1) - 1; - if (i > 0) - length -= 2; - + ideal_length = height / (i + 1) - 1; + if (ideal_length > ++length) + length = ideal_length; + cur = start; while (cur <= end) { @@ -206,9 +211,13 @@ gtk_hruler_draw_ticks (GtkRuler *ruler) if (i == 0) { sprintf (unit_str, "%d", (int) cur); - gdk_draw_string (ruler->backing_store, widget->style->font, gc, - pos + 2, - ythickness + digit_height - 1, + gdk_draw_rectangle (ruler->backing_store, + bg_gc, TRUE, + pos + 1, ythickness, + gdk_string_width(font, unit_str) + 1, + digit_height); + gdk_draw_string (ruler->backing_store, font, gc, + pos + 2, ythickness + font->ascent - 1, unit_str); } |