XForms: Drawing in the browser prehandler (bug?)

From: jac@casurgica.com
Date: Mon Apr 07 2003 - 17:53:44 EDT

  • Next message: Angus Leeming: "Re: XForms: Re: Joining The Club"

    # To subscribers of the xforms list from jac@casurgica.com :

    I need to make a browser that looks a little fancier than the regular one,
    and I want to do it with minimal effort. So I decided to just do my own
    drawing for a browser object, and leave the rest up to xforms. I am drawing
    in response to FL_DRAW events in the browser prehandler.

    It almost works. The problem is that sometimes the stuff isn't drawn in the
    correct place -- it's draw up in the top left corner of the form rather
    than on top of the browser. It seems that the prehandler gets called with
    FL_DRAW twice whenever the browser is exposed, and only once (as expected)
    when the browser just needs drawn (like when you move the scroll bar). The
    raw_event parameter to the prehandler is always null, so I can't use this
    to differentiate between the normal prehandler call and the call that
    happens when the browser is exposed... and that doesn't seem like it would
    make sense anyway.

    Here's the code I am using to test this out:

    int br2_prehandler (FL_OBJECT *obj, int event, FL_Coord x, FL_Coord y, int
    k, void raw_event) {

      int top, bot, max;

      // We're only interested in drawing events.
      if (event != FL_DRAW)
        return 0;

      // Draw the browser's box
      fl_drw_box(obj->boxtype, obj->x, obj->y, obj->w, obj->h, obj->col1,
    obj->bw);

      // Figure out what lines to draw
      top = fl_get_browser_topline(obj);
      bot = top + fl_get_browser_screenlines(obj) + 1;
      max = fl_get_browser_maxline(obj);

      // Don't go past the last line
      if (!max)
        return FL_PREEMPT;
      if (bot > max)
        bot = max;

      fprintf(stderr, "prehandler(%p, %i, %i, %i, %i, %p): %i,%i %i,%i\n",
        obj, event, x, y, k, raw_event, obj->x, obj->y, obj->w, obj->h);

      // More drawing code would go here if this worked.

      // Return
      return FL_PREEMPT;

    };

    What's the deal with this? Why is it drawing in the upper left corner of
    the form when the browser is exposed, and why is the prehandler called
    twice (with identical parameters) with FL_DRAW when this happens? The
    first call of the two is the one that draws wrong.

    I was using version 0.89. I switched to 1.0 and the problem was not fixed.

    Am I overlooking something silly, or is this a bug?

    Thanks,
    Jason Cipriani

    _________________________________________________
    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/
    Development: http://savannah.nongnu.org/files/?group=xforms



    This archive was generated by hypermail 2b29 : Mon Apr 07 2003 - 17:55:08 EDT