X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fgtk-custom-hruler.c;h=e5d39b30ec5a9e8d56c33ac6bb637b58189185fd;hb=04db4c788c8bf5070eb13b9165277ea81ab50070;hp=baa006a355c5d8d831f2c2551d4dc9c7fb31c30c;hpb=327018191b2c9828cf377663fbce58b47744c237;p=ardour.git diff --git a/gtk2_ardour/gtk-custom-hruler.c b/gtk2_ardour/gtk-custom-hruler.c index baa006a355..e5d39b30ec 100644 --- a/gtk2_ardour/gtk-custom-hruler.c +++ b/gtk2_ardour/gtk-custom-hruler.c @@ -21,7 +21,7 @@ * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS * file for a list of people on the GTK+ Team. See the ChangeLog * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. + * GTK+ at ftp://ftp.gtk.org/pub/gtk/. */ /* modified by andreas meyer */ @@ -47,9 +47,8 @@ static void gtk_custom_hruler_draw_pos (GtkCustomRuler * ruler); GType gtk_custom_hruler_get_type (void) { static GType hruler_type = 0; - - if (!hruler_type) - { + + if (!hruler_type) { static const GTypeInfo hruler_info = { sizeof (GtkCustomHRulerClass), @@ -61,12 +60,13 @@ GType gtk_custom_hruler_get_type (void) sizeof (GtkCustomHRuler), 0, /* n_preallocs */ (GInstanceInitFunc) gtk_custom_hruler_init, + NULL /* value_table */ }; - + hruler_type = g_type_register_static (gtk_custom_ruler_get_type(), "GtkCustomHRuler", &hruler_info, 0); } - + return hruler_type; } @@ -133,7 +133,6 @@ gtk_custom_hruler_draw_ticks (GtkCustomRuler * ruler) { GtkWidget *widget; GdkGC *gc, *bg_gc; - GdkFont *font; gint i; GtkCustomRulerMark *marks; gint xthickness; @@ -154,8 +153,7 @@ gtk_custom_hruler_draw_ticks (GtkCustomRuler * ruler) gc = widget->style->fg_gc[GTK_STATE_NORMAL]; bg_gc = widget->style->bg_gc[GTK_STATE_NORMAL]; - font = gtk_style_get_font(widget->style); - + layout = gtk_widget_create_pango_layout (widget, "012456789"); pango_layout_get_extents (layout, &ink_rect, &logical_rect); @@ -168,13 +166,13 @@ gtk_custom_hruler_draw_ticks (GtkCustomRuler * ruler) GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, widget, "custom_hruler", 0, 0, widget->allocation.width, widget->allocation.height); - gdk_draw_line (ruler->backing_store, gc, 0, widget->allocation.height - 1, + gdk_draw_line (ruler->backing_store, gc, 0, widget->allocation.height - 1, widget->allocation.width, widget->allocation.height - 1); if ((ruler->upper - ruler->lower) == 0) { return; } - + /* we have to assume a fixed width font here */ max_chars = widget->allocation.width / 12; // XXX FIX ME: pixel with of the char `8' @@ -199,10 +197,10 @@ gtk_custom_hruler_draw_ticks (GtkCustomRuler * ruler) gdk_draw_line (ruler->backing_store, gc, pos, height, pos, height - 3); break; } - + pango_layout_set_text (layout, marks[i].label, -1); pango_layout_get_extents (layout, &logical_rect, NULL); - + gtk_paint_layout (widget->style, ruler->backing_store, GTK_WIDGET_STATE (widget), @@ -212,14 +210,14 @@ gtk_custom_hruler_draw_ticks (GtkCustomRuler * ruler) "hruler", pos + 2, ythickness + PANGO_PIXELS (logical_rect.y - digit_offset), layout); - + g_free (marks[i].label); } - + if (nmarks) { g_free (marks); } - + g_object_unref (layout); } @@ -253,10 +251,10 @@ gtk_custom_hruler_draw_pos (GtkCustomRuler * ruler) if ((bs_width > 0) && (bs_height > 0)) { /* If a backing store exists, restore the ruler */ if (ruler->backing_store && ruler->non_gr_exp_gc) - gdk_draw_pixmap (ruler->widget.window, - ruler->non_gr_exp_gc, - ruler->backing_store, ruler->xsrc, ruler->ysrc, ruler->xsrc, ruler->ysrc, bs_width, bs_height); - + gdk_draw_drawable (ruler->widget.window, + ruler->non_gr_exp_gc, + GDK_DRAWABLE(ruler->backing_store), ruler->xsrc, ruler->ysrc, ruler->xsrc, ruler->ysrc, bs_width, bs_height); + increment = (gfloat) width / (ruler->upper - ruler->lower); x = ROUND ((ruler->position - ruler->lower) * increment) + (xthickness - bs_width) / 2 - 1; y = (height + bs_height) / 2 + ythickness;