[gtk+/rendering-cleanup: 22/142] style: Convert draw_spinner vfunc to Cairo version
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/rendering-cleanup: 22/142] style: Convert draw_spinner vfunc to Cairo version
- Date: Tue, 14 Sep 2010 15:36:46 +0000 (UTC)
commit be8747d51ff5b81f3808c17d07523131830e7dc5
Author: Benjamin Otte <otte redhat com>
Date: Mon Aug 16 15:09:50 2010 +0200
style: Convert draw_spinner vfunc to Cairo version
gtk/gtkstyle.c | 63 ++++++++++++++++++++++++++++++++++++++++++++-----------
gtk/gtkstyle.h | 36 ++++++++++++++++++++-----------
2 files changed, 73 insertions(+), 26 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index 36cc1d9..ba672da 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -294,9 +294,8 @@ static void gtk_default_draw_resize_grip (GtkStyle *style,
gint width,
gint height);
static void gtk_default_draw_spinner (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state_type,
- GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
guint step,
@@ -4267,9 +4266,8 @@ gtk_default_draw_resize_grip (GtkStyle *style,
static void
gtk_default_draw_spinner (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state_type,
- GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
guint step,
@@ -4279,7 +4277,6 @@ gtk_default_draw_spinner (GtkStyle *style,
gint height)
{
GdkColor *color;
- cairo_t *cr;
guint num_steps;
gdouble dx, dy;
gdouble radius;
@@ -4292,9 +4289,6 @@ gtk_default_draw_spinner (GtkStyle *style,
NULL);
real_step = step % num_steps;
- /* get cairo context */
- cr = gdk_cairo_create (window);
-
/* set a clip region for the expose event */
cairo_rectangle (cr, x, y, width, height);
cairo_clip (cr);
@@ -4337,9 +4331,6 @@ gtk_default_draw_spinner (GtkStyle *style,
cairo_restore (cr);
}
-
- /* free memory */
- cairo_destroy (cr);
}
void
@@ -6297,13 +6288,59 @@ gtk_paint_spinner (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_spinner != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
- GTK_STYLE_GET_CLASS (style)->draw_spinner (style, window, state_type,
- (GdkRectangle *)area, widget, detail,
+ cr = gtk_style_cairo_create (window, area);
+
+ gtk_cairo_paint_spinner (style, cr, state_type,
+ widget, detail,
+ step, x, y, width, height);
+
+ cairo_destroy (cr);
+}
+
+/**
+ * gtk_cairo_paint_spinner:
+ * @style: a #GtkStyle
+ * @cr: a #cairo_t
+ * @state_type: a state
+ * @widget: (allow-none): the widget (may be %NULL)
+ * @detail: (allow-none): a style detail (may be %NULL)
+ * @step: the nth step, a value between 0 and #GtkSpinner:num-steps
+ * @x: the x origin of the rectangle in which to draw the spinner
+ * @y: the y origin of the rectangle in which to draw the spinner
+ * @width: the width of the rectangle in which to draw the spinner
+ * @height: the height of the rectangle in which to draw the spinner
+ *
+ * Draws a spinner on @window using the given parameters.
+ */
+void
+gtk_cairo_paint_spinner (GtkStyle *style,
+ cairo_t *cr,
+ GtkStateType state_type,
+ GtkWidget *widget,
+ const gchar *detail,
+ guint step,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
+{
+ g_return_if_fail (GTK_IS_STYLE (style));
+ g_return_if_fail (cr != NULL);
+ g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_spinner != NULL);
+
+ cairo_save (cr);
+
+ GTK_STYLE_GET_CLASS (style)->draw_spinner (style, cr, state_type,
+ widget, detail,
step, x, y, width, height);
+
+ cairo_restore (cr);
}
/**
diff --git a/gtk/gtkstyle.h b/gtk/gtkstyle.h
index c7c0fea..a300829 100644
--- a/gtk/gtkstyle.h
+++ b/gtk/gtkstyle.h
@@ -360,9 +360,8 @@ struct _GtkStyleClass
gint width,
gint height);
void (*draw_spinner) (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state_type,
- GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
guint step,
@@ -840,17 +839,28 @@ void gtk_cairo_paint_resize_grip (GtkStyle *style,
gint y,
gint width,
gint height);
-void gtk_paint_spinner (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- const GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- guint step,
- gint x,
- gint y,
- gint width,
- gint height);
+void gtk_paint_spinner (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ const GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ guint step,
+ gint x,
+ gint y,
+ gint width,
+ gint height);
+void gtk_cairo_paint_spinner (GtkStyle *style,
+ cairo_t *cr,
+ GtkStateType state_type,
+ GtkWidget *widget,
+ const gchar *detail,
+ guint step,
+ gint x,
+ gint y,
+ gint width,
+ gint height);
+
GType gtk_border_get_type (void) G_GNUC_CONST;
GtkBorder *gtk_border_new (void) G_GNUC_MALLOC;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]