[gtk+/rendering-cleanup: 14/141] style: Convert draw_box_gap vfunc to Cairo version
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/rendering-cleanup: 14/141] style: Convert draw_box_gap vfunc to Cairo version
- Date: Thu, 9 Sep 2010 16:24:30 +0000 (UTC)
commit 72bc243fa0d75c09fc009d158e4359324ebbe64e
Author: Benjamin Otte <otte redhat com>
Date: Mon Aug 16 22:15:43 2010 +0200
style: Convert draw_box_gap vfunc to Cairo version
Includes removal of now unused draw_gap_image_no_cairo() function from
pixbuf theme engine.
gtk/gtkstyle.c | 83 +++++++++++++++++++++++++---------
gtk/gtkstyle.h | 44 +++++++++++-------
modules/engines/pixbuf/pixbuf-draw.c | 48 +------------------
3 files changed, 93 insertions(+), 82 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index 71c4307..145d385 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -212,10 +212,9 @@ static void gtk_default_draw_shadow_gap (GtkStyle *style,
gint gap_x,
gint gap_width);
static void gtk_default_draw_box_gap (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state_type,
GtkShadowType shadow_type,
- GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
gint x,
@@ -3227,10 +3226,9 @@ gtk_default_draw_shadow_gap (GtkStyle *style,
static void
gtk_default_draw_box_gap (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state_type,
GtkShadowType shadow_type,
- GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
gint x,
@@ -3241,28 +3239,17 @@ gtk_default_draw_box_gap (GtkStyle *style,
gint gap_x,
gint gap_width)
{
- cairo_t *cr;
GdkColor color1;
GdkColor color2;
GdkColor color3;
GdkColor color4;
- sanitize_size (window, &width, &height);
-
- cr = gdk_cairo_create (window);
- if (area)
- {
- gdk_cairo_rectangle (cr, area);
- cairo_clip (cr);
- }
-
- 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);
switch (shadow_type)
{
case GTK_SHADOW_NONE:
- cairo_destroy (cr);
return;
case GTK_SHADOW_IN:
color1 = style->dark[state_type];
@@ -3435,9 +3422,6 @@ gtk_default_draw_box_gap (GtkStyle *style,
break;
}
}
-
-
- cairo_destroy (cr);
}
static void
@@ -5650,13 +5634,70 @@ gtk_paint_box_gap (GtkStyle *style,
gint gap_x,
gint gap_width)
{
+ cairo_t *cr;
+
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
- GTK_STYLE_GET_CLASS (style)->draw_box_gap (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_box_gap (style, cr, state_type, shadow_type,
+ widget, detail,
+ x, y, width, height, gap_side, gap_x, gap_width);
+
+ cairo_destroy (cr);
+}
+
+/**
+ * gtk_cairo_paint_box_gap:
+ * @style: a #GtkStyle
+ * @cr: a #cairo_t
+ * @state_type: a state
+ * @shadow_type: type of shadow to draw
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
+ * @x: x origin of the rectangle
+ * @y: y origin of the rectangle
+ * @width: width of the rectangle
+ * @height: width of the rectangle
+ * @gap_side: side in which to leave the gap
+ * @gap_x: starting position of the gap
+ * @gap_width: width of the gap
+ *
+ * Draws a box in @cr using the given style and state and shadow type,
+ * leaving a gap in one side.
+ */
+void
+gtk_cairo_paint_box_gap (GtkStyle *style,
+ cairo_t *cr,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ GtkPositionType gap_side,
+ gint gap_x,
+ gint gap_width)
+{
+ g_return_if_fail (GTK_IS_STYLE (style));
+ g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != 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_box_gap (style, cr, state_type, shadow_type,
+ widget, detail,
x, y, width, height, gap_side, gap_x, gap_width);
+
+ cairo_restore (cr);
}
/**
diff --git a/gtk/gtkstyle.h b/gtk/gtkstyle.h
index 79ff274..6f1df84 100644
--- a/gtk/gtkstyle.h
+++ b/gtk/gtkstyle.h
@@ -277,10 +277,9 @@ struct _GtkStyleClass
gint gap_x,
gint gap_width);
void (*draw_box_gap) (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state_type,
GtkShadowType shadow_type,
- GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
gint x,
@@ -676,20 +675,33 @@ void gtk_cairo_paint_shadow_gap (GtkStyle *style,
GtkPositionType gap_side,
gint gap_x,
gint gap_width);
-void gtk_paint_box_gap (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,
- GtkPositionType gap_side,
- gint gap_x,
- gint gap_width);
+void gtk_paint_box_gap (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,
+ GtkPositionType gap_side,
+ gint gap_x,
+ gint gap_width);
+void gtk_cairo_paint_box_gap (GtkStyle *style,
+ cairo_t *cr,
+ GtkStateType state_type,
+ GtkShadowType shadow_type,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ GtkPositionType gap_side,
+ gint gap_x,
+ gint gap_width);
void gtk_paint_extension (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
diff --git a/modules/engines/pixbuf/pixbuf-draw.c b/modules/engines/pixbuf/pixbuf-draw.c
index a63cc2b..12533be 100644
--- a/modules/engines/pixbuf/pixbuf-draw.c
+++ b/modules/engines/pixbuf/pixbuf-draw.c
@@ -345,47 +345,6 @@ draw_gap_image(GtkStyle *style,
return FALSE;
}
-static gboolean
-draw_gap_image_no_cairo(GtkStyle *style,
- GdkWindow *window,
- GdkRectangle *area,
- GtkWidget *widget,
- ThemeMatchData *match_data,
- gboolean draw_center,
- gint x,
- gint y,
- gint width,
- gint height,
- GtkPositionType gap_side,
- gint gap_x,
- gint gap_width)
-{
- gboolean result;
- cairo_t *cr;
-
- if ((width == -1) && (height == -1))
- gdk_drawable_get_size(window, &width, &height);
- else if (width == -1)
- gdk_drawable_get_size(window, &width, NULL);
- else if (height == -1)
- gdk_drawable_get_size(window, NULL, &height);
-
- cr = gdk_cairo_create (window);
- if (area)
- {
- gdk_cairo_rectangle (cr, area);
- cairo_clip (cr);
- }
-
- result = draw_gap_image (style, cr, widget, match_data,
- draw_center, x, y, width, height,
- gap_side, gap_x, gap_width);
-
- cairo_destroy (cr);
-
- return result;
-}
-
static void
draw_hline (GtkStyle *style,
cairo_t *cr,
@@ -801,10 +760,9 @@ draw_shadow_gap (GtkStyle *style,
static void
draw_box_gap (GtkStyle *style,
- GdkWindow *window,
+ cairo_t *cr,
GtkStateType state,
GtkShadowType shadow,
- GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
gint x,
@@ -826,9 +784,9 @@ draw_box_gap (GtkStyle *style,
match_data.shadow = shadow;
match_data.state = state;
- if (!draw_gap_image_no_cairo (style, window, area, widget, &match_data, TRUE,
+ if (!draw_gap_image (style, cr, widget, &match_data, TRUE,
x, y, width, height, gap_side, gap_x, gap_width))
- parent_class->draw_box_gap (style, window, state, shadow, area, widget, detail,
+ parent_class->draw_box_gap (style, cr, state, shadow, widget, detail,
x, y, width, height, gap_side, gap_x, gap_width);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]