Re: XForms: object class with canvas object

Steve Lamont (
Mon, 9 Mar 98 06:59:16 PST

# To subscribers of the xforms list from (Steve Lamont) :

> i've been using a browser constructed using a canvas and sliders. Now
> there're problems in trying to turn it into a new object class.
> Problem: the object is added to a form before the form is shown.
> where do i obtain the WIndow ID of the canvas object prior to
> the form being displayed? Windowatrributes etc have to set for
> the canvas when the new browser object is added to a form.

Basically, you can't since there is no Window XID for the canvas at
this point.

Presumably what you're trying to do is to create the Canvas's child
Window. You need to defer this until the Canvas Window itself is
created. What I do is to register an activate callback with the
fl_modify_canvas_prop() function and then do my XCreateWindow() and
XMapWindow() calls in the activate callback when everything has been
finally realized.

I have a more or less working Scrolling Canvas (although it isn't in
the form of an XForms object).

The following is my activate routine:

static int activate_canvas( FL_OBJECT *canvas )


Window window;
XVisualInfo *xvinfo = fl_state[fl_get_vclass()].xvinfo;
Colormap colormap = DefaultColormap( fl_get_display(),
DefaultScreen( fl_get_display() ) );

window = XCreateSimpleWindow( fl_get_display(),
FL_ObjWin( canvas ),
0, 0,
IW, IH, 0,
fl_get_pixel( FL_BLACK ),
fl_get_pixel( FL_BLUE ) );
XMapWindow( fl_get_display(), window );

canvas->u_ldata = ( long ) window;

return 0;


Since it was written for a specific application I didn't bother to
make it as general as it should be (for instance, it uses #defined
values for width and height and makes some assumptions about what kind
of environment its operating in) but this might be useful to get started.

To unsubscribe, send the message "unsubscribe" to or see
XForms Home Page:
List Archive: