summaryrefslogtreecommitdiffstats
path: root/library/demos/arrow.tcl
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2001-06-14 10:56:58 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2001-06-14 10:56:58 (GMT)
commitcfa85ce7321d315e312a7bb23d4cdf0b2d666f47 (patch)
treeab207a698a3ec34347d9ed68baa80cb2825a3bd1 /library/demos/arrow.tcl
parent019ad61b8b1833368240e189ad1b47b00feaab4c (diff)
downloadtk-cfa85ce7321d315e312a7bb23d4cdf0b2d666f47.zip
tk-cfa85ce7321d315e312a7bb23d4cdf0b2d666f47.tar.gz
tk-cfa85ce7321d315e312a7bb23d4cdf0b2d666f47.tar.bz2
Added braces to expressions.
Diffstat (limited to 'library/demos/arrow.tcl')
-rw-r--r--library/demos/arrow.tcl89
1 files changed, 45 insertions, 44 deletions
diff --git a/library/demos/arrow.tcl b/library/demos/arrow.tcl
index 78befc3..5d37233 100644
--- a/library/demos/arrow.tcl
+++ b/library/demos/arrow.tcl
@@ -3,7 +3,7 @@
# This demonstration script creates a canvas widget that displays a
# large line with an arrowhead whose shape can be edited interactively.
#
-# RCS: @(#) $Id: arrow.tcl,v 1.2 1998/09/14 18:23:26 stanton Exp $
+# RCS: @(#) $Id: arrow.tcl,v 1.3 2001/06/14 10:56:58 dkf Exp $
if {![info exists widgetDemo]} {
error "This script should be run from the \"widget\" demo."
@@ -33,68 +33,69 @@ proc arrowSetup c {
# Create the arrow and outline.
$c delete all
- eval "$c create line $v(x1) $v(y) $v(x2) $v(y) -width [expr 10*$v(width)] \
- -arrowshape {[expr 10*$v(a)] [expr 10*$v(b)] [expr 10*$v(c)]} \
- -arrow last $v(bigLineStyle)"
- set xtip [expr $v(x2)-10*$v(b)]
- set deltaY [expr 10*$v(c)+5*$v(width)]
- $c create line $v(x2) $v(y) $xtip [expr $v(y)+$deltaY] \
- [expr $v(x2)-10*$v(a)] $v(y) $xtip [expr $v(y)-$deltaY] \
+ eval {$c create line $v(x1) $v(y) $v(x2) $v(y) -arrow last \
+ -width [expr {10*$v(width)}] -arrowshape [list \
+ [expr {10*$v(a)}] [expr {10*$v(b)}] [expr {10*$v(c)}]]} \
+ $v(bigLineStyle)
+ set xtip [expr {$v(x2)-10*$v(b)}]
+ set deltaY [expr {10*$v(c)+5*$v(width)}]
+ $c create line $v(x2) $v(y) $xtip [expr {$v(y)+$deltaY}] \
+ [expr {$v(x2)-10*$v(a)}] $v(y) $xtip [expr {$v(y)-$deltaY}] \
$v(x2) $v(y) -width 2 -capstyle round -joinstyle round
# Create the boxes for reshaping the line and arrowhead.
- eval "$c create rect [expr $v(x2)-10*$v(a)-5] [expr $v(y)-5] \
- [expr $v(x2)-10*$v(a)+5] [expr $v(y)+5] $v(boxStyle) \
- -tags {box1 box}"
- eval "$c create rect [expr $xtip-5] [expr $v(y)-$deltaY-5] \
- [expr $xtip+5] [expr $v(y)-$deltaY+5] $v(boxStyle) \
- -tags {box2 box}"
- eval "$c create rect [expr $v(x1)-5] [expr $v(y)-5*$v(width)-5] \
- [expr $v(x1)+5] [expr $v(y)-5*$v(width)+5] $v(boxStyle) \
- -tags {box3 box}"
+ eval {$c create rect [expr {$v(x2)-10*$v(a)-5}] [expr {$v(y)-5}] \
+ [expr {$v(x2)-10*$v(a)+5}] [expr {$v(y)+5}] \
+ -tags {box1 box}} $v(boxStyle)
+ eval {$c create rect [expr {$xtip-5}] [expr {$v(y)-$deltaY-5}] \
+ [expr {$xtip+5}] [expr {$v(y)-$deltaY+5}] \
+ -tags {box2 box}} $v(boxStyle)
+ eval {$c create rect [expr {$v(x1)-5}] [expr {$v(y)-5*$v(width)-5}] \
+ [expr {$v(x1)+5}] [expr {$v(y)-5*$v(width)+5}] \
+ -tags {box3 box}} $v(boxStyle)
if {$cur != ""} {
eval $c itemconfigure $cur $v(activeStyle)
}
# Create three arrows in actual size with the same parameters
- $c create line [expr $v(x2)+50] 0 [expr $v(x2)+50] 1000 \
+ $c create line [expr {$v(x2)+50}] 0 [expr {$v(x2)+50}] 1000 \
-width 2
- set tmp [expr $v(x2)+100]
- $c create line $tmp [expr $v(y)-125] $tmp [expr $v(y)-75] \
+ set tmp [expr {$v(x2)+100}]
+ $c create line $tmp [expr {$v(y)-125}] $tmp [expr {$v(y)-75}] \
-width $v(width) \
-arrow both -arrowshape "$v(a) $v(b) $v(c)"
- $c create line [expr $tmp-25] $v(y) [expr $tmp+25] $v(y) \
+ $c create line [expr {$tmp-25}] $v(y) [expr {$tmp+25}] $v(y) \
-width $v(width) \
-arrow both -arrowshape "$v(a) $v(b) $v(c)"
- $c create line [expr $tmp-25] [expr $v(y)+75] [expr $tmp+25] \
- [expr $v(y)+125] -width $v(width) \
+ $c create line [expr {$tmp-25}] [expr {$v(y)+75}] [expr {$tmp+25}] \
+ [expr {$v(y)+125}] -width $v(width) \
-arrow both -arrowshape "$v(a) $v(b) $v(c)"
# Create a bunch of other arrows and text items showing the
# current dimensions.
- set tmp [expr $v(x2)+10]
- $c create line $tmp [expr $v(y)-5*$v(width)] \
- $tmp [expr $v(y)-$deltaY] \
+ set tmp [expr {$v(x2)+10}]
+ $c create line $tmp [expr {$v(y)-5*$v(width)}] \
+ $tmp [expr {$v(y)-$deltaY}] \
-arrow both -arrowshape $v(smallTips)
- $c create text [expr $v(x2)+15] [expr $v(y)-$deltaY+5*$v(c)] \
+ $c create text [expr {$v(x2)+15}] [expr {$v(y)-$deltaY+5*$v(c)}] \
-text $v(c) -anchor w
- set tmp [expr $v(x1)-10]
- $c create line $tmp [expr $v(y)-5*$v(width)] \
- $tmp [expr $v(y)+5*$v(width)] \
+ set tmp [expr {$v(x1)-10}]
+ $c create line $tmp [expr {$v(y)-5*$v(width)}] \
+ $tmp [expr {$v(y)+5*$v(width)}] \
-arrow both -arrowshape $v(smallTips)
- $c create text [expr $v(x1)-15] $v(y) -text $v(width) -anchor e
- set tmp [expr $v(y)+5*$v(width)+10*$v(c)+10]
- $c create line [expr $v(x2)-10*$v(a)] $tmp $v(x2) $tmp \
+ $c create text [expr {$v(x1)-15}] $v(y) -text $v(width) -anchor e
+ set tmp [expr {$v(y)+5*$v(width)+10*$v(c)+10}]
+ $c create line [expr {$v(x2)-10*$v(a)}] $tmp $v(x2) $tmp \
-arrow both -arrowshape $v(smallTips)
- $c create text [expr $v(x2)-5*$v(a)] [expr $tmp+5] \
+ $c create text [expr {$v(x2)-5*$v(a)}] [expr {$tmp+5}] \
-text $v(a) -anchor n
- set tmp [expr $tmp+25]
- $c create line [expr $v(x2)-10*$v(b)] $tmp $v(x2) $tmp \
+ set tmp [expr {$tmp+25}]
+ $c create line [expr {$v(x2)-10*$v(b)}] $tmp $v(x2) $tmp \
-arrow both -arrowshape $v(smallTips)
- $c create text [expr $v(x2)-5*$v(b)] [expr $tmp+5] \
+ $c create text [expr {$v(x2)-5*$v(b)}] [expr {$tmp+5}] \
-text $v(b) -anchor n
$c create text $v(x1) 310 -text "-width $v(width)" \
@@ -168,7 +169,7 @@ bind $c <Any-ButtonRelease-1> "arrowSetup $c"
proc arrowMove1 {c x y} {
upvar #0 demo_arrowInfo v
- set newA [expr ($v(x2)+5-round([$c canvasx $x]))/10]
+ set newA [expr {($v(x2)+5-round([$c canvasx $x]))/10}]
if {$newA < 0} {
set newA 0
}
@@ -176,7 +177,7 @@ proc arrowMove1 {c x y} {
set newA 25
}
if {$newA != $v(a)} {
- $c move box1 [expr 10*($v(a)-$newA)] 0
+ $c move box1 [expr {10*($v(a)-$newA)}] 0
set v(a) $newA
}
}
@@ -192,14 +193,14 @@ proc arrowMove1 {c x y} {
proc arrowMove2 {c x y} {
upvar #0 demo_arrowInfo v
- set newB [expr ($v(x2)+5-round([$c canvasx $x]))/10]
+ set newB [expr {($v(x2)+5-round([$c canvasx $x]))/10}]
if {$newB < 0} {
set newB 0
}
if {$newB > 25} {
set newB 25
}
- set newC [expr ($v(y)+5-round([$c canvasy $y])-5*$v(width))/10]
+ set newC [expr {($v(y)+5-round([$c canvasy $y])-5*$v(width))/10}]
if {$newC < 0} {
set newC 0
}
@@ -207,7 +208,7 @@ proc arrowMove2 {c x y} {
set newC 20
}
if {($newB != $v(b)) || ($newC != $v(c))} {
- $c move box2 [expr 10*($v(b)-$newB)] [expr 10*($v(c)-$newC)]
+ $c move box2 [expr {10*($v(b)-$newB)}] [expr {10*($v(c)-$newC)}]
set v(b) $newB
set v(c) $newC
}
@@ -224,7 +225,7 @@ proc arrowMove2 {c x y} {
proc arrowMove3 {c x y} {
upvar #0 demo_arrowInfo v
- set newWidth [expr ($v(y)+2-round([$c canvasy $y]))/5]
+ set newWidth [expr {($v(y)+2-round([$c canvasy $y]))/5}]
if {$newWidth < 0} {
set newWidth 0
}
@@ -232,7 +233,7 @@ proc arrowMove3 {c x y} {
set newWidth 20
}
if {$newWidth != $v(width)} {
- $c move box3 0 [expr 5*($v(width)-$newWidth)]
+ $c move box3 0 [expr {5*($v(width)-$newWidth)}]
set v(width) $newWidth
}
}