Changeset 1342 for trunk/gui/scripts/animover.tcl
- Timestamp:
- Mar 18, 2009, 2:59:21 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/animover.tcl
r115 r1342 31 31 32 32 constructor {args} { # defined below } 33 33 34 34 protected method _redraw {} 35 35 protected variable _x0 0 ;# min value for middle image … … 46 46 private common images 47 47 set images(bgl) [image create photo -file \ 48 48 [file join $dir images bgl.gif]] 49 49 set images(bgr) [image create photo -file \ 50 51 } 52 50 [file join $dir images bgr.gif]] 51 } 52 53 53 itk::usual Animover { 54 54 } … … 59 59 itcl::body Rappture::Animover::constructor {args} { 60 60 itk_component add area { 61 62 61 canvas $itk_interior.area \ 62 -height [expr {[image height $images(bgl)]+4}] 63 63 } { 64 65 64 usual 65 keep -width 66 66 } 67 67 pack $itk_component(area) -expand yes -fill both … … 95 95 set midw 0 96 96 if {$itk_option(-middleimage) != ""} { 97 97 set midw [expr {[image width $itk_option(-middleimage)]/2}] 98 98 } 99 99 100 100 if {$itk_option(-leftimage) != ""} { 101 102 103 101 $c create image 4 $hmid -anchor w \ 102 -image $itk_option(-leftimage) 103 set _x0 [expr {4+[image width $itk_option(-leftimage)]+$midw}] 104 104 } else { 105 105 set _x0 [expr {4+$midw}] 106 106 } 107 107 if {$_x0 < 0} { set _x0 0 } 108 108 109 109 if {$itk_option(-rightimage) != ""} { 110 111 112 110 $c create image [expr {$w-4}] $hmid -anchor e \ 111 -image $itk_option(-rightimage) 112 set _x1 [expr {$w-4-[image width $itk_option(-rightimage)]-$midw}] 113 113 } else { 114 114 set _x1 [expr {$w-4-$midw}] 115 115 } 116 116 117 117 if {$_x >= 0} { 118 119 120 121 122 123 124 125 126 118 if {$_x < $_x0} { 119 set _x $_x0 120 } elseif {$_x > $_x1} { 121 set _x $_x1 122 } 123 if {$itk_option(-middleimage) != ""} { 124 $c create image $_x $hmid -anchor c \ 125 -image $itk_option(-middleimage) -tags middle 126 } 127 127 } 128 128 } … … 138 138 itcl::body Rappture::Animover::_animate {} { 139 139 if {$_x >= 0 && $_x0 < $_x1} { 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 140 if {$_x+$_dx <= $_x0} { 141 if {$itk_option(-direction) == "left"} { 142 set _x $_x1 143 } elseif {$itk_option(-direction) == "both"} { 144 set _dx [expr {-$_dx}] 145 set _x [expr {$_x+$_dx}] 146 } 147 } elseif {$_x+$_dx >= $_x1} { 148 if {$itk_option(-direction) == "right"} { 149 set _x $_x0 150 } elseif {$itk_option(-direction) == "both"} { 151 set _dx [expr {-$_dx}] 152 set _x [expr {$_x+$_dx}] 153 } 154 } else { 155 set _x [expr {$_x+$_dx}] 156 } 157 158 set c $itk_component(area) 159 set h [winfo height $c] 160 set hmid [expr {$h/2}] 161 162 if {[$c find withtag middle] == ""} { 163 $c create image $_x $hmid -anchor c \ 164 -image $itk_option(-middleimage) -tags middle 165 } else { 166 $c coords middle $_x $hmid 167 } 168 168 } 169 169 if {$_x >= 0} { 170 170 after $itk_option(-delay) [itcl::code $this _animate] 171 171 } 172 172 } … … 178 178 itcl::configbody Rappture::Animover::running { 179 179 switch -- $itk_option(-running) { 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 180 normal { 181 if {$_x < 0} { 182 set _x $_x0 183 after idle [itcl::code $this _animate] 184 } 185 } 186 disabled { 187 if {$_x > 0} { 188 set _x -1 189 after cancel [itcl::code $this _animate] 190 $itk_component(area) delete middle 191 } 192 } 193 default { 194 error "bad value \"$itk_option(-running)\": should be normal or disabled" 195 } 196 196 } 197 197 } … … 203 203 itcl::configbody Rappture::Animover::direction { 204 204 switch -- $itk_option(-direction) { 205 206 207 208 209 210 205 left { set _dx [expr {-1*$itk_option(-delta)}] } 206 right { set _dx $itk_option(-delta) } 207 both { set _dx $itk_option(-delta) } 208 default { 209 error "bad value \"$itk_option(-direction)\": should be left, right, or both" 210 } 211 211 } 212 212 } … … 218 218 itcl::configbody Rappture::Animover::delta { 219 219 if {$itk_option(-delta) < 1} { 220 221 } 222 } 220 error "bad value \"$itk_option(-delta)\": should be int >= 1" 221 } 222 }
Note: See TracChangeset
for help on using the changeset viewer.