| 1 |
'\" |
| 2 |
'\" Copyright 1991-1998 by Bell Labs Innovations for Lucent Technologies. |
| 3 |
'\" |
| 4 |
'\" Permission to use, copy, modify, and distribute this software and its |
| 5 |
'\" documentation for any purpose and without fee is hereby granted, provided |
| 6 |
'\" that the above copyright notice appear in all copies and that both that the |
| 7 |
'\" copyright notice and warranty disclaimer appear in supporting documentation, |
| 8 |
'\" and that the names of Lucent Technologies any of their entities not be used |
| 9 |
'\" in advertising or publicity pertaining to distribution of the software |
| 10 |
'\" without specific, written prior permission. |
| 11 |
'\" |
| 12 |
'\" Lucent Technologies disclaims all warranties with regard to this software, |
| 13 |
'\" including all implied warranties of merchantability and fitness. In no event |
| 14 |
'\" shall Lucent Technologies be liable for any special, indirect or |
| 15 |
'\" consequential damages or any damages whatsoever resulting from loss of use, |
| 16 |
'\" data or profits, whether in an action of contract, negligence or other |
| 17 |
'\" tortuous action, arising out of or in connection with the use or performance |
| 18 |
'\" of this software. |
| 19 |
'\" |
| 20 |
'\" |
| 21 |
.so man.macros |
| 22 |
.TH Blt_TreeCreateNode 3 BLT_VERSION BLT "BLT Library Procedures" |
| 23 |
.BS |
| 24 |
.SH NAME |
| 25 |
Blt_TreeCreateNode \- Creates a node in a tree data object. |
| 26 |
.SH SYNOPSIS |
| 27 |
.nf |
| 28 |
#include <bltTree.h> |
| 29 |
.sp |
| 30 |
Blt_TreeNode |
| 31 |
\fBBlt_TreeCreateNode\fR(\fItree\fR, \fIparent\fR, \fIname\fR, \fIposition\fR) |
| 32 |
.fi |
| 33 |
.SH ARGUMENTS |
| 34 |
.AS Blt_TreeNode parent |
| 35 |
.AP Blt_Tree tree in |
| 36 |
Tree containing the parent node. |
| 37 |
.AP Blt_TreeNode parent in |
| 38 |
Node in which to insert the new child. |
| 39 |
.AP "const char" *name in |
| 40 |
Node label. If NULL, a label will automatically be generated. |
| 41 |
.AP int position in |
| 42 |
Position in the parent's list of children to insert the new node. |
| 43 |
.BE |
| 44 |
.SH DESCRIPTION |
| 45 |
.PP |
| 46 |
This procedure creates a new node is a tree data object. The node |
| 47 |
is initially empty, but data values can be added with |
| 48 |
\fBBlt_TreeSetValue\fR. Each node has a serial number that identifies it |
| 49 |
within the tree. No two nodes in the same tree will ever have the |
| 50 |
same ID. You can find a node's ID with \fBBlt_TreeNodeId\fR. |
| 51 |
.PP |
| 52 |
The arguments are as follows: |
| 53 |
.TP 1i |
| 54 |
\fItree\fR |
| 55 |
The tree containing the parent node. |
| 56 |
.TP |
| 57 |
\fIparent\fR |
| 58 |
Node in which the new child will be inserted. |
| 59 |
.TP |
| 60 |
\fIname\fR |
| 61 |
Label of the new node. If \fIname\fR is NULL, a label in the |
| 62 |
form "\fBnode0\fR", "\fBnode1\fR", etc. will automatically be |
| 63 |
generated. \fIName\fR can be any string. Labels are non-unique. A |
| 64 |
parent can contain two nodes with the same label. Nodes can be |
| 65 |
relabeled using \fBBlt_TreeRelabelNode\fR. |
| 66 |
.TP |
| 67 |
\fIposition\fR |
| 68 |
Position the parent's list of children to insert the new node. For |
| 69 |
example, if \fIposition\fR is 0, then the new node is prepended to the |
| 70 |
beginning of the list. If \fIposition\fR is -1, then the node is |
| 71 |
appended onto the end of the parent's list. |
| 72 |
.PP |
| 73 |
.SH RETURNS |
| 74 |
The new node returned is of type \fBBlt_TreeNode\fR. It's a token |
| 75 |
that can be used with other routines to add/delete data values or |
| 76 |
children nodes. |
| 77 |
.SH EXAMPLE |
| 78 |
The following example creates a new node from the root node. |
| 79 |
.CS |
| 80 |
Blt_Tree token; |
| 81 |
Blt_TreeNode root, node; |
| 82 |
|
| 83 |
if (Blt_TreeGetToken(interp, "myTree", &token) != TCL_OK) { |
| 84 |
return TCL_ERROR; |
| 85 |
} |
| 86 |
root = Blt_TreeRootNode(token); |
| 87 |
node = Blt_TreeCreateNode(token, root, "myNode", -1); |
| 88 |
.CE |
| 89 |
.SH NOTIFICATIONS |
| 90 |
\fBBlt_TreeCreateNode\fR can trigger tree notify events. |
| 91 |
You can be notified whenever a node is created by using the |
| 92 |
\fBBlt_TreeCreateNotifyHandler\fR. A callback routine is registered |
| 93 |
that will be automatically invoked whenever a new node is added |
| 94 |
via \fBBlt_TreeCreateNode\fR to the tree. |
| 95 |
.SH KEYWORDS |
| 96 |
tree, token |