]>
Commit | Line | Data |
---|---|---|
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 | ||
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 | |
9 | wxTreeLayout needs. | |
10 | ||
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. | |
14 | ||
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 | |
19 | as normal. | |
20 | ||
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 | |
25 | system. | |
26 | ||
27 | \wxheading{Derived from} | |
28 | ||
29 | wxObject | |
30 | ||
31 | \latexignore{\rtfignore{\wxheading{Members}}} | |
32 | ||
33 | \membersection{wxTreeLayout::wxTreeLayout} | |
34 | ||
35 | \func{}{wxTreeLayout}{\void} | |
36 | ||
37 | Constructor. | |
38 | ||
39 | \membersection{wxTreeLayout::ActivateNode}\label{activatenode} | |
40 | ||
41 | \func{void}{ActivateNode}{\param{long}{ id}, \param{bool }{active}} | |
42 | ||
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}. | |
45 | ||
46 | \membersection{wxTreeLayout::CalcLayout} | |
47 | ||
48 | \func{void}{CalcLayout}{\param{long}{ id}, \param{int}{ level}} | |
49 | ||
50 | Private 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 | ||
56 | Calculates 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 | ||
62 | Call this to let wxTreeLayout draw the tree itself, once the layout has been | |
63 | calculated with \helprefn{DoLayout}{dolayout}. | |
64 | ||
65 | \membersection{wxTreeLayout::DrawBranch} | |
66 | ||
67 | \func{void}{DrawBranch}{\param{long}{ from}, \param{long}{ to}, \param{wxDC\&}{ dc}} | |
68 | ||
69 | Defined by wxTreeLayout to draw an arc between two nodes. | |
70 | ||
71 | \membersection{wxTreeLayout::DrawBranches} | |
72 | ||
73 | \func{void}{DrawBranches}{\param{wxDC\&}{ dc}} | |
74 | ||
75 | Defined 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 | ||
81 | Defined by wxTreeLayout to draw a node. | |
82 | ||
83 | \membersection{wxTreeLayout::DrawNodes} | |
84 | ||
85 | \func{void}{DrawNodes}{\param{wxDC\&}{ dc}} | |
86 | ||
87 | Defined 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 | ||
93 | Must be defined to return the children of node {\it id} in the given list | |
94 | of integers. | |
95 | ||
96 | \membersection{wxTreeLayout::GetNextNode}\label{getnextnode} | |
97 | ||
98 | \func{long}{GetNextNode}{\param{long}{ id}} | |
99 | ||
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. | |
103 | ||
104 | \membersection{wxTreeLayout::GetNodeName} | |
105 | ||
106 | \constfunc{wxString}{GetNodeName}{\param{long}{ id}} | |
107 | ||
108 | May optionally be defined to get a node's name (for example if leaving | |
109 | the drawing to wxTreeLayout). | |
110 | ||
111 | \membersection{wxTreeLayout::GetNodeSize} | |
112 | ||
113 | \constfunc{void}{GetNodeSize}{\param{long}{ id}, \param{long*}{ x}, \param{long*}{ y}} | |
114 | ||
115 | Can be defined to indicate a node's size, or left to wxTreeLayout to use the | |
116 | name as an indication of size. | |
117 | ||
118 | \membersection{wxTreeLayout::GetNodeParent}\label{getnodeparent} | |
119 | ||
120 | \constfunc{long}{GetNodeParent}{\param{long}{ id}} | |
121 | ||
122 | Must be defined to return the parent node of {\it id}. | |
123 | The function should return -1 if there is no parent. | |
124 | ||
125 | \membersection{wxTreeLayout::GetNodeX} | |
126 | ||
127 | \constfunc{long}{GetNodeX}{\param{long}{ id}} | |
128 | ||
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. | |
132 | ||
133 | \membersection{wxTreeLayout::GetNodeY} | |
134 | ||
135 | \constfunc{long}{GetNodeY}{\param{long}{ id}} | |
136 | ||
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. | |
140 | ||
141 | \membersection{wxTreeLayout::GetLeftMargin} | |
142 | ||
143 | \constfunc{long}{GetLeftMargin}{\void} | |
144 | ||
145 | Gets the left margin set with \helprefn{SetMargins}{setmargins}. | |
146 | ||
147 | \membersection{wxTreeLayout::GetOrientation} | |
148 | ||
149 | \constfunc{bool}{GetOrientation}{\void} | |
150 | ||
151 | Gets 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 | ||
157 | Gets the top margin set with \helprefn{SetMargins}{setmargins}. | |
158 | ||
159 | \membersection{wxTreeLayout::GetTopNode} | |
160 | ||
161 | \constfunc{long}{GetTopNode}{\void} | |
162 | ||
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}. | |
165 | ||
166 | \membersection{wxTreeLayout::GetXSpacing} | |
167 | ||
168 | \constfunc{long}{GetXSpacing}{\void} | |
169 | ||
170 | Gets the horizontal spacing between nodes. | |
171 | ||
172 | \membersection{wxTreeLayout::GetYSpacing} | |
173 | ||
174 | \constfunc{long}{GetYSpacing}{\void} | |
175 | ||
176 | Gets the vertical spacing between nodes. | |
177 | ||
178 | \membersection{wxTreeLayout::Initialize} | |
179 | ||
180 | \func{void}{Initialize}{\void} | |
181 | ||
182 | Initializes wxTreeLayout. Call from application or overridden {\bf Initialize} | |
183 | or constructor. | |
184 | ||
185 | \membersection{wxTreeLayout::NodeActive}\label{nodeactive} | |
186 | ||
187 | \func{bool}{NodeActive}{\param{long}{ id}} | |
188 | ||
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}. | |
191 | ||
192 | \membersection{wxTreeLayout::SetNodeName} | |
193 | ||
194 | \func{void}{SetNodeName}{\param{long}{ id}, \param{const wxString\& }{ name}} | |
195 | ||
196 | May 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 | ||
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. | |
205 | ||
206 | \membersection{wxTreeLayout::SetNodeY} | |
207 | ||
208 | \func{void}{SetNodeY}{\param{long}{ id}, \param{long}{ y}} | |
209 | ||
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. | |
213 | ||
214 | \membersection{wxTreeLayout::SetOrientation} | |
215 | ||
216 | \func{void}{SetOrientation}{\param{bool}{ orientation}} | |
217 | ||
218 | Sets 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 | ||
224 | Call 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 | ||
230 | Sets 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 | ||
236 | Sets the left and top margins of the whole tree. | |
237 | ||
238 | \section{\class{wxStoredTree}}\label{wxstoredtree} | |
239 | ||
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. | |
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 | ||
253 | Constructor. 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 | ||
259 | Adds 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 | ||
265 | Gets the client data for the given node. | |
266 | ||
267 | \membersection{wxStoredTree::GetNode}\label{wxstoredtreegetnode} | |
268 | ||
269 | \constfunc{wxStoredNode*}{GetNode}{\param{long}{ id}} | |
270 | ||
271 | Returns the wxStoredNode object for the given node id. | |
272 | ||
273 | \membersection{wxStoredTree::GetNodeCount}\label{wxstoredtreegetnodecount} | |
274 | ||
275 | \constfunc{int}{GetNodeCount}{\void} | |
276 | ||
277 | Returns the current number of nodes. | |
278 | ||
279 | \membersection{wxStoredTree::GetNumNodes}\label{wxstoredtreegetnumnodes} | |
280 | ||
281 | \constfunc{int}{GetNumNodes}{\void} | |
282 | ||
283 | Returns the maximum number of nodes. | |
284 | ||
285 | \membersection{wxStoredTree::HitTest}\label{wxstoredtreehittest} | |
286 | ||
287 | \func{wxString}{HitTest}{\param{wxMouseEvent\&}{ event}, \param{wxDC\& }{dc}} | |
288 | ||
289 | Returns a string with the node name corresponding to the position of the mouse event, or the empty string if no node | |
290 | was detected. | |
291 | ||
292 | \membersection{wxStoredTree::NameToId}\label{wxstoredtreenametoid} | |
293 | ||
294 | \func{long}{NameToId}{\param{const wxString\&}{ name}} | |
295 | ||
296 | Returns 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 | ||
302 | Sets client data for the given node. | |
303 | ||
304 |