]> Pileus Git - ~andy/gtk/commitdiff
style: Convert draw_handle vfunc to Cairo version
authorBenjamin Otte <otte@redhat.com>
Tue, 17 Aug 2010 01:26:20 +0000 (03:26 +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 91722cfb2bd3ee54d47f92ebbe50a5f12379ec24..7a56c775109b11a99f0b415a5c9a349ee8b6cc1c 100644 (file)
@@ -256,10 +256,9 @@ static void gtk_default_draw_slider     (GtkStyle        *style,
                                         gint             height,
                                         GtkOrientation   orientation);
 static void gtk_default_draw_handle     (GtkStyle        *style,
-                                        GdkWindow       *window,
+                                        cairo_t         *cr,
                                         GtkStateType     state_type,
                                         GtkShadowType    shadow_type,
-                                        GdkRectangle    *area,
                                         GtkWidget       *widget,
                                         const gchar     *detail,
                                         gint             x,
@@ -3735,10 +3734,9 @@ draw_dot (cairo_t    *cr,
 
 static void 
 gtk_default_draw_handle (GtkStyle      *style,
-                        GdkWindow     *window,
+                        cairo_t       *cr,
                         GtkStateType   state_type,
                         GtkShadowType  shadow_type,
-                        GdkRectangle  *area,
                         GtkWidget     *widget,
                         const gchar   *detail,
                         gint           x,
@@ -3750,19 +3748,9 @@ gtk_default_draw_handle (GtkStyle      *style,
   gint xx, yy;
   gint xthick, ythick;
   GdkColor light, dark;
-  cairo_t *cr;
-  
-  sanitize_size (window, &width, &height);
-  
-  gtk_paint_box (style, window, state_type, shadow_type, area, widget, 
-                 detail, x, y, width, height);
   
-  cr = gdk_cairo_create (window);
-  if (area)
-    {
-      gdk_cairo_rectangle (cr, area);
-      cairo_clip (cr);
-    }
+  gtk_cairo_paint_box (style, cr, state_type, shadow_type, widget, 
+                       detail, x, y, width, height);
   
   if (detail && !strcmp (detail, "paned"))
     {
@@ -3809,8 +3797,6 @@ gtk_default_draw_handle (GtkStyle      *style,
            draw_dot (cr, &light, &dark, xx + 3, yy + 1, 2);
          }
     }
-
-  cairo_destroy (cr);
 }
 
 static void
@@ -5990,13 +5976,65 @@ gtk_paint_handle (GtkStyle           *style,
                   gint                height,
                   GtkOrientation      orientation)
 {
+  cairo_t *cr;
+
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
 
-  GTK_STYLE_GET_CLASS (style)->draw_handle (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_handle (style, cr, state_type, shadow_type,
+                          widget, detail,
+                          x, y, width, height, orientation);
+
+  cairo_destroy (cr);
+}
+
+/**
+ * gtk_cairo_paint_handle:
+ * @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 handle
+ * @y: y origin of the handle
+ * @width: with of the handle
+ * @height: height of the handle
+ * @orientation: the orientation of the handle
+ * 
+ * Draws a handle as used in #GtkHandleBox and #GtkPaned.
+ **/
+void
+gtk_cairo_paint_handle (GtkStyle           *style,
+                        cairo_t            *cr,
+                        GtkStateType        state_type,
+                        GtkShadowType       shadow_type,
+                        GtkWidget          *widget,
+                        const gchar        *detail,
+                        gint                x,
+                        gint                y,
+                        gint                width,
+                        gint                height,
+                        GtkOrientation      orientation)
+{
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != 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_handle (style, cr, state_type, shadow_type,
+                                            widget, detail,
                                             x, y, width, height, orientation);
+
+  cairo_restore (cr);
 }
 
 /**
index 0024c3ad654482a7ae8e7d5fbfae4284f647378d..aa95919dd2f44ee57aa64a930f8f65d9c0321b48 100644 (file)
@@ -321,10 +321,9 @@ struct _GtkStyleClass
                                 gint                    height,
                                 GtkOrientation          orientation);
   void (*draw_handle)          (GtkStyle               *style,
-                                GdkWindow              *window,
+                                cairo_t                *cr,
                                 GtkStateType            state_type,
                                 GtkShadowType           shadow_type,
-                                GdkRectangle           *area,
                                 GtkWidget              *widget,
                                 const gchar            *detail,
                                 gint                    x,
@@ -764,18 +763,29 @@ void gtk_cairo_paint_slider      (GtkStyle           *style,
                                   gint                width,
                                   gint                height,
                                   GtkOrientation      orientation);
-void gtk_paint_handle      (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,
-                           GtkOrientation      orientation);
+void gtk_paint_handle            (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,
+                                  GtkOrientation      orientation);
+void gtk_cairo_paint_handle      (GtkStyle           *style,
+                                  cairo_t            *cr,
+                                  GtkStateType        state_type,
+                                  GtkShadowType       shadow_type,
+                                  GtkWidget          *widget,
+                                  const gchar        *detail,
+                                  gint                x,
+                                  gint                y,
+                                  gint                width,
+                                  gint                height,
+                                  GtkOrientation      orientation);
 void gtk_paint_expander    (GtkStyle           *style,
                             GdkWindow          *window,
                             GtkStateType        state_type,
index 7bb2623df5717b0276fca31d5b29915cc92327e9..f12218761fc5cdb0c51b72e446bcf4353b879ca3 100644 (file)
@@ -872,10 +872,9 @@ draw_slider (GtkStyle      *style,
 
 static void
 draw_handle (GtkStyle      *style,
-            GdkWindow     *window,
+            cairo_t       *cr,
             GtkStateType   state,
             GtkShadowType  shadow,
-            GdkRectangle  *area,
             GtkWidget     *widget,
             const gchar   *detail,
             gint           x,
@@ -886,9 +885,6 @@ draw_handle (GtkStyle      *style,
 {
   ThemeMatchData match_data;
   
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (window != NULL);
-
   match_data.function = TOKEN_D_HANDLE;
   match_data.detail = (gchar *)detail;
   match_data.flags = (THEME_MATCH_SHADOW | 
@@ -898,9 +894,9 @@ draw_handle (GtkStyle      *style,
   match_data.state = state;
   match_data.orientation = orientation;
 
-  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_handle (style, window, state, shadow, area, widget, detail,
+    parent_class->draw_handle (style, cr, state, shadow, widget, detail,
                               x, y, width, height, orientation);
 }