Re: XForms: Canvases and positioners...

Steve Lamont (spl@szechuan.ucsd.edu)
Tue, 10 Nov 98 06:48:40 PST

# To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> What I mean is nothing happens! It's as if there wasn't a positioner
> there, and I've even tried fl_show_object after I show the form just
> in case - not even the crosshair shows. I went to sleep last night (remember
> - I live in Portugal...) having second thoughts about using the canvas for
> my magnified images - perhaps I would be better off using a pixmap...
> Anyhow, I would like to know what's happening.

Remember that the Canvas is actually just a raw X Window positioned
"floating" on top of your Form. It is going to obscure anything that
is drawn, including the Positioner object. Even reordering the
drawing order will have no effect since the Positioner is drawn on the
XForms managed Window. You can't draw on two Windows at once.

If you want to create a crosshair on a Canvas, you're going to have to
draw your own using either the XForms provided drawing functions
(refer to the chapter "Drawing Objects" in your manual) or use the raw
Xlib functions.

As to the advisability of using a Canvas vs. using a Pixmap, that's
really driven by your application. You can certainly use a Pixmap but
this may not give you the interactivity you want, since you'll be in
essence doing a double copy -- first to the Pixmap and then from the
Pixmap to the Form, since XForms does not create a subwindow for the
Pixmap region on the screen.

One trick I like to use when dealing with images is to create a Canvas
object and attach a background Pixmap to it (see the Xlib function
XSetWindowBackgroundPixmap()). I can then draw to the Window with my
favorite Xlib drawing functions, right on top of the Pixmap. This
only alters the image displayed and not the Pixmap. To get rid of
whatever I've drawn, I simply call XClearWindow() with the Canvas
Window as the argument. The background Pixmap is then automagically
redrawn by the server without any further intervention on the part of
my program.

A crosshair could be easily drawn by a couple of XDrawLine() functions
or a single XDrawSegments() call. See your handy Xlib manual for the
details.

spl

_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/