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



commit 9d9c6273e71ac259fbeddc56623cd217295a790d
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                      |   38 ++++++++++++++++++++++++++++++++++
 gtk/gtkwidget.h                      |    2 +
 4 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index a3926b8..5bcb6d2 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 f1857cf..4aa905a 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 d0dc47f..99b2532 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -4731,6 +4731,44 @@ _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 and the widget's
+ * size will be the width and height as returned by
+ * gtk_widget_get_allocation().
+ *
+ * <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 e5b50de..6f9a321 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -517,6 +517,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]