obj method canvaseditor zoom {{how !?} {warp false}} { if {$warp} then { $self pointerToXY {*}[pointerXY] } set max 64 set changed no switch -exact -- $how { !? # in { if {[my zoom] < $max} then { my zoom [expr {[my zoom] * sqrt(2)}] set changed yes } } out { if {[my zoom] > 1} then { my zoom [expr {[my zoom] / sqrt(2)}] set changed yes } } original - none { if {[my zoom] != 1.0} then { my zoom 1.0 set changed yes } } default { my zoom [fexpr $how] set changed yes } } if {$changed} then { set diff [abs [- [my zoom] [round [my zoom]]]] if {$diff > 0 && $diff < 1e-13} then { my zoom [double [round [my zoom]]] } obj inscope dot set zoom [my zoom] $self canvas configure -scrollregion "0 0\ [* [$self setting width] [my zoom]]\ [* [$self setting height] [my zoom]]" after idle "event generate [my canvas] <Configure>" $self statusLine "Zoom [my zoom]" $self elements -all draw coords lassign [pointerXY] x y lassign [calcZoomClipping [$self canvasx $x] [$self canvasy $y]\ [winfo width [my canvas]] [winfo height [my canvas]] [my zoom]]\ clipX clipY $self canvas xview moveto $clipX $self canvas yview moveto $clipY } my zoom }
obj inscope canvaseditor proc calcZoomClipping {x y width height zoom} { set clipFrac [/ 1.0 $zoom 2] set xFrac [/ [double $x] [double $width]] set xLeft [- $xFrac $clipFrac] set yFrac [/ [double $y] [double $height]] set yTop [- $yFrac $clipFrac] list [max 0.0 $xLeft] [max 0.0 $yTop] }
obj method canvaseditor scrollbars {{onoff on}} { if {[$self canvas xview] eq "0.0 1.0" && [$self canvas yview] eq "0.0 1.0"} then { $self buildInfoWindow $self statusLine\ "No scrolling. Completely visible." } elseif {$onoff} then { $self pointerToXY {*}[pointerXY] $self basicBindings off bind [my canvas] <<Click>> "$self scrollbars off" bind [my canvas] <3> "$self scrollbars off" # place [my canvas].x -rely 1.0 -relx 0 -anchor sw\ -relwidth 1.0 -width -[winfo reqwidth [my canvas].y] place [my canvas].y -relx 1.0 -rely 0 -anchor ne\ -relheight 1.0 -height -[winfo reqheight [my canvas].x] # } else { place forget [my canvas].x place forget [my canvas].y $self basicBindings on } }
© Wolf-Dieter Busch | Home | Sitemap | Urheber | A-Z