• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Change all toggle fields in a form using single selecti...

Stats

  • Locked Locked
  • Replies 1
  • Subscribers 143
  • Views 13896
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Change all toggle fields in a form using single selection

gaurc
gaurc over 9 years ago

I want a form like this...

Select all  (tick box)

A (tick box)

B (tick box)

C (tick box)

D (tick box)

when I tick (make true) "Select all field" all the below fields (A B C D) should be selected and when I remove tick (make nil) all these fields (A B C D)  should be unselected.

Using hiCreateToggleField function how can I do this? What are the other functions involved?

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 9 years ago

    Try this:

    /* abToggleForm.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Feb 23, 1999 
    Modified   Sep 16, 2009 
    By         A.D.Beckett
    
    Functions for creating a variable list of toggles
    with all and none toggles. The list of toggles is
    in a scroll region.
    
    Attempted to make it resizable, but this rather contradicted
    with the scroll region, so left the scroll region in the form 
    instead.
    
    Three main entry functions:
    
    abCreateToggleForm()
    abToggleFormGetSelected()
    abToggleFormSetSelected()
    
    Example:
    
    procedure(myToggleCB(form)
       printf("Selected Files were:\n")
       pprint(abToggleFormGetSelected(form))
       newline()
    )
    
    hiDisplayForm(
      abCreateToggleForm(
         ?name 'myTogForm
         ?textList getDirFiles("/bin")
         ?prompt "Choose Files"
         ?callback 'myToggleCB
      )
    )
    
    ***************************************************
    
    SCCS Info: @(#) abToggleForm.il 09/16/09.12:22:46 1.5
    
    */
    
    /********************************************************************
    *                                                                   *
    *                abCreateToggleForm(?name s_formName                *
    *              ?textList l_textitems ?prompt t_prompt               *
    *         [?formTitle t_formTitle] [?value b_defaultValue]          *
    * [?yStep x_yStep] [?formWidth x_formWidth] [?xPosition x_position] *
    *          [?toggleHeight x_height] [?toggleWidth x_width]          *
    *                      [?callback s_callback])                      *
    *     [?formType 'options/'nonoptions] [?buttonLayout 'OKCancel]    *
    *                                                                   *
    *      Create a form full of toggle items, with an all or none      *
    *       button. Must provide at least the symbol for the form       *
    *              name, the list of items, and a prompt.               *
    *                                                                   *
    ********************************************************************/
    
    procedure(abCreateToggleForm(@key 
            (name nil)
            (formTitle "")
            (textList nil) 
            (prompt "") 
            (value t)
            (yStep 20) (formWidth 300) 
            (xPosition 220) (toggleHeight 200) (toggleWidth 250)
            (callback nil)
            (formType 'nonoptions)
            buttonLayout
            )
        let((toggleList togName (toggleNumber 0)
                (yPosition 0) topLabel allButton noneButton
                scrollRegion separator form)
            ;----------------------------------------------------------------
            ; delete any existing form
            ;----------------------------------------------------------------
            when(boundp(name) && symeval(name)
                hiFormCancel(symeval(name))
                hiDeleteForm(symeval(name)))
            ;----------------------------------------------------------------
            ; Default button layout
            ;----------------------------------------------------------------
            unless(buttonLayout
                buttonLayout=if(formType=='nonoptions 'OKCancel 'HideCancel)
                )
            ;----------------------------------------------------------------
            ; create the label at the top of the toggle list
            ;----------------------------------------------------------------
            topLabel=hiCreateLabel(?name 'label ?labelText prompt)
            ;----------------------------------------------------------------
            ; create the toggles for each entry in the textList
            ;----------------------------------------------------------------
            toggleList=foreach(mapcar text textList
                ;------------------------------------------------------------
                ; create the name of the toggle
                ;------------------------------------------------------------
                togName=concat('toggle ++toggleNumber)
                ;------------------------------------------------------------
                ; return the first value in the group
                ;------------------------------------------------------------
                prog1(
                    ;--------------------------------------------------------
                    ; create the toggle and add it onto the list
                    ;--------------------------------------------------------
                    list(
                        hiCreateBooleanButton(
                            ?name togName
                            ?buttonText text
                            ?callback 
                            sprintf(nil "abToggleFormOtherButtonCB(%s '%s)"
                            name togName)
                            ?value value
                            ); hiCreateBooleanButton
                        0:yPosition
                        toggleWidth:yStep
                        xPosition
                        ); list
                    ;--------------------------------------------------------
                    ; increment the step 
                    ;--------------------------------------------------------
                    yPosition=yPosition+yStep
                    ); prog1
                ); foreach mapcar
            ;----------------------------------------------------------------
            ; add the line and the All and None toggles 
            ;----------------------------------------------------------------
            separator=hiCreateSeparatorField(?name 'separator)
            allButton=hiCreateBooleanButton(
                ?name 'All
                ?buttonText "All"
                ?callback sprintf(nil "abToggleFormAllButtonCB(%s)" name)
                ?value value
                )
            noneButton=hiCreateBooleanButton(
                ?name 'None
                ?buttonText "None"
                ?callback sprintf(nil "abToggleFormNoneButtonCB(%s)" name)
                ?value !value
                )
            ;----------------------------------------------------------------
            ; the sroll region itself
            ;----------------------------------------------------------------
            scrollRegion=hiCreateScrollRegion(
                ?name 'scrollRegion
                ?fields toggleList
                ?borderWidth 0
                )
            ;----------------------------------------------------------------
            ; create the form
            ;----------------------------------------------------------------
            form=hiCreateAppForm(
                ?name name
                ?fields list(
                    list(topLabel 0:0 formWidth:yStep*2)
                    list(scrollRegion 0:yStep*2 formWidth:toggleHeight)
                    list(separator 0:toggleHeight+yStep*2 formWidth:0)
                    list(allButton 0:toggleHeight+yStep*3 formWidth:yStep xPosition)
                    list(noneButton 0:toggleHeight+yStep*4 formWidth:yStep xPosition)
                    )
                ?formTitle formTitle
                ?formType formType
                ?buttonLayout buttonLayout
                ?callback callback
                )
            ;----------------------------------------------------------------
            ; store various information on the form
            ;----------------------------------------------------------------
            form->numButtons=toggleNumber
            if(value then
                form->numSelected=toggleNumber
            else 
                form->numSelected=0
                )
            form
            ))
    
    /***************************************************************
    *                                                              *
    *            abToggleFormOtherButtonCB(form field)             *
    *                                                              *
    *  Callback for each toggle (except all or none) on the form   *
    *                                                              *
    ***************************************************************/
    
    procedure(abToggleFormOtherButtonCB(form field)
        let((numSelected)
            numSelected=form->numSelected
            if(get(form->scrollRegion field)->value 
                numSelected++
                numSelected--)
            form->numSelected=numSelected
            form->None->value=numSelected==0
            form->All->value=numSelected==form->numButtons
        ))
    
    /***************************************************************
    *                                                              *
    *              abToggleFormAllButtons(form value)              *
    *                                                              *
    *    Utility function to set all the buttons to a specified    *
    *                            value.                            *
    *                                                              *
    ***************************************************************/
    
    procedure(abToggleFormAllButtons(form value)
        let(((scrollRegion form->scrollRegion))
            foreach(field scrollRegion->fieldList
                get(scrollRegion field)->value=value
                )
        ))
    
    /***************************************************************
    *                                                              *
    *                abToggleFormAllButtonCB(form)                 *
    *                                                              *
    *                 Callback for the All button                  *
    *                                                              *
    ***************************************************************/
    
    procedure(abToggleFormAllButtonCB(form)
        cond(
            (form->All->value
                abToggleFormAllButtons(form t))
            (form->numSelected==form->numButtons
                form->All->value=t)
            )
        )
    
    /***************************************************************
    *                                                              *
    *                abToggleFormNoneButtonCB(form)                *
    *                                                              *
    *                 Callback for the None button                 *
    *                                                              *
    ***************************************************************/
    
    procedure(abToggleFormNoneButtonCB(form)
        cond(
            (form->None->value
                abToggleFormAllButtons(form nil))
            (form->numSelected==0
                form->None->value=t)
            )
        )
    
    /***************************************************************
    *                                                              *
    *                abToggleFormGetSelected(form)                 *
    *                                                              *
    *  Function that may be used in the form callback function to  *
    *             retrieve all the selected item names             *
    *                                                              *
    ***************************************************************/
    
    procedure(abToggleFormGetSelected(form)
        let(((scrollRegion form->scrollRegion))
            foreach(mapcar field
                setof(field scrollRegion->fieldList
                    get(scrollRegion field)->value)
                get(scrollRegion field)->prompt
                )
            ))
    
    /****************************************************************
    *                                                               *
    *          abToggleFormSetSelected(form promptValList)          *
    *                                                               *
    * Function that may be used to set (or unset) a list of fields. *
    *   The second argument is a list of lists, with each sublist   *
    *  being the prompt for the field, followed by t/nil to set or  *
    *                       unset the toggle.                       *
    *                                                               *
    ****************************************************************/
    
    procedure(abToggleFormSetSelected(form promptValList)
        let(((scrollRegion form->scrollRegion) (fieldTable makeTable('fields nil))
                foundField)
            foreach(field scrollRegion->fieldList
                fieldTable[get(scrollRegion field)->prompt]=field
                )
            foreach(promptVal promptValList
                foundField=fieldTable[car(promptVal)]
                if(foundField then
                    get(scrollRegion foundField)->value=cadr(promptVal)
                else
                    warn("No toggle with prompt %L on form\n" car(promptVal))
                    )
                )
            t
            )
        )
    

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 9 years ago

    Try this:

    /* abToggleForm.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Feb 23, 1999 
    Modified   Sep 16, 2009 
    By         A.D.Beckett
    
    Functions for creating a variable list of toggles
    with all and none toggles. The list of toggles is
    in a scroll region.
    
    Attempted to make it resizable, but this rather contradicted
    with the scroll region, so left the scroll region in the form 
    instead.
    
    Three main entry functions:
    
    abCreateToggleForm()
    abToggleFormGetSelected()
    abToggleFormSetSelected()
    
    Example:
    
    procedure(myToggleCB(form)
       printf("Selected Files were:\n")
       pprint(abToggleFormGetSelected(form))
       newline()
    )
    
    hiDisplayForm(
      abCreateToggleForm(
         ?name 'myTogForm
         ?textList getDirFiles("/bin")
         ?prompt "Choose Files"
         ?callback 'myToggleCB
      )
    )
    
    ***************************************************
    
    SCCS Info: @(#) abToggleForm.il 09/16/09.12:22:46 1.5
    
    */
    
    /********************************************************************
    *                                                                   *
    *                abCreateToggleForm(?name s_formName                *
    *              ?textList l_textitems ?prompt t_prompt               *
    *         [?formTitle t_formTitle] [?value b_defaultValue]          *
    * [?yStep x_yStep] [?formWidth x_formWidth] [?xPosition x_position] *
    *          [?toggleHeight x_height] [?toggleWidth x_width]          *
    *                      [?callback s_callback])                      *
    *     [?formType 'options/'nonoptions] [?buttonLayout 'OKCancel]    *
    *                                                                   *
    *      Create a form full of toggle items, with an all or none      *
    *       button. Must provide at least the symbol for the form       *
    *              name, the list of items, and a prompt.               *
    *                                                                   *
    ********************************************************************/
    
    procedure(abCreateToggleForm(@key 
            (name nil)
            (formTitle "")
            (textList nil) 
            (prompt "") 
            (value t)
            (yStep 20) (formWidth 300) 
            (xPosition 220) (toggleHeight 200) (toggleWidth 250)
            (callback nil)
            (formType 'nonoptions)
            buttonLayout
            )
        let((toggleList togName (toggleNumber 0)
                (yPosition 0) topLabel allButton noneButton
                scrollRegion separator form)
            ;----------------------------------------------------------------
            ; delete any existing form
            ;----------------------------------------------------------------
            when(boundp(name) && symeval(name)
                hiFormCancel(symeval(name))
                hiDeleteForm(symeval(name)))
            ;----------------------------------------------------------------
            ; Default button layout
            ;----------------------------------------------------------------
            unless(buttonLayout
                buttonLayout=if(formType=='nonoptions 'OKCancel 'HideCancel)
                )
            ;----------------------------------------------------------------
            ; create the label at the top of the toggle list
            ;----------------------------------------------------------------
            topLabel=hiCreateLabel(?name 'label ?labelText prompt)
            ;----------------------------------------------------------------
            ; create the toggles for each entry in the textList
            ;----------------------------------------------------------------
            toggleList=foreach(mapcar text textList
                ;------------------------------------------------------------
                ; create the name of the toggle
                ;------------------------------------------------------------
                togName=concat('toggle ++toggleNumber)
                ;------------------------------------------------------------
                ; return the first value in the group
                ;------------------------------------------------------------
                prog1(
                    ;--------------------------------------------------------
                    ; create the toggle and add it onto the list
                    ;--------------------------------------------------------
                    list(
                        hiCreateBooleanButton(
                            ?name togName
                            ?buttonText text
                            ?callback 
                            sprintf(nil "abToggleFormOtherButtonCB(%s '%s)"
                            name togName)
                            ?value value
                            ); hiCreateBooleanButton
                        0:yPosition
                        toggleWidth:yStep
                        xPosition
                        ); list
                    ;--------------------------------------------------------
                    ; increment the step 
                    ;--------------------------------------------------------
                    yPosition=yPosition+yStep
                    ); prog1
                ); foreach mapcar
            ;----------------------------------------------------------------
            ; add the line and the All and None toggles 
            ;----------------------------------------------------------------
            separator=hiCreateSeparatorField(?name 'separator)
            allButton=hiCreateBooleanButton(
                ?name 'All
                ?buttonText "All"
                ?callback sprintf(nil "abToggleFormAllButtonCB(%s)" name)
                ?value value
                )
            noneButton=hiCreateBooleanButton(
                ?name 'None
                ?buttonText "None"
                ?callback sprintf(nil "abToggleFormNoneButtonCB(%s)" name)
                ?value !value
                )
            ;----------------------------------------------------------------
            ; the sroll region itself
            ;----------------------------------------------------------------
            scrollRegion=hiCreateScrollRegion(
                ?name 'scrollRegion
                ?fields toggleList
                ?borderWidth 0
                )
            ;----------------------------------------------------------------
            ; create the form
            ;----------------------------------------------------------------
            form=hiCreateAppForm(
                ?name name
                ?fields list(
                    list(topLabel 0:0 formWidth:yStep*2)
                    list(scrollRegion 0:yStep*2 formWidth:toggleHeight)
                    list(separator 0:toggleHeight+yStep*2 formWidth:0)
                    list(allButton 0:toggleHeight+yStep*3 formWidth:yStep xPosition)
                    list(noneButton 0:toggleHeight+yStep*4 formWidth:yStep xPosition)
                    )
                ?formTitle formTitle
                ?formType formType
                ?buttonLayout buttonLayout
                ?callback callback
                )
            ;----------------------------------------------------------------
            ; store various information on the form
            ;----------------------------------------------------------------
            form->numButtons=toggleNumber
            if(value then
                form->numSelected=toggleNumber
            else 
                form->numSelected=0
                )
            form
            ))
    
    /***************************************************************
    *                                                              *
    *            abToggleFormOtherButtonCB(form field)             *
    *                                                              *
    *  Callback for each toggle (except all or none) on the form   *
    *                                                              *
    ***************************************************************/
    
    procedure(abToggleFormOtherButtonCB(form field)
        let((numSelected)
            numSelected=form->numSelected
            if(get(form->scrollRegion field)->value 
                numSelected++
                numSelected--)
            form->numSelected=numSelected
            form->None->value=numSelected==0
            form->All->value=numSelected==form->numButtons
        ))
    
    /***************************************************************
    *                                                              *
    *              abToggleFormAllButtons(form value)              *
    *                                                              *
    *    Utility function to set all the buttons to a specified    *
    *                            value.                            *
    *                                                              *
    ***************************************************************/
    
    procedure(abToggleFormAllButtons(form value)
        let(((scrollRegion form->scrollRegion))
            foreach(field scrollRegion->fieldList
                get(scrollRegion field)->value=value
                )
        ))
    
    /***************************************************************
    *                                                              *
    *                abToggleFormAllButtonCB(form)                 *
    *                                                              *
    *                 Callback for the All button                  *
    *                                                              *
    ***************************************************************/
    
    procedure(abToggleFormAllButtonCB(form)
        cond(
            (form->All->value
                abToggleFormAllButtons(form t))
            (form->numSelected==form->numButtons
                form->All->value=t)
            )
        )
    
    /***************************************************************
    *                                                              *
    *                abToggleFormNoneButtonCB(form)                *
    *                                                              *
    *                 Callback for the None button                 *
    *                                                              *
    ***************************************************************/
    
    procedure(abToggleFormNoneButtonCB(form)
        cond(
            (form->None->value
                abToggleFormAllButtons(form nil))
            (form->numSelected==0
                form->None->value=t)
            )
        )
    
    /***************************************************************
    *                                                              *
    *                abToggleFormGetSelected(form)                 *
    *                                                              *
    *  Function that may be used in the form callback function to  *
    *             retrieve all the selected item names             *
    *                                                              *
    ***************************************************************/
    
    procedure(abToggleFormGetSelected(form)
        let(((scrollRegion form->scrollRegion))
            foreach(mapcar field
                setof(field scrollRegion->fieldList
                    get(scrollRegion field)->value)
                get(scrollRegion field)->prompt
                )
            ))
    
    /****************************************************************
    *                                                               *
    *          abToggleFormSetSelected(form promptValList)          *
    *                                                               *
    * Function that may be used to set (or unset) a list of fields. *
    *   The second argument is a list of lists, with each sublist   *
    *  being the prompt for the field, followed by t/nil to set or  *
    *                       unset the toggle.                       *
    *                                                               *
    ****************************************************************/
    
    procedure(abToggleFormSetSelected(form promptValList)
        let(((scrollRegion form->scrollRegion) (fieldTable makeTable('fields nil))
                foundField)
            foreach(field scrollRegion->fieldList
                fieldTable[get(scrollRegion field)->prompt]=field
                )
            foreach(promptVal promptValList
                foundField=fieldTable[car(promptVal)]
                if(foundField then
                    get(scrollRegion foundField)->value=cadr(promptVal)
                else
                    warn("No toggle with prompt %L on form\n" car(promptVal))
                    )
                )
            t
            )
        )
    

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information