Re: XForms: Problem updating sub-form coords in dragged tabfolders?

From: Steve Lamont (spl@ncmir.ucsd.edu)
Date: Wed Jun 20 2001 - 10:34:34 EDT

  • Next message: Me: "Re: XForms: Problem updating sub-form coords in dragged tabfolders?"

    # To subscribers of the xforms list from Steve Lamont <spl@ncmir.ucsd.edu> :

    > Here goes, you will see that pressing the button on one of the
    > tab_folder forms _after_ the parent window has been dragged onscreen
    > returns the wrong x,y for the form. It is necessary to de-select then
    > re-select the form which was displayed at the time of dragging to get
    > correct origin coordinates.

    Okay. Here is a workaround that probably ought to be folded into the
    source (TC -- you out there?):

                                    - - -
    int main(int argc, char *argv[])
    {
        FD_fda *fd_fda, *sub1, *sub2;
        FD_fdb *fd_fdb;
        
        fl_initialize(&argc, argv, 0, 0, 0);

        [...]

        fl_show_form(fd_fda->fda,FL_PLACE_FREE,FL_FULLBORDER,"fda");

        /* Add this */

        fl_register_raw_callback( fd_fda->fda, FL_ALL_EVENT, catch_configure );
        fl_show_form(fd_fdb->fdb,FL_PLACE_FREE,FL_FULLBORDER,"fdb");

        /* And this */

        fl_register_raw_callback( fd_fdb->fdb, FL_ALL_EVENT, catch_configure );

        fl_do_forms();
        return 0;
    }

    /*
     * A hack to deal with the ConfigureNotify event.
     */

    int catch_configure( FL_FORM *form, void *xevent )

    {

        XEvent *event = ( XEvent *) xevent;

        /*
         * Are we processing a ConfigureNotify event?
         * ConfigureNotify events are generated when a Form is moved.
         */

        if ( event->type == ConfigureNotify ) {
            
            XConfigureEvent *configure_event = ( XConfigureEvent *) event;
            FL_OBJECT *obj = form->first;

            /*
             * Chain through the objects in this form to find any TabFolders.
             */

            do
                if ( obj->objclass == FL_TABFOLDER ) {

                    /*
                     * Found one... modify the active Form's origin.
                     *
                     * The parent Form's origin will not have been modified
                     * yet, so this becomes a simple process of finding an
                     * offset.
                     */

                    FL_FORM *active = fl_get_active_folder( obj );

                    active->x = configure_event->x + ( active->x - form->x );
                    active->y = configure_event->y + ( active->y - form->y );

                }
            while ( obj = obj->next );
        
        }
        return !FL_PREEMPT;

    }
                                    - - -

    Making the OneLiner actively follow the Form is left as an exercise
    for the student. (Didn't you just hate it when they did that in your
    undergraduate Calculus book?)

                                                            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 : Wed Jun 20 2001 - 11:28:29 EDT