Re: Redrawing drawing_area
- From: rsmith xs4all nl
- To: prs sitkom sdu dk
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Redrawing drawing_area
- Date: Sat, 21 Oct 2000 22:41:59 +0200 (CEST)
On 19 Oct, Peter R. Skadhauge wrote:
Hi,
How can I redraw a drawing area whose content has
changed? That is, how can I manually trigger a configure_event?
There are at least two ways, but using configure events is not one of them.
You can clear the drawing area with gdk_draw_rectangle, and use the
gdk_draw_* calls on the drawingarea->window, but this can produce visible
flicker.
So what I prefer is to use a pixmap, on which one can also draw using the
gdk_draw_* calls, and then use gdk_draw_pixmap to copy the pixmap to the
drawingarea. The expose callback also does that:
gint
drawing_area_expose (GtkWidget *widget,
GdkEventExpose *event, gpointer data)
{
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);
return FALSE;
}
The pixmap is created in the configure event callback:
gint
drawing_area_configure (GtkWidget *widget,
GdkEventConfigure *event, gpointer data)
{
if (pixmap) {
gdk_pixmap_unref (pixmap);
}
pixmap = gdk_pixmap_new (widget->window,
widget->allocation.width,
widget->allocation.height,
-1);
gdk_draw_rectangle (pixmap,
widget->style->black_gc,
TRUE,
0, 0,
widget->allocation.width,
widget->allocation.height);
return TRUE;
}
HTH,
Roland
--
Roland Smith "When life hands you a lemon,
r s m i t h @ x s 4 a l l . n l make lemonade."
http://www.xs4all.nl/~rsmith/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]