- Timestamp:
- Feb 9, 2008, 4:40:47 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/zoo/boolean/boolean.tcl
r115 r875 14 14 15 15 set choice [$driver get input.(iimodel).current] 16 $driver put output.boolean(outb).about.label "Echo of boolean value iimodel" 16 17 $driver put output.boolean(outb).current $choice 18 19 set choice1 [$driver get input.(iimodel1).current] 20 $driver put output.boolean(outb1).about.label "Echo of boolean value iimodel1" 21 $driver put output.boolean(outb1).current $choice1 22 23 set choice2 [$driver get input.(iimodel2).current] 24 $driver put output.boolean(outb2).about.label "Echo of boolean value iimodel2" 25 $driver put output.boolean(outb2).current $choice2 26 27 set choice3 [$driver get input.(iimodel3).current] 28 $driver put output.boolean(outb3).about.label "Echo of boolean value iimodel3" 29 $driver put output.boolean(outb3).current $choice3 17 30 18 31 # save the updated XML describing the run... -
trunk/examples/zoo/boolean/tool.xml
r69 r875 20 20 <description>Used to enable/disable the effects of impact ionization on the mobility model.</description> 21 21 </about> 22 <default>on</default> 23 </boolean> 24 <boolean id="iimodel1"> 25 <about> 26 <label>Impact Ionization Model</label> 27 <description>Used to enable/disable the effects of impact ionization on the mobility model.</description> 28 </about> 22 29 <default>yes</default> 23 30 </boolean> 31 <boolean id="iimodel2"> 32 <about> 33 <label>Impact Ionization Model</label> 34 <description>Used to enable/disable the effects of impact ionization on the mobility model.</description> 35 </about> 36 <default>true</default> 37 </boolean> 38 <boolean id="iimodel3"> 39 <about> 40 <label>Impact Ionization Model</label> 41 <description>Used to enable/disable the effects of impact ionization on the mobility model.</description> 42 </about> 43 <default>1</default> 44 </boolean> 24 45 </input> 25 <output>26 <boolean id="outb">27 <about><label>Echo of boolean value</label></about>28 </boolean>29 </output>30 46 </run> -
trunk/gui/scripts/switch.tcl
r437 r875 43 43 protected method _hilite {comp state} 44 44 protected method _presets {option} 45 protected method _val2boolstr {args} 45 46 46 47 private variable _value "no" ;# value for this widget … … 53 54 } 54 55 } 55 56 56 57 itk::usual Switch { 57 58 keep -cursor -font -foreground -background … … 61 62 # ---------------------------------------------------------------------- 62 63 # CONSTRUCTOR 63 # ---------------------------------------------------------------------- 64 itcl::body Rappture::Switch::constructor {args} { 64 # the type is one of the following: 65 # "yes", "no", 66 # "true", "false", 67 # "on", "off", 68 # "1", "0", 69 # and determines what text is used as the dropdown options. 70 # if left empty or is a non-boolean value, type defaults to "no" 71 # ---------------------------------------------------------------------- 72 itcl::body Rappture::Switch::constructor {type args} { 65 73 itk_component add icon { 66 74 canvas $itk_interior.icon -borderwidth 0 -highlightthickness 0 … … 76 84 } 77 85 86 set valNumNeg 2 87 set valNumPos 3 88 set valTextNeg "no" 89 set valTextPos "yes" 90 91 if { ("" != $type) } { 92 set _value $type 93 } 94 95 if { ("on" == $_value) || ("off" == $_value) } { 96 set valNumNeg 4 97 set valNumPos 5 98 set valTextNeg "off" 99 set valTextPos "on" 100 } elseif { ("true" == $_value) || ("false" == $_value) } { 101 set valNumNeg 6 102 set valNumPos 7 103 set valTextNeg "false" 104 set valTextPos "true" 105 } elseif { ("1" == $_value) || ("0" == $_value) } { 106 # assigning values this way avoids a 107 # "string is integer -strict" problem in _val2boolstr 108 set valNumNeg 0 109 set valNumPos 1 110 set valTextNeg "0" 111 set valTextPos "1" 112 } else { 113 set _value "no" 114 } 115 78 116 itk_component add value { 79 117 label $itk_component(vframe).value -borderwidth 1 -width 7 \ … … 83 121 } 84 122 pack $itk_component(value) -side left -expand yes -fill both 85 86 bind $itk_component(value) <Enter> [itcl::code $this _hilite value on]87 bind $itk_component(value) <Leave> [itcl::code $this _hilite value off]88 123 89 124 itk_component add presets { … … 96 131 } 97 132 98 bind $itk_component(presets) <Enter> [itcl::code $this _hilite presets on]99 bind $itk_component(presets) <Leave> [itcl::code $this _hilite presets off]133 bind $itk_component(presets) <Enter> [itcl::code $this _hilite presets $valTextPos] 134 bind $itk_component(presets) <Leave> [itcl::code $this _hilite presets $valTextNeg] 100 135 101 136 itk_component add presetlist { … … 104 139 -unpostcommand [itcl::code $this _presets unpost] \ 105 140 } 106 $itk_component(presetlist) insert end 1 yes 0 no 141 142 $itk_component(presetlist) insert end $valNumPos $valTextPos $valNumNeg $valTextNeg 107 143 108 144 bind $itk_component(presetlist) <<DropdownlistSelect>> \ … … 135 171 136 172 if {[llength $args] == 1} { 137 set newval [lindex $args 0] 173 174 set newval [_val2boolstr [lindex $args 0]] 138 175 if {![string is boolean -strict $newval]} { 139 176 error "Should be a boolean value" 140 177 } 141 set newval [expr {($newval) ? "yes" : "no"}]142 178 143 179 if {$onlycheck} { … … 152 188 } 153 189 return $_value 190 } 191 192 # ---------------------------------------------------------------------- 193 # USAGE: _val2boolstr <val> 194 # 195 # Clients use this to query/set the value for this widget. With 196 # no args, it returns the current value for the widget. If the 197 # <newval> is specified, it sets the value of the widget and 198 # sends a <<Value>> event. If the -check flag is included, the 199 # new value is not actually applied, but just checked for correctness. 200 # ---------------------------------------------------------------------- 201 itcl::body Rappture::Switch::_val2boolstr {args} { 202 set newval "" 203 if {[llength $args] == 1} { 204 set val [lindex $args 0] 205 206 if {![string is integer -strict $val]} { 207 return $val 208 } 209 210 if { (2 == $val) || (3 == $val) } { 211 set newval [expr {($val%2) ? "yes" : "no"}] 212 } elseif { (4 == $val) || (5 == $val) } { 213 set newval [expr {($val%2) ? "on" : "off"}] 214 } elseif { (6 == $val) || (7 == $val) } { 215 set newval [expr {($val%2) ? "true" : "false"}] 216 } elseif { (0 == $val) || (1 == $val) } { 217 set newval [expr {($val%2) ? "1" : "0"}] 218 } 219 220 } elseif {[llength $args] != 0} { 221 error "wrong # args: should be \"_val2boolstr val\"" 222 } 223 224 return $newval 154 225 } 155 226
Note: See TracChangeset
for help on using the changeset viewer.