RE: XForms: Drawing problem

Michael Glickman (michaelg@linx.com.au)
Mon, 1 Nov 1999 13:03:49 +1100

# To subscribers of the xforms list from Michael Glickman <michaelg@linx.com.au> :

Hello, Marien

XDrawPoints just plots the points, but
does not store it anywhere. Therefore,
you need to call draw_triangle whenever
the window needs to be refreshed.
This can be done in the form event
handler on receipt of an Expose event.

Unfortunately, I don't keep XForms
demos. Check if freedraw.c has an
event hadler to process Expose-s.
It if has, I have no further comments,
if it doesn't - I can't understand how
the original program worked...

Regards, Michael

> -----Original Message-----
> From: Marien van Westen [SMTP:myrnout@hetnet.nl]
> Sent: Sunday, 31 October 1999 23:37 EST
> To: xforms@bob.usuhs.mil
> Subject: XForms: Drawing problem
>
> # To subscribers of the xforms list from Marien van Westen
> <myrnout@hetnet.nl> :
>
> Hello,
>
> Being rather new to the Xforms programming I start with working
> programs
> from the /DEMOS directory and change some lines.
> In the freedraw.c program I changed the following routine:
>
> void draw_triangle(int fill, int x, int y, int w, int h, unsigned long
> col)
> {
> XPoint xpoint[4];
> GC gc = fl_state[fl_vmode].gc[0];
> Window win = fl_winget();
>
> xpoint[0].x = x; xpoint[0].y = y + h - 1;
> xpoint[1].x = x + w/2; xpoint[1].y = y;
> xpoint[2].x = x + w - 1; xpoint[2].y = y + h - 1;
> XSetForeground(dpy, gc, fl_get_pixel(col));
>
> if(fill)
> XFillPolygon (dpy, win, gc, xpoint, 3, Nonconvex, Unsorted);
> else
> {
> xpoint[3].x = xpoint[0].x; xpoint[3].y = xpoint[0].y;
> XDrawLines(dpy, win, gc, xpoint, 4, CoordModeOrigin);
> }
> }
>
> Into this one:
>
> void draw_triangle(int fill, int x, int y, int w, int h, unsigned long
> col)
> /* Draws Sierpinski Triangle */
> {
> int xp, yp, i, n ;
> XPoint xpoint[5000];
> GC gc = fl_state[fl_vmode].gc[0];
> Window win = fl_winget();
> xpoint[0].x = x; xpoint[0].y = y + h - 1;
> xpoint[1].x = x + w/2; xpoint[1].y = y;
> xpoint[2].x = x + w - 1; xpoint[2].y = y + h - 1;
> XSetForeground(dpy, gc, fl_get_pixel(col));
> xp=xpoint[1].x ; yp=xpoint[1].y;
> for (i= 3; i<5000; i++)
> {
> n = rand() % 3 ;
> xp = floor((xpoint[n].x+xp)/2);
> yp = floor((xpoint[n].y+yp)/2);
> xpoint[i].x = xp; xpoint[i].y = yp;
> }
> XDrawPoints(dpy, win, gc, xpoint, 5000, CoordModeOrigin);
> }
>
> The routine does what it should do (push the triangle button with
> Width
> and Height set to maximum value to see what happens).
> But when I change to another desktop and then return back to the
> desktop where this program runs,
> some strange things happen. The triangle button has
> changed shape and the "outline" button has moved.
> Trying to resize the window causes Xwindows to crash (happens with
> KDE,
> Fvwm2 and icewm in the same way).
>
> Can anybody tell me what I am doing wrong? I am using version 0.88 of
> the library.
>
> Marien van Westen (myrnout@hetnet.nl)
>
> _________________________________________________
> To unsubscribe, send the message "unsubscribe" to
> xforms-request@bob.usuhs.mil or see
> http://bob.usuhs.mil/mailserv/xforms.html
> XForms Home Page: http://bragg.phys.uwm.edu/xforms
> List Archive: http://bob.usuhs.mil/mailserv/list-archives/
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/