Ignore:
Timestamp:
Oct 22, 2010, 4:06:10 PM (14 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

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

    r1491 r1929  
    5858itcl::body Rappture::Spinint::constructor {args} {
    5959    itk_component add entry {
    60         entry $itk_interior.entry
     60        entry $itk_interior.entry
    6161    } {
    62         usual
    63         keep -width
    64         rename -background -textbackground textBackground Background
    65         rename -foreground -textforeground textForeground Foreground
    66         rename -highlightbackground -background background Background
     62        usual
     63        keep -width
     64        rename -background -textbackground textBackground Background
     65        rename -foreground -textforeground textForeground Foreground
     66        rename -highlightbackground -background background Background
    6767    }
    6868    pack $itk_component(entry) -side left -expand yes -fill x
    6969
    7070    bind $itk_component(entry) <KeyPress> \
    71         [itcl::code $this _validate %A]
     71        [itcl::code $this _validate %A]
    7272    bind $itk_component(entry) <KeyPress-Return> \
    73         "$this value \[$itk_component(entry) get\]"
     73        "$this value \[$itk_component(entry) get\]"
    7474
    7575    itk_component add controls {
    76         frame $itk_interior.cntls
     76        frame $itk_interior.cntls
    7777    }
    7878    pack $itk_component(controls) -side right
    7979
    8080    itk_component add up {
    81         button $itk_component(controls).spinup -bitmap Spinint-up \
    82             -borderwidth 1 -relief raised -highlightthickness 0 \
    83             -command [itcl::code $this bump up]
     81        button $itk_component(controls).spinup -bitmap Spinint-up \
     82            -borderwidth 1 -relief raised -highlightthickness 0 \
     83            -command [itcl::code $this bump up]
    8484    } {
    85         usual
    86         ignore -borderwidth -highlightthickness
     85        usual
     86        ignore -borderwidth -highlightthickness
    8787    }
    8888    pack $itk_component(up) -side top -expand yes -fill both
    8989
    9090    itk_component add down {
    91         button $itk_component(controls).spindn -bitmap Spinint-down \
    92             -borderwidth 1 -relief raised -highlightthickness 0 \
    93             -command [itcl::code $this bump down]
     91        button $itk_component(controls).spindn -bitmap Spinint-down \
     92            -borderwidth 1 -relief raised -highlightthickness 0 \
     93            -command [itcl::code $this bump down]
    9494    } {
    95         usual
    96         ignore -borderwidth -highlightthickness
     95        usual
     96        ignore -borderwidth -highlightthickness
    9797    }
    9898    pack $itk_component(down) -side bottom -expand yes -fill both
     
    111111itcl::body Rappture::Spinint::value {args} {
    112112    if {[llength $args] == 1} {
    113         set newval [lindex $args 0]
     113        set newval [lindex $args 0]
    114114
    115         if {"" != $newval} {
    116             if {"" != $itk_option(-min) && $newval < $itk_option(-min)} {
    117                 set newval $itk_option(-min)
    118             }
    119             if {"" != $itk_option(-max) && $newval > $itk_option(-max)} {
    120                 set newval $itk_option(-max)
    121             }
    122         }
     115        if {"" != $newval} {
     116            if {"" != $itk_option(-min) && $newval < $itk_option(-min)} {
     117                set newval $itk_option(-min)
     118            }
     119            if {"" != $itk_option(-max) && $newval > $itk_option(-max)} {
     120                set newval $itk_option(-max)
     121            }
     122        }
    123123
    124         $itk_component(entry) delete 0 end
    125         $itk_component(entry) insert 0 $newval
    126         after 10 [list catch [list event generate $itk_component(hull) <<Value>>]]
     124        $itk_component(entry) delete 0 end
     125        $itk_component(entry) insert 0 $newval
     126        after 10 [list catch [list event generate $itk_component(hull) <<Value>>]]
    127127    } elseif {[llength $args] != 0} {
    128         error "wrong # args: should be \"value ?newval?\""
     128        error "wrong # args: should be \"value ?newval?\""
    129129    }
    130130    return [$itk_component(entry) get]
     
    140140itcl::body Rappture::Spinint::bump {{delta up}} {
    141141    if {"up" == $delta} {
    142         set delta $itk_option(-delta)
     142        set delta $itk_option(-delta)
    143143    } elseif {"down" == $delta} {
    144         set delta [expr {-$itk_option(-delta)}]
     144        set delta [expr {-$itk_option(-delta)}]
    145145    } elseif {![string is integer $delta]} {
    146         error "bad delta \"$delta\": should be up, down, or integer"
     146        error "bad delta \"$delta\": should be up, down, or integer"
    147147    }
    148148
    149149    set val [$itk_component(entry) get]
    150150    if {$val == ""} {
    151         set val 0
     151        set val 0
    152152    }
    153153    value [expr {$val+$delta}]
     
    163163itcl::body Rappture::Spinint::_validate {char} {
    164164    if {[string match "\[ -~\]" $char]} {
    165         if {![string match "\[0-9\]" $char]} {
    166             bell
    167             return -code break
    168         }
     165        if {![string match "\[0-9\]" $char]} {
     166            bell
     167            return -code break
     168        }
    169169    }
    170170}
Note: See TracChangeset for help on using the changeset viewer.