Changeset 1924
- Timestamp:
- Oct 18, 2010, 7:20:38 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/flowdial.tcl
r1916 r1924 36 36 itk_option define -max max Max "" 37 37 itk_option define -variable variable Variable "" 38 itk_option define -offset offset Offset 139 38 40 39 itk_option define -thickness thickness Thickness 0 … … 68 67 protected method _fixSize {} 69 68 protected method _fixValue {args} 70 protected method _fixOffsets {}71 69 72 70 private method _current {value} … … 81 79 private variable _activecolor "" ;# width allocated for values 82 80 private variable _vwidth 0 ;# width allocated for values 83 private variable _offset_pos 1 ;#84 private variable _offset_neg -1 ;#85 81 public variable min 0.0 86 82 public variable max 1.0 … … 101 97 bind $itk_component(dial) <Configure> [itcl::code $this _redraw] 102 98 103 #if 0 {99 if 0 { 104 100 bind $itk_component(dial) <ButtonPress-1> [itcl::code $this _click %x %y] 105 101 bind $itk_component(dial) <B1-Motion> [itcl::code $this _click %x %y] 106 102 bind $itk_component(dial) <ButtonRelease-1> [itcl::code $this _click %x %y] 107 #bind $itk_component(hull) <KeyPress-Left> [itcl::code $this _navigate $_offset_neg] 108 #bind $itk_component(hull) <KeyPress-Right> [itcl::code $this _navigate $_offset_pos] 109 103 bind $itk_component(hull) <KeyPress-Left> [itcl::code $this _navigate -1] 104 bind $itk_component(hull) <KeyPress-Right> [itcl::code $this _navigate 1] 110 105 $itk_component(dial) bind "knob" <Enter> \ 111 106 [list $itk_component(dial) configure -cursor sb_h_double_arrow] 112 107 $itk_component(dial) bind "knob" <Leave> \ 113 108 [list $itk_component(dial) configure -cursor ""] 114 #}109 } 115 110 eval itk_initialize $args 116 111 117 112 _fixSize 118 _fixOffsets119 113 } 120 114 … … 137 131 itcl::body Rappture::Flowdial::current {value} { 138 132 if {"" == $value} { 139 return 133 return 140 134 } 141 135 _current [ms2rel $value] … … 154 148 if { $relval < 0.0 } { 155 149 set relval 0.0 156 } 150 } 157 151 if { $relval > 1.0 } { 158 152 set relval 1.0 159 } 153 } 160 154 set _current $relval 161 155 after cancel [itcl::code $this _redraw] … … 334 328 # clients. 335 329 # ---------------------------------------------------------------------- 336 #itcl::body Rappture::Flowdial::_navigate {offset} {337 # set index [lsearch -exact $_values $_current]338 # if {$index >= 0} {339 # incr index $offset340 # if {$index >= [llength $_values]} {341 # set index [expr {[llength $_values]-1}]342 # } elseif {$index < 0} {343 # set index 0344 # }345 #346 # set newval [lindex $_values $index]347 # if {$newval != $_current} {348 # current $newval349 # _redraw350 #351 # event generate $itk_component(hull) <<Value>>352 # }353 # }354 #}355 356 357 # ----------------------------------------------------------------------358 # USAGE: _navigate <offset>359 #360 # Called automatically whenever the user presses left/right keys361 # to nudge the current value left or right by some <offset>. If the362 # value actually changes, it generates a <<Value>> event to notify363 # clients.364 # ----------------------------------------------------------------------365 330 itcl::body Rappture::Flowdial::_navigate {offset} { 366 _current [ms2rel [expr $_current + $offset]] 367 event generate $itk_component(hull) <<Value>> 331 set index [lsearch -exact $_values $_current] 332 if {$index >= 0} { 333 incr index $offset 334 if {$index >= [llength $_values]} { 335 set index [expr {[llength $_values]-1}] 336 } elseif {$index < 0} { 337 set index 0 338 } 339 340 set newval [lindex $_values $index] 341 if {$newval != $_current} { 342 current $newval 343 _redraw 344 345 event generate $itk_component(hull) <<Value>> 346 } 347 } 368 348 } 369 349 … … 434 414 upvar #0 $itk_option(-variable) var 435 415 _current [ms2rel $var] 436 }437 438 # ----------------------------------------------------------------------439 # USAGE: _fixOffsets440 #441 # ----------------------------------------------------------------------442 itcl::body Rappture::Flowdial::_fixOffsets {} {443 if {0 == $itk_option(-offset)} {444 return445 }446 set _offset_pos $itk_option(-offset)447 set _offset_neg [expr -1*$_offset_pos]448 bind $itk_component(hull) <KeyPress-Left> [itcl::code $this _navigate $_offset_neg]449 bind $itk_component(hull) <KeyPress-Right> [itcl::code $this _navigate $_offset_pos]450 416 } 451 417 … … 624 590 } 625 591 } 626 627 # ----------------------------------------------------------------------628 # CONFIGURE: -offset629 # ----------------------------------------------------------------------630 itcl::configbody Rappture::Flowdial::offset {631 if {![string is double $itk_option(-offset)]} {632 error "bad value \"$itk_option(-offset)\": should be >= 0.0"633 }634 _fixOffsets635 }
Note: See TracChangeset
for help on using the changeset viewer.