]> Pileus Git - ~andy/gtk/commitdiff
style: Convert draw_vline vfunc to a Cairo version
authorBenjamin Otte <otte@redhat.com>
Mon, 16 Aug 2010 13:40:03 +0000 (15:40 +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 bce3d67c0031bf085f5ebc9039f1b488cb6eb03f..58009013335b152e187dc094037b5be0f336d36b 100644 (file)
@@ -109,9 +109,8 @@ static void gtk_default_draw_hline      (GtkStyle        *style,
                                         gint             x2,
                                         gint             y);
 static void gtk_default_draw_vline      (GtkStyle        *style,
-                                        GdkWindow       *window,
+                                        cairo_t         *cr,
                                         GtkStateType     state_type,
-                                        GdkRectangle    *area,
                                         GtkWidget       *widget,
                                         const gchar     *detail,
                                         gint             y1,
@@ -1688,17 +1687,15 @@ gtk_default_draw_hline (GtkStyle      *style,
 
 
 static void
-gtk_default_draw_vline (GtkStyle     *style,
-                        GdkWindow    *window,
+gtk_default_draw_vline (GtkStyle      *style,
+                        cairo_t       *cr,
                         GtkStateType  state_type,
-                        GdkRectangle  *area,
                         GtkWidget     *widget,
                         const gchar   *detail,
                         gint          y1,
                         gint          y2,
                         gint          x)
 {
-  cairo_t *cr;
   gint thickness_light;
   gint thickness_dark;
   gint i;
@@ -1706,15 +1703,8 @@ gtk_default_draw_vline (GtkStyle     *style,
   thickness_light = style->xthickness / 2;
   thickness_dark = style->xthickness - thickness_light;
 
-  cr = gdk_cairo_create (window);
   cairo_set_line_width (cr, 1.0);
 
-  if (area)
-    {
-      gdk_cairo_rectangle (cr, area);
-      cairo_clip (cr);
-    }
-
   for (i = 0; i < thickness_dark; i++)
     { 
       _cairo_draw_line (cr, &style->dark[state_type],
@@ -1731,8 +1721,6 @@ gtk_default_draw_vline (GtkStyle     *style,
       _cairo_draw_line (cr, &style->light[state_type],
                         x + i, y1 + thickness_light - i, x + i, y2);
     }
-
-  cairo_destroy (cr);
 }
 
 static void
@@ -4905,13 +4893,56 @@ gtk_paint_vline (GtkStyle           *style,
                  gint                y2_,
                  gint                x)
 {
+  cairo_t *cr;
+
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
 
-  GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type,
-                                           (GdkRectangle *) area, widget, detail,
+  cr = gtk_style_cairo_create (window, area);
+
+  GTK_STYLE_GET_CLASS (style)->draw_vline (style, cr, state_type,
+                                           widget, detail,
                                            y1_, y2_, x);
+
+  cairo_destroy (cr);
+}
+
+/**
+ * gtk_cairo_paint_vline:
+ * @style: a #GtkStyle
+ * @cr: a #cairo_t
+ * @state_type: a state
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
+ * @y1_: the starting y coordinate
+ * @y2_: the ending y coordinate
+ * @x: the x coordinate
+ *
+ * Draws a vertical line from (@x, @y1_) to (@x, @y2_) in @cr
+ * using the given style and state.
+ */
+void
+gtk_cairo_paint_vline (GtkStyle           *style,
+                       cairo_t            *cr,
+                       GtkStateType        state_type,
+                       GtkWidget          *widget,
+                       const gchar        *detail,
+                       gint                y1_,
+                       gint                y2_,
+                       gint                x)
+{
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (cr != NULL);
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
+
+  cairo_save (cr);
+
+  GTK_STYLE_GET_CLASS (style)->draw_vline (style, cr, state_type,
+                                           widget, detail,
+                                           y1_, y2_, x);
+
+  cairo_restore (cr);
 }
 
 /**
index 999babd73386555a6a85823f78d06f17196db070..ff208762fcbffb02cd4b79d1132f8b4d5b26b53f 100644 (file)
@@ -174,9 +174,8 @@ struct _GtkStyleClass
                                 gint                    x2,
                                 gint                    y);
   void (*draw_vline)           (GtkStyle               *style,
-                                GdkWindow              *window,
+                                cairo_t                *cr,
                                 GtkStateType            state_type,
-                                GdkRectangle           *area,
                                 GtkWidget              *widget,
                                 const gchar            *detail,
                                 gint                    y1_,
@@ -470,15 +469,23 @@ void gtk_cairo_paint_hline       (GtkStyle           *style,
                                   gint                x1,
                                   gint                x2,
                                   gint                y);
-void gtk_paint_vline       (GtkStyle           *style,
-                           GdkWindow          *window,
-                           GtkStateType        state_type,
-                           const GdkRectangle *area,
-                           GtkWidget          *widget,
-                           const gchar        *detail,
-                           gint                y1_,
-                           gint                y2_,
-                           gint                x);
+void gtk_paint_vline             (GtkStyle           *style,
+                                  GdkWindow          *window,
+                                  GtkStateType        state_type,
+                                  const GdkRectangle *area,
+                                  GtkWidget          *widget,
+                                  const gchar        *detail,
+                                  gint                y1_,
+                                  gint                y2_,
+                                  gint                x);
+void gtk_cairo_paint_vline       (GtkStyle           *style,
+                                  cairo_t            *cr,
+                                  GtkStateType        state_type,
+                                  GtkWidget          *widget,
+                                  const gchar        *detail,
+                                  gint                y1_,
+                                  gint                y2_,
+                                  gint                x);
 void gtk_paint_shadow      (GtkStyle           *style,
                            GdkWindow          *window,
                            GtkStateType        state_type,
index 74007b6b682b2931c8af3a44433325ac6458066d..f1f3c5b9b48125c06372116cecc62b5b0b0b557e 100644 (file)
@@ -418,9 +418,8 @@ draw_hline (GtkStyle     *style,
 
 static void
 draw_vline (GtkStyle     *style,
-           GdkWindow    *window,
+           cairo_t      *cr,
            GtkStateType  state,
-           GdkRectangle *area,
            GtkWidget    *widget,
            const gchar  *detail,
            gint          y1,
@@ -430,9 +429,6 @@ draw_vline (GtkStyle     *style,
   ThemeImage    *image;
   ThemeMatchData match_data;
   
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (window != NULL);
-
   match_data.function = TOKEN_D_VLINE;
   match_data.detail = (gchar *)detail;
   match_data.flags = THEME_MATCH_ORIENTATION | THEME_MATCH_STATE;
@@ -443,12 +439,12 @@ draw_vline (GtkStyle     *style,
   if (image)
     {
       if (image->background)
-       theme_pixbuf_render_no_cairo (image->background,
-                            window, area, COMPONENT_ALL, FALSE,
+       theme_pixbuf_render (image->background,
+                            cr, COMPONENT_ALL, FALSE,
                             x, y1, 2, (y2 - y1) + 1);
     }
   else
-    parent_class->draw_vline (style, window, state, area, widget, detail,
+    parent_class->draw_vline (style, cr, state, widget, detail,
                              y1, y2, x);
 }