\hy-9{0}{
}




\hy-5{2}{Manual for wxTree 1.0: a tree-drawing library for wxWindows}

\hy-6{3}{Julian Smart
Artificial Intelligence Applications Institute

University of Edinburgh
EH1 1HN}

November 1993

\hy-5{1}{

Contents

}
\hy-6{4}{Copyright notice}

\hy-6{6}{Introduction}

\hy-6{8}{wxTree Class Reference}


\hy-10{5}{Copyright notice}

Copyright (c) 1993 Artificial Intelligence Applications Institute,
The University of Edinburgh.

Permission to use, copy, modify, and distribute this software and its
documentation for any purpose is hereby granted without fee, provided that the
above copyright notice, author statement and this permission notice appear in
all copies of this software and related documentation.

THE SOFTWARE IS PROVIDED ``AS-IS'' AND WITHOUT WARRANTY OF ANY KIND, EXPRESS,
IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

IN NO EVENT SHALL THE ARTIFICIAL INTELLIGENCE APPLICATIONS INSTITUTE OR THE
UNIVERSITY OF EDINBURGH BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF
DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.


\hy-10{7}{Introduction}

This manual describes a tree-drawing class library for wxWindows. It
provides layout of simple trees with one root node, drawn left-to-right,
with user-defined spacing between nodes.

wxTree is an abstract class that must be subclassed. The programmer
defines various member functions which will access whatever data structures
are appropriate for the application, and wxTree uses these when laying
out the tree.

wxStoredTree is a class derived from wxTree that may be used directly to
draw trees on a canvas. It supplies storage for the nodes, and draws
to a device context.


\hy-10{9}{wxTree Class Reference}

The member functions are given in alphabetical order except for the
constructors and destructors which appear first.

\hy-8{10}{wxTree: wxObject}


\hy-10{11}{wxTree: wxObject}

This abstract class is used for drawing a tree. You must derive a new
class from this, and define member functions to access the data that
wxTree needs.

Nodes are identified by long integer identifiers. The derived class
communicates the actual tree structure to wxTree by defining \hy-13{12}{wxTree::GetChildren}
and \hy-13{13}{wxTree::GetNodeParent} functions.

The application should call \hy-13{14}{DoLayout} to do the tree
layout. Depending on how the derived class has been defined, either
\hy-13{15}{wxTree::Draw} must be called (for example by the OnDraw member
of a wxCanvas) or the application-defined drawing code should be called
as normal.

For example, if you have an image drawing system already defined, you
may want wxTree to position existing node images in that system. So you
just need a way for wxTree to set the node image positions according to
the layout algorithm, and the rest will be done by your own image drawing
system.

\hy-8{16}{wxTree::wxTree}

\hy-8{20}{wxTree::ActivateNode}

\hy-8{26}{wxTree::DoLayout}

\hy-8{30}{wxTree::Draw}

\hy-8{35}{wxTree::DrawBranch}

\hy-8{40}{wxTree::DrawBranches}

\hy-8{43}{wxTree::DrawNode}

\hy-8{47}{wxTree::DrawNodes}

\hy-8{50}{wxTree::GetChildren}

\hy-8{56}{wxTree::GetDC}

\hy-8{59}{wxTree::GetNextNode}

\hy-8{64}{wxTree::GetNodeName}

\hy-8{68}{wxTree::GetNodeSize}

\hy-8{74}{wxTree::GetNodeParent}

\hy-8{79}{wxTree::GetNodeX}

\hy-8{83}{wxTree::GetNodeY}

\hy-8{87}{wxTree::GetLeftMargin}

\hy-8{91}{wxTree::GetTopMargin}

\hy-8{95}{wxTree::GetTopNode}

\hy-8{100}{wxTree::GetXSpacing}

\hy-8{103}{wxTree::GetYSpacing}

\hy-8{106}{wxTree::Initialize}

\hy-8{110}{wxTree::Layout}

\hy-8{115}{wxTree::NodeActive}

\hy-8{120}{wxTree::SetNodeName}

\hy-8{125}{wxTree::SetNodeX}

\hy-8{130}{wxTree::SetNodeY}

\hy-8{135}{wxTree::SetTopNode}

\hy-8{139}{wxTree::SetDC}

\hy-8{143}{wxTree::SetSpacing}

\hy-8{148}{wxTree::SetMargins}


\hy-10{17}{wxTree::wxTree}

\hy-8{18}{void wxTree(wxDC * \hy-8{19}{dc = NULL})}

Constructor.


\hy-10{21}{wxTree::ActivateNode}

\hy-8{22}{void ActivateNode(long \hy-8{23}{ id}, Bool  \hy-8{24}{active})}

Define this so wxTree can turn nodes on and off for drawing purposes
(not all nodes may be connected in the tree). See also \hy-13{25}{NodeActive}.


\hy-10{27}{wxTree::DoLayout}

\hy-8{28}{void DoLayout(long \hy-8{29}{ topNode = -1})}

Calculates the layout for the tree, optionally specifying the top node.


\hy-10{31}{wxTree::Draw}

\hy-8{32}{void Draw(void)}

Call this to let wxTree draw the tree itself, once the layout has been
calculated with \hy-13{33}{DoLayout}. The device context must
have been set in the constructor or using \hy-13{34}{SetDC}.


\hy-10{36}{wxTree::DrawBranch}

\hy-8{37}{void DrawBranch(long \hy-8{38}{ from}, long \hy-8{39}{ to})}

Defined by wxTree to draw an arc between two nodes.


\hy-10{41}{wxTree::DrawBranches}

\hy-8{42}{void DrawBranches(void)}

Defined by wxTree to draw the arcs between nodes.


\hy-10{44}{wxTree::DrawNode}

\hy-8{45}{void DrawNode(long \hy-8{46}{ id})}

Defined by wxTree to draw a node.


\hy-10{48}{wxTree::DrawNodes}

\hy-8{49}{void DrawNodes(void)}

Defined by wxTree to draw the nodes.


\hy-10{51}{wxTree::GetChildren}

\hy-8{52}{void GetChildren(long \hy-8{53}{ id}, wxList & \hy-8{54}{list})}

Must be defined to return the children of node \hy-7{55}{id} in the given list
of integers.


\hy-10{57}{wxTree::GetDC}

\hy-8{58}{long GetDC(void)}

Gets the (optional) device context associated with the tree.


\hy-10{60}{wxTree::GetNextNode}

\hy-8{61}{long GetNextNode(long \hy-8{62}{ id})}

Must be defined to return the next node after \hy-7{63}{id}, so that wxTree can
iterate through all relevant nodes. The ordering is not important.
The function should return -1 if there are no more nodes.


\hy-10{65}{wxTree::GetNodeName}

\hy-8{66}{char * GetNodeName(long \hy-8{67}{ id})}

May optionally be defined to get a node's name (for example if leaving
the drawing to wxTree).


\hy-10{69}{wxTree::GetNodeSize}

\hy-8{70}{void GetNodeSize(long \hy-8{71}{ id}, float \hy-8{72}{ *x}, float \hy-8{73}{ *y})}

Can be defined to indicate a node's size, or left to wxTree to use the
name as an indication of size.


\hy-10{75}{wxTree::GetNodeParent}

\hy-8{76}{long GetNodeParent(long \hy-8{77}{ id})}

Must be defined to return the parent node of \hy-7{78}{id}.
The function should return -1 if there is no parent.


\hy-10{80}{wxTree::GetNodeX}

\hy-8{81}{float GetNodeX(long \hy-8{82}{ id})}

Must be defined to return the current X position of the node. Note that
coordinates are assumed to be at the top-left of the node so some conversion
may be necessary for your application.


\hy-10{84}{wxTree::GetNodeY}

\hy-8{85}{float GetNodeY(long \hy-8{86}{ id})}

Must be defined to return the current Y position of the node. Note that
coordinates are assumed to be at the top-left of the node so some conversion
may be necessary for your application.


\hy-10{88}{wxTree::GetLeftMargin}

\hy-8{89}{float GetLeftMargin(void)}

Gets the left margin set with \hy-13{90}{SetMargins}.


\hy-10{92}{wxTree::GetTopMargin}

\hy-8{93}{float GetTopMargin(void)}

Gets the top margin set with \hy-13{94}{SetMargins}.


\hy-10{96}{wxTree::GetTopNode}

\hy-8{97}{long GetTopNode(void)}

wxTree calls this to get the top of the tree. Don't redefine this; call
\hy-13{98}{SetTopNode} instead before calling \hy-13{99}{DoLayout}.


\hy-10{101}{wxTree::GetXSpacing}

\hy-8{102}{float GetXSpacing(void)}

Gets the horizontal spacing between nodes.


\hy-10{104}{wxTree::GetYSpacing}

\hy-8{105}{float GetYSpacing(void)}

Gets the vertical spacing between nodes.


\hy-10{107}{wxTree::Initialize}

\hy-8{108}{void Initialize(void)}

Initializes wxTree. Call from application or overridden \hy-8{109}{Initialize}
or constructor.


\hy-10{111}{wxTree::Layout}

\hy-8{112}{void Layout(long \hy-8{113}{ node_id}, int \hy-8{114}{ level})}

Private function for laying out a branch.


\hy-10{116}{wxTree::NodeActive}

\hy-8{117}{Bool NodeActive(long \hy-8{118}{ id})}

Define this so wxTree can know which nodes are to be drawn (not all
nodes may be connected in the tree). See also \hy-13{119}{ActivateNode}.


\hy-10{121}{wxTree::SetNodeName}

\hy-8{122}{void SetNodeName(long \hy-8{123}{ id}, char * \hy-8{124}{ name})}

May optionally be defined to set a node's name.


\hy-10{126}{wxTree::SetNodeX}

\hy-8{127}{void SetNodeX(long \hy-8{128}{ id}, float \hy-8{129}{ x})}

Must be defined to set the current X position of the node. Note that
coordinates are assumed to be at the top-left of the node so some conversion
may be necessary for your application.


\hy-10{131}{wxTree::SetNodeY}

\hy-8{132}{void SetNodeY(long \hy-8{133}{ id}, float \hy-8{134}{ y})}

Must be defined to set the current Y position of the node. Note that
coordinates are assumed to be at the top-left of the node so some conversion
may be necessary for your application.


\hy-10{136}{wxTree::SetTopNode}

\hy-8{137}{void SetTopNode(long \hy-8{138}{ id})}

Call this to identify the top of the tree to wxTree.


\hy-10{140}{wxTree::SetDC}

\hy-8{141}{void SetDC(wxDC * \hy-8{142}{dc})}

Use this to set the tree's device context, if leaving the drawing up
to wxTree.


\hy-10{144}{wxTree::SetSpacing}

\hy-8{145}{void SetSpacing(float \hy-8{146}{ x}, float \hy-8{147}{ y})}

Sets the horizontal and vertical spacing between nodes in the tree.


\hy-10{149}{wxTree::SetMargins}

\hy-8{150}{void SetMargins(float \hy-8{151}{ x}, float \hy-8{152}{ y})}

Sets the left and top margins of the whole tree.




\hyindex{
"wxTree Manual"
4 5
6 7
8 9
10 11
16 17
20 21
26 27
30 31
35 36
40 41
43 44
47 48
50 51
56 57
59 60
64 65
68 69
74 75
79 80
83 84
87 88
91 92
95 96
100 101
103 104
106 107
110 111
115 116
120 121
125 126
130 131
135 136
139 140
143 144
148 149
12 51
12 51
13 75
13 75
14 27
14 27
15 31
15 31
25 116
25 116
33 27
33 27
34 140
34 140
90 149
90 149
94 149
94 149
98 136
98 136
99 27
99 27
119 21
119 21
12 51
12 51
13 75
13 75
14 27
14 27
15 31
15 31
25 116
25 116
33 27
33 27
34 140
34 140
90 149
90 149
94 149
94 149
98 136
98 136
99 27
99 27
119 21
119 21
}
