]> Pileus Git - ~andy/gtk/commitdiff
style: Convert draw_tab vfunc to Cairo version
authorBenjamin Otte <otte@redhat.com>
Mon, 16 Aug 2010 20:10:00 +0000 (22:10 +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 5ddbdeb56afcc2cb16a1c49bbc369fc64e47f40a..d4bbef0c5f1c509460e9ccdfea46a248793ff10c 100644 (file)
@@ -189,10 +189,9 @@ static void gtk_default_draw_option     (GtkStyle        *style,
                                         gint             width,
                                         gint             height);
 static void gtk_default_draw_tab        (GtkStyle        *style,
-                                        GdkWindow       *window,
+                                        cairo_t         *cr,
                                         GtkStateType     state_type,
                                         GtkShadowType    shadow_type,
-                                        GdkRectangle    *area,
                                         GtkWidget       *widget,
                                         const gchar     *detail,
                                         gint             x,
@@ -3000,10 +2999,9 @@ gtk_default_draw_option (GtkStyle      *style,
 
 static void
 gtk_default_draw_tab (GtkStyle      *style,
-                     GdkWindow     *window,
+                     cairo_t       *cr,
                      GtkStateType   state_type,
                      GtkShadowType  shadow_type,
-                     GdkRectangle  *area,
                      GtkWidget     *widget,
                      const gchar   *detail,
                      gint           x,
@@ -3013,19 +3011,10 @@ gtk_default_draw_tab (GtkStyle      *style,
 {
 #define ARROW_SPACE 4
 
-  cairo_t *cr;
   GtkRequisition indicator_size;
   GtkBorder indicator_spacing;
   gint arrow_height;
 
-  cr = gdk_cairo_create (window);
-
-  if (area)
-    {
-      gdk_cairo_rectangle (cr, area);
-      cairo_clip (cr);
-    }
-
   option_menu_get_props (widget, &indicator_size, &indicator_spacing);
 
   indicator_size.width += (indicator_size.width % 2) - 1;
@@ -3053,8 +3042,6 @@ gtk_default_draw_tab (GtkStyle      *style,
   draw_arrow (cr, &style->fg[state_type],
              GTK_ARROW_DOWN, x, y + arrow_height + ARROW_SPACE,
              indicator_size.width, arrow_height);
-
-  cairo_destroy (cr);
 }
 
 static void 
@@ -5492,13 +5479,60 @@ gtk_paint_tab (GtkStyle           *style,
                gint                width,
                gint                height)
 {
+  cairo_t *cr;
+
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
 
-  GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type,
-                                         (GdkRectangle *) area, widget, detail,
+  cr = gtk_style_cairo_create (window, area);
+
+  gtk_cairo_paint_tab (style, cr, state_type, shadow_type,
+                       widget, detail,
+                       x, y, width, height);
+
+  cairo_destroy (cr);
+}
+
+/**
+ * gtk_cairo_paint_tab:
+ * @style: a #GtkStyle
+ * @cr: a #cairo_t
+ * @state_type: a state
+ * @shadow_type: the type of shadow to draw
+ * @widget: (allow-none): the widget
+ * @detail: (allow-none): a style detail
+ * @x: x origin of the rectangle to draw the tab in
+ * @y: y origin of the rectangle to draw the tab in
+ * @width: the width of the rectangle to draw the tab in
+ * @height: the height of the rectangle to draw the tab in
+ *
+ * Draws an option menu tab (i.e. the up and down pointing arrows)
+ * in the given rectangle on @cr using the given parameters.
+ */ 
+void
+gtk_cairo_paint_tab (GtkStyle           *style,
+                     cairo_t            *cr,
+                     GtkStateType        state_type,
+                     GtkShadowType       shadow_type,
+                     GtkWidget          *widget,
+                     const gchar        *detail,
+                     gint                x,
+                     gint                y,
+                     gint                width,
+                     gint                height)
+{
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
+  g_return_if_fail (cr != NULL);
+
+  cairo_save (cr);
+
+  GTK_STYLE_GET_CLASS (style)->draw_tab (style, cr, state_type, shadow_type,
+                                         widget, detail,
                                          x, y, width, height);
+
+  cairo_restore (cr);
 }
 
 /**
index 27d7414400ac178e0f4b57f6cdb99ebf43f6aeff..d51e1ef3267ef53562c2b1031691b79b02e3a473 100644 (file)
@@ -254,10 +254,9 @@ struct _GtkStyleClass
                                 gint                    width,
                                 gint                    height);
   void (*draw_tab)             (GtkStyle               *style,
-                                GdkWindow              *window,
+                                cairo_t                *cr,
                                 GtkStateType            state_type,
                                 GtkShadowType           shadow_type,
-                                GdkRectangle           *area,
                                 GtkWidget              *widget,
                                 const gchar            *detail,
                                 gint                    x,
@@ -630,17 +629,27 @@ void gtk_cairo_paint_option      (GtkStyle           *style,
                                   gint                y,
                                   gint                width,
                                   gint                height);
-void gtk_paint_tab         (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);
+void gtk_paint_tab               (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);
+void gtk_cairo_paint_tab         (GtkStyle           *style,
+                                  cairo_t            *cr,
+                                  GtkStateType        state_type,
+                                  GtkShadowType       shadow_type,
+                                  GtkWidget          *widget,
+                                  const gchar        *detail,
+                                  gint                x,
+                                  gint                y,
+                                  gint                width,
+                                  gint                height);
 void gtk_paint_shadow_gap  (GtkStyle           *style,
                            GdkWindow          *window,
                            GtkStateType        state_type,
index 8e6bc84b68383bef16c0eb51830538d79c2a27b1..2cfae28a2640cf916b649b722e859b094d9da58a 100644 (file)
@@ -741,10 +741,9 @@ draw_option (GtkStyle     *style,
 
 static void
 draw_tab (GtkStyle     *style,
-         GdkWindow    *window,
+         cairo_t      *cr,
          GtkStateType  state,
          GtkShadowType shadow,
-         GdkRectangle *area,
          GtkWidget    *widget,
          const gchar  *detail,
          gint          x,
@@ -754,18 +753,15 @@ draw_tab (GtkStyle     *style,
 {
   ThemeMatchData match_data;
   
-  g_return_if_fail(style != NULL);
-  g_return_if_fail(window != NULL);
-
   match_data.function = TOKEN_D_TAB;
   match_data.detail = (gchar *)detail;
   match_data.flags = THEME_MATCH_SHADOW | THEME_MATCH_STATE;
   match_data.shadow = shadow;
   match_data.state = state;
   
-  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_tab (style, window, state, shadow, area, widget, detail,
+    parent_class->draw_tab (style, cr, state, shadow, widget, detail,
                            x, y, width, height);
 }