<!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: Wt::WTree Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css" /> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="search/search.js"></script> <script type="text/javascript"> $(document).ready(function() { searchBox.OnSelectItem(0); }); </script> </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  <span id="projectnumber">3.2.3</span> </div> </td> </tr> </tbody> </table> </div> <!-- Generated by Doxygen 1.7.5.1 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <img id="MSearchSelect" src="search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> </span><span class="right"> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </span> </div> </li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="inherits.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="namespaceWt.html">Wt</a> </li> <li class="navelem"><a class="el" href="classWt_1_1WTree.html">WTree</a> </li> </ul> </div> </div> <div class="header"> <div class="summary"> <a href="#pub-types">Public Types</a> | <a href="#pub-methods">Public Member Functions</a> </div> <div class="headertitle"> <div class="title">Wt::WTree Class Reference</div> </div> </div> <div class="contents"> <!-- doxytag: class="Wt::WTree" --><!-- doxytag: inherits="Wt::WCompositeWidget" --> <p>A widget that represents a navigatable tree. <a href="classWt_1_1WTree.html#details">More...</a></p> <p><code>#include <Wt/WTree></code></p> <div class="dynheader"> Inheritance diagram for Wt::WTree:</div> <div class="dyncontent"> <div class="center"><img src="classWt_1_1WTree__inherit__graph.png" border="0" usemap="#Wt_1_1WTree_inherit__map" alt="Inheritance graph"/></div> <map name="Wt_1_1WTree_inherit__map" id="Wt_1_1WTree_inherit__map"> <area shape="rect" href="classWt_1_1WCompositeWidget.html" title="A widget that hides the implementation of composite widgets." alt="" coords="5,155,168,181"/><area shape="rect" href="classWt_1_1WWidget.html" title="The abstract base class for a user-interface component." alt="" coords="37,80,136,107"/><area shape="rect" href="classWt_1_1WObject.html" title="A base class for objects that participate in the signal/slot system." alt="" coords="39,5,135,32"/></map> <center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div> <p><a href="classWt_1_1WTree-members.html">List of all members.</a></p> <table class="memberdecls"> <tr><td colspan="2"><h2><a name="pub-types"></a> Public Types</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a2308f07ae7dfb959360ad1bdcf394e44"></a><!-- doxytag: member="Wt::WTree::WTreeNodeSet" ref="a2308f07ae7dfb959360ad1bdcf394e44" args="" --> typedef std::set< <a class="el" href="classWt_1_1WTreeNode.html">WTreeNode</a> * > </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTree.html#a2308f07ae7dfb959360ad1bdcf394e44">WTreeNodeSet</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Typedef for a set of WTreeNode's. <br/></td></tr> <tr><td colspan="2"><h2><a name="pub-methods"></a> Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a0814258c8147d68000402468016f9817"></a><!-- doxytag: member="Wt::WTree::WTree" ref="a0814258c8147d68000402468016f9817" args="(WContainerWidget *parent=0)" -->  </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTree.html#a0814258c8147d68000402468016f9817">WTree</a> (<a class="el" href="classWt_1_1WContainerWidget.html">WContainerWidget</a> *parent=0)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Creates a new tree. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTree.html#a040f5fa4df57cbfb586d686ffe1326d0">setTreeRoot</a> (<a class="el" href="classWt_1_1WTreeNode.html">WTreeNode</a> *root)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Sets the tree root node. <a href="#a040f5fa4df57cbfb586d686ffe1326d0"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classWt_1_1WTreeNode.html">WTreeNode</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTree.html#a54de80f955e54acbab38a344546ce0bf">treeRoot</a> () const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the root node. <a href="#a54de80f955e54acbab38a344546ce0bf"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTree.html#a7270f705ad5f9be1e2bee06a73348a9a">setSelectionMode</a> (<a class="el" href="namespaceWt.html#a74b3f7eb1689a3cbf0ea514ffd20bccc">SelectionMode</a> mode)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Sets the selection mode. <a href="#a7270f705ad5f9be1e2bee06a73348a9a"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="afcc60067220a91ce69dde46ea413afc5"></a><!-- doxytag: member="Wt::WTree::selectionMode" ref="afcc60067220a91ce69dde46ea413afc5" args="() const " --> <a class="el" href="namespaceWt.html#a74b3f7eb1689a3cbf0ea514ffd20bccc">SelectionMode</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTree.html#afcc60067220a91ce69dde46ea413afc5">selectionMode</a> () const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the selection mode. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a7d415764d1fce3d4c9d33713892c0ef9"></a><!-- doxytag: member="Wt::WTree::selectedNodes" ref="a7d415764d1fce3d4c9d33713892c0ef9" args="() const " --> const <a class="el" href="classWt_1_1WTree.html#a2308f07ae7dfb959360ad1bdcf394e44">WTreeNodeSet</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTree.html#a7d415764d1fce3d4c9d33713892c0ef9">selectedNodes</a> () const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the set of selected tree nodes. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a9e09dff326743004dc9f2bf27408551a"></a><!-- doxytag: member="Wt::WTree::select" ref="a9e09dff326743004dc9f2bf27408551a" args="(const WTreeNodeSet &nodes)" --> void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTree.html#a9e09dff326743004dc9f2bf27408551a">select</a> (const <a class="el" href="classWt_1_1WTree.html#a2308f07ae7dfb959360ad1bdcf394e44">WTreeNodeSet</a> &nodes)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Sets a selection of tree nodes. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a52c770a65ac3f4c2493f714271a5133a"></a><!-- doxytag: member="Wt::WTree::select" ref="a52c770a65ac3f4c2493f714271a5133a" args="(WTreeNode *node, bool selected=true)" --> void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTree.html#a52c770a65ac3f4c2493f714271a5133a">select</a> (<a class="el" href="classWt_1_1WTreeNode.html">WTreeNode</a> *node, bool selected=true)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Selects or unselect the given <em>node</em>. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3969fd0bab17347bb32727dba2ff9682"></a><!-- doxytag: member="Wt::WTree::isSelected" ref="a3969fd0bab17347bb32727dba2ff9682" args="(WTreeNode *node) const " --> bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTree.html#a3969fd0bab17347bb32727dba2ff9682">isSelected</a> (<a class="el" href="classWt_1_1WTreeNode.html">WTreeNode</a> *node) const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns if the given <em>node</em> is currently selected. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a14a781edeb90b3040a5e09238290514e"></a><!-- doxytag: member="Wt::WTree::clearSelection" ref="a14a781edeb90b3040a5e09238290514e" args="()" --> void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTree.html#a14a781edeb90b3040a5e09238290514e">clearSelection</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Clears the current selection. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a103603f639e07f83d1a75e293b70966d"></a><!-- doxytag: member="Wt::WTree::itemSelectionChanged" ref="a103603f639e07f83d1a75e293b70966d" args="()" --> <a class="el" href="classWt_1_1Signal.html">Signal</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTree.html#a103603f639e07f83d1a75e293b70966d">itemSelectionChanged</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Signal that is emitted when the selection changes. <br/></td></tr> </table> <hr/><a name="details" id="details"></a><h2>Detailed Description</h2> <div class="textblock"><p>A widget that represents a navigatable tree. </p> <p>WTree provides a tree widget, and coordinates selection functionality.</p> <p>Unlike the MVC-based <a class="el" href="classWt_1_1WTreeView.html" title="A view class that displays a model as a tree or tree table.">WTreeView</a>, the tree renders a widget hierarchy, rather than a hierarhical standard model. This provides extra flexibility (as any widget can be used as contents), at the cost of server-side, client-side and bandwidth resources (especially for large tree tables).</p> <p>The tree is implemented as a hierarchy of <a class="el" href="classWt_1_1WTreeNode.html" title="A single node in a tree.">WTreeNode</a> widgets.</p> <p>Selection is rendered by calling <a class="el" href="classWt_1_1WTreeNode.html#ae4bb84bf91002f80941d2e890cab12cd" title="Renders the node to be selected.">WTreeNode::renderSelected(bool)</a>. Only tree nodes that are <a class="el" href="classWt_1_1WTreeNode.html#a60428cfc48b2a39550efc308b38406b2">selectable</a> may participate in the selection.</p> <p>Usage example: </p> <div class="fragment"><pre class="fragment"> <a class="code" href="classWt_1_1WIconPair.html" title="A widget that shows one of two icons depending on its state.">Wt::WIconPair</a> *folderIcon = <span class="keyword">new</span> <a class="code" href="classWt_1_1WIconPair.html" title="A widget that shows one of two icons depending on its state.">Wt::WIconPair</a>(<span class="stringliteral">"icons/yellow-folder-closed.png"</span>, <span class="stringliteral">"icons/yellow-folder-open.png"</span>, <span class="keyword">false</span>); <a class="code" href="classWt_1_1WTree.html" title="A widget that represents a navigatable tree.">Wt::WTree</a> *tree = <span class="keyword">new</span> <a class="code" href="classWt_1_1WTree.html#a0814258c8147d68000402468016f9817" title="Creates a new tree.">Wt::WTree</a>(); tree-><a class="code" href="classWt_1_1WTree.html#a7270f705ad5f9be1e2bee06a73348a9a" title="Sets the selection mode.">setSelectionMode</a>(<a class="code" href="namespaceWt.html#a74b3f7eb1689a3cbf0ea514ffd20bccca4fd3c5ba6ce5289a1e732d85f002882a" title="Single selection only.">Wt::SingleSelection</a>); <a class="code" href="classWt_1_1WTreeNode.html" title="A single node in a tree.">Wt::WTreeNode</a> *root = <span class="keyword">new</span> <a class="code" href="classWt_1_1WTreeNode.html" title="A single node in a tree.">Wt::WTreeNode</a>(<span class="stringliteral">"Tree root"</span>, folderIcon); root-><a class="code" href="classWt_1_1WCompositeWidget.html#af9a8abf4e8b5be186a31cd951e60bdc6" title="Sets (one or more) CSS style classes.">setStyleClass</a>(<span class="stringliteral">"example-tree"</span>); tree-><a class="code" href="classWt_1_1WTree.html#a040f5fa4df57cbfb586d686ffe1326d0" title="Sets the tree root node.">setTreeRoot</a>(root); root-><a class="code" href="classWt_1_1WTreeNode.html#a32c24104359b595cbaf914e35accb3b4" title="Returns the label.">label</a>()->setTextFormat(<a class="code" href="namespaceWt.html#a140dea437d52d3d7c438ea3bd16a1480ae06bb9ae9a26d13c3dcf9f20d5067885" title="Format text as plain text.">Wt::PlainText</a>); root-><a class="code" href="classWt_1_1WTreeNode.html#aff37a6152a8195dd9b2a80e593d94298" title="Sets the image pack for this (sub)tree (deprecated).">setImagePack</a>(<span class="stringliteral">"resources/"</span>); root-><a class="code" href="classWt_1_1WTreeNode.html#aaf3d613cc461f4d9d39a71cd45bd155e" title="Sets the load policy for this tree.">setLoadPolicy</a>(<a class="code" href="classWt_1_1WTreeNode.html#a51c02b42c069e61a269fde598b9a1bffa387323cbdc8efd12ef6bf8553876c011" title="Pre-load one level of child nodes.">Wt::WTreeNode::NextLevelLoading</a>); root-><a class="code" href="classWt_1_1WTreeNode.html#adeb2bd7c946ef9c7bb5b72b3f88453a6" title="Adds a child node.">addChildNode</a>(<span class="keyword">new</span> <a class="code" href="classWt_1_1WTreeNode.html" title="A single node in a tree.">Wt::WTreeNode</a>(<span class="stringliteral">"one"</span>)); root-><a class="code" href="classWt_1_1WTreeNode.html#adeb2bd7c946ef9c7bb5b72b3f88453a6" title="Adds a child node.">addChildNode</a>(<span class="keyword">new</span> <a class="code" href="classWt_1_1WTreeNode.html" title="A single node in a tree.">Wt::WTreeNode</a>(<span class="stringliteral">"two"</span>)); <a class="code" href="classWt_1_1WTreeNode.html" title="A single node in a tree.">Wt::WTreeNode</a> *three = <span class="keyword">new</span> <a class="code" href="classWt_1_1WTreeNode.html" title="A single node in a tree.">Wt::WTreeNode</a>(<span class="stringliteral">"three"</span>); three-><a class="code" href="classWt_1_1WTreeNode.html#adeb2bd7c946ef9c7bb5b72b3f88453a6" title="Adds a child node.">addChildNode</a>(<span class="keyword">new</span> WTreeNode(<span class="stringliteral">"three: one"</span>)); three-><a class="code" href="classWt_1_1WTreeNode.html#adeb2bd7c946ef9c7bb5b72b3f88453a6" title="Adds a child node.">addChildNode</a>(<span class="keyword">new</span> WTreeNode(<span class="stringliteral">"three: two"</span>)); root-><a class="code" href="classWt_1_1WTreeNode.html#adeb2bd7c946ef9c7bb5b72b3f88453a6" title="Adds a child node.">addChildNode</a>(three); root-><a class="code" href="classWt_1_1WTreeNode.html#a10e99f9db96ec2fc500927a5d50caafe" title="Expands this node.">expand</a>(); </pre></div><h3>CSS</h3> <p>The tree is styled by the current CSS theme. The look can be overridden using the <code>Wt-tree</code> CSS class. The style selectors that affect the rendering of the decoration of the nodes are indicated in the documentation for <a class="el" href="classWt_1_1WTreeNode.html" title="A single node in a tree.">WTreeNode</a>. In addition, the following selector may be used to style the header:</p> <div class="fragment"><pre class="fragment"> .Wt-tree .Wt-selected : selected item </pre></div><p>A screenshot of the tree: </p> <table border="0" align="center"> <tr> <td><div class="image"> <img src="WTree-default-1.png" alt="WTree-default-1.png"/> <div class="caption"> An example WTree (default)</div></div> </td><td><div class="image"> <img src="WTree-polished-1.png" alt="WTree-polished-1.png"/> <div class="caption"> An example WTree (polished)</div></div> </td></tr> </table> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classWt_1_1WTreeNode.html" title="A single node in a tree.">WTreeNode</a>, <a class="el" href="classWt_1_1WTreeTable.html" title="A table with a navigatable tree in the first column.">WTreeTable</a>, <a class="el" href="classWt_1_1WTreeView.html" title="A view class that displays a model as a tree or tree table.">WTreeView</a> </dd></dl> </div><hr/><h2>Member Function Documentation</h2> <a class="anchor" id="a7270f705ad5f9be1e2bee06a73348a9a"></a><!-- doxytag: member="Wt::WTree::setSelectionMode" ref="a7270f705ad5f9be1e2bee06a73348a9a" args="(SelectionMode mode)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void Wt::WTree::setSelectionMode </td> <td>(</td> <td class="paramtype"><a class="el" href="namespaceWt.html#a74b3f7eb1689a3cbf0ea514ffd20bccc">SelectionMode</a> </td> <td class="paramname"><em>mode</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Sets the selection mode. </p> <p>The default selection mode is <a class="el" href="namespaceWt.html#a74b3f7eb1689a3cbf0ea514ffd20bcccab681964d34d71d850361461bafc46891" title="No selections.">Wt::NoSelection</a>. </p> </div> </div> <a class="anchor" id="a040f5fa4df57cbfb586d686ffe1326d0"></a><!-- doxytag: member="Wt::WTree::setTreeRoot" ref="a040f5fa4df57cbfb586d686ffe1326d0" args="(WTreeNode *root)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void Wt::WTree::setTreeRoot </td> <td>(</td> <td class="paramtype"><a class="el" href="classWt_1_1WTreeNode.html">WTreeNode</a> * </td> <td class="paramname"><em>root</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Sets the tree root node. </p> <p>The initial value is <code>0</code>. </p> </div> </div> <a class="anchor" id="a54de80f955e54acbab38a344546ce0bf"></a><!-- doxytag: member="Wt::WTree::treeRoot" ref="a54de80f955e54acbab38a344546ce0bf" args="() const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classWt_1_1WTreeNode.html">WTreeNode</a>* Wt::WTree::treeRoot </td> <td>(</td> <td class="paramname"></td><td>)</td> <td> const</td> </tr> </table> </div> <div class="memdoc"> <p>Returns the root node. </p> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classWt_1_1WTree.html#a040f5fa4df57cbfb586d686ffe1326d0" title="Sets the tree root node.">setTreeRoot()</a> </dd></dl> </div> </div> </div> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Enumerator</a></div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <hr size="1"><address style="text-align: right; margin: 3px"><small> Generated on Thu Nov 1 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>