]> Pileus Git - ~andy/gtk/commitdiff
style: Convert draw_check vfunc to Cairo version
authorBenjamin Otte <otte@redhat.com>
Mon, 16 Aug 2010 19:55:02 +0000 (21:55 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 26 Sep 2010 13:02:58 +0000 (15:02 +0200)
gtk/gtkstyle.c
gtk/gtkstyle.h
modules/engines/pixbuf/pixbuf-draw.c

index 8978b856d2134fb90ec0668548a93d2a51fb8ff2..842515dd837c382040e9c42f8d7f42616243761c 100644 (file)
@@ -169,10 +169,9 @@ static void gtk_default_draw_flat_box   (GtkStyle        *style,
                                         gint             width,
                                         gint             height);
 static void gtk_default_draw_check      (GtkStyle        *style,
-                                        GdkWindow       *window,
+                                        cairo_t         *cr,
                                         GtkStateType     state_type,
                                         GtkShadowType    shadow_type,
-                                        GdkRectangle    *area,
                                         GtkWidget       *widget,
                                         const gchar     *detail,
                                         gint             x,
@@ -2777,10 +2776,9 @@ gtk_default_draw_flat_box (GtkStyle      *style,
 
 static void 
 gtk_default_draw_check (GtkStyle      *style,
-                       GdkWindow     *window,
+                       cairo_t       *cr,
                        GtkStateType   state_type,
                        GtkShadowType  shadow_type,
-                       GdkRectangle  *area,
                        GtkWidget     *widget,
                        const gchar   *detail,
                        gint           x,
@@ -2788,7 +2786,6 @@ gtk_default_draw_check (GtkStyle      *style,
                        gint           width,
                        gint           height)
 {
-  cairo_t *cr = gdk_cairo_create (window);
   enum { BUTTON, MENU, CELL } type = BUTTON;
   int exterior_size;
   int interior_size;
@@ -2802,12 +2799,6 @@ gtk_default_draw_check (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;
@@ -2896,8 +2887,6 @@ gtk_default_draw_check (GtkStyle      *style,
                       line_thickness);
       cairo_fill (cr);
     }
-  
-  cairo_destroy (cr);
 }
 
 static void 
@@ -5340,13 +5329,60 @@ gtk_paint_check (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_check != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
 
-  GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type,
-                                           (GdkRectangle *) area, widget, detail,
+  cr = gtk_style_cairo_create (window, area);
+
+  gtk_cairo_paint_check (style, cr, state_type, shadow_type,
+                         widget, detail,
+                         x, y, width, height);
+
+  cairo_destroy (cr);
+}
+
+/**
+ * gtk_cairo_paint_check:
+ * @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 check in
+ * @y: y origin of the rectangle to draw the check in
+ * @width: the width of the rectangle to draw the check in
+ * @height: the height of the rectangle to draw the check in
+ * 
+ * Draws a check button indicator in the given rectangle on @cr with 
+ * the given parameters.
+ */
+void
+gtk_cairo_paint_check (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_check != NULL);
+  g_return_if_fail (cr != NULL);
+
+  cairo_save (cr);
+
+  GTK_STYLE_GET_CLASS (style)->draw_check (style, cr, state_type, shadow_type,
+                                           widget, detail,
                                            x, y, width, height);
+
+  cairo_restore (cr);
 }
 
 /**
index eca824322b41ab3bbf54968498cf8f8bab15d715..0a09c99749ac6bf5c83effb0f5bf05f1d88878b9 100644 (file)
@@ -234,10 +234,9 @@ struct _GtkStyleClass
                                 gint                    width,
                                 gint                    height);
   void (*draw_check)           (GtkStyle               *style,
-                                GdkWindow              *window,
+                                cairo_t                *cr,
                                 GtkStateType            state_type,
                                 GtkShadowType           shadow_type,
-                                GdkRectangle           *area,
                                 GtkWidget              *widget,
                                 const gchar            *detail,
                                 gint                    x,
@@ -590,17 +589,27 @@ void gtk_cairo_paint_flat_box    (GtkStyle           *style,
                                   gint                y,
                                   gint                width,
                                   gint                height);
-void gtk_paint_check       (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_check             (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_check       (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_option      (GtkStyle           *style,
                            GdkWindow          *window,
                            GtkStateType        state_type,
index c35cc604fafbb462a5cf906f53c744058880247a..e6c2558f7816a194200bcfed7aa6296f35bdb8ac 100644 (file)
@@ -689,10 +689,9 @@ draw_flat_box (GtkStyle     *style,
 
 static void
 draw_check (GtkStyle     *style,
-           GdkWindow    *window,
+           cairo_t      *cr,
            GtkStateType  state,
            GtkShadowType shadow,
-           GdkRectangle *area,
            GtkWidget    *widget,
            const gchar  *detail,
            gint          x,
@@ -702,18 +701,15 @@ draw_check (GtkStyle     *style,
 {
   ThemeMatchData match_data;
   
-  g_return_if_fail(style != NULL);
-  g_return_if_fail(window != NULL);
-
   match_data.function = TOKEN_D_CHECK;
   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_check (style, window, state, shadow, area, widget, detail,
+    parent_class->draw_check (style, cr, state, shadow, widget, detail,
                              x, y, width, height);
 }