configure_event( GtkWidget *widget, GdkEventConfigure *event )
{
if (pixmap)
- gdk_pixmap_unref(pixmap);
+ g_object_unref(pixmap);
pixmap = gdk_pixmap_new(widget->window,
widget->allocation.width,
static gboolean
expose_event( GtkWidget *widget, GdkEventExpose *event )
{
- gdk_draw_pixmap(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
- pixmap,
- event->area.x, event->area.y,
- event->area.x, event->area.y,
- event->area.width, event->area.height);
+ gdk_draw_drawable(widget->window,
+ widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
+ pixmap,
+ event->area.x, event->area.y,
+ event->area.x, event->area.y,
+ event->area.width, event->area.height);
return FALSE;
}
<emphasis>drawables</emphasis>. A drawable is simply something that can be drawn
upon. It can be a window, a pixmap, or a bitmap (a black and white
image). We've already seen two such calls above,
-<literal>gdk_draw_rectangle()</literal> and <literal>gdk_draw_pixmap()</literal>. The
+<literal>gdk_draw_rectangle()</literal> and <literal>gdk_draw_drawable()</literal>. The
complete list is:</para>
<programlisting role="C">
+gdk_draw_point ()
gdk_draw_line ()
gdk_draw_rectangle ()
gdk_draw_arc ()
gdk_draw_polygon ()
-gdk_draw_string ()
-gdk_draw_text ()
gdk_draw_pixmap ()
gdk_draw_bitmap ()
gdk_draw_image ()
gdk_draw_points ()
gdk_draw_segments ()
+gdk_draw_lines ()
+gdk_draw_pixbuf ()
+gdk_draw_glyphs ()
+gdk_draw_layout_line ()
+gdk_draw_layout ()
+gdk_draw_layout_line_with_colors ()
+gdk_draw_layout_with_colors ()
+gdk_draw_glyphs_transformed ()
+gdk_draw_glyphs_trapezoids ()
</programlisting>
<para>See the reference documentation or the header file
-<literal><gdk/gdk.h></literal> for further details on these functions.
+<literal><gdk/gdkdrawable.h></literal> for further details on these functions.
These functions all share the same first two arguments. The first
argument is the drawable to draw upon, the second argument is a
-<emphasis>graphics context</emphasis> (GC). </para>
+<emphasis>graphics context</emphasis> (GC).</para>
<para>A graphics context encapsulates information about things such as
foreground and background color and line width. GDK has a full set of
update_rect.width = 10;
update_rect.height = 10;
gdk_draw_rectangle (pixmap,
- widget->style->black_gc,
- TRUE,
+ widget->style->black_gc,
+ TRUE,
update_rect.x, update_rect.y,
update_rect.width, update_rect.height);
- gtk_widget_draw (widget, &update_rect);
+ gtk_widget_queue_draw_area (widget,
+ update_rect.x, update_rect.y,
+ update_rect.width, update_rect.height);
}
</programlisting>
we call the function:</para>
<programlisting role="C">
-void gtk_widget_draw (GtkWidget *widget,
- GdkRectangle *area);
+void gtk_widget_queue_draw_area (GtkWidget *widget,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
</programlisting>
-<para>which notifies X that the area given by the <literal>area</literal> parameter
+<para>which notifies X that the area given by the <literal>x</literal>,
+<literal>y</literal>, <literal>width</literal> and <literal>height</literal> parameters
needs to be updated. X will eventually generate an expose event
(possibly combining the areas passed in several calls to
-<literal>gtk_widget_draw()</literal>) which will cause our expose event handler
+<literal>gtk_widget_queue_draw_area()</literal>) which will cause our expose event handler
to copy the relevant portions to the screen.</para>
<para>We have now covered the entire drawing program except for a few
update_rect.x, update_rect.y,
update_rect.width, update_rect.height);
gtk_widget_queue_draw_area (widget,
- update_rect.x, update_rect.y,
- update_rect.width, update_rect.height);
+ update_rect.x, update_rect.y,
+ update_rect.width, update_rect.height);
}
static gboolean button_press_event( GtkWidget *widget,