# arrow.tcl --
#
# This demonstration script creates a canvas widget that displays a
# large line with an arrowhead whose shape can be edited interactively.
#
# SCCS: @(#) arrow.tcl 1.6 96/04/12 12:08:30
# arrowSetup --
# This procedure regenerates all the text and graphics in the canvas
# window. It's called when the canvas is initially created, and also
# whenever any of the parameters of the arrow head are changed
# interactively.
#
# Arguments:
# c - Name of the canvas widget.
upvar #0 demo_arrowInfo v
# Remember the current box, if there is one.
} else {
set cur ""
}
# Create the arrow and outline.
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)"
# 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}"
}
# Create three arrows in actual size with the same parameters
# Create a bunch of other arrows and text items showing the
# current dimensions.
}
global tk_library
catch {destroy $w}
toplevel $w
label $w.msg -font $font -wraplength 5i -justify left -text "This widget allows you to experiment with different widths and arrowhead shapes for lines in canvases. To change the line width or the shape of the arrowhead, drag any of the three boxes attached to the oversized arrow. The arrows on the right give examples at normal scale. The text at the bottom shows the configuration options as you'd enter them for a canvas line item."
} else {
-stipple @[file join $tk_library demos images grey.25]"
}
# arrowMove1 --
# This procedure is called for each mouse motion event on box1 (the
# one at the vertex of the arrow). It updates the controlling parameters
# for the line and arrowhead.
#
# Arguments:
# c - The name of the canvas window.
# x, y - The coordinates of the mouse.
upvar #0 demo_arrowInfo v
}
}
}
}
# arrowMove2 --
# This procedure is called for each mouse motion event on box2 (the
# one at the trailing tip of the arrowhead). It updates the controlling
# parameters for the line and arrowhead.
#
# Arguments:
# c - The name of the canvas window.
# x, y - The coordinates of the mouse.
upvar #0 demo_arrowInfo v
}
}
}
}
}
}
# arrowMove3 --
# This procedure is called for each mouse motion event on box3 (the
# one that controls the thickness of the line). It updates the
# controlling parameters for the line and arrowhead.
#
# Arguments:
# c - The name of the canvas window.
# x, y - The coordinates of the mouse.
upvar #0 demo_arrowInfo v
}
}
}
}