1 \chapter{wxTreeLayout Class Reference
}
2 \setheader{{\it CHAPTER
\thechapter}}{}{}{}{}{{\it CHAPTER
\thechapter}}%
3 \setfooter{\thepage}{}{}{}{}{\thepage}
5 \section{\class{wxTreeLayout
}}\label{wxtreelayout
}
7 This abstract class is used for drawing a tree. You must derive a new
8 class from this, and define member functions to access the data that
11 Nodes are identified by long integer identifiers. The derived class
12 communicates the actual tree structure to wxTreeLayout by defining
\helprefn{wxTreeLayout::GetChildren
}{getchildren
}\rtfsp
13 and
\helprefn{wxTreeLayout::GetNodeParent
}{getnodeparent
} functions.
15 The application should call
\helprefn{DoLayout
}{dolayout
} to do the tree
16 layout. Depending on how the derived class has been defined, either
17 \rtfsp\helprefn{wxTreeLayout::Draw
}{draw
} must be called (for example by the OnPaint member
18 of a wxScrolledWindow) or the application-defined drawing code should be called
21 For example, if you have an image drawing system already defined, you
22 may want wxTreeLayout to position existing node images in that system. So you
23 just need a way for wxTreeLayout to set the node image positions according to
24 the layout algorithm, and the rest will be done by your own image drawing
27 \wxheading{Derived from
}
31 \latexignore{\rtfignore{\wxheading{Members
}}}
33 \membersection{wxTreeLayout::wxTreeLayout
}
35 \func{}{wxTreeLayout
}{\void}
39 \membersection{wxTreeLayout::ActivateNode
}\label{activatenode
}
41 \func{void
}{ActivateNode
}{\param{long
}{ id
},
\param{bool
}{active
}}
43 Define this so wxTreeLayout can turn nodes on and off for drawing purposes
44 (not all nodes may be connected in the tree). See also
\helprefn{NodeActive
}{nodeactive
}.
46 \membersection{wxTreeLayout::CalcLayout
}
48 \func{void
}{CalcLayout
}{\param{long
}{ id
},
\param{int
}{ level
}}
50 Private function for laying out a branch.
52 \membersection{wxTreeLayout::DoLayout
}\label{dolayout
}
54 \func{void
}{DoLayout
}{\param{wxDC\&
}{ dc
},
\param{long
}{ topNode = -
1}}
56 Calculates the layout for the tree, optionally specifying the top node.
58 \membersection{wxTreeLayout::Draw
}\label{draw
}
60 \func{void
}{Draw
}{\param{wxDC\&
}{ dc
}}
62 Call this to let wxTreeLayout draw the tree itself, once the layout has been
63 calculated with
\helprefn{DoLayout
}{dolayout
}.
65 \membersection{wxTreeLayout::DrawBranch
}
67 \func{void
}{DrawBranch
}{\param{long
}{ from
},
\param{long
}{ to
},
\param{wxDC\&
}{ dc
}}
69 Defined by wxTreeLayout to draw an arc between two nodes.
71 \membersection{wxTreeLayout::DrawBranches
}
73 \func{void
}{DrawBranches
}{\param{wxDC\&
}{ dc
}}
75 Defined by wxTreeLayout to draw the arcs between nodes.
77 \membersection{wxTreeLayout::DrawNode
}
79 \func{void
}{DrawNode
}{\param{long
}{ id
},
\param{wxDC\&
}{ dc
}}
81 Defined by wxTreeLayout to draw a node.
83 \membersection{wxTreeLayout::DrawNodes
}
85 \func{void
}{DrawNodes
}{\param{wxDC\&
}{ dc
}}
87 Defined by wxTreeLayout to draw the nodes.
89 \membersection{wxTreeLayout::GetChildren
}\label{getchildren
}
91 \func{void
}{GetChildren
}{\param{long
}{ id
},
\param{wxList \&
}{list
}}
93 Must be defined to return the children of node
{\it id
} in the given list
96 \membersection{wxTreeLayout::GetNextNode
}\label{getnextnode
}
98 \func{long
}{GetNextNode
}{\param{long
}{ id
}}
100 Must be defined to return the next node after
{\it id
}, so that wxTreeLayout can
101 iterate through all relevant nodes. The ordering is not important.
102 The function should return -
1 if there are no more nodes.
104 \membersection{wxTreeLayout::GetNodeName
}
106 \constfunc{wxString
}{GetNodeName
}{\param{long
}{ id
}}
108 May optionally be defined to get a node's name (for example if leaving
109 the drawing to wxTreeLayout).
111 \membersection{wxTreeLayout::GetNodeSize
}
113 \constfunc{void
}{GetNodeSize
}{\param{long
}{ id
},
\param{long*
}{ x
},
\param{long*
}{ y
}}
115 Can be defined to indicate a node's size, or left to wxTreeLayout to use the
116 name as an indication of size.
118 \membersection{wxTreeLayout::GetNodeParent
}\label{getnodeparent
}
120 \constfunc{long
}{GetNodeParent
}{\param{long
}{ id
}}
122 Must be defined to return the parent node of
{\it id
}.
123 The function should return -
1 if there is no parent.
125 \membersection{wxTreeLayout::GetNodeX
}
127 \constfunc{long
}{GetNodeX
}{\param{long
}{ id
}}
129 Must be defined to return the current X position of the node. Note that
130 coordinates are assumed to be at the top-left of the node so some conversion
131 may be necessary for your application.
133 \membersection{wxTreeLayout::GetNodeY
}
135 \constfunc{long
}{GetNodeY
}{\param{long
}{ id
}}
137 Must be defined to return the current Y position of the node. Note that
138 coordinates are assumed to be at the top-left of the node so some conversion
139 may be necessary for your application.
141 \membersection{wxTreeLayout::GetLeftMargin
}
143 \constfunc{long
}{GetLeftMargin
}{\void}
145 Gets the left margin set with
\helprefn{SetMargins
}{setmargins
}.
147 \membersection{wxTreeLayout::GetOrientation
}
149 \constfunc{bool
}{GetOrientation
}{\void}
151 Gets the orientation: TRUE means top-to-bottom, FALSE means left-to-right (the default).
153 \membersection{wxTreeLayout::GetTopMargin
}
155 \constfunc{long
}{GetTopMargin
}{\void}
157 Gets the top margin set with
\helprefn{SetMargins
}{setmargins
}.
159 \membersection{wxTreeLayout::GetTopNode
}
161 \constfunc{long
}{GetTopNode
}{\void}
163 wxTreeLayout calls this to get the top of the tree. Don't redefine this; call
164 \rtfsp\helprefn{SetTopNode
}{settopnode
} instead before calling
\helprefn{DoLayout
}{dolayout
}.
166 \membersection{wxTreeLayout::GetXSpacing
}
168 \constfunc{long
}{GetXSpacing
}{\void}
170 Gets the horizontal spacing between nodes.
172 \membersection{wxTreeLayout::GetYSpacing
}
174 \constfunc{long
}{GetYSpacing
}{\void}
176 Gets the vertical spacing between nodes.
178 \membersection{wxTreeLayout::Initialize
}
180 \func{void
}{Initialize
}{\void}
182 Initializes wxTreeLayout. Call from application or overridden
{\bf Initialize
}
185 \membersection{wxTreeLayout::NodeActive
}\label{nodeactive
}
187 \func{bool
}{NodeActive
}{\param{long
}{ id
}}
189 Define this so wxTreeLayout can know which nodes are to be drawn (not all
190 nodes may be connected in the tree). See also
\helprefn{ActivateNode
}{activatenode
}.
192 \membersection{wxTreeLayout::SetNodeName
}
194 \func{void
}{SetNodeName
}{\param{long
}{ id
},
\param{const wxString\&
}{ name
}}
196 May optionally be defined to set a node's name.
198 \membersection{wxTreeLayout::SetNodeX
}
200 \func{void
}{SetNodeX
}{\param{long
}{ id
},
\param{long
}{ x
}}
202 Must be defined to set the current X position of the node. Note that
203 coordinates are assumed to be at the top-left of the node so some conversion
204 may be necessary for your application.
206 \membersection{wxTreeLayout::SetNodeY
}
208 \func{void
}{SetNodeY
}{\param{long
}{ id
},
\param{long
}{ y
}}
210 Must be defined to set the current Y position of the node. Note that
211 coordinates are assumed to be at the top-left of the node so some conversion
212 may be necessary for your application.
214 \membersection{wxTreeLayout::SetOrientation
}
216 \func{void
}{SetOrientation
}{\param{bool
}{ orientation
}}
218 Sets the tree orientation: TRUE means top-to-bottom, FALSE means left-to-right (the default).
220 \membersection{wxTreeLayout::SetTopNode
}\label{settopnode
}
222 \func{void
}{SetTopNode
}{\param{long
}{ id
}}
224 Call this to identify the top of the tree to wxTreeLayout.
226 \membersection{wxTreeLayout::SetSpacing
}
228 \func{void
}{SetSpacing
}{\param{long
}{ x
},
\param{long
}{ y
}}
230 Sets the horizontal and vertical spacing between nodes in the tree.
232 \membersection{wxTreeLayout::SetMargins
}\label{setmargins
}
234 \func{void
}{SetMargins
}{\param{long
}{ x
},
\param{long
}{ y
}}
236 Sets the left and top margins of the whole tree.
238 \section{\class{wxStoredTree
}}\label{wxstoredtree
}
240 wxStoredTree provides storage for node labels, position and client data. It also provides hit-testing
241 (which node a mouse event occurred on). It is usually a more convenient class to use than wxTreeLayout.
243 \wxheading{Derived from
}
245 \helpref{wxTreeLayout
}{wxtreelayout
}
247 \latexignore{\rtfignore{\wxheading{Members
}}}
249 \membersection{wxStoredTree::wxStoredTree
}
251 \func{}{wxStoredTree
}{\param{int
}{noNodes =
200}}
253 Constructor. Specify the maximum number of nodes to be allocated.
255 \membersection{wxStoredTree::AddChild
}\label{wxstoredtreeaddchild
}
257 \func{long
}{AddChild
}{\param{const wxString\&
}{ name
},
\param{const wxString\&
}{ parent = ""
}}
259 Adds a child with a given parent, returning the node id.
261 \membersection{wxStoredTree::GetClientData
}\label{wxstoredtreegetclientdata
}
263 \constfunc{long
}{GetClientData
}{\param{long
}{ id
}}
265 Gets the client data for the given node.
267 \membersection{wxStoredTree::GetNode
}\label{wxstoredtreegetnode
}
269 \constfunc{wxStoredNode*
}{GetNode
}{\param{long
}{ id
}}
271 Returns the wxStoredNode object for the given node id.
273 \membersection{wxStoredTree::GetNodeCount
}\label{wxstoredtreegetnodecount
}
275 \constfunc{int
}{GetNodeCount
}{\void}
277 Returns the current number of nodes.
279 \membersection{wxStoredTree::GetNumNodes
}\label{wxstoredtreegetnumnodes
}
281 \constfunc{int
}{GetNumNodes
}{\void}
283 Returns the maximum number of nodes.
285 \membersection{wxStoredTree::HitTest
}\label{wxstoredtreehittest
}
287 \func{wxString
}{HitTest
}{\param{wxMouseEvent\&
}{ event
},
\param{wxDC\&
}{dc
}}
289 Returns a string with the node name corresponding to the position of the mouse event, or the empty string if no node
292 \membersection{wxStoredTree::NameToId
}\label{wxstoredtreenametoid
}
294 \func{long
}{NameToId
}{\param{const wxString\&
}{ name
}}
296 Returns the id for the given node name, or -
1 if there was no such node.
298 \membersection{wxStoredTree::SetClientData
}\label{wxstoredtreesetclientdata
}
300 \func{void
}{SetClientData
}{\param{long
}{ id
},
\param{long
}{ clientData
}}
302 Sets client data for the given node.