Please enable JavaScript to view this site.

KOL/MCK - User Guide

type

PTree = ^TTree;

TTree = object( TObj )

Object to store tree-like data in memory (non-visual).

 

function NewTree( AParent: PTree ): PTree;

Nameless version (for case when TREE_NONAME symbol is defined).  

Constructs tree node, adding it to the end of children list of the AParent. If AParent is nil, new root tree node is created.

 

function NewTree( AParent: PTree; const AName: WideString ): PTree;

WideString version (for case when TREE_WIDE symbol is defined).

Constructs tree node, adding it to the end of children list of the AParent. If AParent is nil, new root tree node is created.

 

function NewTree( AParent: PTree; const AName: AnsiString ): PTree;

Constructs tree node, adding it to the end of children list of the AParent. If AParent is nil, new root tree node is created.

 

 

constructor CreateTree( AParent: PTree; const AName: AnsiString );

 

destructor Destroy; virtual;

 

procedure Clear;

Destoyes all child nodes.

 

 

TTree properties

 

If TREE_WIDE symbol is defined:

property Name: WideString read fNodeName write fNodeName;

 

Default:

 

property Name: AnsiString read fNodeName write fNodeName;

Optional node name.

 

property Data: Pointer;

Optional user-defined pointer.

 

property Count: Integer;

Number of child nodes of given node.

 

property Items[ Idx: Integer ]: PTree;

Child nodes list items.

 

procedure Add( Node: PTree );

Adds another node as a child of given tree node. This operation as well as Insert can be used to move node together with its children to another location of the same tree or even from another tree.

Anyway, added Node first correctly removed from old place (if it is defined for it).

 

But for simplest task, such as filling of tree with nodes, code should looking as follows:

Node := NewTree( nil, 'test of creating node without parent' );

RootOfMyTree.Add( Node );

 

Though, this code gives the same result as:

Node := NewTree( RootOfMyTree, 'test of creatign node as a child' );

 

 

procedure Insert( Before, Node: PTree );

Inserts earlier created 'Node' just before given child node 'Before' as a child of given tree node. See also Add method.

 

property Parent: PTree;

Returns parent node (or nil, if there is no parent).

 

property Index: Integer;

Returns an index of the node in a list of nodes of the same parent (or -1, if Parent is not defined).

 

property PrevSibling: PTree;

Returns previous node in a list of children of the Parent. Nil is returned, if given node is the first child of the Parent or has no Parent.

 

property NextSibling: PTree;

Returns next node in a list of children of the Parent. Nil is returned, if given node is the last child of the Parent or has no Parent at all.

 

property Root: PTree;

Returns root node (i.e. the last Parent, enumerating parents recursively).

 

property Level: Integer;

Returns level of the node, i.e. integer value, equal to 0 for root of a tree, 1 for its children, etc.

 

property Total: Integer;

Returns total number of children of the node and all its children counting its recursively (but node itself is not considered, i.e. Total for node without children is equal to 0).

 

procedure SortByName;

Sorts children of the node in ascending order. Sorting is not recursive, i.e. only immediate children are sorted.

 

procedure SwapNodes( i1, i2: Integer );

Swaps two child nodes.

 

function IsParentOfNode( Node: PTree ): Boolean;

Returns true, if Node is the tree itself or is a parent of the given node on any level.

 

function IndexOf( Node: PTree ): Integer;

Total index of the child node (on any level under this node).

 

KOL / MCK User Guide - Created by Carl Peeraer - Diamant Soft, based on the work of Vladimir Kladov - Artwerp.be

  

Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Nav Header: ALT+n
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Exit Menu/Up: ESC