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
 <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 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 List</span></a></li>
<li><a href="globals.html"><span>File 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 <boost/lexical_cast.hpp></span>
<a name="l00007"></a>00007
<a name="l00008"></a>00008 <span class="preprocessor">#include <Wt/WApplication></span>
<a name="l00009"></a>00009 <span class="preprocessor">#include <Wt/WText></span>
<a name="l00010"></a>00010 <span class="preprocessor">#include <Wt/WImage></span>
<a name="l00011"></a>00011 <span class="preprocessor">#include <Wt/WPushButton></span>
<a name="l00012"></a>00012
<a name="l00013"></a>00013 <span class="preprocessor">#include "<a class="code" href="DemoTreeList_8h.html">DemoTreeList.h</a>"</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include "<a class="code" href="TreeNode_8h.html">TreeNode.h</a>"</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include "<a class="code" href="IconPair_8h.html">IconPair.h</a>"</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">"<h2>Wt Tree List example</h2>"</span>
<a name="l00026"></a>00026 <span class="stringliteral">"<p>This is a simple demo of a treelist, implemented using"</span>
<a name="l00027"></a>00027 <span class="stringliteral">" <a href='http://witty.sourceforge.net/'>Wt</a>.</p>"</span>
<a name="l00028"></a>00028 <span class="stringliteral">"<p>The leafs of the tree contain the source code of the "</span>
<a name="l00029"></a>00029 <span class="stringliteral">"tree-list in the classes <b>TreeNode</b> and "</span>
<a name="l00030"></a>00030 <span class="stringliteral">"<b>IconPair</b>, as well as the implementation of this "</span>
<a name="l00031"></a>00031 <span class="stringliteral">"demo itself in the class <b>DemoTreeList</b>.</p>"</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 "map" node, and insert in the given parent.">makeTreeMap</a>(<span class="stringliteral">"Examples"</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 "map" node, and insert in the given parent.">makeTreeMap</a>(<span class="stringliteral">"Tree List"</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 "map" node, and insert in the given parent.">makeTreeMap</a>(<span class="stringliteral">"class IconPair"</span>, treelist);
<a name="l00038"></a>00038 <a class="code" href="classDemoTreeList.html#aef0149499570b8b89cbabe75879e30b6" title="Create a "file" node, and insert in the given parent.">makeTreeFile</a>(<span class="stringliteral">"<a href=\"IconPair.h\">IconPair.h</a>"</span>, wstateicon);
<a name="l00039"></a>00039 <a class="code" href="classDemoTreeList.html#aef0149499570b8b89cbabe75879e30b6" title="Create a "file" node, and insert in the given parent.">makeTreeFile</a>(<span class="stringliteral">"<a href=\"IconPair.C\">IconPair.C</a>"</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 "map" node, and insert in the given parent.">makeTreeMap</a>(<span class="stringliteral">"class TreeNode"</span>, treelist);
<a name="l00041"></a>00041 <a class="code" href="classDemoTreeList.html#aef0149499570b8b89cbabe75879e30b6" title="Create a "file" node, and insert in the given parent.">makeTreeFile</a>(<span class="stringliteral">"<a href=\"TreeNode.h\">TreeNode.h</a>"</span>, wtreenode);
<a name="l00042"></a>00042 <a class="code" href="classDemoTreeList.html#aef0149499570b8b89cbabe75879e30b6" title="Create a "file" node, and insert in the given parent.">makeTreeFile</a>(<span class="stringliteral">"<a href=\"TreeNode.C\">TreeNode.C</a>"</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 "map" node, and insert in the given parent.">makeTreeMap</a>(<span class="stringliteral">"class DemoTreeList"</span>, treelist);
<a name="l00044"></a>00044 <a class="code" href="classDemoTreeList.html#aef0149499570b8b89cbabe75879e30b6" title="Create a "file" node, and insert in the given parent.">makeTreeFile</a>(<span class="stringliteral">"<a href=\"DemoTreeList.h\">DemoTreeList.h</a>"</span>, demotreelist);
<a name="l00045"></a>00045 <a class="code" href="classDemoTreeList.html#aef0149499570b8b89cbabe75879e30b6" title="Create a "file" node, and insert in the given parent.">makeTreeFile</a>(<span class="stringliteral">"<a href=\"DemoTreeList.C\">DemoTreeList.C</a>"</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 "map" node, and insert in the given parent.">makeTreeMap</a>(<span class="stringliteral">"Test map"</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">"<p>Use the following buttons to change the tree "</span>
<a name="l00054"></a>00054 <span class="stringliteral">"contents:</p>"</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">"Add map"</span>, <span class="keyword">this</span>);
<a name="l00058"></a>00058 <a class="code" href="classDemoTreeList.html#a4f796ef14583c6b7fc0aec13508d83ee">addMapButton_</a>-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WInteractWidget.html#ae11e050cce0d4a8f742afa3ef92bfe8c">clicked</a>().connect(<span class="keyword">this</span>, &<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">"Remove map"</span>, <span class="keyword">this</span>);
<a name="l00062"></a>00062 <a class="code" href="classDemoTreeList.html#aa77bb14d293f3efde79a47d3b4a5214e">removeMapButton_</a>-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WInteractWidget.html#ae11e050cce0d4a8f742afa3ef92bfe8c">clicked</a>().connect(<span class="keyword">this</span>, &<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>-><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">"<p>Remarks:"</span>
<a name="l00067"></a>00067 <span class="stringliteral">"<ul>"</span>
<a name="l00068"></a>00068 <span class="stringliteral">"<li><p>This is not the instantiation of a pre-defined "</span>
<a name="l00069"></a>00069 <span class="stringliteral">"tree list component, but the full implementation of such "</span>
<a name="l00070"></a>00070 <span class="stringliteral">"a component, in about 350 lines of C++ code !</p> "</span>
<a name="l00071"></a>00071 <span class="stringliteral">"<p>In comparison, the <a href='http://myfaces.apache.org'> "</span>
<a name="l00072"></a>00072 <span class="stringliteral">"Apache MyFaces</a> JSF implementation of tree2, with similar "</span>
<a name="l00073"></a>00073 <span class="stringliteral">"functionality, uses about 2400 lines of Java, and 140 lines "</span>
<a name="l00074"></a>00074 <span class="stringliteral">"of JavaScript code.</p></li>"</span>
<a name="l00075"></a>00075 <span class="stringliteral">"<li><p>Once loaded, the tree list does not require any "</span>
<a name="l00076"></a>00076 <span class="stringliteral">"interaction with the server for handling the click events on "</span>
<a name="l00077"></a>00077 <span class="stringliteral">"the <img src='icons/nav-plus-line-middle.gif' /> and "</span>
<a name="l00078"></a>00078 <span class="stringliteral">"<img src='icons/nav-minus-line-middle.gif' /> icons, "</span>
<a name="l00079"></a>00079 <span class="stringliteral">"because these events have been connected to slots using "</span>
<a name="l00080"></a>00080 <span class="stringliteral">"STATIC connections. Such connections are converted to the "</span>
<a name="l00081"></a>00081 <span class="stringliteral">"appropriate JavaScript code that is inserted into the page. "</span>
<a name="l00082"></a>00082 <span class="stringliteral">"Still, the events are signaled to the server to update the "</span>
<a name="l00083"></a>00083 <span class="stringliteral">"application state.</p></li>"</span>
<a name="l00084"></a>00084 <span class="stringliteral">"<li><p>In contrast, the buttons for manipulating the tree "</span>
<a name="l00085"></a>00085 <span class="stringliteral">"contents use DYNAMIC connections, and thus the update "</span>
<a name="l00086"></a>00086 <span class="stringliteral">"is computed at server-side, and communicated back to the "</span>
<a name="l00087"></a>00087 <span class="stringliteral">"browser (by default using AJAX).</p></li>"</span>
<a name="l00088"></a>00088 <span class="stringliteral">"<li><p>When loading a page, only visible widgets (that are not "</span>
<a name="l00089"></a>00089 <span class="stringliteral">"<b>setHidden(true)</b>) are transmitted. "</span>
<a name="l00090"></a>00090 <span class="stringliteral">"The remaining widgets are loaded in the background after "</span>
<a name="l00091"></a>00091 <span class="stringliteral">"rendering the page. "</span>
<a name="l00092"></a>00092 <span class="stringliteral">"As a result the application is loaded as fast as possible.</p>"</span>
<a name="l00093"></a>00093 <span class="stringliteral">"</li>"</span>
<a name="l00094"></a>00094 <span class="stringliteral">"<li><p>The browser reload button is supported and behaves as "</span>
<a name="l00095"></a>00095 <span class="stringliteral">"expected: the page is reloaded from the server. Again, "</span>
<a name="l00096"></a>00096 <span class="stringliteral">"only visible widgets are transmitted immediately.</p> "</span>
<a name="l00097"></a>00097 <span class="stringliteral">"<p>(For the curious, this is the way to see the actual "</span>
<a name="l00098"></a>00098 <span class="stringliteral">"HTML/JavaScript code !)</p></li>"</span>
<a name="l00099"></a>00099 <span class="stringliteral">"</ul></p>"</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 "map" node, and insert in the given parent.">makeTreeMap</a>(<span class="stringliteral">"Map "</span> + boost::lexical_cast<std::string>(++<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 "file" node, and insert in the given parent.">makeTreeFile</a>(<span class="stringliteral">"File "</span> + boost::lexical_cast<std::string>(<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>-><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>-><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 > 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>-><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>-><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>-><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 "map" 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">"icons/yellow-folder-closed.png"</span>,
<a name="l00133"></a>00133 <span class="stringliteral">"icons/yellow-folder-open.png"</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-><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 "file" 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">"icons/document.png"</span>, <span class="stringliteral">"icons/yellow-folder-open.png"</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-><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>& 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-><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 & 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">"Helvetica"</span>);
<a name="l00169"></a>00169 app-><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">".treenodelabel"</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-><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">".treenodechildcount"</span>,
<a name="l00175"></a>00175 <span class="stringliteral">"color:blue; font-family:Helvetica,serif;"</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, &<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 <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>
|