- NAME
- Tree
- Tree widget
- CREATION
- Tree pathName ?option value...?
- STANDARD OPTIONS
- WIDGET-SPECIFIC OPTIONS
- WIDGET COMMAND
- pathName bindImage
event
script
- pathName bindText
event
script
- pathName cget
option
- pathName closetree
node
- pathName configure
?option? ?value option value ...?
- pathName delete
?arg...?
- pathName edit
node
?clickres?
?select?
- pathName exists
node
- pathName index
node
- pathName insert
index
parent
node
?option value...?
- pathName itemcget
node
option
- pathName itemconfigure
node
?option? ?value option value ...?
- pathName move
parent
node
index
- pathName nodes
node
- pathName opentree
node
- pathName parent
node
- pathName see
node
- pathName selection
cmd
?arg...?
- pathName xview
?arg...?
- pathName yview
?arg...?
DESCRIPTION
Tree widget uses canvas to display a hierarchical list of items (called nodes).
Each node is composed of a label with its own font and foreground attributes, and an optional
image or window. Each node can have a list of subnodes, which can be collapsed or expanded.
Each node is drawn in a single line, whose height is defined by the
deltay option, so they must have at most this height.
A node is uniquely identified by a string given at creation (by the
insert command). The node named root is the root of
the tree and is not drawn.
The tree structure is directly maintained by the widget.
WIDGET-SPECIFIC OPTIONS
- -closecmd
-
Specifies a command to be called when user close a node. The
closed node is appended to the command.
- -deltax
-
Specifies horizontal indentation between a node and its children.
- -deltay
-
Specifies vertical size of the nodes.
- -dragenabled
-
A boolean specifying if drag is enabled.
- -dragendcmd
-
Command associated when drag-end event occurs.
See DragSite::register for more informations.
- -dragevent
-
Event associated to the drag. Must be a <ButtonPress-x> event.
- -draginitcmd
-
Tree has a command wrapper for drag-init events. This command refused the drag
if no node is designated. In other cases:
If draginitcmd is empty, it returns:
- the value of option dragtype or TREE_NODE if empty as the data type,
- {default move Control copy Alt link} as the operations,
- the node identifier as the data.
If draginitcmd is not empty, it is called with the following arguments:
- the pathname of the tree,
- the identifier of the dragged node,
- the toplevel created to represent dragged data.
and must return a value conforming to draginitcmd option described in
DragSite::register.
- -dragtype
-
Specifies the type of the dragged data. Default is TREE_NODE
- -dropcmd
-
Tree has a command wrapper for drop events. This command stops auto scrolling
and extract node and position.
If dropcmd is not empty, it is called with the same aguments as
dragovercmd command.
- -dropenabled
-
A boolean specifying if drop is enabled.
- -dropovercmd
-
Tree has a command wrapper for drag-over events. This command enables auto scrolling
and position extraction during the drag-over. Three drop methods are possible,
following the dropovertype option:
node | user can only drop over a node
|
position | user can only drop between nodes
|
both | user can drop over and between nodes
|
If dropovercmd is not empty, the command is called with the following aguments:
- the pathname of the tree,
- the pathname of the drag source,
- the targeted node if dropovertype is node or both, or a list of
the targeted node and the position whithin its children if dropovertype is
position or both,
- the current operation,
- the data type,
- the data.
and must return a value conforming to dropovercmd option described in
DropSite::register.
- -dropovertype
-
Specifies the type of drop-over interaction. Must be one of
node, position or both.
- -droptypes
-
Specifies a list of accepted dropped object/operation. Default is empty.
- -height
-
Specifies the desired height for the tree in units of deltay pixels.
- -linesfill
-
Specifies a foreground color for the lines between nodes.
- -opencmd
-
Specifies a command to be called when user open a node. The
opened node is appended to the command.
- -padx
-
Specifies distance between image or window and text of the nodes.
- -redraw
-
Specifies wether or not the tree should be redrawn when entering idle.
Set it to false if you call update while modifying the tree.
- -showlines
-
Specifies whether or not lines should be drawn between nodes.
- -width
-
Specifies the desired width for the tree in units of 10 pixels.
WIDGET COMMAND
- pathName bindImage
event
script
-
This command associates a command to execute whenever the event
sequence given by event occurs on the image of a node.
The node idenfier on which the event occurs is appended to the command.
- pathName bindText
event
script
-
This command associates a command to execute whenever the event
sequence given by event occurs on the label of a node.
The node idenfier on which the event occurs is appended to the command.
- pathName cget
option
-
Returns the current value of the configuration option given by option.
Option may have any of the values accepted by the create command.
- pathName closetree
node
-
This command close all the subtree given by node (recurse
through the tree starting at node and set open option to 0)
- pathName configure
?option? ?value option value ...?
-
Modify the configuration options of the widget.
Option may have any of the values accepted by the create command,
except those who are read-only.
- pathName delete
?arg...?
-
Deletes all nodes (and children of them) in arg.
To delete all the tree, do eval Tree::delete $tree [Tree::nodes $tree root]
- pathName edit
node
?clickres?
?select?
-
Provides a way for the user to edit in place the label of a node. This is
possible only if node can be visible (all its parents are open).
The command does not modify the label of the edited node. The command returns an empty
string if edition is canceled, or the typed text if edition is accepted.
When editing, the user can cancel by pressing Escape, or accept by pressing Return.
clickres specifies what to do if the user click outside the editable area.
If clickres is 0 (the default), the edition is canceled.
If clickres is 1, the edition is accepted.
In all other case, the edition continues.
select specifies wether or not the initial text should be selected. Default is 1.
- pathName exists
node
-
Returns 1 if node exists in the tree, else 0.
- pathName index
node
-
Returns the position of node in its parent.
- pathName insert
index
parent
node
?option value...?
-
Inserts a new node identified by node in the children list of parent
at position index.
- -data
-
User data associated to the node.
- -drawcross
-
Specifies how the cross used to expand or collapse the children of a node
should be drawn.
Must be one of auto, allways or never.
If auto, the cross is drawn only if the node has children.
If allways, the cross is always drawn.
If never, the cross is never drawn.
- -fill
-
Specifies the foreground color of the label of the node.
- -font
-
Specifies a font for the label of the node.
- -image
-
Specifies an image to display at the left of the label of the node.
window option override image.
- -open
-
Specifies wether or not the children of the node should be drawn.
- -text
-
Specifies the label of the node.
- -window
-
Specifies a pathname to display at the left of the label of the node.
window option override image.
- pathName itemcget
node
option
-
Returns the current value of a configuration option for the item given by index.
Option may have any of the values accepted by the item creation command.
- pathName itemconfigure
node
?option? ?value option value ...?
-
Modify the configuration options of the item given by index. Options may have
any of the values accepted by the item creation command,
except those who are read-only.
- pathName move
parent
node
index
-
Moves node to the children list of parent at position index.
parent can not be a descendant of node.
- pathName nodes
node
-
Returns the children of node.
- pathName opentree
node
-
This command open all the subtree given by node (recurse
through the tree starting at node and set open option to 1)
- pathName parent
node
-
Returns the parent of node.
- pathName see
node
-
Arrange the scrolling area to make node visible.
- pathName selection
cmd
?arg...?
-
Modifies the list of selected nodes following cmd:
- clear
- remove all nodes of the selection.
- set
- set the selection to all nodes in arg
- add
- add all nodes of arg in the selection
- remove
- remove all nodes of arg of the selection
- get
- return the current selected nodes
- pathName xview
?arg...?
-
Description text
- pathName yview
?arg...?
-
Description text