File: DemoTreeList_8C_source.html

package info (click to toggle)
witty 3.2.1-2%2Bdeb7u1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 70,436 kB
  • sloc: cpp: 117,095; ansic: 77,999; xml: 7,564; sh: 1,037; perl: 208; makefile: 144; java: 86; sql: 14
file content (251 lines) | stat: -rw-r--r-- 31,449 bytes parent folder | download
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
<!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>Wt examples: /home/koen/project/wt/public-git/wt/examples/treelist/DemoTreeList.C Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />



</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Wt examples
   &#160;<span id="projectnumber">3.2.1</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</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>
    </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 class="header">
  <div class="headertitle">
<div class="title">/home/koen/project/wt/public-git/wt/examples/treelist/DemoTreeList.C</div>  </div>
</div>
<div class="contents">
<a href="DemoTreeList_8C.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * See the LICENSE file for terms of use.</span>
<a name="l00005"></a>00005 <span class="comment"> */</span>
<a name="l00006"></a>00006 <span class="preprocessor">#include &lt;boost/lexical_cast.hpp&gt;</span>
<a name="l00007"></a>00007 
<a name="l00008"></a>00008 <span class="preprocessor">#include &lt;Wt/WApplication&gt;</span>
<a name="l00009"></a>00009 <span class="preprocessor">#include &lt;Wt/WText&gt;</span>
<a name="l00010"></a>00010 <span class="preprocessor">#include &lt;Wt/WImage&gt;</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &lt;Wt/WPushButton&gt;</span>
<a name="l00012"></a>00012 
<a name="l00013"></a>00013 <span class="preprocessor">#include &quot;<a class="code" href="DemoTreeList_8h.html">DemoTreeList.h</a>&quot;</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include &quot;<a class="code" href="TreeNode_8h.html">TreeNode.h</a>&quot;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include &quot;<a class="code" href="IconPair_8h.html">IconPair.h</a>&quot;</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="keyword">using namespace </span>Wt;
<a name="l00018"></a>00018 <span class="keyword">using</span> std::rand;
<a name="l00019"></a>00019 
<a name="l00020"></a><a class="code" href="classDemoTreeList.html#a5b07059aecf22b392e2d055cf451b0c7">00020</a> <a class="code" href="classDemoTreeList.html#a5b07059aecf22b392e2d055cf451b0c7" title="Create a DemoTreeList.">DemoTreeList::DemoTreeList</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html">WContainerWidget</a> *parent)
<a name="l00021"></a>00021   : <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html">WContainerWidget</a>(parent),
<a name="l00022"></a>00022     testCount_(0)
<a name="l00023"></a>00023 {
<a name="l00024"></a>00024   <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html#a2cfe66d9b62940f889e99538a9f478d2">addWidget</a>
<a name="l00025"></a>00025     (<span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html">WText</a>(<span class="stringliteral">&quot;&lt;h2&gt;Wt Tree List example&lt;/h2&gt;&quot;</span>
<a name="l00026"></a>00026                <span class="stringliteral">&quot;&lt;p&gt;This is a simple demo of a treelist, implemented using&quot;</span>
<a name="l00027"></a>00027                <span class="stringliteral">&quot; &lt;a href=&#39;http://witty.sourceforge.net/&#39;&gt;Wt&lt;/a&gt;.&lt;/p&gt;&quot;</span>
<a name="l00028"></a>00028                <span class="stringliteral">&quot;&lt;p&gt;The leafs of the tree contain the source code of the &quot;</span>
<a name="l00029"></a>00029                <span class="stringliteral">&quot;tree-list in the classes &lt;b&gt;TreeNode&lt;/b&gt; and &quot;</span>
<a name="l00030"></a>00030                <span class="stringliteral">&quot;&lt;b&gt;IconPair&lt;/b&gt;, as well as the implementation of this &quot;</span>
<a name="l00031"></a>00031                <span class="stringliteral">&quot;demo itself in the class &lt;b&gt;DemoTreeList&lt;/b&gt;.&lt;/p&gt;&quot;</span>));
<a name="l00032"></a>00032 
<a name="l00033"></a>00033   <a class="code" href="classDemoTreeList.html#a5b3471e575b6bf0dfa9e19cc41510d7d">tree_</a> = <a class="code" href="classDemoTreeList.html#ac1ddf9da261c37e9255eaa1fb972d6e2" title="Create a &quot;map&quot; node, and insert in the given parent.">makeTreeMap</a>(<span class="stringliteral">&quot;Examples&quot;</span>, 0);
<a name="l00034"></a>00034   <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html#a2cfe66d9b62940f889e99538a9f478d2">addWidget</a>(<a class="code" href="classDemoTreeList.html#a5b3471e575b6bf0dfa9e19cc41510d7d">tree_</a>);
<a name="l00035"></a>00035 
<a name="l00036"></a>00036   <a class="code" href="classTreeNode.html" title="Example implementation of a single tree list node.">TreeNode</a> *treelist = <a class="code" href="classDemoTreeList.html#ac1ddf9da261c37e9255eaa1fb972d6e2" title="Create a &quot;map&quot; node, and insert in the given parent.">makeTreeMap</a>(<span class="stringliteral">&quot;Tree List&quot;</span>, <a class="code" href="classDemoTreeList.html#a5b3471e575b6bf0dfa9e19cc41510d7d">tree_</a>);
<a name="l00037"></a>00037   <a class="code" href="classTreeNode.html" title="Example implementation of a single tree list node.">TreeNode</a> *wstateicon = <a class="code" href="classDemoTreeList.html#ac1ddf9da261c37e9255eaa1fb972d6e2" title="Create a &quot;map&quot; node, and insert in the given parent.">makeTreeMap</a>(<span class="stringliteral">&quot;class IconPair&quot;</span>, treelist);
<a name="l00038"></a>00038   <a class="code" href="classDemoTreeList.html#aef0149499570b8b89cbabe75879e30b6" title="Create a &quot;file&quot; node, and insert in the given parent.">makeTreeFile</a>(<span class="stringliteral">&quot;&lt;a href=\&quot;IconPair.h\&quot;&gt;IconPair.h&lt;/a&gt;&quot;</span>, wstateicon);
<a name="l00039"></a>00039   <a class="code" href="classDemoTreeList.html#aef0149499570b8b89cbabe75879e30b6" title="Create a &quot;file&quot; node, and insert in the given parent.">makeTreeFile</a>(<span class="stringliteral">&quot;&lt;a href=\&quot;IconPair.C\&quot;&gt;IconPair.C&lt;/a&gt;&quot;</span>, wstateicon);
<a name="l00040"></a>00040   <a class="code" href="classTreeNode.html" title="Example implementation of a single tree list node.">TreeNode</a> *wtreenode = <a class="code" href="classDemoTreeList.html#ac1ddf9da261c37e9255eaa1fb972d6e2" title="Create a &quot;map&quot; node, and insert in the given parent.">makeTreeMap</a>(<span class="stringliteral">&quot;class TreeNode&quot;</span>, treelist);
<a name="l00041"></a>00041   <a class="code" href="classDemoTreeList.html#aef0149499570b8b89cbabe75879e30b6" title="Create a &quot;file&quot; node, and insert in the given parent.">makeTreeFile</a>(<span class="stringliteral">&quot;&lt;a href=\&quot;TreeNode.h\&quot;&gt;TreeNode.h&lt;/a&gt;&quot;</span>, wtreenode);
<a name="l00042"></a>00042   <a class="code" href="classDemoTreeList.html#aef0149499570b8b89cbabe75879e30b6" title="Create a &quot;file&quot; node, and insert in the given parent.">makeTreeFile</a>(<span class="stringliteral">&quot;&lt;a href=\&quot;TreeNode.C\&quot;&gt;TreeNode.C&lt;/a&gt;&quot;</span>, wtreenode);
<a name="l00043"></a>00043   <a class="code" href="classTreeNode.html" title="Example implementation of a single tree list node.">TreeNode</a> *demotreelist = <a class="code" href="classDemoTreeList.html#ac1ddf9da261c37e9255eaa1fb972d6e2" title="Create a &quot;map&quot; node, and insert in the given parent.">makeTreeMap</a>(<span class="stringliteral">&quot;class DemoTreeList&quot;</span>, treelist);
<a name="l00044"></a>00044   <a class="code" href="classDemoTreeList.html#aef0149499570b8b89cbabe75879e30b6" title="Create a &quot;file&quot; node, and insert in the given parent.">makeTreeFile</a>(<span class="stringliteral">&quot;&lt;a href=\&quot;DemoTreeList.h\&quot;&gt;DemoTreeList.h&lt;/a&gt;&quot;</span>, demotreelist);
<a name="l00045"></a>00045   <a class="code" href="classDemoTreeList.html#aef0149499570b8b89cbabe75879e30b6" title="Create a &quot;file&quot; node, and insert in the given parent.">makeTreeFile</a>(<span class="stringliteral">&quot;&lt;a href=\&quot;DemoTreeList.C\&quot;&gt;DemoTreeList.C&lt;/a&gt;&quot;</span>, demotreelist);
<a name="l00046"></a>00046 
<a name="l00047"></a>00047   <a class="code" href="classDemoTreeList.html#af38b14ae38847b7f8c47d56fe5e89b34">testMap_</a> = <a class="code" href="classDemoTreeList.html#ac1ddf9da261c37e9255eaa1fb972d6e2" title="Create a &quot;map&quot; node, and insert in the given parent.">makeTreeMap</a>(<span class="stringliteral">&quot;Test map&quot;</span>, <a class="code" href="classDemoTreeList.html#a5b3471e575b6bf0dfa9e19cc41510d7d">tree_</a>);
<a name="l00048"></a>00048 
<a name="l00049"></a>00049   <span class="comment">/*</span>
<a name="l00050"></a>00050 <span class="comment">   * Buttons to dynamically demonstrate changing the tree contents.</span>
<a name="l00051"></a>00051 <span class="comment">   */</span>
<a name="l00052"></a>00052   <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html#a2cfe66d9b62940f889e99538a9f478d2">addWidget</a>
<a name="l00053"></a>00053     (<span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html">WText</a>(<span class="stringliteral">&quot;&lt;p&gt;Use the following buttons to change the tree &quot;</span>
<a name="l00054"></a>00054                <span class="stringliteral">&quot;contents:&lt;/p&gt;&quot;</span>));
<a name="l00055"></a>00055 
<a name="l00056"></a>00056   <a class="code" href="classDemoTreeList.html#a4f796ef14583c6b7fc0aec13508d83ee">addMapButton_</a>
<a name="l00057"></a>00057     = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WPushButton.html">WPushButton</a>(<span class="stringliteral">&quot;Add map&quot;</span>, <span class="keyword">this</span>);
<a name="l00058"></a>00058   <a class="code" href="classDemoTreeList.html#a4f796ef14583c6b7fc0aec13508d83ee">addMapButton_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WInteractWidget.html#ae11e050cce0d4a8f742afa3ef92bfe8c">clicked</a>().connect(<span class="keyword">this</span>, &amp;<a class="code" href="classDemoTreeList.html#a59023d58bc5bb025d463935ed6f57b6b" title="Add a map.">DemoTreeList::addMap</a>);
<a name="l00059"></a>00059 
<a name="l00060"></a>00060   <a class="code" href="classDemoTreeList.html#aa77bb14d293f3efde79a47d3b4a5214e">removeMapButton_</a>
<a name="l00061"></a>00061     = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WPushButton.html">WPushButton</a>(<span class="stringliteral">&quot;Remove map&quot;</span>, <span class="keyword">this</span>);
<a name="l00062"></a>00062   <a class="code" href="classDemoTreeList.html#aa77bb14d293f3efde79a47d3b4a5214e">removeMapButton_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WInteractWidget.html#ae11e050cce0d4a8f742afa3ef92bfe8c">clicked</a>().connect(<span class="keyword">this</span>, &amp;<a class="code" href="classDemoTreeList.html#a32e8d75762ff66fcab135cd55c6bcca6" title="Remove a map.">DemoTreeList::removeMap</a>);
<a name="l00063"></a>00063   <a class="code" href="classDemoTreeList.html#aa77bb14d293f3efde79a47d3b4a5214e">removeMapButton_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html#a5f68ea0ab29adfb8e559153fca281e03">disable</a>();
<a name="l00064"></a>00064 
<a name="l00065"></a>00065   <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html#a2cfe66d9b62940f889e99538a9f478d2">addWidget</a>
<a name="l00066"></a>00066     (<span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html">WText</a>(<span class="stringliteral">&quot;&lt;p&gt;Remarks:&quot;</span>
<a name="l00067"></a>00067                <span class="stringliteral">&quot;&lt;ul&gt;&quot;</span>
<a name="l00068"></a>00068                <span class="stringliteral">&quot;&lt;li&gt;&lt;p&gt;This is not the instantiation of a pre-defined &quot;</span>
<a name="l00069"></a>00069                <span class="stringliteral">&quot;tree list component, but the full implementation of such &quot;</span>
<a name="l00070"></a>00070                <span class="stringliteral">&quot;a component, in about 350 lines of C++ code !&lt;/p&gt; &quot;</span>
<a name="l00071"></a>00071                <span class="stringliteral">&quot;&lt;p&gt;In comparison, the &lt;a href=&#39;http://myfaces.apache.org&#39;&gt; &quot;</span>
<a name="l00072"></a>00072                <span class="stringliteral">&quot;Apache MyFaces&lt;/a&gt; JSF implementation of tree2, with similar &quot;</span>
<a name="l00073"></a>00073                <span class="stringliteral">&quot;functionality, uses about 2400 lines of Java, and 140 lines &quot;</span>
<a name="l00074"></a>00074                <span class="stringliteral">&quot;of JavaScript code.&lt;/p&gt;&lt;/li&gt;&quot;</span>
<a name="l00075"></a>00075                <span class="stringliteral">&quot;&lt;li&gt;&lt;p&gt;Once loaded, the tree list does not require any &quot;</span>
<a name="l00076"></a>00076                <span class="stringliteral">&quot;interaction with the server for handling the click events on &quot;</span>
<a name="l00077"></a>00077                <span class="stringliteral">&quot;the &lt;img src=&#39;icons/nav-plus-line-middle.gif&#39; /&gt; and &quot;</span>
<a name="l00078"></a>00078                <span class="stringliteral">&quot;&lt;img src=&#39;icons/nav-minus-line-middle.gif&#39; /&gt; icons, &quot;</span>
<a name="l00079"></a>00079                <span class="stringliteral">&quot;because these events have been connected to slots using &quot;</span>
<a name="l00080"></a>00080                <span class="stringliteral">&quot;STATIC connections. Such connections are converted to the &quot;</span>
<a name="l00081"></a>00081                <span class="stringliteral">&quot;appropriate JavaScript code that is inserted into the page. &quot;</span>
<a name="l00082"></a>00082                <span class="stringliteral">&quot;Still, the events are signaled to the server to update the &quot;</span>
<a name="l00083"></a>00083                <span class="stringliteral">&quot;application state.&lt;/p&gt;&lt;/li&gt;&quot;</span>
<a name="l00084"></a>00084                <span class="stringliteral">&quot;&lt;li&gt;&lt;p&gt;In contrast, the buttons for manipulating the tree &quot;</span>
<a name="l00085"></a>00085                <span class="stringliteral">&quot;contents use DYNAMIC connections, and thus the update &quot;</span>
<a name="l00086"></a>00086                <span class="stringliteral">&quot;is computed at server-side, and communicated back to the &quot;</span>
<a name="l00087"></a>00087                <span class="stringliteral">&quot;browser (by default using AJAX).&lt;/p&gt;&lt;/li&gt;&quot;</span>
<a name="l00088"></a>00088                <span class="stringliteral">&quot;&lt;li&gt;&lt;p&gt;When loading a page, only visible widgets (that are not &quot;</span>
<a name="l00089"></a>00089                <span class="stringliteral">&quot;&lt;b&gt;setHidden(true)&lt;/b&gt;) are transmitted. &quot;</span>
<a name="l00090"></a>00090                <span class="stringliteral">&quot;The remaining widgets are loaded in the background after &quot;</span>
<a name="l00091"></a>00091                <span class="stringliteral">&quot;rendering the page. &quot;</span>
<a name="l00092"></a>00092                <span class="stringliteral">&quot;As a result the application is loaded as fast as possible.&lt;/p&gt;&quot;</span>
<a name="l00093"></a>00093                <span class="stringliteral">&quot;&lt;/li&gt;&quot;</span>
<a name="l00094"></a>00094                <span class="stringliteral">&quot;&lt;li&gt;&lt;p&gt;The browser reload button is supported and behaves as &quot;</span>
<a name="l00095"></a>00095                <span class="stringliteral">&quot;expected: the page is reloaded from the server. Again, &quot;</span>
<a name="l00096"></a>00096                <span class="stringliteral">&quot;only visible widgets are transmitted immediately.&lt;/p&gt; &quot;</span>
<a name="l00097"></a>00097                <span class="stringliteral">&quot;&lt;p&gt;(For the curious, this is the way to see the actual &quot;</span>
<a name="l00098"></a>00098                <span class="stringliteral">&quot;HTML/JavaScript code !)&lt;/p&gt;&lt;/li&gt;&quot;</span>
<a name="l00099"></a>00099                <span class="stringliteral">&quot;&lt;/ul&gt;&lt;/p&gt;&quot;</span>));
<a name="l00100"></a>00100 }
<a name="l00101"></a>00101 
<a name="l00102"></a><a class="code" href="classDemoTreeList.html#a59023d58bc5bb025d463935ed6f57b6b">00102</a> <span class="keywordtype">void</span> <a class="code" href="classDemoTreeList.html#a59023d58bc5bb025d463935ed6f57b6b" title="Add a map.">DemoTreeList::addMap</a>()
<a name="l00103"></a>00103 {
<a name="l00104"></a>00104   <a class="code" href="classTreeNode.html" title="Example implementation of a single tree list node.">TreeNode</a> *node
<a name="l00105"></a>00105     = <a class="code" href="classDemoTreeList.html#ac1ddf9da261c37e9255eaa1fb972d6e2" title="Create a &quot;map&quot; node, and insert in the given parent.">makeTreeMap</a>(<span class="stringliteral">&quot;Map &quot;</span> + boost::lexical_cast&lt;std::string&gt;(++<a class="code" href="classDemoTreeList.html#a297ac3606b05e9185efc802cf0ebbadd">testCount_</a>),
<a name="l00106"></a>00106                   <a class="code" href="classDemoTreeList.html#af38b14ae38847b7f8c47d56fe5e89b34">testMap_</a>);
<a name="l00107"></a>00107   <a class="code" href="classDemoTreeList.html#aef0149499570b8b89cbabe75879e30b6" title="Create a &quot;file&quot; node, and insert in the given parent.">makeTreeFile</a>(<span class="stringliteral">&quot;File &quot;</span> + boost::lexical_cast&lt;std::string&gt;(<a class="code" href="classDemoTreeList.html#a297ac3606b05e9185efc802cf0ebbadd">testCount_</a>),
<a name="l00108"></a>00108                node);
<a name="l00109"></a>00109 
<a name="l00110"></a>00110   <a class="code" href="classDemoTreeList.html#aa77bb14d293f3efde79a47d3b4a5214e">removeMapButton_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html#ae6935d8baca9d37dd1d080b4383da87c">enable</a>();
<a name="l00111"></a>00111 }
<a name="l00112"></a>00112 
<a name="l00113"></a><a class="code" href="classDemoTreeList.html#a32e8d75762ff66fcab135cd55c6bcca6">00113</a> <span class="keywordtype">void</span> <a class="code" href="classDemoTreeList.html#a32e8d75762ff66fcab135cd55c6bcca6" title="Remove a map.">DemoTreeList::removeMap</a>()
<a name="l00114"></a>00114 {
<a name="l00115"></a>00115   <span class="keywordtype">int</span> numMaps = <a class="code" href="classDemoTreeList.html#af38b14ae38847b7f8c47d56fe5e89b34">testMap_</a>-&gt;<a class="code" href="classTreeNode.html#a73afc6b5f7587505a5c1ba1cf2a51341" title="Returns the list of children.">childNodes</a>().size();
<a name="l00116"></a>00116 
<a name="l00117"></a>00117   <span class="keywordflow">if</span> (numMaps &gt; 0) {
<a name="l00118"></a>00118     <span class="keywordtype">int</span> c = rand() % numMaps;
<a name="l00119"></a>00119 
<a name="l00120"></a>00120     <a class="code" href="classTreeNode.html" title="Example implementation of a single tree list node.">TreeNode</a> *child = <a class="code" href="classDemoTreeList.html#af38b14ae38847b7f8c47d56fe5e89b34">testMap_</a>-&gt;<a class="code" href="classTreeNode.html#a73afc6b5f7587505a5c1ba1cf2a51341" title="Returns the list of children.">childNodes</a>()[c];
<a name="l00121"></a>00121     <a class="code" href="classDemoTreeList.html#af38b14ae38847b7f8c47d56fe5e89b34">testMap_</a>-&gt;<a class="code" href="classTreeNode.html#aa772a12f5220a2256247048a1edcc581" title="Removes a child node.">removeChildNode</a>(child);
<a name="l00122"></a>00122     <span class="keyword">delete</span> child;
<a name="l00123"></a>00123 
<a name="l00124"></a>00124     <span class="keywordflow">if</span> (numMaps == 1)
<a name="l00125"></a>00125       <a class="code" href="classDemoTreeList.html#aa77bb14d293f3efde79a47d3b4a5214e">removeMapButton_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html#a5f68ea0ab29adfb8e559153fca281e03">disable</a>();
<a name="l00126"></a>00126   }
<a name="l00127"></a>00127 }
<a name="l00128"></a>00128 
<a name="l00129"></a><a class="code" href="classDemoTreeList.html#ac1ddf9da261c37e9255eaa1fb972d6e2">00129</a> <a class="code" href="classTreeNode.html" title="Example implementation of a single tree list node.">TreeNode</a> *<a class="code" href="classDemoTreeList.html#ac1ddf9da261c37e9255eaa1fb972d6e2" title="Create a &quot;map&quot; node, and insert in the given parent.">DemoTreeList::makeTreeMap</a>(<span class="keyword">const</span> std::string name, <a class="code" href="classTreeNode.html" title="Example implementation of a single tree list node.">TreeNode</a> *parent)
<a name="l00130"></a>00130 {
<a name="l00131"></a>00131   <a class="code" href="classIconPair.html" title="An icon pair (identical to WIconPair)">IconPair</a> *labelIcon
<a name="l00132"></a>00132     = <span class="keyword">new</span> <a class="code" href="classIconPair.html" title="An icon pair (identical to WIconPair)">IconPair</a>(<span class="stringliteral">&quot;icons/yellow-folder-closed.png&quot;</span>,
<a name="l00133"></a>00133                    <span class="stringliteral">&quot;icons/yellow-folder-open.png&quot;</span>,
<a name="l00134"></a>00134                    <span class="keyword">false</span>);
<a name="l00135"></a>00135 
<a name="l00136"></a>00136   <a class="code" href="classTreeNode.html" title="Example implementation of a single tree list node.">TreeNode</a> *node = <span class="keyword">new</span> <a class="code" href="classTreeNode.html" title="Example implementation of a single tree list node.">TreeNode</a>(name, <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/namespaceWt.html#a140dea437d52d3d7c438ea3bd16a1480ae06bb9ae9a26d13c3dcf9f20d5067885">PlainText</a>, labelIcon, 0);
<a name="l00137"></a>00137   <span class="keywordflow">if</span> (parent)
<a name="l00138"></a>00138     parent-&gt;<a class="code" href="classTreeNode.html#aa3bca1b27d9cbb05b0fa13504498179e" title="Adds a child node.">addChildNode</a>(node);
<a name="l00139"></a>00139 
<a name="l00140"></a>00140   <span class="keywordflow">return</span> node;
<a name="l00141"></a>00141 }
<a name="l00142"></a>00142 
<a name="l00143"></a><a class="code" href="classDemoTreeList.html#aef0149499570b8b89cbabe75879e30b6">00143</a> <a class="code" href="classTreeNode.html" title="Example implementation of a single tree list node.">TreeNode</a> *<a class="code" href="classDemoTreeList.html#aef0149499570b8b89cbabe75879e30b6" title="Create a &quot;file&quot; node, and insert in the given parent.">DemoTreeList::makeTreeFile</a>(<span class="keyword">const</span> std::string name,
<a name="l00144"></a>00144                                       <a class="code" href="classTreeNode.html" title="Example implementation of a single tree list node.">TreeNode</a> *parent)
<a name="l00145"></a>00145 {
<a name="l00146"></a>00146   <a class="code" href="classIconPair.html" title="An icon pair (identical to WIconPair)">IconPair</a> *labelIcon
<a name="l00147"></a>00147     = <span class="keyword">new</span> <a class="code" href="classIconPair.html" title="An icon pair (identical to WIconPair)">IconPair</a>(<span class="stringliteral">&quot;icons/document.png&quot;</span>, <span class="stringliteral">&quot;icons/yellow-folder-open.png&quot;</span>,
<a name="l00148"></a>00148                    <span class="keyword">false</span>);
<a name="l00149"></a>00149 
<a name="l00150"></a>00150   <a class="code" href="classTreeNode.html" title="Example implementation of a single tree list node.">TreeNode</a> *node = <span class="keyword">new</span> <a class="code" href="classTreeNode.html" title="Example implementation of a single tree list node.">TreeNode</a>(name, <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/namespaceWt.html#a140dea437d52d3d7c438ea3bd16a1480a847ab5a73b906fea275bd16877b420a4">XHTMLText</a>, labelIcon, 0);
<a name="l00151"></a>00151   <span class="keywordflow">if</span> (parent)
<a name="l00152"></a>00152     parent-&gt;<a class="code" href="classTreeNode.html#aa3bca1b27d9cbb05b0fa13504498179e" title="Adds a child node.">addChildNode</a>(node);
<a name="l00153"></a>00153 
<a name="l00154"></a>00154   <span class="keywordflow">return</span> node;
<a name="l00155"></a>00155 }
<a name="l00156"></a>00156 
<a name="l00157"></a><a class="code" href="DemoTreeList_8C.html#acb337c09cd35644b56da8b0e5bb17b9c">00157</a> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WApplication.html">WApplication</a> *<a class="code" href="ComposeExample_8C.html#acb337c09cd35644b56da8b0e5bb17b9c">createApplication</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WEnvironment.html">WEnvironment</a>&amp; env)
<a name="l00158"></a>00158 {
<a name="l00159"></a>00159   <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WApplication.html">WApplication</a> *app = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WApplication.html">WApplication</a>(env);
<a name="l00160"></a>00160   <span class="keyword">new</span> <a class="code" href="classDemoTreeList.html" title="A demonstration of the treelist.">DemoTreeList</a>(app-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WApplication.html#a17e118a04d962459484a12989a80bc05">root</a>());
<a name="l00161"></a>00161 
<a name="l00162"></a>00162   <span class="comment">/*</span>
<a name="l00163"></a>00163 <span class="comment">   * The look &amp; feel of the tree node is configured using a CSS style sheet.</span>
<a name="l00164"></a>00164 <span class="comment">   * If you are not familiar with CSS, you can use the WCssDecorationStyle</span>
<a name="l00165"></a>00165 <span class="comment">   * class ...</span>
<a name="l00166"></a>00166 <span class="comment">   */</span>
<a name="l00167"></a>00167   <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WCssDecorationStyle.html">WCssDecorationStyle</a> treeNodeLabelStyle;
<a name="l00168"></a>00168   treeNodeLabelStyle.<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WCssDecorationStyle.html#a5e552350f0955212ea237994a98638dc">font</a>().<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WFont.html#adf4922a79463304dedc2114049c054c1">setFamily</a>(WFont::Serif, <span class="stringliteral">&quot;Helvetica&quot;</span>);
<a name="l00169"></a>00169   app-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WApplication.html#a6a9a20d65ce9e7c2f62b27387c94e10d">styleSheet</a>().<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WCssStyleSheet.html#ad2c989b38a7ee084a7c9b681e16e8a8c">addRule</a>(<span class="stringliteral">&quot;.treenodelabel&quot;</span>, treeNodeLabelStyle);
<a name="l00170"></a>00170 
<a name="l00171"></a>00171   <span class="comment">/*</span>
<a name="l00172"></a>00172 <span class="comment">   * ... or if you speak CSS fluently, you can add verbatim rules.</span>
<a name="l00173"></a>00173 <span class="comment">   */</span>
<a name="l00174"></a>00174   app-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WApplication.html#a6a9a20d65ce9e7c2f62b27387c94e10d">styleSheet</a>().<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WCssStyleSheet.html#ad2c989b38a7ee084a7c9b681e16e8a8c">addRule</a>(<span class="stringliteral">&quot;.treenodechildcount&quot;</span>,
<a name="l00175"></a>00175                             <span class="stringliteral">&quot;color:blue; font-family:Helvetica,serif;&quot;</span>);
<a name="l00176"></a>00176 
<a name="l00177"></a>00177   <span class="keywordflow">return</span> app;
<a name="l00178"></a>00178 }
<a name="l00179"></a>00179 
<a name="l00180"></a><a class="code" href="DemoTreeList_8C.html#a3c04138a5bfe5d72780bb7e82a18e627">00180</a> <span class="keywordtype">int</span> <a class="code" href="ComposeExample_8C.html#a3c04138a5bfe5d72780bb7e82a18e627">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
<a name="l00181"></a>00181 {
<a name="l00182"></a>00182    <span class="keywordflow">return</span> WRun(argc, argv, &amp;<a class="code" href="ComposeExample_8C.html#acb337c09cd35644b56da8b0e5bb17b9c">createApplication</a>);
<a name="l00183"></a>00183 }
<a name="l00184"></a>00184 
</pre></div></div>
</div>
<hr size="1"><address style="text-align: right; margin: 3px"><small>
Generated on Fri Mar 30 2012 for <a href="http://www.webtoolkit.eu/wt">the
C++ Web Toolkit (Wt)</a> by&nbsp;<a
href="http://www.doxygen.org/index.html"><img src="doxygen.png"
alt="doxygen" border="0" style="vertical-align: middle; display:
inline-block; height: 2em"></a> 1.7.5.1</small></address>
</body>
</html>