[gtk+/cairo-style: 3/21] style: Convert draw_vline vfunc to a Cairo version



commit 91bb17633a5e805b496884318d95b7e1f1c65aff
Author: Benjamin Otte <otte redhat com>
Date:   Mon Aug 16 15:40:03 2010 +0200

    style: Convert draw_vline vfunc to a Cairo version

 gtk/gtkstyle.c |   65 +++++++++++++++++++++++++++++++++++++++++--------------
 gtk/gtkstyle.h |   29 +++++++++++++++---------
 2 files changed, 66 insertions(+), 28 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index 8cdbff9..cb0be83 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -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,
@@ -1686,17 +1685,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;
@@ -1704,15 +1701,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],
@@ -1729,8 +1719,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
@@ -4890,13 +4878,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);
 }
 
 /**
diff --git a/gtk/gtkstyle.h b/gtk/gtkstyle.h
index 382c67a..d26b012 100644
--- a/gtk/gtkstyle.h
+++ b/gtk/gtkstyle.h
@@ -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,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]