Changeset 1924


Ignore:
Timestamp:
Oct 18, 2010, 7:20:38 PM (14 years ago)
Author:
dkearney
Message:

removing my previous changes to flowdial.tcl

File:
1 edited

Legend:

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

    r1916 r1924  
    3636    itk_option define -max max Max ""
    3737    itk_option define -variable variable Variable ""
    38     itk_option define -offset offset Offset 1
    3938
    4039    itk_option define -thickness thickness Thickness 0
     
    6867    protected method _fixSize {}
    6968    protected method _fixValue {args}
    70     protected method _fixOffsets {}
    7169
    7270    private method _current {value}
     
    8179    private variable _activecolor ""  ;# width allocated for values
    8280    private variable _vwidth 0        ;# width allocated for values
    83     private variable _offset_pos 1    ;#
    84     private variable _offset_neg -1   ;#
    8581    public variable min 0.0
    8682    public variable max 1.0
     
    10197    bind $itk_component(dial) <Configure> [itcl::code $this _redraw]
    10298
    103 #    if 0 {
     99    if 0 {
    104100    bind $itk_component(dial) <ButtonPress-1> [itcl::code $this _click %x %y]
    105101    bind $itk_component(dial) <B1-Motion> [itcl::code $this _click %x %y]
    106102    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]
    110105    $itk_component(dial) bind  "knob" <Enter> \
    111106        [list $itk_component(dial) configure -cursor sb_h_double_arrow]
    112107    $itk_component(dial) bind  "knob" <Leave> \
    113108        [list $itk_component(dial) configure -cursor ""]
    114 #    }
     109    }
    115110    eval itk_initialize $args
    116111
    117112    _fixSize
    118     _fixOffsets
    119113}
    120114
     
    137131itcl::body Rappture::Flowdial::current {value} {
    138132    if {"" == $value} {
    139         return
     133        return 
    140134    }
    141135    _current [ms2rel $value]
     
    154148    if { $relval < 0.0 } {
    155149        set relval 0.0
    156     }
     150    } 
    157151    if { $relval > 1.0 } {
    158152        set relval 1.0
    159     }
     153    }                                       
    160154    set _current $relval
    161155    after cancel [itcl::code $this _redraw]
     
    334328# clients.
    335329# ----------------------------------------------------------------------
    336 #itcl::body Rappture::Flowdial::_navigate {offset} {
    337 #    set index [lsearch -exact $_values $_current]
    338 #    if {$index >= 0} {
    339 #        incr index $offset
    340 #        if {$index >= [llength $_values]} {
    341 #            set index [expr {[llength $_values]-1}]
    342 #        } elseif {$index < 0} {
    343 #            set index 0
    344 #        }
    345 #
    346 #        set newval [lindex $_values $index]
    347 #        if {$newval != $_current} {
    348 #            current $newval
    349 #            _redraw
    350 #
    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 keys
    361 # to nudge the current value left or right by some <offset>.  If the
    362 # value actually changes, it generates a <<Value>> event to notify
    363 # clients.
    364 # ----------------------------------------------------------------------
    365330itcl::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    }
    368348}
    369349
     
    434414    upvar #0 $itk_option(-variable) var
    435415    _current [ms2rel $var]
    436 }
    437 
    438 # ----------------------------------------------------------------------
    439 # USAGE: _fixOffsets
    440 #
    441 # ----------------------------------------------------------------------
    442 itcl::body Rappture::Flowdial::_fixOffsets {} {
    443     if {0 == $itk_option(-offset)} {
    444         return
    445     }
    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]
    450416}
    451417
     
    624590    }
    625591}
    626 
    627 # ----------------------------------------------------------------------
    628 # CONFIGURE: -offset
    629 # ----------------------------------------------------------------------
    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     _fixOffsets
    635 }
Note: See TracChangeset for help on using the changeset viewer.