Re: XForms: more on formbrowser and image form

From: Steve Lamont (spl@szechuan.ucsd.edu)
Date: Tue May 09 2000 - 17:41:44 EDT

  • Next message: jprinos@dehavilland.ca: "Re: XForms: more on formbrowser and image form"

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

    > After a little investigating, I found that the expose_handler was
    > tying up the process.

    Is this because it was trying to update the Canvas whenever the child
    Form was scrolled?

    If the image is not changing, you may want to consider creating a
    Pixmap and using XSetWindowBackgroundPixmap() to hang the image onto
    the Canvas. Then the server will take care of updating the displayed
    image instead of your application, avoiding much interaction with the
    server.

    > Now I have to figure out how to set a callback to the formbrowser,
    > and determine the offset from the state of the formbrowser and draw
    > a subimage.

    There's no useful callback to the FormBrowser. The best I can suggest
    is to use the Expose event handler as you had done originally.

    > Is this the best way to go?

    Maybe not -- see above.

    > Can I find out the scrollbar offsets in pixels?

    Unfortunately, that's not in the API at the moment -- it might be a
    good thing to add.

    The only the best I can offer is a hack.

    In your expose event, call XGetGeometry() as follows

        static int expose_handle( FL_OBJECT *ob, Window win,
                                      int w, int h, XEvent *xev, void *data)
        
        {
        
            int x;
            int y;
            Window root;
            unsigned int width;
            unsigned int height;
            unsigned int border_width;
            unsigned int depth;
            
            XGetGeometry( fl_get_display(), ob->form->window, &root,
                              &x, &y, &width, &height, &border_width, &depth );
        
            [...]

    `x' and `y' will give you the origin of the Form containing your
    Canvas, relative to the origin of the FormBrowser. Flipping the signs
    will give you the scrollbar offsets, in pixels.

                                                            spl
    _________________________________________________
    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://world.std.com/~xforms
    List Archive: http://bob.usuhs.mil/mailserv/list-archives/



    This archive was generated by hypermail 2b29 : Tue May 09 2000 - 17:46:42 EDT