This file is indexed.

/usr/share/doc/libcwidget-doc/html/documentation/api/treeitem_8h_source.html is in libcwidget-doc 0.5.16-3.1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>cwidget: src/cwidget/widgets/treeitem.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.4 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">cwidget&#160;<span id="projectnumber">0.5.16</span></div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="dir_243988d349377286cc7f96103c5b81e1.html">src</a>      </li>
      <li class="navelem"><a class="el" href="dir_9f12a1d6ca44d84f8b067f6d6a3d0a3c.html">cwidget</a>      </li>
      <li class="navelem"><a class="el" href="dir_432a773280520c90f7ab83227d95a74c.html">widgets</a>      </li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">treeitem.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// treeitem.h    (this is -*-c++-*-)</span>
<a name="l00002"></a>00002 <span class="comment">//</span>
<a name="l00003"></a>00003 <span class="comment">//  Copyright 1999-2001, 2004-2005, 2007 Daniel Burrows</span>
<a name="l00004"></a>00004 <span class="comment">//</span>
<a name="l00005"></a>00005 <span class="comment">//  This program is free software; you can redistribute it and/or modify</span>
<a name="l00006"></a>00006 <span class="comment">//  it under the terms of the GNU General Public License as published by</span>
<a name="l00007"></a>00007 <span class="comment">//  the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00008"></a>00008 <span class="comment">//  (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment">//</span>
<a name="l00010"></a>00010 <span class="comment">//  This program is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment">//  but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment">//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00013"></a>00013 <span class="comment">//  GNU General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment">//</span>
<a name="l00015"></a>00015 <span class="comment">//  You should have received a copy of the GNU General Public License</span>
<a name="l00016"></a>00016 <span class="comment">//  along with this program; see the file COPYING.  If not, write to</span>
<a name="l00017"></a>00017 <span class="comment">//  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,</span>
<a name="l00018"></a>00018 <span class="comment">//  Boston, MA 02111-1307, USA.</span>
<a name="l00019"></a>00019 <span class="comment">//</span>
<a name="l00020"></a>00020 <span class="comment">//  The basic tree item declaration (moved here to reduce the size of</span>
<a name="l00021"></a>00021 <span class="comment">//  tree.h)</span>
<a name="l00022"></a>00022 <span class="comment">//</span>
<a name="l00023"></a>00023 <span class="comment">//  I think this is *TOO* general.  A simplified version will probably be</span>
<a name="l00024"></a>00024 <span class="comment">//  introduced at some point -- but the API should be fairly stable and nothing</span>
<a name="l00025"></a>00025 <span class="comment">//  outside this file is likely to change significantly.  Yeah, right.</span>
<a name="l00026"></a>00026 
<a name="l00027"></a>00027 <span class="preprocessor">#ifndef TREEITEM_H</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span><span class="preprocessor">#define TREEITEM_H</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;cwidget/curses++.h&gt;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;cwidget/style.h&gt;</span>
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 <span class="preprocessor">#include &quot;minibuf_win.h&quot;</span>
<a name="l00036"></a>00036 
<a name="l00037"></a>00037 <span class="keyword">namespace </span>cwidget
<a name="l00038"></a>00038 {
<a name="l00039"></a>00039   <span class="keyword">namespace </span>widgets
<a name="l00040"></a>00040   {
<a name="l00041"></a>00041     <span class="keyword">class </span>tree;
<a name="l00042"></a>00042     <span class="keyword">class </span>treeitem;
<a name="l00043"></a>00043     <span class="keyword">class </span>sortpolicy;
<a name="l00044"></a>00044 
<a name="l00045"></a><a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">00045</a>     <span class="keyword">class </span><a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">tree_levelref</a>
<a name="l00046"></a>00046     <span class="comment">// A generic way to iterate over a *single level* of a tree.  Not really an</span>
<a name="l00047"></a>00047     <span class="comment">// &quot;iterator&quot; since it doesn&#39;t do the operators and so on.</span>
<a name="l00048"></a>00048     {
<a name="l00049"></a>00049       <a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">tree_levelref</a> *parent;
<a name="l00050"></a>00050     <span class="keyword">public</span>:
<a name="l00051"></a>00051       <a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">tree_levelref</a>():parent(NULL) {}
<a name="l00052"></a>00052       <a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">tree_levelref</a>(<span class="keyword">const</span> <a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">tree_levelref</a> &amp;x)
<a name="l00053"></a>00053         :parent(x.parent?x.parent-&gt;clone():NULL) {}
<a name="l00054"></a>00054       <span class="keyword">virtual</span> ~<a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">tree_levelref</a>() {}
<a name="l00055"></a>00055 
<a name="l00056"></a>00056       <span class="keyword">virtual</span> <a class="code" href="classcwidget_1_1widgets_1_1treeitem.html">treeitem</a> *get_item()=0;
<a name="l00057"></a>00057       <span class="keyword">virtual</span> <span class="keywordtype">void</span> advance_next()=0;
<a name="l00058"></a>00058       <span class="keyword">virtual</span> <span class="keywordtype">void</span> return_prev()=0;
<a name="l00059"></a>00059       <span class="comment">// Like ++ and --, sort of..</span>
<a name="l00060"></a>00060 
<a name="l00061"></a>00061       <span class="keyword">virtual</span> <span class="keywordtype">bool</span> is_begin()=0;
<a name="l00062"></a>00062       <span class="comment">// Should return true if this iterator is at the front of a list (so going</span>
<a name="l00063"></a>00063       <span class="comment">// back will do Really Bad Things) -- many STL containers need this..</span>
<a name="l00064"></a>00064       <span class="keyword">virtual</span> <span class="keywordtype">bool</span> is_end()=0;
<a name="l00065"></a>00065       <span class="comment">// Should return true if this iterator no longer refers to something valid.</span>
<a name="l00066"></a>00066 
<a name="l00067"></a>00067       <span class="keyword">virtual</span> <a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">tree_levelref</a> *clone() <span class="keyword">const</span>=0;
<a name="l00068"></a>00068 
<a name="l00069"></a>00069       <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a>;
<a name="l00070"></a>00070     };
<a name="l00071"></a>00071 
<a name="l00072"></a><a class="code" href="classcwidget_1_1widgets_1_1tree__root__iterator.html">00072</a>     <span class="keyword">class </span><a class="code" href="classcwidget_1_1widgets_1_1tree__root__iterator.html">tree_root_iterator</a>:<span class="keyword">public</span> <a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">tree_levelref</a>
<a name="l00073"></a>00073     <span class="comment">// A dummy iterator for use on parent-less trees (all other iterators</span>
<a name="l00074"></a>00074     <span class="comment">// assume that they have a valid parent -- er?)</span>
<a name="l00075"></a>00075     {
<a name="l00076"></a>00076       <a class="code" href="classcwidget_1_1widgets_1_1treeitem.html">treeitem</a> *val;
<a name="l00077"></a>00077       <a class="code" href="classcwidget_1_1widgets_1_1treeitem.html">treeitem</a> *prevval;
<a name="l00078"></a>00078 
<a name="l00079"></a>00079       <a class="code" href="classcwidget_1_1widgets_1_1treeitem.html">treeitem</a> *get_item() {<span class="keywordflow">return</span> val;}
<a name="l00080"></a>00080     <span class="keyword">public</span>:
<a name="l00081"></a>00081       <a class="code" href="classcwidget_1_1widgets_1_1tree__root__iterator.html">tree_root_iterator</a>(<a class="code" href="classcwidget_1_1widgets_1_1treeitem.html">treeitem</a> *_val):val(_val), prevval(NULL) {}
<a name="l00082"></a>00082       <a class="code" href="classcwidget_1_1widgets_1_1tree__root__iterator.html">tree_root_iterator</a>(<span class="keyword">const</span> <a class="code" href="classcwidget_1_1widgets_1_1tree__root__iterator.html">tree_root_iterator</a> &amp;x):<a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">tree_levelref</a>(x), val(x.val), prevval(x.prevval) {}
<a name="l00083"></a>00083 
<a name="l00084"></a>00084       <span class="keywordtype">void</span> advance_next() {<span class="keywordflow">if</span>(val) { prevval=val; val=NULL;} }
<a name="l00085"></a>00085       <span class="keywordtype">void</span> return_prev() {<span class="keywordflow">if</span>(prevval) {val=prevval; prevval=NULL;} }
<a name="l00086"></a>00086 
<a name="l00087"></a>00087       <a class="code" href="classcwidget_1_1widgets_1_1tree__root__iterator.html">tree_root_iterator</a> *clone()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classcwidget_1_1widgets_1_1tree__root__iterator.html">tree_root_iterator</a>(*<span class="keyword">this</span>);}
<a name="l00088"></a>00088 
<a name="l00089"></a>00089       <span class="keywordtype">bool</span> is_end() {<span class="keywordflow">return</span> !val;}
<a name="l00090"></a>00090       <span class="keywordtype">bool</span> is_begin() {<span class="keywordflow">return</span> prevval==NULL;}
<a name="l00091"></a>00091 
<a name="l00092"></a>00092       <span class="comment">// Returns an &quot;end iterator&quot; for this tree</span>
<a name="l00093"></a>00093       <a class="code" href="classcwidget_1_1widgets_1_1tree__root__iterator.html">tree_root_iterator</a> *end()
<a name="l00094"></a>00094       {
<a name="l00095"></a>00095         <a class="code" href="classcwidget_1_1widgets_1_1tree__root__iterator.html">tree_root_iterator</a> *rval=<span class="keyword">new</span> <a class="code" href="classcwidget_1_1widgets_1_1tree__root__iterator.html">tree_root_iterator</a>(*<span class="keyword">this</span>);
<a name="l00096"></a>00096         rval-&gt;advance_next();
<a name="l00097"></a>00097         <span class="keywordflow">return</span> rval;
<a name="l00098"></a>00098       }
<a name="l00099"></a>00099     };
<a name="l00100"></a>00100 
<a name="l00101"></a><a class="code" href="classcwidget_1_1widgets_1_1treeitem.html">00101</a>     <span class="keyword">class </span><a class="code" href="classcwidget_1_1widgets_1_1treeitem.html">treeitem</a>
<a name="l00102"></a>00102     <span class="comment">// An abstracted item (could be a leaf node or a subtree) -- this isn&#39;t really</span>
<a name="l00103"></a>00103     <span class="comment">// meant to be that useful in general, derive from the specialized children</span>
<a name="l00104"></a>00104     <span class="comment">// instead.</span>
<a name="l00105"></a>00105     {
<a name="l00106"></a>00106       <span class="keywordtype">int</span> depth;
<a name="l00107"></a>00107       <span class="keywordtype">bool</span> selectable;
<a name="l00108"></a>00108     <span class="keyword">protected</span>:
<a name="l00109"></a>00109       <span class="keyword">virtual</span> <span class="keywordtype">void</span> set_depth(<span class="keywordtype">int</span> _depth) {depth=_depth;}
<a name="l00110"></a>00110       <span class="keyword">virtual</span> <span class="keywordtype">void</span> set_selectable(<span class="keywordtype">bool</span> _selectable) {selectable=_selectable;}
<a name="l00111"></a>00111     <span class="keyword">public</span>:
<a name="l00112"></a>00112       <a class="code" href="classcwidget_1_1widgets_1_1treeitem.html">treeitem</a>(<span class="keywordtype">bool</span> _selectable=<span class="keyword">true</span>):depth(0),selectable(_selectable) {}
<a name="l00113"></a>00113 
<a name="l00126"></a>00126       <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classcwidget_1_1widgets_1_1treeitem.html#aa79e24faa2c50b0135e9aa5da4011b8c" title="Display this item and this item only (does not descend to the children of the item, if any).">paint</a>(<a class="code" href="classcwidget_1_1widgets_1_1tree.html">tree</a> *win, <span class="keywordtype">int</span> y, <span class="keywordtype">bool</span> hierarchical,
<a name="l00127"></a>00127                          <span class="keyword">const</span> <a class="code" href="classcwidget_1_1style.html" title="A &quot;style&quot; is a setting to be applied to a display element (widget, text, etc).">style</a> &amp;st)=0;
<a name="l00128"></a>00128 
<a name="l00138"></a>00138       <span class="keywordtype">void</span> <a class="code" href="classcwidget_1_1widgets_1_1treeitem.html#aa79e24faa2c50b0135e9aa5da4011b8c" title="Display this item and this item only (does not descend to the children of the item, if any).">paint</a>(<a class="code" href="classcwidget_1_1widgets_1_1tree.html">tree</a> *win, <span class="keywordtype">int</span> y, <span class="keywordtype">bool</span> hierarchical,
<a name="l00139"></a>00139                  <span class="keyword">const</span> std::wstring &amp;str, <span class="keywordtype">int</span> depth_shift=2);
<a name="l00140"></a>00140 
<a name="l00141"></a>00141       <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">wchar_t</span> *tag()=0;
<a name="l00142"></a>00142       <span class="comment">// The tag that this item should be sorted by [for the trivial version of</span>
<a name="l00143"></a>00143       <span class="comment">// the subtree object]</span>
<a name="l00144"></a>00144       <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">wchar_t</span> *<a class="code" href="classcwidget_1_1widgets_1_1label.html" title="label widgets display some (possibly formatted) text statically.">label</a>()=0;
<a name="l00145"></a>00145       <span class="comment">// The label to display when this item is &quot;active&quot; in non-hierarchical mode.</span>
<a name="l00146"></a>00146 
<a name="l00147"></a>00147       <span class="keywordtype">int</span> get_depth() {<span class="keywordflow">return</span> depth;}
<a name="l00148"></a>00148       <span class="keywordtype">bool</span> get_selectable() {<span class="keywordflow">return</span> selectable;}
<a name="l00149"></a>00149 
<a name="l00150"></a>00150       <span class="keyword">virtual</span> <a class="code" href="classcwidget_1_1style.html" title="A &quot;style&quot; is a setting to be applied to a display element (widget, text, etc).">style</a> get_normal_style() {<span class="keywordflow">return</span> <a class="code" href="classcwidget_1_1style.html" title="A &quot;style&quot; is a setting to be applied to a display element (widget, text, etc).">style</a>();}
<a name="l00151"></a>00151       <span class="keyword">virtual</span> <a class="code" href="classcwidget_1_1style.html" title="A &quot;style&quot; is a setting to be applied to a display element (widget, text, etc).">style</a> get_highlight_style() {<span class="keywordflow">return</span> get_normal_style()+<a class="code" href="namespacecwidget.html#a29e7c989ed81ceffdae0b85d2e571920">style_attrs_flip</a>(A_REVERSE);}
<a name="l00152"></a>00152 
<a name="l00153"></a>00153       <span class="keyword">virtual</span> <span class="keywordtype">void</span> sort(<a class="code" href="classcwidget_1_1widgets_1_1sortpolicy.html">sortpolicy</a> &amp;sort_method) {}
<a name="l00154"></a>00154       <span class="comment">// Sorts an item&#39;s subtree using the given method.</span>
<a name="l00155"></a>00155 
<a name="l00156"></a>00156       <span class="keyword">virtual</span> <span class="keywordtype">void</span> sort() {}
<a name="l00157"></a>00157       <span class="comment">// Sorts an item&#39;s subtree (NOP for most items) -- provided to make it easy</span>
<a name="l00158"></a>00158       <span class="comment">// to recursively sort the list.</span>
<a name="l00159"></a>00159 
<a name="l00169"></a>00169 
<a name="l00171"></a><a class="code" href="classcwidget_1_1widgets_1_1treeitem.html#a4f2959cba2ed114eabe17dd0aa75a093">00171</a>       sigc::signal1&lt;void, bool&gt; <a class="code" href="classcwidget_1_1widgets_1_1treeitem.html#a4f2959cba2ed114eabe17dd0aa75a093" title="A signal emitted when the tree-item is highlighted or unhighlighted.">highlighted_changed</a>;
<a name="l00172"></a>00172 
<a name="l00174"></a>00174 
<a name="l00175"></a>00175       <span class="keyword">virtual</span> <span class="keywordtype">bool</span> dispatch_key(<span class="keyword">const</span> <a class="code" href="structcwidget_1_1config_1_1key.html" title="Represents a keystroke as seen by curses.">config::key</a> &amp;k, <a class="code" href="classcwidget_1_1widgets_1_1tree.html">tree</a> *owner) {<span class="keywordflow">return</span> <span class="keyword">false</span>;}
<a name="l00176"></a>00176       <span class="comment">// Called when a key is pressed while the item is highlighted.  The return</span>
<a name="l00177"></a>00177       <span class="comment">// value indicates whether a redraw of the screen is needed.</span>
<a name="l00178"></a>00178       <span class="comment">// (not any more; now it indicates whether the item consumed the keystroke</span>
<a name="l00179"></a>00179       <span class="comment">//  -- this also triggers a screen repainting, but is a more useful semantic)</span>
<a name="l00180"></a>00180       <span class="keyword">virtual</span> <span class="keywordtype">void</span> dispatch_mouse(<span class="keywordtype">short</span> <span class="keywordtype">id</span>, <span class="keywordtype">int</span> x, mmask_t bstate, <a class="code" href="classcwidget_1_1widgets_1_1tree.html">tree</a> *owner)
<a name="l00181"></a>00181       {
<a name="l00182"></a>00182       }
<a name="l00183"></a>00183       <span class="comment">// Called when a mouse event occurs at the y location assigned to this</span>
<a name="l00184"></a>00184       <span class="comment">// item.</span>
<a name="l00185"></a>00185 
<a name="l00186"></a>00186       <span class="keyword">virtual</span> <a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">tree_levelref</a> *begin() {<span class="keywordflow">return</span> NULL;}
<a name="l00187"></a>00187       <span class="keyword">virtual</span> tree_levelref *end() {<span class="keywordflow">return</span> NULL;}
<a name="l00188"></a>00188       <span class="comment">// These can act like containers; these routines return a NEWLY ALLOCATED</span>
<a name="l00189"></a>00189       <span class="comment">// POINTER, though.</span>
<a name="l00190"></a>00190 
<a name="l00191"></a>00191       <span class="keyword">virtual</span> <span class="keywordtype">bool</span> has_visible_children() {<span class="keywordflow">return</span> <span class="keyword">false</span>;}
<a name="l00192"></a>00192       <span class="keyword">virtual</span> <span class="keywordtype">bool</span> has_children() {<span class="keywordflow">return</span> <span class="keyword">false</span>;}
<a name="l00193"></a>00193 
<a name="l00194"></a>00194       <span class="keyword">virtual</span> <span class="keywordtype">bool</span> matches(<span class="keyword">const</span> std::wstring &amp;s)<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">false</span>;}
<a name="l00195"></a>00195       <span class="comment">// Returns true if this item matches the given string.</span>
<a name="l00196"></a>00196 
<a name="l00197"></a>00197       <span class="comment">// More hackery: do what&#39;s needed to expand the children of this item.</span>
<a name="l00198"></a>00198       <span class="keyword">virtual</span> <span class="keywordtype">void</span> expand() {}
<a name="l00199"></a>00199       <span class="keyword">virtual</span> <span class="keywordtype">void</span> expand_all() {}
<a name="l00200"></a>00200       <span class="keyword">virtual</span> <span class="keywordtype">void</span> collapse_all() {}
<a name="l00201"></a>00201 
<a name="l00202"></a>00202       <span class="keyword">template</span>&lt;<span class="keyword">class</span> childtype, <span class="keyword">class</span> sorter&gt;
<a name="l00203"></a>00203       <span class="keyword">friend</span> <span class="keyword">class </span>subtree;
<a name="l00204"></a>00204 
<a name="l00205"></a>00205       <span class="keyword">virtual</span> ~treeitem() {}
<a name="l00206"></a>00206     };
<a name="l00207"></a>00207 
<a name="l00208"></a><a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">00208</a>     <span class="keyword">class </span><a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a>
<a name="l00209"></a>00209     {
<a name="l00210"></a>00210       <a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">tree_levelref</a> *curr;
<a name="l00211"></a>00211       <span class="keywordtype">bool</span> ignore_collapsed;
<a name="l00212"></a>00212 
<a name="l00213"></a>00213     <span class="keyword">public</span>:
<a name="l00214"></a>00214       <a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a>(<a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">tree_levelref</a> *_curr, <span class="keywordtype">bool</span> _ignore_collapsed=<span class="keyword">false</span>):curr(_curr),ignore_collapsed(_ignore_collapsed) {}
<a name="l00215"></a>00215       <a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a>(<span class="keyword">const</span> <a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a> &amp;x):curr(x.curr?x.curr-&gt;clone():NULL),ignore_collapsed(x.ignore_collapsed) {}
<a name="l00216"></a>00216       <a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a>(<span class="keyword">const</span> <a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a> &amp;x, <span class="keywordtype">bool</span> _ignore_collapsed):curr(x.curr?x.curr-&gt;clone():NULL),ignore_collapsed(_ignore_collapsed) {}
<a name="l00217"></a>00217 
<a name="l00218"></a>00218       <span class="keywordtype">bool</span> is_root() {<span class="keywordflow">return</span> curr-&gt;parent==NULL;}
<a name="l00219"></a>00219       <span class="comment">// Ugh, a really nasty hack.</span>
<a name="l00220"></a>00220       <a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a> get_up()
<a name="l00221"></a>00221       {
<a name="l00222"></a>00222         <span class="keywordflow">return</span> <a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a>(curr-&gt;parent-&gt;clone());
<a name="l00223"></a>00223       }
<a name="l00224"></a>00224 
<a name="l00225"></a>00225       <span class="keywordtype">void</span> expand()
<a name="l00226"></a>00226       {
<a name="l00227"></a>00227         <span class="keywordflow">if</span>(curr &amp;&amp; curr-&gt;get_item())
<a name="l00228"></a>00228           curr-&gt;get_item()-&gt;expand();
<a name="l00229"></a>00229       }
<a name="l00230"></a>00230 
<a name="l00231"></a>00231       <a class="code" href="classcwidget_1_1widgets_1_1treeitem.html">treeitem</a> &amp;operator*() {<span class="keywordflow">return</span> *curr-&gt;get_item();}
<a name="l00232"></a>00232       <span class="keyword">const</span> <a class="code" href="classcwidget_1_1widgets_1_1treeitem.html">treeitem</a> &amp;operator*()<span class="keyword"> const </span>{<span class="keywordflow">return</span> *curr-&gt;get_item();}
<a name="l00233"></a>00233       <a class="code" href="classcwidget_1_1widgets_1_1treeitem.html">treeitem</a> *operator-&gt;() {<span class="keywordflow">return</span> curr-&gt;get_item();}
<a name="l00234"></a>00234       <span class="keyword">const</span> <a class="code" href="classcwidget_1_1widgets_1_1treeitem.html">treeitem</a> *operator-&gt;()<span class="keyword"> const </span>{<span class="keywordflow">return</span> curr-&gt;get_item();}
<a name="l00235"></a>00235 
<a name="l00236"></a>00236       <span class="keywordtype">bool</span> operator==(<span class="keyword">const</span> <a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a> &amp;x)
<a name="l00237"></a>00237       {
<a name="l00238"></a>00238         <span class="keywordflow">if</span>(!curr)
<a name="l00239"></a>00239           <span class="keywordflow">return</span> !x.curr;
<a name="l00240"></a>00240         <span class="keywordflow">else</span> <span class="keywordflow">if</span>(!x.curr)
<a name="l00241"></a>00241           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00242"></a>00242         <span class="keywordflow">else</span> <span class="keywordflow">if</span>(curr-&gt;is_end())
<a name="l00243"></a>00243           <span class="keywordflow">return</span> x.curr-&gt;is_end() &amp;&amp; curr-&gt;parent == x.curr-&gt;parent;
<a name="l00244"></a>00244         <span class="keywordflow">else</span> <span class="keywordflow">if</span>(x.curr-&gt;is_end())
<a name="l00245"></a>00245           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00246"></a>00246         <span class="keywordflow">else</span>
<a name="l00247"></a>00247           <span class="keywordflow">return</span> curr-&gt;get_item()==x.curr-&gt;get_item();
<a name="l00248"></a>00248       }
<a name="l00249"></a>00249       <span class="keywordtype">bool</span> operator!=(<span class="keyword">const</span> <a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a> &amp;x)
<a name="l00250"></a>00250       {<span class="keywordflow">return</span> !(*<span class="keyword">this</span>==x);}
<a name="l00251"></a>00251 
<a name="l00252"></a>00252       <a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a> &amp;operator=(<span class="keyword">const</span> <a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a> &amp;x)
<a name="l00253"></a>00253       {
<a name="l00254"></a>00254         <span class="keywordflow">while</span>(curr)
<a name="l00255"></a>00255           {
<a name="l00256"></a>00256             <a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">tree_levelref</a> *old=curr;
<a name="l00257"></a>00257             curr=curr-&gt;parent;
<a name="l00258"></a>00258             <span class="keyword">delete</span> old;
<a name="l00259"></a>00259           }
<a name="l00260"></a>00260 
<a name="l00261"></a>00261         curr=x.curr?x.curr-&gt;clone():NULL;
<a name="l00262"></a>00262 
<a name="l00263"></a>00263         <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00264"></a>00264       }
<a name="l00265"></a>00265 
<a name="l00266"></a>00266       <a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a> &amp;operator++()
<a name="l00267"></a>00267       {
<a name="l00268"></a>00268         <span class="keywordflow">if</span>(curr-&gt;get_item() &amp;&amp;
<a name="l00269"></a>00269            (ignore_collapsed?curr-&gt;get_item()-&gt;has_children():curr-&gt;get_item()-&gt;has_visible_children()))
<a name="l00270"></a>00270           {
<a name="l00271"></a>00271             <a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">tree_levelref</a> *newref=curr-&gt;get_item()-&gt;begin();
<a name="l00272"></a>00272             newref-&gt;parent=curr;
<a name="l00273"></a>00273             curr=newref;
<a name="l00274"></a>00274           }
<a name="l00275"></a>00275         <span class="keywordflow">else</span>
<a name="l00276"></a>00276           {
<a name="l00277"></a>00277             curr-&gt;advance_next();
<a name="l00278"></a>00278 
<a name="l00279"></a>00279             <span class="keywordflow">while</span>(curr-&gt;is_end() &amp;&amp; curr-&gt;parent)
<a name="l00280"></a>00280               {
<a name="l00281"></a>00281                 <a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">tree_levelref</a> *old=curr;
<a name="l00282"></a>00282                 curr=curr-&gt;parent;
<a name="l00283"></a>00283                 curr-&gt;advance_next();
<a name="l00284"></a>00284                 <span class="keyword">delete</span> old;
<a name="l00285"></a>00285               }
<a name="l00286"></a>00286           }
<a name="l00287"></a>00287 
<a name="l00288"></a>00288         <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00289"></a>00289       }
<a name="l00290"></a>00290       <a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a> operator++(<span class="keywordtype">int</span>)
<a name="l00291"></a>00291       {
<a name="l00292"></a>00292         <a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a> oldval(curr?curr-&gt;clone():NULL);
<a name="l00293"></a>00293 
<a name="l00294"></a>00294         ++*<span class="keyword">this</span>;
<a name="l00295"></a>00295 
<a name="l00296"></a>00296         <span class="keywordflow">return</span> oldval;
<a name="l00297"></a>00297       }
<a name="l00298"></a>00298 
<a name="l00299"></a>00299       <a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a> &amp;operator--()
<a name="l00300"></a>00300       {
<a name="l00301"></a>00301         <span class="keywordflow">if</span>(curr-&gt;is_begin())
<a name="l00302"></a>00302           {
<a name="l00303"></a>00303             <span class="keywordflow">if</span>(curr-&gt;parent)
<a name="l00304"></a>00304               {
<a name="l00305"></a>00305                 <a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">tree_levelref</a> *old=curr;
<a name="l00306"></a>00306                 curr=curr-&gt;parent;
<a name="l00307"></a>00307                 <span class="keyword">delete</span> old;
<a name="l00308"></a>00308               }
<a name="l00309"></a>00309           }
<a name="l00310"></a>00310         <span class="keywordflow">else</span>
<a name="l00311"></a>00311           {
<a name="l00312"></a>00312             curr-&gt;return_prev();
<a name="l00313"></a>00313             <span class="keywordflow">while</span>(curr-&gt;get_item() &amp;&amp;
<a name="l00314"></a>00314                   (ignore_collapsed?curr-&gt;get_item()-&gt;has_children():curr-&gt;get_item()-&gt;has_visible_children()))
<a name="l00315"></a>00315               {
<a name="l00316"></a>00316                 <a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">tree_levelref</a> *newref=curr-&gt;get_item()-&gt;end();
<a name="l00317"></a>00317 
<a name="l00318"></a>00318                 newref-&gt;parent=curr;
<a name="l00319"></a>00319                 newref-&gt;return_prev();
<a name="l00320"></a>00320                 curr=newref;
<a name="l00321"></a>00321               }
<a name="l00322"></a>00322           }
<a name="l00323"></a>00323         <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00324"></a>00324       }
<a name="l00325"></a>00325 
<a name="l00326"></a>00326       <a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a> operator--(<span class="keywordtype">int</span>)
<a name="l00327"></a>00327       {
<a name="l00328"></a>00328         <a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a> oldval(curr?curr-&gt;clone():NULL);
<a name="l00329"></a>00329 
<a name="l00330"></a>00330         --*<span class="keyword">this</span>;
<a name="l00331"></a>00331 
<a name="l00332"></a>00332         <span class="keywordflow">return</span> oldval;
<a name="l00333"></a>00333       }
<a name="l00334"></a>00334 
<a name="l00335"></a>00335       <span class="keywordtype">void</span> move_forward_level()
<a name="l00336"></a>00336       {
<a name="l00337"></a>00337         <span class="keywordflow">if</span>(!curr-&gt;is_end())
<a name="l00338"></a>00338           {
<a name="l00339"></a>00339             <a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">tree_levelref</a> *old=curr-&gt;clone();
<a name="l00340"></a>00340             curr-&gt;advance_next();
<a name="l00341"></a>00341 
<a name="l00342"></a>00342             <span class="keywordflow">if</span>(curr-&gt;is_end())
<a name="l00343"></a>00343               {
<a name="l00344"></a>00344                 <span class="keyword">delete</span> curr;
<a name="l00345"></a>00345                 curr=old;
<a name="l00346"></a>00346               }
<a name="l00347"></a>00347             <span class="keywordflow">else</span>
<a name="l00348"></a>00348               <span class="keyword">delete</span> old;
<a name="l00349"></a>00349           }
<a name="l00350"></a>00350       }
<a name="l00351"></a>00351 
<a name="l00352"></a>00352       <span class="keywordtype">void</span> move_backward_level()
<a name="l00353"></a>00353       {
<a name="l00354"></a>00354         <span class="keywordflow">if</span>(!curr-&gt;is_begin())
<a name="l00355"></a>00355           curr-&gt;return_prev();
<a name="l00356"></a>00356       }
<a name="l00357"></a>00357 
<a name="l00358"></a>00358       ~<a class="code" href="classcwidget_1_1widgets_1_1treeiterator.html">treeiterator</a>()
<a name="l00359"></a>00359       {
<a name="l00360"></a>00360         <span class="keywordflow">while</span>(curr)
<a name="l00361"></a>00361           {
<a name="l00362"></a>00362             <a class="code" href="classcwidget_1_1widgets_1_1tree__levelref.html">tree_levelref</a> *old=curr;
<a name="l00363"></a>00363             curr=curr-&gt;parent;
<a name="l00364"></a>00364             <span class="keyword">delete</span> old;
<a name="l00365"></a>00365           }
<a name="l00366"></a>00366       }
<a name="l00367"></a>00367     };
<a name="l00368"></a>00368 
<a name="l00369"></a>00369     <span class="comment">// A generic sorter.</span>
<a name="l00370"></a>00370     <span class="comment">//</span>
<a name="l00371"></a>00371     <span class="comment">// Making operator() virtual is a bit icky.</span>
<a name="l00372"></a><a class="code" href="classcwidget_1_1widgets_1_1sortpolicy.html">00372</a>     <span class="keyword">class </span><a class="code" href="classcwidget_1_1widgets_1_1sortpolicy.html">sortpolicy</a>
<a name="l00373"></a>00373     {
<a name="l00374"></a>00374     <span class="keyword">public</span>:
<a name="l00375"></a>00375       <a class="code" href="classcwidget_1_1widgets_1_1sortpolicy.html">sortpolicy</a>() {}
<a name="l00376"></a>00376 
<a name="l00377"></a>00377       <span class="keyword">virtual</span> <span class="keywordtype">bool</span> operator()(<a class="code" href="classcwidget_1_1widgets_1_1treeitem.html">treeitem</a> *item1,
<a name="l00378"></a>00378                               <a class="code" href="classcwidget_1_1widgets_1_1treeitem.html">treeitem</a> *item2)=0;
<a name="l00379"></a>00379 
<a name="l00380"></a>00380       <span class="keyword">virtual</span> ~<a class="code" href="classcwidget_1_1widgets_1_1sortpolicy.html">sortpolicy</a>() {}
<a name="l00381"></a>00381     };
<a name="l00382"></a>00382 
<a name="l00383"></a>00383     <span class="comment">// ack!  How dare this be templated?</span>
<a name="l00384"></a>00384     <span class="comment">//template&lt;class childtype&gt;</span>
<a name="l00385"></a><a class="code" href="classcwidget_1_1widgets_1_1tag__sort__policy.html">00385</a>     <span class="keyword">class </span><a class="code" href="classcwidget_1_1widgets_1_1tag__sort__policy.html">tag_sort_policy</a>:<span class="keyword">public</span> <a class="code" href="classcwidget_1_1widgets_1_1sortpolicy.html">sortpolicy</a>
<a name="l00386"></a>00386     {
<a name="l00387"></a>00387     <span class="keyword">public</span>:
<a name="l00388"></a>00388       <span class="keywordtype">bool</span> operator()(<a class="code" href="classcwidget_1_1widgets_1_1treeitem.html">treeitem</a> *item1, <a class="code" href="classcwidget_1_1widgets_1_1treeitem.html">treeitem</a> *item2)
<a name="l00389"></a>00389       {
<a name="l00390"></a>00390         <span class="keywordflow">return</span> (wcscmp(item1-&gt;tag(), item2-&gt;tag())&lt;0);
<a name="l00391"></a>00391       }
<a name="l00392"></a>00392     };
<a name="l00393"></a>00393 
<a name="l00394"></a>00394     <span class="comment">// Hack? hmm..</span>
<a name="l00395"></a>00395     <span class="comment">//</span>
<a name="l00396"></a>00396     <span class="comment">// Here&#39;s the situation: STL sort passes the sort method by value, probably</span>
<a name="l00397"></a>00397     <span class="comment">// to keep people from being horrendously inefficient like I&#39;m about to.  But</span>
<a name="l00398"></a>00398     <span class="comment">// we can get around that with an inline wrapper:</span>
<a name="l00399"></a><a class="code" href="classcwidget_1_1widgets_1_1sortpolicy__wrapper.html">00399</a>     <span class="keyword">class </span><a class="code" href="classcwidget_1_1widgets_1_1sortpolicy__wrapper.html">sortpolicy_wrapper</a>
<a name="l00400"></a>00400     {
<a name="l00401"></a>00401       <a class="code" href="classcwidget_1_1widgets_1_1sortpolicy.html">sortpolicy</a> &amp;real_policy;
<a name="l00402"></a>00402     <span class="keyword">public</span>:
<a name="l00403"></a>00403       <a class="code" href="classcwidget_1_1widgets_1_1sortpolicy__wrapper.html">sortpolicy_wrapper</a>(<a class="code" href="classcwidget_1_1widgets_1_1sortpolicy.html">sortpolicy</a> &amp;_real_policy):real_policy(_real_policy)
<a name="l00404"></a>00404       {
<a name="l00405"></a>00405       }
<a name="l00406"></a>00406 
<a name="l00407"></a>00407       <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator()(<a class="code" href="classcwidget_1_1widgets_1_1treeitem.html">treeitem</a> *item1,
<a name="l00408"></a>00408                              <a class="code" href="classcwidget_1_1widgets_1_1treeitem.html">treeitem</a> *item2)<span class="keyword"> const</span>
<a name="l00409"></a>00409 <span class="keyword">      </span>{
<a name="l00410"></a>00410         <span class="keywordflow">return</span> real_policy(item1, item2);
<a name="l00411"></a>00411       }
<a name="l00412"></a>00412     };
<a name="l00413"></a>00413   }
<a name="l00414"></a>00414 }
<a name="l00415"></a>00415 
<a name="l00416"></a>00416 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Fri Jun 17 2011 07:49:38 for cwidget by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>