summaryrefslogtreecommitdiffstats
path: root/library/demos/items.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'library/demos/items.tcl')
-rw-r--r--library/demos/items.tcl47
1 files changed, 26 insertions, 21 deletions
diff --git a/library/demos/items.tcl b/library/demos/items.tcl
index 19cd4f4..5dc14b8 100644
--- a/library/demos/items.tcl
+++ b/library/demos/items.tcl
@@ -34,6 +34,13 @@ canvas $c -scrollregion {0c 0c 30c 24c} -width 15c -height 10c \
ttk::scrollbar $w.frame.vscroll -command "$c yview"
ttk::scrollbar $w.frame.hscroll -orient horizontal -command "$c xview"
+bind $c <TouchpadScroll> {
+ lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
+ if {$deltaX != 0 || $deltaY != 0} {
+ tk::ScrollByPixels %W $deltaX $deltaY
+ }
+}
+
grid $c -in $w.frame \
-row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news
grid $w.frame.vscroll \
@@ -45,11 +52,11 @@ grid columnconfig $w.frame 0 -weight 1 -minsize 0
# Display a 3x3 rectangular grid.
-$c create rect 0c 0c 30c 24c -width 2
-$c create line 0c 8c 30c 8c -width 2
-$c create line 0c 16c 30c 16c -width 2
-$c create line 10c 0c 10c 24c -width 2
-$c create line 20c 0c 20c 24c -width 2
+$c create rect 0c 0c 30c 24c -width 1.5p
+$c create line 0c 8c 30c 8c -width 1.5p
+$c create line 0c 16c 30c 16c -width 1.5p
+$c create line 10c 0c 10c 24c -width 1.5p
+$c create line 20c 0c 20c 24c -width 1.5p
set font1 {Helvetica 12}
set font2 {Helvetica 24 bold}
@@ -74,7 +81,7 @@ $c create line 4.67c 1c 4.67c 4c -arrow last -tags item
$c create line 6.33c 1c 6.33c 4c -arrow both -tags item
$c create line 5c 6c 9c 6c 9c 1c 8c 1c 8c 4.8c 8.8c 4.8c 8.8c 1.2c \
8.2c 1.2c 8.2c 4.6c 8.6c 4.6c 8.6c 1.4c 8.4c 1.4c 8.4c 4.4c \
- -width 3 -fill $red -tags item
+ -width 2.25p -fill $red -tags item
# Main widget program sets variable tk_demoDirectory
$c create line 1c 5c 7c 5c 7c 7c 9c 7c -width .5c \
-stipple @[file join $tk_demoDirectory images gray25.xbm] \
@@ -86,7 +93,7 @@ $c create text 15c .2c -text "Curves (smoothed lines)" -anchor n
$c create line 11c 4c 11.5c 1c 13.5c 1c 14c 4c -smooth on \
-fill $blue -tags item
$c create line 15.5c 1c 19.5c 1.5c 15.5c 4.5c 19.5c 4c -smooth on \
- -arrow both -width 3 -tags item
+ -arrow both -width 2.25p -tags item
$c create line 12c 6c 13.5c 4.5c 16.5c 7.5c 18c 6c \
16.5c 4.5c 13.5c 7.5c 12c 6c -smooth on -width 3m -cap round \
-stipple @[file join $tk_demoDirectory images gray25.xbm] \
@@ -95,7 +102,7 @@ $c create line 12c 6c 13.5c 4.5c 16.5c 7.5c 18c 6c \
$c create text 25c .2c -text Polygons -anchor n
$c create polygon 21c 1.0c 22.5c 1.75c 24c 1.0c 23.25c 2.5c \
24c 4.0c 22.5c 3.25c 21c 4.0c 21.75c 2.5c -fill $green \
- -outline {} -width 4 -tags item
+ -outline {} -width 3p -tags item
$c create polygon 25c 4c 25c 4c 25c 1c 26c 1c 27c 4c 28c 1c \
29c 1c 29c 4c 29c 4c -fill $red -outline {} -smooth on -tags item
$c create polygon 22c 4.5c 25c 4.5c 25c 6.75c 28c 6.75c \
@@ -148,8 +155,13 @@ image create photo items.ousterhout \
-file [file join $tk_demoDirectory images ouster.png]
image create photo items.ousterhout.active -format "png -alpha 0.5" \
-file [file join $tk_demoDirectory images ouster.png]
-$c create image 13c 20c -tags item -image items.ousterhout \
- -activeimage items.ousterhout.active
+set zoomFactor [expr {$tk::scalingPct / 100}]
+foreach img {items.ousterhout items.ousterhout.active} {
+ image create photo ${img}2
+ ${img}2 copy $img -zoom $zoomFactor
+}
+$c create image 13c 20c -tags item -image items.ousterhout2 \
+ -activeimage items.ousterhout.active2
}
$c create bitmap 17c 18.5c -tags item \
-bitmap @[file join $tk_demoDirectory images noletter.xbm]
@@ -173,17 +185,10 @@ $c create text 28.5c 17.4c -text Scale: -anchor s
$c bind item <Enter> "itemEnter $c"
$c bind item <Leave> "itemLeave $c"
-if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} {
- bind $c <Button-2> "itemMark $c %x %y"
- bind $c <B2-Motion> "itemStroke $c %x %y"
- bind $c <Button-3> "$c scan mark %x %y"
- bind $c <B3-Motion> "$c scan dragto %x %y"
-} else {
- bind $c <Button-2> "$c scan mark %x %y"
- bind $c <B2-Motion> "$c scan dragto %x %y"
- bind $c <Button-3> "itemMark $c %x %y"
- bind $c <B3-Motion> "itemStroke $c %x %y"
-}
+bind $c <Button-2> "$c scan mark %x %y"
+bind $c <B2-Motion> "$c scan dragto %x %y"
+bind $c <Button-3> "itemMark $c %x %y"
+bind $c <B3-Motion> "itemStroke $c %x %y"
bind $c <<NextChar>> "itemsUnderArea $c"
bind $c <Button-1> "itemStartDrag $c %x %y"
bind $c <B1-Motion> "itemDrag $c %x %y"