Changeset 1929 for trunk/gui/scripts/spinint.tcl
- Timestamp:
- Oct 22, 2010, 4:06:10 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/spinint.tcl
r1491 r1929 58 58 itcl::body Rappture::Spinint::constructor {args} { 59 59 itk_component add entry { 60 60 entry $itk_interior.entry 61 61 } { 62 63 64 65 66 62 usual 63 keep -width 64 rename -background -textbackground textBackground Background 65 rename -foreground -textforeground textForeground Foreground 66 rename -highlightbackground -background background Background 67 67 } 68 68 pack $itk_component(entry) -side left -expand yes -fill x 69 69 70 70 bind $itk_component(entry) <KeyPress> \ 71 71 [itcl::code $this _validate %A] 72 72 bind $itk_component(entry) <KeyPress-Return> \ 73 73 "$this value \[$itk_component(entry) get\]" 74 74 75 75 itk_component add controls { 76 76 frame $itk_interior.cntls 77 77 } 78 78 pack $itk_component(controls) -side right 79 79 80 80 itk_component add up { 81 82 83 81 button $itk_component(controls).spinup -bitmap Spinint-up \ 82 -borderwidth 1 -relief raised -highlightthickness 0 \ 83 -command [itcl::code $this bump up] 84 84 } { 85 86 85 usual 86 ignore -borderwidth -highlightthickness 87 87 } 88 88 pack $itk_component(up) -side top -expand yes -fill both 89 89 90 90 itk_component add down { 91 92 93 91 button $itk_component(controls).spindn -bitmap Spinint-down \ 92 -borderwidth 1 -relief raised -highlightthickness 0 \ 93 -command [itcl::code $this bump down] 94 94 } { 95 96 95 usual 96 ignore -borderwidth -highlightthickness 97 97 } 98 98 pack $itk_component(down) -side bottom -expand yes -fill both … … 111 111 itcl::body Rappture::Spinint::value {args} { 112 112 if {[llength $args] == 1} { 113 113 set newval [lindex $args 0] 114 114 115 116 117 118 119 120 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 } 123 123 124 125 126 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>>]] 127 127 } elseif {[llength $args] != 0} { 128 128 error "wrong # args: should be \"value ?newval?\"" 129 129 } 130 130 return [$itk_component(entry) get] … … 140 140 itcl::body Rappture::Spinint::bump {{delta up}} { 141 141 if {"up" == $delta} { 142 142 set delta $itk_option(-delta) 143 143 } elseif {"down" == $delta} { 144 144 set delta [expr {-$itk_option(-delta)}] 145 145 } elseif {![string is integer $delta]} { 146 146 error "bad delta \"$delta\": should be up, down, or integer" 147 147 } 148 148 149 149 set val [$itk_component(entry) get] 150 150 if {$val == ""} { 151 151 set val 0 152 152 } 153 153 value [expr {$val+$delta}] … … 163 163 itcl::body Rappture::Spinint::_validate {char} { 164 164 if {[string match "\[ -~\]" $char]} { 165 166 167 168 165 if {![string match "\[0-9\]" $char]} { 166 bell 167 return -code break 168 } 169 169 } 170 170 }
Note: See TracChangeset
for help on using the changeset viewer.