Ignore:
Timestamp:
May 13, 2006, 1:13:19 PM (19 years ago)
Author:
mmc
Message:

Added a new <enable> parameter to all inputs. Controls can now be
enabled/disabled based on the status of other controls. If a group
is disabled, it disappears entirely. If a parameter is enabled to
a hard-coded "off" value, then it acts like a hidden (secret)
parameter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/switch.tcl

    r115 r437  
    3232    itk_option define -width width Width 0
    3333    itk_option define -height height Height 0
     34    itk_option define -state state State "normal"
    3435
    3536    constructor {args} { # defined below }
     
    109110
    110111    bind $itk_component(value) <ButtonPress> \
    111         [list $itk_component(presetlist) post $itk_component(vframe) left]
     112        [itcl::code $this _presets dropdown]
    112113    $itk_component(presets) configure -command \
    113         [list $itk_component(presetlist) post $itk_component(vframe) left]
     114        [itcl::code $this _presets dropdown]
    114115
    115116    eval itk_initialize $args
     
    277278# ----------------------------------------------------------------------
    278279itcl::body Rappture::Switch::_hilite {comp state} {
     280    if {$itk_option(-state) == "disabled"} {
     281        set state 0  ;# never hilite when disabled
     282    }
    279283    if {$comp == "value"} {
    280284        if {$state} {
     
    285289        return
    286290    }
    287 
    288291    if {$state} {
    289292        $itk_component($comp) configure -relief solid
     
    305308# ----------------------------------------------------------------------
    306309itcl::body Rappture::Switch::_presets {option} {
     310    if {$itk_option(-state) != "normal"} {
     311        return  ;# disabled? then bail out!
     312    }
    307313    switch -- $option {
     314        dropdown {
     315            $itk_component(presetlist) post $itk_component(vframe) left
     316        }
    308317        post {
    309318            set i [$itk_component(presetlist) index $_value]
     
    324333        }
    325334        default {
    326             error "bad option \"$option\": should be post, unpost, select"
     335            error "bad option \"$option\": should be dropdown, post, unpost, select"
    327336        }
    328337    }
     
    359368        _redraw
    360369    }
     370}
     371
     372# ----------------------------------------------------------------------
     373# CONFIGURATION OPTION: -state
     374# ----------------------------------------------------------------------
     375itcl::configbody Rappture::Switch::state {
     376    set valid {normal disabled}
     377    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
     378        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
     379    }
     380    $itk_component(value) configure -state $itk_option(-state)
     381    $itk_component(presets) configure -state $itk_option(-state)
    361382}
    362383
Note: See TracChangeset for help on using the changeset viewer.