A demonstration of the treelist.
More...
#include <DemoTreeList.h>
A demonstration of the treelist.
This is the main class for the treelist example.
Definition at line 29 of file DemoTreeList.h.
◆ DemoTreeList()
DemoTreeList::DemoTreeList |
( |
| ) |
|
Create a DemoTreeList.
Definition at line 19 of file DemoTreeList.C.
24 (cpp14::make_unique<WText>(
"<h2>Wt Tree List example</h2>" 25 "<p>This is a simple demo of a treelist, implemented using" 26 " <a href='http://witty.sourceforge.net/'>Wt</a>.</p>" 27 "<p>The leafs of the tree contain the source code of the " 28 "tree-list in the classes <b>TreeNode</b> and " 29 "<b>IconPair</b>, as well as the implementation of this " 30 "demo itself in the class <b>DemoTreeList</b>.</p>"));
33 tree_ = addWidget(std::move(tree));
37 makeTreeFile(
"<a href=\"IconPair.h\">IconPair.h</a>", wstateicon);
38 makeTreeFile(
"<a href=\"IconPair.C\">IconPair.C</a>", wstateicon);
40 makeTreeFile(
"<a href=\"TreeNode.h\">TreeNode.h</a>", wtreenode);
41 makeTreeFile(
"<a href=\"TreeNode.C\">TreeNode.C</a>", wtreenode);
43 makeTreeFile(
"<a href=\"DemoTreeList.h\">DemoTreeList.h</a>", demotreelist);
44 makeTreeFile(
"<a href=\"DemoTreeList.C\">DemoTreeList.C</a>", demotreelist);
52 (cpp14::make_unique<WText>(
"<p>Use the following buttons to change the tree " 56 = this->addWidget(cpp14::make_unique<WPushButton>(
"Add folder"));
60 = this->addWidget(cpp14::make_unique<WPushButton>(
"Remove folder"));
65 (cpp14::make_unique<WText>(
"<p>Remarks:" 67 "<li><p>This is not the instantiation of a pre-defined " 68 "tree list component, but the full implementation of such " 69 "a component, in about 350 lines of C++ code !</p> " 70 "<p>In comparison, the <a href='http://myfaces.apache.org'> " 71 "Apache MyFaces</a> JSF implementation of tree2, with similar " 72 "functionality, uses about 2400 lines of Java, and 140 lines " 73 "of JavaScript code.</p></li>" 74 "<li><p>Once loaded, the tree list does not require any " 75 "interaction with the server for handling the click events on " 76 "the <img src='icons/nav-plus-line-middle.gif' /> and " 77 "<img src='icons/nav-minus-line-middle.gif' /> icons, " 78 "because these events have been connected to slots using " 79 "STATIC connections. Such connections are converted to the " 80 "appropriate JavaScript code that is inserted into the page. " 81 "Still, the events are signaled to the server to update the " 82 "application state.</p></li>" 83 "<li><p>In contrast, the buttons for manipulating the tree " 84 "contents use DYNAMIC connections, and thus the update " 85 "is computed at server-side, and communicated back to the " 86 "browser (by default using AJAX).</p></li>" 87 "<li><p>When loading a page, only visible widgets (that are not " 88 "<b>setHidden(true)</b>) are transmitted. " 89 "The remaining widgets are loaded in the background after " 90 "rendering the page. " 91 "As a result the application is loaded as fast as possible.</p>" 93 "<li><p>The browser reload button is supported and behaves as " 94 "expected: the page is reloaded from the server. Again, " 95 "only visible widgets are transmitted immediately.</p> " 96 "<p>(For the curious, this is the way to see the actual " 97 "HTML/JavaScript code !)</p></li>" WPushButton * removeFolderButton_
void addFolder()
Add a folder.
TreeNode * makeTreeFolder(const std::string name, TreeNode *parent)
Create a "folder" node, and insert in the given parent.
WPushButton * addFolderButton_
TreeNode * makeTreeFile(const std::string name, TreeNode *parent)
Create a "file" node, and insert in the given parent.
Example implementation of a single tree list node.
void removeFolder()
Remove a folder.
◆ addFolder()
void DemoTreeList::addFolder |
( |
| ) |
|
|
private |
Add a folder.
Definition at line 101 of file DemoTreeList.C.
WPushButton * removeFolderButton_
TreeNode * makeTreeFolder(const std::string name, TreeNode *parent)
Create a "folder" node, and insert in the given parent.
TreeNode * makeTreeFile(const std::string name, TreeNode *parent)
Create a "file" node, and insert in the given parent.
Example implementation of a single tree list node.
◆ makeTreeFile() [1/2]
TreeNode * DemoTreeList::makeTreeFile |
( |
const std::string |
name, |
|
|
TreeNode * |
parent |
|
) |
| |
|
private |
Create a "file" node, and insert in the given parent.
Definition at line 152 of file DemoTreeList.C.
156 = cpp14::make_unique<IconPair>(
"icons/document.png",
"icons/yellow-folder-open.png",
159 auto node = cpp14::make_unique<TreeNode>(name, TextFormat::XHTML, std::move(labelIcon));
160 auto node_ = node.get();
void addChildNode(std::unique_ptr< TreeNode > node)
Adds a child node.
◆ makeTreeFile() [2/2]
std::unique_ptr< TreeNode > DemoTreeList::makeTreeFile |
( |
const std::string |
name | ) |
|
|
private |
Create a "file" root.
Definition at line 167 of file DemoTreeList.C.
170 = cpp14::make_unique<IconPair>(
"icons/document.png",
"icons/yellow-folder-open.png",
173 cpp14::make_unique<TreeNode>(name, TextFormat::XHTML, std::move(labelIcon));
◆ makeTreeFolder() [1/2]
TreeNode * DemoTreeList::makeTreeFolder |
( |
const std::string |
name, |
|
|
TreeNode * |
parent |
|
) |
| |
|
private |
Create a "folder" node, and insert in the given parent.
Definition at line 125 of file DemoTreeList.C.
127 auto labelIcon = cpp14::make_unique<IconPair>(
128 "icons/yellow-folder-closed.png",
129 "icons/yellow-folder-open.png",
133 cpp14::make_unique<TreeNode>(name, TextFormat::Plain, std::move(labelIcon));
134 auto node_ = node.get();
void addChildNode(std::unique_ptr< TreeNode > node)
Adds a child node.
◆ makeTreeFolder() [2/2]
std::unique_ptr< TreeNode > DemoTreeList::makeTreeFolder |
( |
const std::string |
name | ) |
|
|
private |
Create a "folder" root.
Definition at line 140 of file DemoTreeList.C.
142 auto labelIcon = cpp14::make_unique<IconPair>(
143 "icons/yellow-folder-closed.png",
144 "icons/yellow-folder-open.png",
147 cpp14::make_unique<TreeNode>(name, TextFormat::Plain, std::move(labelIcon));
◆ removeFolder()
void DemoTreeList::removeFolder |
( |
| ) |
|
|
private |
Remove a folder.
Definition at line 110 of file DemoTreeList.C.
114 if (numFolders > 0) {
115 int c = rand() % numFolders;
WPushButton * removeFolderButton_
void removeChildNode(TreeNode *node, int index)
Removes a child node.
const std::vector< TreeNode * > & childNodes() const
Returns the list of children.
Example implementation of a single tree list node.
◆ addFolderButton_
WPushButton* DemoTreeList::addFolderButton_ |
|
private |
◆ removeFolderButton_
WPushButton* DemoTreeList::removeFolderButton_ |
|
private |
◆ testCount_
int DemoTreeList::testCount_ |
|
private |
◆ testFolder_
◆ tree_
The documentation for this class was generated from the following files: