[gtk+/rendering-cleanup: 55/141] API: Add gtk_cell_renderer_render_cairo()



commit 66ebc7e93a5914c6bf892d0d670b26ed5b9984f5
Author: Benjamin Otte <otte redhat com>
Date:   Sun Aug 22 03:53:45 2010 +0200

    API: Add gtk_cell_renderer_render_cairo()
    
    It's like gtk_cell_renderer_render(), just cooler.

 gtk/gtkcellrenderer.c |   53 ++++++++++++++++++++++++++++++++++++++++++++----
 gtk/gtkcellrenderer.h |    6 +++++
 2 files changed, 54 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkcellrenderer.c b/gtk/gtkcellrenderer.c
index f029852..bd2c6ae 100644
--- a/gtk/gtkcellrenderer.c
+++ b/gtk/gtkcellrenderer.c
@@ -639,19 +639,62 @@ gtk_cell_renderer_render (GtkCellRenderer      *cell,
 			  const GdkRectangle   *expose_area,
 			  GtkCellRendererState  flags)
 {
-  gboolean selected = FALSE;
-  GtkCellRendererPrivate *priv = cell->priv;
   cairo_t *cr;
 
   g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
   g_return_if_fail (GTK_CELL_RENDERER_GET_CLASS (cell)->render != NULL);
 
-  selected = (flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED;
-
   cr = gdk_cairo_create (window);
   gdk_cairo_rectangle (cr, expose_area);
   cairo_clip (cr);
 
+  gtk_cell_renderer_render_cairo (cell,
+                                  cr,
+                                  widget,
+                                  background_area,
+                                  cell_area,
+                                  flags);
+
+  cairo_destroy (cr);
+}
+
+/**
+ * gtk_cell_renderer_render_cairo:
+ * @cell: a #GtkCellRenderer
+ * @cr: a cairo context to draw to
+ * @widget: the widget owning @window
+ * @background_area: entire cell area (including tree expanders and maybe 
+ *    padding on the sides)
+ * @cell_area: area normally rendered by a cell renderer
+ * @flags: flags that affect rendering
+ *
+ * Invokes the virtual render function of the #GtkCellRenderer. The three
+ * passed-in rectangles are areas in @cr. Most renderers will draw within
+ * @cell_area; the xalign, yalign, xpad, and ypad fields of the #GtkCellRenderer
+ * should be honored with respect to @cell_area. @background_area includes the
+ * blank space around the cell, and also the area containing the tree expander;
+ * so the @background_area rectangles for all cells tile to cover the entire
+ * @window.
+ **/
+void
+gtk_cell_renderer_render_cairo (GtkCellRenderer      *cell,
+                                cairo_t              *cr,
+                                GtkWidget            *widget,
+                                const GdkRectangle   *background_area,
+                                const GdkRectangle   *cell_area,
+                                GtkCellRendererState  flags)
+{
+  gboolean selected = FALSE;
+  GtkCellRendererPrivate *priv = cell->priv;
+
+  g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
+  g_return_if_fail (GTK_CELL_RENDERER_GET_CLASS (cell)->render != NULL);
+  g_return_if_fail (cr != NULL);
+
+  selected = (flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED;
+
+  cairo_save (cr);
+
   if (priv->cell_background_set && !selected)
     {
       gdk_cairo_rectangle (cr, background_area);
@@ -666,7 +709,7 @@ gtk_cell_renderer_render (GtkCellRenderer      *cell,
 					      cell_area,
 					      flags);
 
-  cairo_destroy (cr);
+  cairo_restore (cr);
 }
 
 /**
diff --git a/gtk/gtkcellrenderer.h b/gtk/gtkcellrenderer.h
index 94ce0c5..ef49aa1 100644
--- a/gtk/gtkcellrenderer.h
+++ b/gtk/gtkcellrenderer.h
@@ -124,6 +124,12 @@ void             gtk_cell_renderer_render         (GtkCellRenderer      *cell,
 						   const GdkRectangle   *cell_area,
 						   const GdkRectangle   *expose_area,
 						   GtkCellRendererState  flags);
+void             gtk_cell_renderer_render_cairo   (GtkCellRenderer      *cell,
+                                                   cairo_t              *cr,
+						   GtkWidget            *widget,
+						   const GdkRectangle   *background_area,
+						   const GdkRectangle   *cell_area,
+						   GtkCellRendererState  flags);
 gboolean         gtk_cell_renderer_activate       (GtkCellRenderer      *cell,
 						   GdkEvent             *event,
 						   GtkWidget            *widget,



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