]> Pileus Git - ~andy/gtk/commitdiff
style: Convert draw_slider vfunc to Cairo version
authorBenjamin Otte <otte@redhat.com>
Tue, 17 Aug 2010 00:46:46 +0000 (02:46 +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 71bcd2d4841fed11554cfa10b0049a8e7ac303e6..91722cfb2bd3ee54d47f92ebbe50a5f12379ec24 100644 (file)
@@ -245,10 +245,9 @@ static void gtk_default_draw_focus      (GtkStyle        *style,
                                         gint             width,
                                         gint             height);
 static void gtk_default_draw_slider     (GtkStyle        *style,
-                                        GdkWindow       *window,
+                                        cairo_t         *cr,
                                         GtkStateType     state_type,
                                         GtkShadowType    shadow_type,
-                                        GdkRectangle    *area,
                                         GtkWidget       *widget,
                                         const gchar     *detail,
                                         gint             x,
@@ -3679,10 +3678,9 @@ gtk_default_draw_focus (GtkStyle      *style,
 
 static void 
 gtk_default_draw_slider (GtkStyle      *style,
-                         GdkWindow     *window,
+                         cairo_t       *cr,
                          GtkStateType   state_type,
                          GtkShadowType  shadow_type,
-                         GdkRectangle  *area,
                          GtkWidget     *widget,
                          const gchar   *detail,
                          gint           x,
@@ -3691,23 +3689,21 @@ gtk_default_draw_slider (GtkStyle      *style,
                          gint           height,
                          GtkOrientation orientation)
 {
-  sanitize_size (window, &width, &height);
-  
-  gtk_paint_box (style, window, state_type, shadow_type,
-                 area, widget, detail, x, y, width, height);
+  gtk_cairo_paint_box (style, cr, state_type, shadow_type,
+                       widget, detail, x, y, width, height);
 
   if (detail &&
       (strcmp ("hscale", detail) == 0 ||
        strcmp ("vscale", detail) == 0))
     {
       if (orientation == GTK_ORIENTATION_HORIZONTAL)
-        gtk_paint_vline (style, window, state_type, area, widget, detail, 
-                         y + style->ythickness, 
-                         y + height - style->ythickness - 1, x + width / 2);
+        gtk_cairo_paint_vline (style, cr, state_type, widget, detail, 
+                               y + style->ythickness, 
+                               y + height - style->ythickness - 1, x + width / 2);
       else
-        gtk_paint_hline (style, window, state_type, area, widget, detail, 
-                         x + style->xthickness, 
-                         x + width - style->xthickness - 1, y + height / 2);
+        gtk_cairo_paint_hline (style, cr, state_type, widget, detail, 
+                               x + style->xthickness, 
+                               x + width - style->xthickness - 1, y + height / 2);
     }
 }
 
@@ -5900,13 +5896,66 @@ gtk_paint_slider (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_slider != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
 
-  GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type,
-                                            (GdkRectangle *) area, widget, detail,
+  sanitize_size (window, &width, &height);
+
+  cr = gtk_style_cairo_create (window, area);
+
+  GTK_STYLE_GET_CLASS (style)->draw_slider (style, cr, state_type, shadow_type,
+                                            widget, detail,
+                                            x, y, width, height, orientation);
+
+  cairo_destroy (cr);
+}
+
+/**
+ * gtk_cairo_paint_slider:
+ * @style: a #GtkStyle
+ * @cr: a #cairo_t
+ * @state_type: a state
+ * @shadow_type: a shadow
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
+ * @x: the x origin of the rectangle in which to draw a slider
+ * @y: the y origin of the rectangle in which to draw a slider
+ * @width: the width of the rectangle in which to draw a slider
+ * @height: the height of the rectangle in which to draw a slider
+ * @orientation: the orientation to be used
+ *
+ * Draws a slider in the given rectangle on @cr using the
+ * given style and orientation.
+ **/
+void
+gtk_cairo_paint_slider (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_slider != 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_slider (style, cr, state_type, shadow_type,
+                                            widget, detail,
                                             x, y, width, height, orientation);
+
+  cairo_restore (cr);
 }
 
 /**
index ad64a9e6fdd21717614a7a7ea8dbca1e95c0aaf1..0024c3ad654482a7ae8e7d5fbfae4284f647378d 100644 (file)
@@ -310,10 +310,9 @@ struct _GtkStyleClass
                                 gint                    width,
                                 gint                    height);
   void (*draw_slider)          (GtkStyle               *style,
-                                GdkWindow              *window,
+                                cairo_t                *cr,
                                 GtkStateType            state_type,
                                 GtkShadowType           shadow_type,
-                                GdkRectangle           *area,
                                 GtkWidget              *widget,
                                 const gchar            *detail,
                                 gint                    x,
@@ -742,18 +741,29 @@ void gtk_cairo_paint_focus       (GtkStyle           *style,
                                   gint                y,
                                   gint                width,
                                   gint                height);
-void gtk_paint_slider      (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_slider            (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_slider      (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_handle      (GtkStyle           *style,
                            GdkWindow          *window,
                            GtkStateType        state_type,
index 2dac99dfa5de1f65dffe1b472144d5ea42a9a416..7bb2623df5717b0276fca31d5b29915cc92327e9 100644 (file)
@@ -841,10 +841,9 @@ draw_focus (GtkStyle     *style,
 
 static void
 draw_slider (GtkStyle      *style,
-            GdkWindow     *window,
+            cairo_t       *cr,
             GtkStateType   state,
             GtkShadowType  shadow,
-            GdkRectangle  *area,
             GtkWidget     *widget,
             const gchar   *detail,
             gint           x,
@@ -855,9 +854,6 @@ draw_slider (GtkStyle      *style,
 {
   ThemeMatchData           match_data;
   
-  g_return_if_fail(style != NULL);
-  g_return_if_fail(window != NULL);
-
   match_data.function = TOKEN_D_SLIDER;
   match_data.detail = (gchar *)detail;
   match_data.flags = (THEME_MATCH_SHADOW | 
@@ -867,9 +863,9 @@ draw_slider (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_slider (style, window, state, shadow, area, widget, detail,
+    parent_class->draw_slider (style, cr, state, shadow, widget, detail,
                               x, y, width, height, orientation);
 }