[gtk+/cairo-style: 14/21] style: Convert draw_extension vfunc to Cairo version



commit 5e5933de92fa4c8f45a295f155f0e3a3cd880c8e
Author: Benjamin Otte <otte redhat com>
Date:   Mon Aug 16 22:19:56 2010 +0200

    style: Convert draw_extension vfunc to Cairo version

 gtk/gtkstyle.c |   76 ++++++++++++++++++++++++++++++++++++++++++--------------
 gtk/gtkstyle.h |   38 +++++++++++++++++----------
 2 files changed, 81 insertions(+), 33 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index 68e2259..f8b1776 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -225,10 +225,9 @@ static void gtk_default_draw_box_gap    (GtkStyle        *style,
 					 gint             gap_x,
 					 gint             gap_width);
 static void gtk_default_draw_extension  (GtkStyle        *style,
-					 GdkWindow       *window,
+					 cairo_t         *cr,
 					 GtkStateType     state_type,
 					 GtkShadowType    shadow_type,
-					 GdkRectangle    *area,
 					 GtkWidget       *widget,
 					 const gchar     *detail,
 					 gint             x,
@@ -3429,10 +3428,9 @@ gtk_default_draw_box_gap (GtkStyle       *style,
 
 static void 
 gtk_default_draw_extension (GtkStyle       *style,
-                            GdkWindow      *window,
+                            cairo_t        *cr,
                             GtkStateType    state_type,
                             GtkShadowType   shadow_type,
-                            GdkRectangle   *area,
                             GtkWidget      *widget,
                             const gchar    *detail,
                             gint            x,
@@ -3441,21 +3439,12 @@ gtk_default_draw_extension (GtkStyle       *style,
                             gint            height,
                             GtkPositionType gap_side)
 {
-  cairo_t *cr;
+  GdkWindow *window = gtk_widget_get_window (widget);
   GdkColor color1;
   GdkColor color2;
   GdkColor color3;
   GdkColor color4;
   
-  sanitize_size (window, &width, &height);
-
-  cr = gdk_cairo_create (window);
-  if (area)
-    {
-      gdk_cairo_rectangle (cr, area);
-      cairo_clip (cr);
-    }
-  
   switch (gap_side)
     {
     case GTK_POS_TOP:
@@ -3495,7 +3484,6 @@ gtk_default_draw_extension (GtkStyle       *style,
   switch (shadow_type)
     {
     case GTK_SHADOW_NONE:
-      cairo_destroy (cr);
       return;
     case GTK_SHADOW_IN:
       color1 = style->dark[state_type];
@@ -3596,8 +3584,6 @@ gtk_default_draw_extension (GtkStyle       *style,
           break;
         }
     }
-
-  cairo_destroy (cr);
 }
 
 static void 
@@ -5735,13 +5721,65 @@ gtk_paint_extension (GtkStyle           *style,
                      gint                height,
                      GtkPositionType     gap_side)
 {
+  cairo_t *cr;
+
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
 
-  GTK_STYLE_GET_CLASS (style)->draw_extension (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_extension (style, cr, state_type, shadow_type,
+                             widget, detail,
+                             x, y, width, height, gap_side);
+
+  cairo_destroy (cr);
+}
+
+/**
+ * gtk_cairo_paint_extension: 
+ * @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 extension
+ * @y: y origin of the extension
+ * @width: width of the extension
+ * @height: width of the extension
+ * @gap_side: the side on to which the extension is attached
+ * 
+ * Draws an extension, i.e. a notebook tab.
+ **/
+void
+gtk_cairo_paint_extension (GtkStyle           *style,
+                           cairo_t            *cr,
+                           GtkStateType        state_type,
+                           GtkShadowType       shadow_type,
+                           GtkWidget          *widget,
+                           const gchar        *detail,
+                           gint                x,
+                           gint                y,
+                           gint                width,
+                           gint                height,
+                           GtkPositionType     gap_side)
+{
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != 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_extension (style, cr, state_type, shadow_type,
+                                               widget, detail,
                                                x, y, width, height, gap_side);
+
+  cairo_restore (cr);
 }
 
 /**
diff --git a/gtk/gtkstyle.h b/gtk/gtkstyle.h
index 6f1df84..449dc0e 100644
--- a/gtk/gtkstyle.h
+++ b/gtk/gtkstyle.h
@@ -290,10 +290,9 @@ struct _GtkStyleClass
 				 gint			 gap_x,
 				 gint			 gap_width);
   void (*draw_extension)	(GtkStyle		*style,
-				 GdkWindow		*window,
+				 cairo_t                *cr,
 				 GtkStateType		 state_type,
 				 GtkShadowType		 shadow_type,
-				 GdkRectangle		*area,
 				 GtkWidget		*widget,
 				 const gchar		*detail,
 				 gint			 x,
@@ -702,18 +701,29 @@ void gtk_cairo_paint_box_gap     (GtkStyle           *style,
                                   GtkPositionType     gap_side,
                                   gint                gap_x,
                                   gint                gap_width);
-void gtk_paint_extension   (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,
-			    GtkPositionType     gap_side);
+void gtk_paint_extension         (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,
+                                  GtkPositionType     gap_side);
+void gtk_cairo_paint_extension   (GtkStyle           *style,
+                                  cairo_t            *cr,
+                                  GtkStateType        state_type,
+                                  GtkShadowType       shadow_type,
+                                  GtkWidget          *widget,
+                                  const gchar        *detail,
+                                  gint                x,
+                                  gint                y,
+                                  gint                width,
+                                  gint                height,
+                                  GtkPositionType     gap_side);
 void gtk_paint_focus       (GtkStyle           *style,
 			    GdkWindow          *window,
 			    GtkStateType        state_type,



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