diff options
Diffstat (limited to 'library/demos/items.tcl')
-rw-r--r-- | library/demos/items.tcl | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/library/demos/items.tcl b/library/demos/items.tcl index 11aa32f..c665be2 100644 --- a/library/demos/items.tcl +++ b/library/demos/items.tcl @@ -3,7 +3,7 @@ # This demonstration script creates a canvas that displays the # canvas item types. # -# RCS: @(#) $Id: items.tcl,v 1.7 2004/12/21 11:56:35 dkf Exp $ +# RCS: @(#) $Id: items.tcl,v 1.11 2010/01/04 22:13:59 patthoyts Exp $ if {![info exists widgetDemo]} { error "This script should be run from the \"widget\" demo." @@ -128,8 +128,8 @@ $c create text 25.5c 11c -anchor w -font $font1 -fill $blue \ -text "Several lines,\n each centered\nindividually,\nand all anchored\nat the left edge." \ -justify center -tags item $c create rectangle 24.9c 13.9c 25.1c 14.1c -$c create text 25c 14c -font $font2 -anchor c -fill $red -stipple gray50 \ - -text "Stippled characters" -tags item +$c create text 25c 14c -font $font2 -anchor c -fill $red -angle 15 \ + -text "Angled characters" -tags item $c create text 5c 16.2c -text Arcs -anchor n $c create arc 0.5c 17c 7c 20c -fill $green -outline black \ @@ -142,9 +142,13 @@ $c create arc 0.5c 20c 9.5c 24c -width 4m -style pieslice \ $c create arc 5.5c 20.5c 9.5c 23.5c -width 4m -style chord \ -fill $blue -outline {} -start 45 -extent 270 -tags item -$c create text 15c 16.2c -text Bitmaps -anchor n -$c create bitmap 13c 20c -tags item \ - -bitmap @[file join $tk_demoDirectory images face.xbm] +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 text 15c 16.2c -text "Bitmaps and Images" -anchor n +$c create image 13c 20c -tags item -image items.ousterhout \ + -activeimage items.ousterhout.active $c create bitmap 17c 18.5c -tags item \ -bitmap @[file join $tk_demoDirectory images noletter.xbm] $c create bitmap 17c 21.5c -tags item \ @@ -185,15 +189,18 @@ proc itemEnter {c} { return } set type [$c type current] - if {$type == "window"} { + if {$type == "window" || $type == "image"} { set restoreCmd {} return - } - if {$type == "bitmap"} { + } elseif {$type == "bitmap"} { set bg [lindex [$c itemconf current -background] 4] set restoreCmd [list $c itemconfig current -background $bg] $c itemconfig current -background SteelBlue2 return + } elseif {$type == "image"} { + set restoreCmd [list $c itemconfig current -state normal] + $c itemconfig current -state active + return } set fill [lindex [$c itemconfig current -fill] 4] if {(($type == "rectangle") || ($type == "oval") || ($type == "arc")) @@ -281,6 +288,6 @@ proc itemDrag {c x y} { # is invoked. proc butPress {w color} { - set i [$w create text 25c 18.1c -text "Ouch!!" -fill $color -anchor n] + set i [$w create text 25c 18.1c -text "Oooohhh!!" -fill $color -anchor n] after 500 "$w delete $i" } |