<< Prev | - Up - |
The TreeNode
class implements the following methods :
init(canvas:C font:F height:H label:L icon:I eicon:EI)
: Initializes a root node in the canvas C
. The labels of the root node and all children nodes will be displayed in the font F
and take H
pixels of height to display themselves. The label of the root node is defined by L
and the node can display an icon in front of it, defined by I
. If EI
is specified, it is another icon to display when the node is in the expanded (displays its children nodes) state. An icon is a valid Tk or QTk image or bitmap. The C
parameter is required, while all other parameters are not.
init(parent:N label:L icon:I eicon:EI)
: Initializes a node children of the node N
. L
, I
and EI
have the same meaning as for the root node (see above). The N
parameter is required, while all other parameters are not.
unlockedInit(...)
: Same as the init
method (for both forms), except that the init
method gets a global lock on the tree to initialize itself, while this method doesn't.
select(state:B)
: If B
is true, draws a surrounding rectangle around the node. If B
is false, removes the surrounding rectangle around the node (if any).
bind(event:E args:A action:P)
: Binds the node to respond to the event E
, and execute the action P
with the parameters A
. See the Tk documentation for the exact syntax of E
, A
and P
. E
and P
are required, while A
is not.
draw(x:X y:Y height:H)
: Draws the node at the specified X
and Y
coordinates. H
is bound by the method to the total height required to draw the node (including sub-nodes if the node is expanded and have children nodes). You should use this method only with the root node. X
and Y
are required, while H
is not.
delete(height:H)
: Deletes the node and all its children nodes if necessary. H
is bound by the method to the total height the nodes was taking (including sub-nodes if any). H
is not required.
configure(box:B icon:I eicon:EI label:L fill:F)
: Dynamically change the parameters of the node :
B
: Specifies the state of the expand/collapse box in front of the node: This parameter can have four different values :
plus
: Displays a plus box. This is normally displayed when the node is collapsed.
minus
: Displays a minus box. This is normally displayed when the node is expanded.
line
: Displays a straigth line. This is normally displayed if the node doesn't have any children nodes.
point
: Displays a box with a dot inside.
Warning : use with care as this can prevent the user from using correctly the tree.
I
: Specifies a valid Tk or QTk image to display as icon in front of the node label. If specified as nil
, no icon is displayed
EI
: Specifies a valid Tk or QTk image to display as icon in front of the node label if the node is expanded. If specified as nil
then I
is used instead.
L
: Specifies the label of the node.
F
: Specifies the color of the label of the node.
Any combination of these parameters is allowed, including changing all them in one call, or none of them.
expand
: Expands the node so that its children nodes are displayed if the node is displayed.
collapse
: Collapses the node so that even if the node is displayed, its children nodes are not.
switch
: Switches between the expanded and collapsed mode.
get(label:L x:X y:Y height:H shown:S parent:P box:B)
: This methods binds the different specified variables to their current value. Any combination of variables can be specified. The variables are bound to :
L
: Label of the node.
X
: X coordinate of the node.
Y
: Y coordinate of the node.
H
: Total height of the node in the canvas, including children nodes if they are displayed.
S
: true
is the node is shown, false
otherwise.
P
: Parent node. The parent node of the root node is the root node itself.
B
: State of the expand/collapse box (see configure
).
addLeaf(node:N)
: Adds the node N
to the list of children nodes of this node. The parent node of N
must be the node whose addLeaf
method is called.
addLeaf(nodes:LN)
: Same as addLeaf(node:N)
except that LN
is a list of nodes to add. If several nodes have to be added in one bunch, use this form of addLeaf
.
deleteLeaf(node:N)
: Delete the children node N
.
isDeleted(B)
: Binds B
to true
if the node is deleted, otherwise to false
.
<< Prev | - Up - |