Re: XForms: call_object_callback difficulties

From: Steve Lamont (spl@szechuan.ucsd.edu)
Date: Wed Feb 02 2000 - 16:30:47 EST

  • Next message: Steve Lamont: "XForms: FTP outage"

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

    > I have found that I can call the callback function directly... e.g.
    >
    > set_voltage(vslider, 3); (set_voltage is the callback, and
    > vslider is the xforms object)
    >
    > the compiler understandably always throws out....
    >
    > warning: passing arg 1 of `set_voltage' from incompatible pointer type
    >
    > (i.e. it's complaining about the xforms object vslider..but it works!)
    >
    > Is there a nice way to do this?

    Since the sliders are in an array,

            set_voltage( vslider[3], 3 );

    should do it.

    BTW, the `*ob' parameter in a callback, of course, points to the
    object structure in question, so you can avoid this sort of kluge with
    something like

        void slider_cb(FL_OBJECT *ob, long data)
        
        {
        
            FD_try *fd_try = ( FD_try *) ob->form->fdui;
            FL_OBJECT **sliders = fd_try->slider;
            int i;
        
            for ( i = 0;
                  i < sizeof( fd_try->slider ) / sizeof( fd_try->slider[0] );
                      i++ )
                if ( sliders[i] == ob )
                    break;
        
            printf( "slider %d = %g\n", i, fl_get_slider_value( ob ) );
            
        }

    > Finally, may I add one minor suggestion to the documentation..
    > It would be handy to document how to set up FDesign
    > so that you can isolate the FDesign bits from the callbacks, so that
    > when you modify the copied callback code, you don't lose all your
    > precious filled-in callbacks when you decide to
    > shift a slider or box etc.. around.
    >
    > e.g.
    > fdesign myprog -altformat -main -callback -I myheader.h

    There really isn't any way do do what you suggest without adding
    considerable complication to `fdesign'.

    There was some talk a few months ago about adding a callback code
    editing capability to `fdesign' but this was pretty much abandoned
    given the complexity of the task -- you would have to add elaborate
    text editing function to `fdesign' (and I guarantee you that's a
    recipe for flame wars as everyone has their own favorite editor and
    coding style) or spawn a text editor process, not to mention either
    change the `.fd' file format or output an extra file.

    The easiest thing is not to use `-callback' after you generate your
    initial user interface.

    I find that for anything other than quick and dirty test code that I
    never need or want to regenerate the main or callback files. I
    generate the majority of the basic user interface before I begin
    coding anything else and then just add the extra callbacks to my
    callback file by hand if I need to insert anything else.

                                                            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 Feb 02 2000 - 16:31:44 EST