The helper specification is a record.
This is what a complete specification may look like:
h(drawNode:DrawNode
drawOrMove:DrawOrMove
allowCursor:AllowCursor
drawCursor:DrawCursor
getConnectionPoint:GetConnectionPoint
handleEvent:HandleEvent
getNodeWidth:GetNodeWidth
params:Params
)
DrawNode
:
(Node x Canvas x ScaledX:int x ScaledY:int -> NewItem)
This procedure does the actual drawing. Its arguments are the node to
be drawn, a "Canvas"-Object (which is NOT a real tk canvas) and the X-
and Y-coordinates of the middle of the new node.
The "Canvas" has a method for creating Objects:
tkGet(Tickle ?Id)
DrawOrMove
:
(Node -> bool)
This procedure gets a Node, and depending on the node's state should
decide whether the node has to be redrawn (if its state has changed)
or can be just moved (if necessary).
AllowCursor
:
(Node -> bool)
This procedure gets a node, and depending on the node's state should
decide whether this node (when selected) should get the cursor (or
whether this node can't be selected).
DrawCursor
:
(Node x Canvas x ScaledX:int x ScaledY:int -> )
This procedure draws the "cursor", the shadow under a selected
node.
GetConnectionPoint
:
(Node x Node x MomX:int x MomY:int x MyY:int -> int x int x int
x int)
This procedure gets the current node, this node's parent node, the
parent node's X and Y coordinates and its own Y coordinate and should
return the endpoints of the connection line between the node and its
parent.
HandleEvent
:
(Event -> )
This procedure is currently called when one of the following events
occurs:
nodeSelected(Node)
- the node Node
was
selected
nodeInspected(Node)
- the node Node
was double-clicked
(More events will be included in a future release)
GetNodeWidth
:
(Node -> int)
This procedure gets a node and returns the width this node occupies
(for dynamically sized nodes, e.g. with text labels).