Command: wtree

Syntax

{ <window> = } wtree <type>, <file>

or

{ <window> = } wtree <type> {
    <data block>
}

or

{ <window> = } wtree

Description

Define a tree window, a pictorial representation of an object parent/child hierarchy. Each branch or leaf in the tree is referred to as a tree node.

Parameters

The tree is initially populated within this command from data in a data block or file.

If not present, then the tree is to be populated dynamically by subsequent commands and interactive operations.

Switches

This option is valid only for simple trees and is ignored otherwise. All images are displayed with the same pixel dimensions, defined by the -pix switch (default 16 x 16). Images which have different dimensions are scaled accordingly.

If the embed container does not exist or is invalid, this switch is ignored.

Data Block

Required only for simple trees, this contains a declaration of all initial nodes in the tree. All nodes will be of class <type>.

The data is a series of lines each containing a string (the node label) and an image number (see the -cr switch). { and } are used to mark the parent/child relationships, e.g.

node_1,1 {
    node_1_child_1,2
    node_1_child_2,2
    node_1_child_3,2 {
        node_1_child_3_child_1,3
        node_1_child_3_child_2,3
    }
}
node_2,1
node_3,1 {
    node_3_child_1,4
}

Notes

For dynamic trees, and for further population of simple trees, additional nodes can be added to the tree by a window function window.add_node.

The tree is displayed as a left-to-right pictorial hierarchy, each node being displayed with its image and text. If the node is a parent node it also has a +/- symbol beside it to indicate that the node can be expanded or contracted to display its children. Double-clicking on the +/- expands or contracts a parent node as appropriate.

Each node is an instance of a treenode class, which defines the behavior of the node when the user interacts with it. There are callbacks associated with a class which when invoked can dynamically populate, de-populate nodes, take action on node selection/de-selection, or can add more nodes to the tree. Treenode classes are created by the treenode_define command. Refer to this command for more information.

Examples

Define a class of treenode with default behavior.

atable test
treenode_define ~test.person_t { }

Define an array of images to use.

string images[] = <'male.xpm','female.xpm','family.xpm'>

Create a simple family tree.

window my_win = wtree ~test.person_t,-cr=images,\
    -pix=<32,32> {
    'Pinnington',3 {
        'Jim',1 {
            'Linda',2
            'Andrew',1
            'Susan',2
        }
        'Jack',1
        'Ella',2
        'Jesse',2
    }
    'Wright',1 {
        'Leonard',1 {
            'Peter',1
        }
        'Herbert',1 {
            'Neil',1
            'Brenda',2
            'David',1
        }
        'Vera',2
    }
}

See Also

Commands:

color, embed, treenode, treenode_define, wclose, window, wopen, wsize

Identifiers:

free_window (window), new_window (window), win# (window), window_numbers (numeric)

Structures:

treenode, window