[gtk+/cairo-style: 10/21] style: Convert draw_option vfunc to Cairo version
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/cairo-style: 10/21] style: Convert draw_option vfunc to Cairo version
- Date: Tue, 17 Aug 2010 02:24:30 +0000 (UTC)
commit 930c04dddd2519e1e4dd5206f427a2701e957e06
Author: Benjamin Otte <otte redhat com>
Date: Mon Aug 16 21:58:15 2010 +0200
style: Convert draw_option vfunc to Cairo version
gtk/gtkstyle.c | 66 +++++++++++++++++++++++++++++++++++++++++++------------
gtk/gtkstyle.h | 35 ++++++++++++++++++-----------
2 files changed, 73 insertions(+), 28 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index ba114a4..da512d6 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -179,10 +179,9 @@ static void gtk_default_draw_check (GtkStyle *style,
gint width,
gint height);
static void gtk_default_draw_option (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state_type,
GtkShadowType shadow_type,
- GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
gint x,
@@ -2877,10 +2876,9 @@ gtk_default_draw_check (GtkStyle *style,
static void
gtk_default_draw_option (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state_type,
GtkShadowType shadow_type,
- GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
gint x,
@@ -2888,7 +2886,6 @@ gtk_default_draw_option (GtkStyle *style,
gint width,
gint height)
{
- cairo_t *cr = gdk_cairo_create (window);
enum { BUTTON, MENU, CELL } type = BUTTON;
int exterior_size;
@@ -2900,12 +2897,6 @@ gtk_default_draw_option (GtkStyle *style,
type = MENU;
}
- if (area)
- {
- gdk_cairo_rectangle (cr, area);
- cairo_clip (cr);
- }
-
exterior_size = MIN (width, height);
if (exterior_size % 2 == 0) /* Ensure odd */
exterior_size -= 1;
@@ -2991,8 +2982,6 @@ gtk_default_draw_option (GtkStyle *style,
line_thickness);
cairo_fill (cr);
}
-
- cairo_destroy (cr);
}
static void
@@ -5401,13 +5390,60 @@ gtk_paint_option (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_option != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
- GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type,
- (GdkRectangle *) area, widget, detail,
+ cr = gtk_style_cairo_create (window, area);
+
+ gtk_cairo_paint_option (style, cr, state_type, shadow_type,
+ widget, detail,
+ x, y, width, height);
+
+ cairo_destroy (cr);
+}
+
+/**
+ * gtk_cairo_paint_option:
+ * @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 option in
+ * @y: y origin of the rectangle to draw the option in
+ * @width: the width of the rectangle to draw the option in
+ * @height: the height of the rectangle to draw the option in
+ *
+ * Draws a radio button indicator in the given rectangle on @cr with
+ * the given parameters.
+ */
+void
+gtk_cairo_paint_option (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_option != NULL);
+ g_return_if_fail (cr != NULL);
+
+ cairo_save (cr);
+
+ GTK_STYLE_GET_CLASS (style)->draw_option (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 0fd4785..5753dbc 100644
--- a/gtk/gtkstyle.h
+++ b/gtk/gtkstyle.h
@@ -244,10 +244,9 @@ struct _GtkStyleClass
gint width,
gint height);
void (*draw_option) (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state_type,
GtkShadowType shadow_type,
- GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
gint x,
@@ -610,17 +609,27 @@ void gtk_cairo_paint_check (GtkStyle *style,
gint y,
gint width,
gint height);
-void gtk_paint_option (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_option (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_option (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_tab (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]