# items.tcl --
#
# This demonstration script creates a canvas that displays the
# canvas item types.
#
# SCCS: @(#) items.tcl 1.14 96/10/04 17:09:35
catch {destroy $w}
toplevel $w
label $w.msg -font $font -wraplength 5i -justify left -text "This window contains a canvas widget with examples of the various kinds of items supported by canvases. The following operations are supported:\n Button-1 drag:\tmoves item under pointer.\n Button-2 drag:\trepositions view.\n Button-3 drag:\tstrokes out area.\n Ctrl+f:\t\tprints items under area."
frame $w.frame
-xscrollcommand "$w.frame.hscroll set" \
-yscrollcommand "$w.frame.vscroll set"
# Display a 3x3 rectangular grid.
set blue DeepSkyBlue3
} else {
}
# Set up demos within each of the areas of the grid.
-text "A short string of text, word-wrapped, justified left, and anchored north (at the top). The rectangles show the anchor points for each piece of text." -tags item
-text "Several lines,\n each centered\nindividually,\nand all anchored\nat the left edge." \
# Set up event bindings for canvas:
# Utility procedures for highlighting the item under the pointer:
global restoreCmd
set restoreCmd {}
return
}
set restoreCmd {}
return
}
return
}
set restoreCmd "$c itemconfig current -outline $outline"
} else {
set restoreCmd "$c itemconfig current -fill $fill"
}
}
global restoreCmd
eval $restoreCmd
}
# Utility procedures for stroking out a rectangle and printing what's
# underneath the rectangle's area.
}
}
}
set items ""
}
}
puts stdout "Items enclosed by area: $items"
set items ""
}
}
puts stdout "Items overlapping area: $items"
}
# Utility procedures to support dragging of items.
}
}
# Procedure that's invoked when the button embedded in the canvas
# is invoked.
after 500 "$w delete $i"
}