[gtk+/rendering-cleanup-next: 154/155] API: Add gtk_widget_draw()



commit 1e0a65e989fb0bca8f8e63c47fbe3dae41916f7b
Author: Benjamin Otte <otte redhat com>
Date:   Sat Sep 11 05:19:28 2010 +0200

    API: Add gtk_widget_draw()
    
    And here's the final patch that all the previous patches were about.

 docs/reference/gtk/gtk3-sections.txt |    1 +
 gtk/gtk.symbols                      |    1 +
 gtk/gtkwidget.c                      |   47 ++++++++++++++++++++++++++++++++++
 gtk/gtkwidget.h                      |    2 +
 4 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index 8171078..d48d952 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -4772,6 +4772,7 @@ gtk_widget_map
 gtk_widget_unmap
 gtk_widget_realize
 gtk_widget_unrealize
+gtk_widget_draw
 gtk_widget_queue_draw
 gtk_widget_queue_resize
 gtk_widget_queue_resize_no_redraw
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index c2b6353..cdc3698 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -4198,6 +4198,7 @@ gtk_widget_create_pango_context
 gtk_widget_create_pango_layout
 gtk_widget_destroy
 gtk_widget_destroyed
+gtk_widget_draw
 gtk_widget_ensure_style
 gtk_widget_error_bell
 gtk_widget_event
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 107403c..00922c0 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -5115,6 +5115,53 @@ _gtk_widget_draw_internal (GtkWidget *widget,
     }
 }
 
+/**
+ * gtk_widget_draw:
+ * @widget: the widget to draw. It must be drawable (see 
+ *   gtk_widget_is_drawable()) and a size must have been allocated.
+ * @cr: a cairo context to draw to
+ *
+ * Draws @widget to @cr. The top left corner of the widget will be
+ * drawn to the currently set origin point of @cr.
+ *
+ * You should pass a cairo context as @cr argument that is in an
+ * original state. Otherwise the resulting drawing is undefined. For
+ * example changing the operator using cairo_set_operator() or the
+ * line width using cairo_set_line_width() might have unwanted side
+ * effects.
+ * You may however change the context's transform matrix - like with
+ * cairo_scale(), cairo_translate() or cairo_set_matrix() and clip
+ * region with cairo_clip() prior to calling this function. Also, it
+ * is fine to modify the context with cairo_save() and
+ * cairo_push_group() prior to calling this function.
+ *
+ * <note><para>Special purpose widgets may contain special code for
+ * rendering to the screen and might appear differently on screen
+ * and when rendered using gtk_widget_draw().</para></note>
+ **/
+void
+gtk_widget_draw (GtkWidget *widget,
+                 cairo_t   *cr)
+{
+  GdkEventExpose *tmp_event;
+
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (cr != NULL);
+
+  cairo_save (cr);
+  /* We have to reset the event here so that draw functions can call
+   * gtk_widget_draw() on random other widgets and get the desired
+   * effect: Drawing all contents, not just the current window.
+   */
+  tmp_event = _gtk_cairo_get_event (cr);
+  gtk_cairo_set_event (cr, NULL);
+
+  _gtk_widget_draw_internal (widget, cr, TRUE);
+
+  gtk_cairo_set_event (cr, tmp_event);
+  cairo_restore (cr);
+}
+
 static gboolean
 gtk_widget_real_key_press_event (GtkWidget         *widget,
 				 GdkEventKey       *event)
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 7cf6d6b..e0c900d 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -529,6 +529,8 @@ void	   gtk_widget_unmap		  (GtkWidget	       *widget);
 void	   gtk_widget_realize		  (GtkWidget	       *widget);
 void	   gtk_widget_unrealize		  (GtkWidget	       *widget);
 
+void       gtk_widget_draw                (GtkWidget           *widget,
+                                           cairo_t             *cr);
 /* Queuing draws */
 void	   gtk_widget_queue_draw	  (GtkWidget	       *widget);
 void	   gtk_widget_queue_draw_area	  (GtkWidget	       *widget,



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