[gtk+] style: Convert draw_flat_box vfunc to Cairo version
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] style: Convert draw_flat_box vfunc to Cairo version
- Date: Sun, 26 Sep 2010 13:20:03 +0000 (UTC)
commit bea727a142f15ef9d263e57eaa32c11f78a52bd6
Author: Benjamin Otte <otte redhat com>
Date: Mon Aug 16 21:50:08 2010 +0200
style: Convert draw_flat_box vfunc to Cairo version
gtk/gtkstyle.c | 81 ++++++++++++++++++++++++----------
gtk/gtkstyle.h | 35 +++++++++-----
modules/engines/pixbuf/pixbuf-draw.c | 10 +---
3 files changed, 83 insertions(+), 43 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index 273262c..8978b85 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -159,10 +159,9 @@ static void gtk_default_draw_box (GtkStyle *style,
gint width,
gint height);
static void gtk_default_draw_flat_box (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state_type,
GtkShadowType shadow_type,
- GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
gint x,
@@ -2572,10 +2571,9 @@ get_darkened (const GdkColor *color,
static void
gtk_default_draw_flat_box (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state_type,
GtkShadowType shadow_type,
- GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
gint x,
@@ -2583,22 +2581,11 @@ gtk_default_draw_flat_box (GtkStyle *style,
gint width,
gint height)
{
- cairo_t *cr;
GdkColor *gc1;
GdkColor *freeme = NULL;
- sanitize_size (window, &width, &height);
-
- cr = gdk_cairo_create (window);
-
cairo_set_line_width (cr, 1.0);
- if (area)
- {
- gdk_cairo_rectangle (cr, area);
- cairo_clip (cr);
- }
-
if (detail)
{
int trimmed_len = strlen (detail);
@@ -2771,8 +2758,7 @@ gtk_default_draw_flat_box (GtkStyle *style,
else
gc1 = &style->bg[state_type];
- if (!style->bg_pixmap[state_type] || gc1 != &style->bg[state_type] ||
- GDK_IS_PIXMAP (window))
+ if (!style->bg_pixmap[state_type] || gc1 != &style->bg[state_type])
{
_cairo_draw_rectangle (cr, gc1, TRUE,
x, y, width, height);
@@ -2782,12 +2768,9 @@ gtk_default_draw_flat_box (GtkStyle *style,
x, y, width - 1, height - 1);
}
else
- gtk_style_apply_default_background (style, cr, window,
+ gtk_style_apply_default_background (style, cr, gtk_widget_get_window (widget),
state_type, x, y, width, height);
-
- cairo_destroy (cr);
-
if (freeme)
gdk_color_free (freeme);
}
@@ -5265,13 +5248,65 @@ gtk_paint_flat_box (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_flat_box != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
- GTK_STYLE_GET_CLASS (style)->draw_flat_box (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_flat_box (style, cr, state_type, shadow_type,
+ widget, detail,
+ x, y, width, height);
+
+ cairo_destroy (cr);
+}
+
+/**
+ * gtk_cairo_paint_flat_box:
+ * @style: a #GtkStyle
+ * @cr: a #cairo_t
+ * @state_type: a state
+ * @shadow_type: the type of shadow to draw
+ * @area: (allow-none): clip rectangle, or %NULL if the
+ * output should not be clipped
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
+ * @x: x origin of the box
+ * @y: y origin of the box
+ * @width: the width of the box
+ * @height: the height of the box
+ *
+ * Draws a flat box on @cr with the given parameters.
+ */
+void
+gtk_cairo_paint_flat_box (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_flat_box != 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_flat_box (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 72b079f..eca8243 100644
--- a/gtk/gtkstyle.h
+++ b/gtk/gtkstyle.h
@@ -224,10 +224,9 @@ struct _GtkStyleClass
gint width,
gint height);
void (*draw_flat_box) (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state_type,
GtkShadowType shadow_type,
- GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
gint x,
@@ -570,17 +569,27 @@ void gtk_cairo_paint_box (GtkStyle *style,
gint y,
gint width,
gint height);
-void gtk_paint_flat_box (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_flat_box (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_flat_box (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_check (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
diff --git a/modules/engines/pixbuf/pixbuf-draw.c b/modules/engines/pixbuf/pixbuf-draw.c
index ed7f36c..c35cc60 100644
--- a/modules/engines/pixbuf/pixbuf-draw.c
+++ b/modules/engines/pixbuf/pixbuf-draw.c
@@ -663,10 +663,9 @@ draw_box (GtkStyle *style,
static void
draw_flat_box (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state,
GtkShadowType shadow,
- GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
gint x,
@@ -676,18 +675,15 @@ draw_flat_box (GtkStyle *style,
{
ThemeMatchData match_data;
- g_return_if_fail(style != NULL);
- g_return_if_fail(window != NULL);
-
match_data.function = TOKEN_D_FLAT_BOX;
match_data.detail = (gchar *)detail;
match_data.flags = THEME_MATCH_SHADOW | THEME_MATCH_STATE;
match_data.shadow = shadow;
match_data.state = state;
- if (!draw_simple_image_no_cairo (style, window, area, widget, &match_data, TRUE, TRUE,
+ if (!draw_simple_image (style, cr, widget, &match_data, TRUE, TRUE,
x, y, width, height))
- parent_class->draw_flat_box (style, window, state, shadow, area, widget, detail,
+ parent_class->draw_flat_box (style, cr, state, shadow, widget, detail,
x, y, width, height);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]