[gtk+] style: Convert draw_layout vfunc to Cairo version
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] style: Convert draw_layout vfunc to Cairo version
- Date: Sun, 26 Sep 2010 13:20:58 +0000 (UTC)
commit d80e2897b95e7a3a7d7ecb92177209a6d5a3fe5b
Author: Benjamin Otte <otte redhat com>
Date: Mon Aug 16 15:21:01 2010 +0200
style: Convert draw_layout vfunc to Cairo version
gtk/gtkstyle.c | 66 +++++++++++++++++++++++++++++++++++++++++--------------
gtk/gtkstyle.h | 32 +++++++++++++++++----------
2 files changed, 69 insertions(+), 29 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index 12f0c5a..5728e35 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 038edac..44a0bf0 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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]