Home > Community > Forums > Custom IC SKILL > GUI callback problem.

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 GUI callback problem. 

Last post Fri, Nov 6 2009 2:45 AM by marbs. 2 replies.
Started by marbs 06 Nov 2009 01:49 AM. Topic has 2 replies and 1798 views
Page 1 of 1 (3 items)
Sort Posts:
  • Fri, Nov 6 2009 1:49 AM

    • marbs
    • Top 100 Contributor
    • Joined on Mon, Jun 15 2009
    • Posts 63
    • Points 810
    GUI callback problem. Reply
    Hello Sir,

    From the GUI code example below,
    How can I make a callback statement
    for the procedure " oferExampleFormCB(form) " in the main form?,
    because I've got no output from the procedure "oferExampleFormCB(form) "
    when I click the apply or ok button from the GUI.

    Thanks in advance,
    Marbs







    /* oferExample.il


    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Feb 09, 1999
    Modified   Mar 02, 1999
    By         A.D.Beckett


    Example code to demonstrate how to use various form functions,
    use of loading and saving templates, dynamic field addition, etc.


    Note that the templates don't include the values of the
    dynamic fields - that's an exercise for the reader!


    ***************************************************


    SCCS Info: @(#) oferExample.il 03/02/99.14:02:59 1.2


    */


    /***************************************************************
    *                                                              *
    *                       oferCreateForm()                       *
    *                                                              *
    *                     Create the main form                     *
    *                                                              *
    ***************************************************************/


    procedure(oferCreateForm()
         let((libName cellName viewName browse userData templateFile templateLoad
    templateSave
            sep1 sep2 sep3 radio optionTwo optionThree)
            ; template loading and saving
            templateFile=hiCreateStringField(
                    ?name 'templateFile
                    ?prompt "Template File"
                    )
            templateLoad=hiCreateButton(
                    ?name 'templateLoad
                    ?buttonText "Load"
                    ?callback "oferLoadTemplate()"
                    )
            templateSave=hiCreateButton(
                    ?name 'templateSave
                    ?buttonText "Save"
                    ?callback "oferSaveTemplate()"
                    )
            ; cellView specification
            sep1=hiCreateSeparatorField(?name 'sep1)
            libName=hiCreateStringField(
                    ?name 'libName
                    ?prompt "Library Name"
                    ?callback "ddsUpdateSyncWithForm()"
                    )
            cellName=hiCreateStringField(
                    ?name 'cellName
                    ?prompt "Cell Name"
                    ?callback "ddsUpdateSyncWithForm()"
                    )
            viewName=hiCreateStringField(
                    ?name 'viewName
                    ?prompt "View Name"
                    ?callback "ddsUpdateSyncWithForm()"
                    )
            browse=hiCreateButton(
                    ?name 'browse
                    ?buttonText "Browse"
                    ?callback "oferSyncBrowser()"
                    )
            sep2=hiCreateSeparatorField(?name 'sep2)
            ; example radio button
            radio=hiCreateRadioField(
                    ?name 'radio
                    ?prompt "Radio"
                    ?choices list("One" "Two" "Three")
                    ?value  "One"
                    ?callback list("oferRadioButtonCB()")
                    )
            ; extra entries for radio button options two and three
            ; these won't be mapped to start off with.
            optionTwo=hiCreateStringField(
                    ?name 'optionTwo
                    ?prompt "Option for Two"
                    )
            optionThree=hiCreateStringField(
                    ?name 'optionThree
                    ?prompt "Option for Three"
                    )
            ; the user data button
            sep3=hiCreateSeparatorField(?name 'sep3)
            userData=hiCreateButton(
                    ?name 'userData
                    ?buttonText "User Data"
                    ?callback "oferDisplayUserDataForm()"
                    )
            hiCreateAppForm(
                ?name 'oferExampleForm
                ?formTitle "Ofer's example form"
                ?fields
                    list(
                        list(templateFile 0:0 600:30 200)
                        list(templateLoad 100:5 45:20)
                        list(templateSave 150:5 45:20)
                        list(sep1 0:35 600:0)
                        list(libName 0:40 600:30 200)
                        list(cellName 0:70 600:30 200)
                        list(viewName 0:100 600:30 200)
                        list(browse 200:130 100:25)
                        list(sep2 0:165 600:0)
                        list(radio 0:190 600:0 200)
                        list(sep3 0:205 600:0)
                        list(userData 200:220 100:25)
                        )
                )
            ; store the extra fields on the form, ready for later
            oferExampleForm->extraFields=
                list(nil 'optionTwo optionTwo
                        'optionThree optionThree)
            oferExampleForm
            )
         )


    /***************************************************************
    *                                                              *
    *                   oferCreateUserDataForm()                   *
    *                                                              *
    *                  Creates the user data form                  *
    *                                                              *
    ***************************************************************/


    procedure(oferCreateUserDataForm()
         let((userFilename userRadio)
            userFilename=hiCreateStringField(
                    ?name 'userFilename
                    ?prompt "Filename"
                    )
            userRadio=hiCreateRadioField(
                    ?name 'userRadio
                    ?choices list("a" "b" "c" "d")
                    ?value "a"
                    ?prompt "Another Radio"
                    )
            ; example - don't bother filling
            hiCreateAppForm(
                ?name 'oferUserDataForm
                ?formTitle "Ofer's User Data"
                ?fields list(
                    userFilename
                    userRadio
                    )
                )
            )
         )


    /***************************************************************
    *                                                              *
    *                      oferSaveTemplate()                      *
    *                                                              *
    *              Callback code to save the template              *
    *                                                              *
    ***************************************************************/


    procedure(oferSaveTemplate()
         let( (fileName fport)
            fileName=oferExampleForm->templateFile->value
            when(fileName==""
                error("Must specify template filename")
                )
            fport=outfile(fileName)
            unless(fport
                error("Could not write to template file %s" fileName)
                )
            fprintf(fport "oferKeys='(nil\n")
            ; output all of the main form keys
            foreach(key '(libName cellName viewName radio)
                fprintf(fport "  %s %L\n" key get(oferExampleForm key)->value)
                )
            ; output all of the user data form keys
            foreach(key '(userFilename userRadio)
                fprintf(fport "  %s %L\n" key get(oferUserDataForm key)->value)
                )
            ; end of the file
            fprintf(fport ")\n")
            close(fport)
            )
         )


    /***************************************************************
    *                                                              *
    *                      oferLoadTemplate()                      *
    *                                                              *
    *              Callback code to load the template              *
    *                                                              *
    ***************************************************************/


    procedure(oferLoadTemplate()
         let( (fileName fport)
            fileName=oferExampleForm->templateFile->value
            when(fileName==""
                error("Must specify template filename")
                )
            ; load it, and trap any errors. The file is just skill
            ; code, so can be loaded.
            errset(load(fileName) t)
            ; the keys are all in a disembodied property list called oferKeys
            ; input all of the main form keys
            ; use get(), because oferKeys->key won't work, because the key variable
            ; needs to be evaluated.
            foreach(key '(libName cellName viewName radio)
                when(get(oferKeys key)
                    get(oferExampleForm key)->value=get(oferKeys key)
                    )
                )
            ; output all of the user data form keys
            foreach(key '(userFilename userRadio)
                when(get(oferKeys key)
                    get(oferUserDataForm key)->value=get(oferKeys key)
                    )
                )
            )
         )


    /***************************************************************
    *                                                              *
    *                      oferSyncBrowser()                       *
    *                                                              *
    *                 Synchronise with the browser                 *
    *                                                              *
    ***************************************************************/


    procedure(oferSyncBrowser()
         ddsSyncWithForm(
            oferExampleForm
            'browse
            'libName
            'cellName
            'viewName
            )
         )


    /****************************************************************
    *                                                               *
    *                      oferRadioButtonCB()                      *
    *                                                               *
    *   Callback for the radio button on the form - this adds or    *
    *       subtracts the dynamic fields. The dynamic fields        *
    * are created at startup, and stored in a disembodied property  *
    * list on the form, and the form positions are calculated based *
    *        on the current positions of fields on the form.        *
    *                                                               *
    ****************************************************************/


    procedure(oferRadioButtonCB()
         let((radioVal newOffset newPosition oldPosition
                (currentOffset 0) (fieldHeight 30) newYcoord)
            ; determine the offset of the bottom fields at the moment
            when(oferExampleForm->optionTwo
                currentOffset=currentOffset+fieldHeight
                )
            when(oferExampleForm->optionThree
                currentOffset=currentOffset+fieldHeight
                )
            ; determine the offset that we want, based on the radio
            ; button value
            radioVal=oferExampleForm->radio->value
            newOffset=case(radioVal
                ("Two" fieldHeight)
                ("Three" fieldHeight*2)
                (t 0)
                )
            ; shift the two bottom fields by the appropriate amount
            foreach(field '(sep3 userData)
                ; calculate the new position from the old, offset accordingly
                oldPosition=car(hiGetFieldInfo(oferExampleForm field))
                newPosition=xCoord(oldPosition):yCoord(oldPosition)
                            +newOffset-currentOffset
                hiMoveField(
                    oferExampleForm
                    field
                    newPosition
                    )
                )
            ; delete form fields if they're not needed
            when(radioVal=="One" && oferExampleForm->optionTwo
                hiDeleteField(oferExampleForm 'optionTwo))
            when(radioVal!="Three" && oferExampleForm->optionThree
                hiDeleteField(oferExampleForm 'optionThree))
            ; determine where the extra fields will be placed
            newYcoord=yCoord(car(hiGetFieldInfo(oferExampleForm 'radio)))+10
            ; add the two fields if they're needed and not there already
            when(radioVal=="Two" || radioVal=="Three"
                unless(oferExampleForm->optionTwo
                    hiAddField(oferExampleForm
                        list(oferExampleForm->extraFields->optionTwo
                            0:newYcoord 600:30 200))
                    )
                )
            when(radioVal=="Three"
                unless(oferExampleForm->optionThree
                    hiAddField(oferExampleForm
                        list(oferExampleForm->extraFields->optionThree
                            0:newYcoord+fieldHeight 600:30 200))
                    )
                )
            ))


    /***************************************************************
    *                                                              *
    *                  oferDisplayUserDataForm()                   *
    *                                                              *
    *  Display the user data form - callback from the main form.   *
    *                                                              *
    ***************************************************************/


    procedure(oferDisplayUserDataForm()
         hiDisplayForm(oferUserDataForm)
         )


    /****************************************************************
    *                                                               *
    *                    oferExampleFormCB(form)                    *
    *                                                               *
    * The form callback - doesn't do much except print out what has *
    *                         been entered                          *
    *                                                               *
    ****************************************************************/


    procedure(oferExampleFormCB(form)
         printf("You entered cellView %s/%s/%s\n"
            form->libName->value
            form->cellName->value
            form->viewName->value
            )
         printf("The radio button was set to %s\n"
            form->radio->value
            )
         printf("And the user data fields were\nfilename: %s\nradio: %s\n"
            oferUserDataForm->userFilename->value
            oferUserDataForm->userRadio->value
            )
         )


    /***************************************************************
    *                                                              *
    *                        oferExample()                         *
    *                                                              *
    *                       Main entry point                       *
    *                                                              *
    ***************************************************************/


    procedure(oferExample()
         unless(boundp('oferExampleForm)
            oferCreateForm()
            )
         unless(boundp('oferUserDataForm)
            oferCreateUserDataForm()
            )
         hiDisplayForm(oferExampleForm)
         )
    • Post Points: 20
  • Fri, Nov 6 2009 1:58 AM

    Re: GUI callback problem. Reply

    Odd. I must have left this as an exercise for the reader (that's my excuse) - either that or (far more likely) I hacked the example at some point in ancient history (before I checked it in) and removed the ?callback argument to hiCreateAppForm. No idea why it's not there.

    Anyway, all you need to do is add:

    ?callback 'oferExampleFormCB

    into the arguments of hiCreateAppForm() in the function oferCreateForm.

    To test it, either quit out of virtuoso and restart, or type:

    oferExampleForm='unbound

    before calling oferExample() again (make sure the form is not displayed before doing this).

    Regards,

    Andrew.

    • Post Points: 20
  • Fri, Nov 6 2009 2:45 AM

    • marbs
    • Top 100 Contributor
    • Joined on Mon, Jun 15 2009
    • Posts 63
    • Points 810
    Re: GUI callback problem. Reply

    Thank you very much for the reply sir,

    I will test it on monday, because I have no work tomorrow.

    I am excited to test it.

    • Post Points: 5
Page 1 of 1 (3 items)
Sort Posts:
Started by marbs at 06 Nov 2009 01:49 AM. Topic has 2 replies.