Re: drawing



On Fri, 2 May 2003 18:31:31 +1000
Ivo Andrejco <andrejcoivo yahoo com au> wrote:

Hi there,

I was wondering if someone could help.

when I(user using mouse) draw on drawing area and then resize everything
disappears. I roughly understand why. My question is how to store data so it
does not disappear between expose events. I means it's easy to redraw what the
application draws but how to handle user drawing.

That depends if your application is used for drawing pixels, or if you're
drawing resolution independent lines, circles, curves etc.

If you're just drawing pixels (like the GIMP), look at the "scribble" example
that comes with GTK+. Although you might have to use a pixbuf instead of a
pixmap for easier scaling when you resize the drawing-area.

If you're doing resolution independent drawing (like Xfig), you have to recreate
the image when you resize the drawing area. In that case you should create a
"display list". That's a list of all the drawing actions that the user has
carried out, e.g. lines, circles etc, with all the coordinates converted to some
"world" coordinate space. Every time te user draws something, it's added to the
list. If the window is resized, you just walk the list in the expose event
handler, and redraw all the elements, while converting their coordinates to the
new drawing area size.

HTH, Roland
-- 
R.F. Smith                           /"\    ASCII Ribbon Campaign
r s m i t h @ x s 4 a l l . n l      \ /    No HTML/RTF in email
http://www.xs4all.nl/~rsmith/         X     No Word docs in email
                                     / \    Respect for open standards

Attachment: pgpZUSHwDBL7J.pgp
Description: PGP signature



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