[gtk+/cairo-style: 6/21] style: Convert draw_diamond vfunc to Cairo version
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/cairo-style: 6/21] style: Convert draw_diamond vfunc to Cairo version
- Date: Tue, 17 Aug 2010 02:24:09 +0000 (UTC)
commit a30665318820940cd86cc206bbabe0c7e7c9b844
Author: Benjamin Otte <otte redhat com>
Date: Mon Aug 16 16:19:48 2010 +0200
style: Convert draw_diamond vfunc to Cairo version
gtk/gtkstyle.c | 73 ++++++++++++++++++++++++++++++++++++++++++-------------
gtk/gtkstyle.h | 35 +++++++++++++++++----------
2 files changed, 77 insertions(+), 31 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index 5fc420b..ce0d10d 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -139,10 +139,9 @@ static void gtk_default_draw_arrow (GtkStyle *style,
gint width,
gint height);
static void gtk_default_draw_diamond (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state_type,
GtkShadowType shadow_type,
- GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
gint x,
@@ -2313,10 +2312,9 @@ gtk_default_draw_arrow (GtkStyle *style,
static void
gtk_default_draw_diamond (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state_type,
GtkShadowType shadow_type,
- GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
gint x,
@@ -2338,9 +2336,6 @@ gtk_default_draw_diamond (GtkStyle *style,
GdkColor *inner_ne = NULL;
GdkColor *inner_sw = NULL;
GdkColor *inner_se = NULL;
- cairo_t *cr;
-
- sanitize_size (window, &width, &height);
half_width = width / 2;
half_height = height / 2;
@@ -2388,13 +2383,6 @@ gtk_default_draw_diamond (GtkStyle *style,
break;
}
- cr = gdk_cairo_create (window);
- if (area)
- {
- gdk_cairo_rectangle (cr, area);
- cairo_clip (cr);
- }
-
if (inner_sw)
{
_cairo_draw_line (cr, inner_sw,
@@ -2435,8 +2423,6 @@ gtk_default_draw_diamond (GtkStyle *style,
x + half_width, y,
x + width, y + half_height);
}
-
- cairo_destroy (cr);
}
static void
@@ -5112,13 +5098,64 @@ gtk_paint_diamond (GtkStyle *style,
gint width,
gint height)
{
+ cairo_t *cr;
+
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
- GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type,
- (GdkRectangle *) area, widget, detail,
+ sanitize_size (window, &width, &height);
+
+ cr = gtk_style_cairo_create (window, area);
+
+ gtk_cairo_paint_diamond (style, cr, state_type, shadow_type,
+ widget, detail,
+ x, y, width, height);
+
+ cairo_destroy (cr);
+}
+
+/**
+ * gtk_cairo_paint_diamond:
+ * @style: a #GtkStyle
+ * @cr: a #cairo_t
+ * @state_type: a state
+ * @shadow_type: the type of shadow to draw
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
+ * @x: x origin of the rectangle to draw the diamond in
+ * @y: y origin of the rectangle to draw the diamond in
+ * @width: width of the rectangle to draw the diamond in
+ * @height: height of the rectangle to draw the diamond in
+ *
+ * Draws a diamond in the given rectangle on @window using the given
+ * parameters.
+ */
+void
+gtk_cairo_paint_diamond (GtkStyle *style,
+ cairo_t *cr,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
+{
+ g_return_if_fail (GTK_IS_STYLE (style));
+ g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
+ g_return_if_fail (cr != NULL);
+ g_return_if_fail (width >= 0);
+ g_return_if_fail (height >= 0);
+
+ cairo_save (cr);
+
+ GTK_STYLE_GET_CLASS (style)->draw_diamond (style, cr, state_type, shadow_type,
+ widget, detail,
x, y, width, height);
+
+ cairo_restore (cr);
}
/**
diff --git a/gtk/gtkstyle.h b/gtk/gtkstyle.h
index 705f414..898db38 100644
--- a/gtk/gtkstyle.h
+++ b/gtk/gtkstyle.h
@@ -204,10 +204,9 @@ struct _GtkStyleClass
gint width,
gint height);
void (*draw_diamond) (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state_type,
GtkShadowType shadow_type,
- GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
gint x,
@@ -530,17 +529,27 @@ void gtk_cairo_paint_arrow (GtkStyle *style,
gint y,
gint width,
gint height);
-void gtk_paint_diamond (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- const GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- gint width,
- gint height);
+void gtk_paint_diamond (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gint width,
+ gint height);
+void gtk_cairo_paint_diamond (GtkStyle *style,
+ cairo_t *cr,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gint width,
+ gint height);
void gtk_paint_box (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]