]> git.saurik.com Git - wxWidgets.git/blame - utils/wxtree/docs/classes.tex
no message
[wxWidgets.git] / utils / wxtree / docs / classes.tex
CommitLineData
4414cc1d
JS
1\chapter{wxTreeLayout Class Reference}
2\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
3\setfooter{\thepage}{}{}{}{}{\thepage}
4
5\section{\class{wxTreeLayout}}\label{wxtreelayout}
6
7This abstract class is used for drawing a tree. You must derive a new
8class from this, and define member functions to access the data that
9wxTreeLayout needs.
10
11Nodes are identified by long integer identifiers. The derived class
12communicates the actual tree structure to wxTreeLayout by defining \helprefn{wxTreeLayout::GetChildren}{getchildren}\rtfsp
13and \helprefn{wxTreeLayout::GetNodeParent}{getnodeparent} functions.
14
15The application should call \helprefn{DoLayout}{dolayout} to do the tree
16layout. 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
18of a wxScrolledWindow) or the application-defined drawing code should be called
19as normal.
20
21For example, if you have an image drawing system already defined, you
22may want wxTreeLayout to position existing node images in that system. So you
23just need a way for wxTreeLayout to set the node image positions according to
24the layout algorithm, and the rest will be done by your own image drawing
25system.
26
27\wxheading{Derived from}
28
29wxObject
30
31\latexignore{\rtfignore{\wxheading{Members}}}
32
33\membersection{wxTreeLayout::wxTreeLayout}
34
35\func{}{wxTreeLayout}{\void}
36
37Constructor.
38
39\membersection{wxTreeLayout::ActivateNode}\label{activatenode}
40
41\func{void}{ActivateNode}{\param{long}{ id}, \param{bool }{active}}
42
43Define 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}.
45
46\membersection{wxTreeLayout::CalcLayout}
47
48\func{void}{CalcLayout}{\param{long}{ id}, \param{int}{ level}}
49
50Private function for laying out a branch.
51
52\membersection{wxTreeLayout::DoLayout}\label{dolayout}
53
54\func{void}{DoLayout}{\param{wxDC\&}{ dc}, \param{long}{ topNode = -1}}
55
56Calculates the layout for the tree, optionally specifying the top node.
57
58\membersection{wxTreeLayout::Draw}\label{draw}
59
60\func{void}{Draw}{\param{wxDC\&}{ dc}}
61
62Call this to let wxTreeLayout draw the tree itself, once the layout has been
63calculated with \helprefn{DoLayout}{dolayout}.
64
65\membersection{wxTreeLayout::DrawBranch}
66
67\func{void}{DrawBranch}{\param{long}{ from}, \param{long}{ to}, \param{wxDC\&}{ dc}}
68
69Defined by wxTreeLayout to draw an arc between two nodes.
70
71\membersection{wxTreeLayout::DrawBranches}
72
73\func{void}{DrawBranches}{\param{wxDC\&}{ dc}}
74
75Defined by wxTreeLayout to draw the arcs between nodes.
76
77\membersection{wxTreeLayout::DrawNode}
78
79\func{void}{DrawNode}{\param{long}{ id}, \param{wxDC\&}{ dc}}
80
81Defined by wxTreeLayout to draw a node.
82
83\membersection{wxTreeLayout::DrawNodes}
84
85\func{void}{DrawNodes}{\param{wxDC\&}{ dc}}
86
87Defined by wxTreeLayout to draw the nodes.
88
89\membersection{wxTreeLayout::GetChildren}\label{getchildren}
90
91\func{void}{GetChildren}{\param{long}{ id}, \param{wxList \&}{list}}
92
93Must be defined to return the children of node {\it id} in the given list
94of integers.
95
96\membersection{wxTreeLayout::GetNextNode}\label{getnextnode}
97
98\func{long}{GetNextNode}{\param{long}{ id}}
99
100Must be defined to return the next node after {\it id}, so that wxTreeLayout can
101iterate through all relevant nodes. The ordering is not important.
102The function should return -1 if there are no more nodes.
103
104\membersection{wxTreeLayout::GetNodeName}
105
106\constfunc{wxString}{GetNodeName}{\param{long}{ id}}
107
108May optionally be defined to get a node's name (for example if leaving
109the drawing to wxTreeLayout).
110
111\membersection{wxTreeLayout::GetNodeSize}
112
113\constfunc{void}{GetNodeSize}{\param{long}{ id}, \param{long*}{ x}, \param{long*}{ y}}
114
115Can be defined to indicate a node's size, or left to wxTreeLayout to use the
116name as an indication of size.
117
118\membersection{wxTreeLayout::GetNodeParent}\label{getnodeparent}
119
120\constfunc{long}{GetNodeParent}{\param{long}{ id}}
121
122Must be defined to return the parent node of {\it id}.
123The function should return -1 if there is no parent.
124
125\membersection{wxTreeLayout::GetNodeX}
126
127\constfunc{long}{GetNodeX}{\param{long}{ id}}
128
129Must be defined to return the current X position of the node. Note that
130coordinates are assumed to be at the top-left of the node so some conversion
131may be necessary for your application.
132
133\membersection{wxTreeLayout::GetNodeY}
134
135\constfunc{long}{GetNodeY}{\param{long}{ id}}
136
137Must be defined to return the current Y position of the node. Note that
138coordinates are assumed to be at the top-left of the node so some conversion
139may be necessary for your application.
140
141\membersection{wxTreeLayout::GetLeftMargin}
142
143\constfunc{long}{GetLeftMargin}{\void}
144
145Gets the left margin set with \helprefn{SetMargins}{setmargins}.
146
147\membersection{wxTreeLayout::GetOrientation}
148
149\constfunc{bool}{GetOrientation}{\void}
150
151Gets the orientation: TRUE means top-to-bottom, FALSE means left-to-right (the default).
152
153\membersection{wxTreeLayout::GetTopMargin}
154
155\constfunc{long}{GetTopMargin}{\void}
156
157Gets the top margin set with \helprefn{SetMargins}{setmargins}.
158
159\membersection{wxTreeLayout::GetTopNode}
160
161\constfunc{long}{GetTopNode}{\void}
162
163wxTreeLayout 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}.
165
166\membersection{wxTreeLayout::GetXSpacing}
167
168\constfunc{long}{GetXSpacing}{\void}
169
170Gets the horizontal spacing between nodes.
171
172\membersection{wxTreeLayout::GetYSpacing}
173
174\constfunc{long}{GetYSpacing}{\void}
175
176Gets the vertical spacing between nodes.
177
178\membersection{wxTreeLayout::Initialize}
179
180\func{void}{Initialize}{\void}
181
182Initializes wxTreeLayout. Call from application or overridden {\bf Initialize}
183or constructor.
184
185\membersection{wxTreeLayout::NodeActive}\label{nodeactive}
186
187\func{bool}{NodeActive}{\param{long}{ id}}
188
189Define this so wxTreeLayout can know which nodes are to be drawn (not all
190nodes may be connected in the tree). See also \helprefn{ActivateNode}{activatenode}.
191
192\membersection{wxTreeLayout::SetNodeName}
193
194\func{void}{SetNodeName}{\param{long}{ id}, \param{const wxString\& }{ name}}
195
196May optionally be defined to set a node's name.
197
198\membersection{wxTreeLayout::SetNodeX}
199
200\func{void}{SetNodeX}{\param{long}{ id}, \param{long}{ x}}
201
202Must be defined to set the current X position of the node. Note that
203coordinates are assumed to be at the top-left of the node so some conversion
204may be necessary for your application.
205
206\membersection{wxTreeLayout::SetNodeY}
207
208\func{void}{SetNodeY}{\param{long}{ id}, \param{long}{ y}}
209
210Must be defined to set the current Y position of the node. Note that
211coordinates are assumed to be at the top-left of the node so some conversion
212may be necessary for your application.
213
214\membersection{wxTreeLayout::SetOrientation}
215
216\func{void}{SetOrientation}{\param{bool}{ orientation}}
217
218Sets the tree orientation: TRUE means top-to-bottom, FALSE means left-to-right (the default).
219
220\membersection{wxTreeLayout::SetTopNode}\label{settopnode}
221
222\func{void}{SetTopNode}{\param{long}{ id}}
223
224Call this to identify the top of the tree to wxTreeLayout.
225
226\membersection{wxTreeLayout::SetSpacing}
227
228\func{void}{SetSpacing}{\param{long}{ x}, \param{long}{ y}}
229
230Sets the horizontal and vertical spacing between nodes in the tree.
231
232\membersection{wxTreeLayout::SetMargins}\label{setmargins}
233
234\func{void}{SetMargins}{\param{long}{ x}, \param{long}{ y}}
235
236Sets the left and top margins of the whole tree.
237
238\section{\class{wxStoredTree}}\label{wxstoredtree}
239
240wxStoredTree 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.
242
243\wxheading{Derived from}
244
245\helpref{wxTreeLayout}{wxtreelayout}
246
247\latexignore{\rtfignore{\wxheading{Members}}}
248
249\membersection{wxStoredTree::wxStoredTree}
250
251\func{}{wxStoredTree}{\param{int }{noNodes = 200}}
252
253Constructor. Specify the maximum number of nodes to be allocated.
254
255\membersection{wxStoredTree::AddChild}\label{wxstoredtreeaddchild}
256
257\func{long}{AddChild}{\param{const wxString\&}{ name}, \param{const wxString\&}{ parent = ""}}
258
259Adds a child with a given parent, returning the node id.
260
261\membersection{wxStoredTree::GetClientData}\label{wxstoredtreegetclientdata}
262
263\constfunc{long}{GetClientData}{\param{long}{ id}}
264
265Gets the client data for the given node.
266
267\membersection{wxStoredTree::GetNode}\label{wxstoredtreegetnode}
268
269\constfunc{wxStoredNode*}{GetNode}{\param{long}{ id}}
270
271Returns the wxStoredNode object for the given node id.
272
273\membersection{wxStoredTree::GetNodeCount}\label{wxstoredtreegetnodecount}
274
275\constfunc{int}{GetNodeCount}{\void}
276
277Returns the current number of nodes.
278
279\membersection{wxStoredTree::GetNumNodes}\label{wxstoredtreegetnumnodes}
280
281\constfunc{int}{GetNumNodes}{\void}
282
283Returns the maximum number of nodes.
284
285\membersection{wxStoredTree::HitTest}\label{wxstoredtreehittest}
286
287\func{wxString}{HitTest}{\param{wxMouseEvent\&}{ event}, \param{wxDC\& }{dc}}
288
289Returns a string with the node name corresponding to the position of the mouse event, or the empty string if no node
290was detected.
291
292\membersection{wxStoredTree::NameToId}\label{wxstoredtreenametoid}
293
294\func{long}{NameToId}{\param{const wxString\&}{ name}}
295
296Returns the id for the given node name, or -1 if there was no such node.
297
298\membersection{wxStoredTree::SetClientData}\label{wxstoredtreesetclientdata}
299
300\func{void}{SetClientData}{\param{long}{ id}, \param{long}{ clientData}}
301
302Sets client data for the given node.
303
304