diff options
author | Benjamin Otte <otte@redhat.com> | 2010-08-16 15:21:01 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2010-09-26 15:02:58 +0200 |
commit | d80e2897b95e7a3a7d7ecb92177209a6d5a3fe5b (patch) | |
tree | 4680c234fa3b59747f6f841e33e4caf96391e5a5 | |
parent | ff6e75adbc2e5b215f01f0b1448c3382dbdfbc32 (diff) | |
download | gtk+-d80e2897b95e7a3a7d7ecb92177209a6d5a3fe5b.tar.gz |
style: Convert draw_layout vfunc to Cairo version
-rw-r--r-- | gtk/gtkstyle.c | 66 | ||||
-rw-r--r-- | gtk/gtkstyle.h | 32 |
2 files changed, 69 insertions, 29 deletions
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 12f0c5a7d5..5728e35c62 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -275,10 +275,9 @@ static void gtk_default_draw_expander (GtkStyle *style, gint y, GtkExpanderStyle expander_style); static void gtk_default_draw_layout (GtkStyle *style, - GdkWindow *window, + cairo_t *cr, GtkStateType state_type, gboolean use_text, - GdkRectangle *area, GtkWidget *widget, const gchar *detail, gint x, @@ -3923,28 +3922,18 @@ gtk_default_draw_expander (GtkStyle *style, static void gtk_default_draw_layout (GtkStyle *style, - GdkWindow *window, + cairo_t *cr, GtkStateType state_type, gboolean use_text, - GdkRectangle *area, GtkWidget *widget, const gchar *detail, gint x, gint y, PangoLayout *layout) { - cairo_t *cr; GdkColor *gc; const PangoMatrix *matrix; - cr = gdk_cairo_create (window); - - if (area) - { - gdk_cairo_rectangle (cr, area); - cairo_clip (cr); - } - matrix = pango_context_get_matrix (pango_layout_get_context (layout)); if (matrix) { @@ -3985,8 +3974,6 @@ gtk_default_draw_layout (GtkStyle *style, gdk_cairo_set_source_color (cr, gc); pango_cairo_show_layout (cr, layout); - - cairo_destroy (cr); } static void @@ -6151,13 +6138,58 @@ gtk_paint_layout (GtkStyle *style, gint y, PangoLayout *layout) { + cairo_t *cr; + g_return_if_fail (GTK_IS_STYLE (style)); g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL); g_return_if_fail (style->depth == gdk_drawable_get_depth (window)); - GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, use_text, - (GdkRectangle *) area, widget, detail, + cr = gtk_style_cairo_create (window, area); + + gtk_cairo_paint_layout (style, cr, state_type, use_text, + widget, detail, + x, y, layout); + + cairo_destroy (cr); +} + +/** + * gtk_cairo_paint_layout: + * @style: a #GtkStyle + * @cr: a #cairo_t + * @state_type: a state + * @use_text: whether to use the text or foreground + * graphics context of @style + * @widget: (allow-none): the widget + * @detail: (allow-none): a style detail + * @x: x origin + * @y: y origin + * @layout: the layout to draw + * + * Draws a layout on @cr using the given parameters. + **/ +void +gtk_cairo_paint_layout (GtkStyle *style, + cairo_t *cr, + GtkStateType state_type, + gboolean use_text, + GtkWidget *widget, + const gchar *detail, + gint x, + gint y, + PangoLayout *layout) +{ + g_return_if_fail (GTK_IS_STYLE (style)); + g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL); + g_return_if_fail (cr != NULL); + + cairo_save (cr); + + GTK_STYLE_GET_CLASS (style)->draw_layout (style, cr, state_type, use_text, + widget, detail, x, y, layout); + + cairo_restore (cr); } /** diff --git a/gtk/gtkstyle.h b/gtk/gtkstyle.h index 038edac020..44a0bf0428 100644 --- a/gtk/gtkstyle.h +++ b/gtk/gtkstyle.h @@ -341,10 +341,9 @@ struct _GtkStyleClass gint y, GtkExpanderStyle expander_style); void (*draw_layout) (GtkStyle *style, - GdkWindow *window, + cairo_t *cr, GtkStateType state_type, gboolean use_text, - GdkRectangle *area, GtkWidget *widget, const gchar *detail, gint x, @@ -802,16 +801,25 @@ void gtk_cairo_paint_expander (GtkStyle *style, gint x, gint y, GtkExpanderStyle expander_style); -void gtk_paint_layout (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - gboolean use_text, - const GdkRectangle *area, - GtkWidget *widget, - const gchar *detail, - gint x, - gint y, - PangoLayout *layout); +void gtk_paint_layout (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + gboolean use_text, + const GdkRectangle *area, + GtkWidget *widget, + const gchar *detail, + gint x, + gint y, + PangoLayout *layout); +void gtk_cairo_paint_layout (GtkStyle *style, + cairo_t *cr, + GtkStateType state_type, + gboolean use_text, + GtkWidget *widget, + const gchar *detail, + gint x, + gint y, + PangoLayout *layout); void gtk_paint_resize_grip (GtkStyle *style, GdkWindow *window, GtkStateType state_type, |