static gboolean gimp_ruler_expose (GtkWidget *widget, GdkEventExpose *event) { if (gtk_widget_is_drawable (widget)) { GimpRuler *ruler = GIMP_RULER (widget); GimpRulerPrivate *priv = GIMP_RULER_GET_PRIVATE (ruler); GtkAllocation allocation; cairo_t *cr; gimp_ruler_draw_ticks (ruler); cr = gdk_cairo_create (gtk_widget_get_window (widget)); gdk_cairo_region (cr, event->region); cairo_clip (cr); gtk_widget_get_allocation (widget, &allocation); cairo_translate (cr, allocation.x, allocation.y); cairo_set_source_surface (cr, priv->backing_store, 0, 0); cairo_paint (cr); gimp_ruler_draw_pos (ruler); cairo_destroy (cr); } return FALSE; }
static gboolean gimp_ruler_draw (GtkWidget *widget, cairo_t *cr) { GimpRuler *ruler = GIMP_RULER (widget); GimpRulerPrivate *priv = GIMP_RULER_GET_PRIVATE (ruler); GtkStyleContext *context = gtk_widget_get_style_context (widget); GtkAllocation allocation; gtk_widget_get_allocation (widget, &allocation); gtk_render_background (context, cr, 0, 0, allocation.width, allocation.height); gtk_render_frame (context, cr, 0, 0, allocation.width, allocation.height); if (! priv->backing_store_valid) gimp_ruler_draw_ticks (ruler); cairo_set_source_surface (cr, priv->backing_store, 0, 0); cairo_paint (cr); gimp_ruler_draw_pos (ruler, cr); return FALSE; }