File: treelay.tex

package info (click to toggle)
wxwidgets2.8 2.8.10.1-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 239,052 kB
  • ctags: 289,550
  • sloc: cpp: 1,838,857; xml: 396,717; python: 282,506; ansic: 126,171; makefile: 51,406; sh: 14,581; asm: 299; sql: 258; lex: 194; perl: 139; yacc: 128; pascal: 95; php: 39; lisp: 38; tcl: 24; haskell: 20; java: 18; cs: 18; erlang: 17; ruby: 16; ada: 9; ml: 9; csh: 9
file content (327 lines) | stat: -rw-r--r-- 10,763 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
\section{\class{wxTreeLayout}}\label{wxtreelayout}

wxTreeLayout provides layout of simple trees with one root node, drawn left-to-right,
with user-defined spacing between nodes.

wxTreeLayout 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 wxTreeLayout uses these when laying
out the tree.

Nodes are identified by long integer identifiers. The derived class
communicates the actual tree structure to wxTreeLayout by defining \helpref{wxTreeLayout::GetChildren}{wxtreelayoutgetchildren}\rtfsp
and \helpref{wxTreeLayout::GetNodeParent}{wxtreelayoutgetnodeparent} functions.

The application should call \helpref{wxTreeLayout::DoLayout}{wxtreelayoutdolayout} to do the tree
layout. Depending on how the derived class has been defined, either
\rtfsp\helpref{wxTreeLayout::Draw}{wxtreelayoutdraw} must be called (for example by the OnPaint member
of a wxScrolledWindow) 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 wxTreeLayout to position existing node images in that system. So you
just need a way for wxTreeLayout to set the node image positions according to
the layout algorithm, and the rest will be done by your own image drawing
system.

The algorithm is due to Gabriel Robins \cite{robins87}, a linear-time
algorithm originally implemented in LISP for AI applications.

The original algorithm has been modified so that both X and Y planes
are calculated simultaneously, increasing efficiency slightly. The basic
code is only a page or so long.

\helponly{Below is the example tree generated by the program test.cc.

\begin{figure}
$$\image{11cm;0cm}{treetst.ps}$$
\caption{Example tree}\label{exampletree}
\end{figure}
}

\wxheading{Derived from}

wxObject

\wxheading{See also}

\helpref{wxTreeLayoutStored}{wxtreelayoutstored}

\latexignore{\rtfignore{\wxheading{Members}}}

\membersection{wxTreeLayout::wxTreeLayout}

\func{}{wxTreeLayout}{\void}

Constructor.

\membersection{wxTreeLayout::ActivateNode}\label{wxtreelayoutactivatenode}

\func{void}{ActivateNode}{\param{long}{ id}, \param{bool }{active}}

Define this so wxTreeLayout can turn nodes on and off for drawing purposes
(not all nodes may be connected in the tree). See also \helpref{wxTreeLayout::NodeActive}{wxtreelayoutnodeactive}.

\membersection{wxTreeLayout::CalcLayout}

\func{void}{CalcLayout}{\param{long}{ id}, \param{int}{ level}}

Private function for laying out a branch.

\membersection{wxTreeLayout::DoLayout}\label{wxtreelayoutdolayout}

\func{void}{DoLayout}{\param{wxDC\&}{ dc}, \param{long}{ topNode = -1}}

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

\membersection{wxTreeLayout::Draw}\label{wxtreelayoutdraw}

\func{void}{Draw}{\param{wxDC\&}{ dc}}

Call this to let wxTreeLayout draw the tree itself, once the layout has been
calculated with \helpref{wxTreeLayout::DoLayout}{wxtreelayoutdolayout}.

\membersection{wxTreeLayout::DrawBranch}

\func{void}{DrawBranch}{\param{long}{ from}, \param{long}{ to}, \param{wxDC\&}{ dc}}

Defined by wxTreeLayout to draw an arc between two nodes.

\membersection{wxTreeLayout::DrawBranches}

\func{void}{DrawBranches}{\param{wxDC\&}{ dc}}

Defined by wxTreeLayout to draw the arcs between nodes.

\membersection{wxTreeLayout::DrawNode}

\func{void}{DrawNode}{\param{long}{ id}, \param{wxDC\&}{ dc}}

Defined by wxTreeLayout to draw a node.

\membersection{wxTreeLayout::DrawNodes}

\func{void}{DrawNodes}{\param{wxDC\&}{ dc}}

Defined by wxTreeLayout to draw the nodes.

\membersection{wxTreeLayout::GetChildren}\label{wxtreelayoutgetchildren}

\func{void}{GetChildren}{\param{long}{ id}, \param{wxList \&}{list}}

Must be defined to return the children of node {\it id} in the given list
of integers.

\membersection{wxTreeLayout::GetNextNode}\label{wxtreelayoutgetnextnode}

\func{long}{GetNextNode}{\param{long}{ id}}

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

\membersection{wxTreeLayout::GetNodeName}

\constfunc{wxString}{GetNodeName}{\param{long}{ id}}

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

\membersection{wxTreeLayout::GetNodeSize}

\constfunc{void}{GetNodeSize}{\param{long}{ id}, \param{long*}{ x}, \param{long*}{ y}}

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

\membersection{wxTreeLayout::GetNodeParent}\label{wxtreelayoutgetnodeparent}

\constfunc{long}{GetNodeParent}{\param{long}{ id}}

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

\membersection{wxTreeLayout::GetNodeX}

\constfunc{long}{GetNodeX}{\param{long}{ 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.

\membersection{wxTreeLayout::GetNodeY}

\constfunc{long}{GetNodeY}{\param{long}{ 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.

\membersection{wxTreeLayout::GetLeftMargin}

\constfunc{long}{GetLeftMargin}{\void}

Gets the left margin set with \helpref{wxTreeLayout::SetMargins}{wxtreelayoutsetmargins}.

\membersection{wxTreeLayout::GetOrientation}

\constfunc{bool}{GetOrientation}{\void}

Gets the orientation: true means top-to-bottom, false means left-to-right (the default).

\membersection{wxTreeLayout::GetTopMargin}

\constfunc{long}{GetTopMargin}{\void}

Gets the top margin set with \helpref{wxTreeLayout::SetMargins}{wxtreelayoutsetmargins}.

\membersection{wxTreeLayout::GetTopNode}

\constfunc{long}{GetTopNode}{\void}

wxTreeLayout calls this to get the top of the tree. Don't redefine this; call
\rtfsp\helpref{wxTreeLayout::SetTopNode}{wxtreelayoutsettopnode} instead before calling \helpref{wxTreeLayout::DoLayout}{wxtreelayoutdolayout}.

\membersection{wxTreeLayout::GetXSpacing}

\constfunc{long}{GetXSpacing}{\void}

Gets the horizontal spacing between nodes.

\membersection{wxTreeLayout::GetYSpacing}

\constfunc{long}{GetYSpacing}{\void}

Gets the vertical spacing between nodes.

\membersection{wxTreeLayout::Initialize}

\func{void}{Initialize}{\void}

Initializes wxTreeLayout. Call from application or overridden {\bf Initialize}
or constructor.

\membersection{wxTreeLayout::NodeActive}\label{wxtreelayoutnodeactive}

\func{bool}{NodeActive}{\param{long}{ id}}

Define this so wxTreeLayout can know which nodes are to be drawn (not all
nodes may be connected in the tree). See also \helpref{wxTreeLayout::ActivateNode}{wxtreelayoutactivatenode}.

\membersection{wxTreeLayout::SetNodeName}

\func{void}{SetNodeName}{\param{long}{ id}, \param{const wxString\& }{ name}}

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

\membersection{wxTreeLayout::SetNodeX}

\func{void}{SetNodeX}{\param{long}{ id}, \param{long}{ 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.

\membersection{wxTreeLayout::SetNodeY}

\func{void}{SetNodeY}{\param{long}{ id}, \param{long}{ 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.

\membersection{wxTreeLayout::SetOrientation}

\func{void}{SetOrientation}{\param{bool}{ orientation}}

Sets the tree orientation: true means top-to-bottom, false means left-to-right (the default).

\membersection{wxTreeLayout::SetTopNode}\label{wxtreelayoutsettopnode}

\func{void}{SetTopNode}{\param{long}{ id}}

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

\membersection{wxTreeLayout::SetSpacing}

\func{void}{SetSpacing}{\param{long}{ x}, \param{long}{ y}}

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

\membersection{wxTreeLayout::SetMargins}\label{wxtreelayoutsetmargins}

\func{void}{SetMargins}{\param{long}{ x}, \param{long}{ y}}

Sets the left and top margins of the whole tree.

\section{\class{wxTreeLayoutStored}}\label{wxtreelayoutstored}

wxTreeLayoutStored provides storage for node labels, position and client data. It also provides hit-testing
(which node a mouse event occurred on). It is usually a more convenient class to use than wxTreeLayout.

\wxheading{Derived from}

\helpref{wxTreeLayout}{wxtreelayout}\\
\helpref{wxObject}{wxobject}

\wxheading{See also}

\helpref{wxTreeLayout}{wxtreelayout}

\latexignore{\rtfignore{\wxheading{Members}}}

\membersection{wxTreeLayoutStored::wxTreeLayoutStored}

\func{}{wxTreeLayoutStored}{\param{int }{noNodes = 200}}

Constructor. Specify the maximum number of nodes to be allocated.

\membersection{wxTreeLayoutStored::AddChild}\label{wxtreelayoutstoredaddchild}

\func{long}{AddChild}{\param{const wxString\&}{ name}, \param{const wxString\&}{ parent = ""}}

Adds a child with a given parent, returning the node id.

\membersection{wxTreeLayoutStored::GetClientData}\label{wxtreelayoutstoredgetclientdata}

\constfunc{long}{GetClientData}{\param{long}{ id}}

Gets the client data for the given node.

\membersection{wxTreeLayoutStored::GetNode}\label{wxtreelayoutstoredgetnode}

\constfunc{wxStoredNode*}{GetNode}{\param{long}{ id}}

Returns the wxStoredNode object for the given node id.

\membersection{wxTreeLayoutStored::GetNodeCount}\label{wxtreelayoutstoredgetnodecount}

\constfunc{int}{GetNodeCount}{\void}

Returns the current number of nodes.

\membersection{wxTreeLayoutStored::GetNumNodes}\label{wxtreelayoutstoredgetnumnodes}

\constfunc{int}{GetNumNodes}{\void}

Returns the maximum number of nodes.

\membersection{wxTreeLayoutStored::HitTest}\label{wxtreelayoutstoredhittest}

\func{wxString}{HitTest}{\param{wxMouseEvent\&}{ event}, \param{wxDC\& }{dc}}

Returns a string with the node name corresponding to the position of the mouse event, or the empty string if no node
was detected.

\membersection{wxTreeLayoutStored::NameToId}\label{wxtreelayoutstorednametoid}

\func{long}{NameToId}{\param{const wxString\&}{ name}}

Returns the id for the given node name, or -1 if there was no such node.

\membersection{wxTreeLayoutStored::SetClientData}\label{wxtreelayoutstoredsetclientdata}

\func{void}{SetClientData}{\param{long}{ id}, \param{long}{ clientData}}

Sets client data for the given node.