On Sun, 20 Feb 2005 05:42:45 +0800 roronoa zorro wrote:
> Does anybody know how to implement a drag-line function with drawing area? 
> What i want is to draw a line from the start point to the current point in 
> motion_notify_event. However, if i add the draw method in 
> motion_notify_event it will draw lines from the start point to all the 
> points that the mouse passes by. Is is possible to delete the previous 
> lines and only display the connection with the current one?

Create an offscreen pixmap.  With each motion-notify-event: Clear the
offscreen pixmap, draw from the start point to the current point in the
offscreen pixmap, copy the offscreen pixmap to the drawing area.  This
is called double buffering and serves two purposes.  First, by clearing
the offscreen pixmap you effectively clear the last line drawn.  Second,
you avoid flickering that can happen if you try to clear and draw
directly in the drawing area.

Many apps use this technique.  I use it in my Graphics Muse Tools (which
are GIMP plugins using GTK+).  The GFXLayers and GFXShapes are examples
of how it works.
http://www.ximba.org/gfxmuse/download.html

-- 
Michael J. Hammel - [EMAIL PROTECTED] - XEUS: www.ximba.org
---------------------------------------------------------------------
Truth is stranger than fiction, but fiction is cheaper and faster than truth.

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to