# ruler.tcl --
#
# This demonstration script creates a canvas widget that displays a ruler
# with tab stops that can be set, moved, and deleted.
#
# SCCS: @(#) ruler.tcl 1.8 96/04/12 12:12:27
# rulerMkTab --
# This procedure creates a new triangular polygon in a canvas to
# represent a tab stop.
#
# Arguments:
# c - The canvas window.
# x, y - Coordinates at which to create the tab stop.
upvar #0 demo_rulerInfo v
}
global tk_library
catch {destroy $w}
toplevel $w
label $w.msg -font $font -wraplength 5i -justify left -text "This canvas widget shows a mock-up of a ruler. You can create tab stops by dragging them out of the well to the right of the ruler. You can also drag existing tab stops. If you drag a tab stop far enough up or down so that it turns dim, it will be deleted when you release the mouse button."
set demo_rulerInfo(grid) .25c
} else {
}
}
# rulerNewTab --
# Does all the work of creating a tab stop, including creating the
# triangle object and adding tags to it to give it tab behavior.
#
# Arguments:
# c - The canvas window.
# x, y - The coordinates of the tab stop.
upvar #0 demo_rulerInfo v
}
# rulerSelectTab --
# This procedure is invoked when mouse button 1 is pressed over
# a tab. It remembers information about the tab so that it can
# be dragged interactively.
#
# Arguments:
# c - The canvas widget.
# x, y - The coordinates of the mouse (identifies the point by
# which the tab was picked up for dragging).
upvar #0 demo_rulerInfo v
eval "$c itemconf active $v(activeStyle)"
}
# rulerMoveTab --
# This procedure is invoked during mouse motion events to drag a tab.
# It adjusts the position of the tab, and changes its appearance if
# it is about to be dragged out of the ruler.
#
# Arguments:
# c - The canvas widget.
# x, y - The coordinates of the mouse.
upvar #0 demo_rulerInfo v
return
}
}
}
eval "$c itemconf active $v(activeStyle)"
} else {
eval "$c itemconf active $v(deleteStyle)"
}
}
# rulerReleaseTab --
# This procedure is invoked during button release events that end
# a tab drag operation. It deselects the tab and deletes the tab if
# it was dragged out of the ruler.
#
# Arguments:
# c - The canvas widget.
# x, y - The coordinates of the mouse.
upvar #0 demo_rulerInfo v
return
}
} else {
eval "$c itemconf active $v(normalStyle)"
}
}