This commit is contained in:
Wieczorek Bartosz 2017-03-15 17:29:44 +01:00
parent 625bbfc5ea
commit bfa87eda2f
3 changed files with 60 additions and 16 deletions

View File

@ -14,8 +14,48 @@
#include <Wt/WText>
#include <Wt/WTextArea>
#include <Wt/WIconPair>
#include <Wt/WLogger>
#include <Wt/WText>
#include <Wt/WTree>
#include <Wt/WTreeNode>
#include <Wt/WHBoxLayout>
#include <Wt/WVBoxLayout>
namespace eedb {
auto make_tree() {
Wt::WTree * tree = new Wt::WTree();
tree->setSelectionMode(Wt::ExtendedSelection);
Wt::WIconPair * folderIcon = new Wt::WIconPair("icons/yellow-folder-closed.png", "icons/yellow-folder-open.png", false);
Wt::WTreeNode * node = new Wt::WTreeNode("Furniture", folderIcon);
tree->setTreeRoot(node);
node->label()->setTextFormat(Wt::PlainText);
node->setLoadPolicy(Wt::WTreeNode::NextLevelLoading);
node->addChildNode(new Wt::WTreeNode("Table"));
node->addChildNode(new Wt::WTreeNode("Cupboard"));
Wt::WTreeNode * three = new Wt::WTreeNode("Chair");
node->addChildNode(three);
node->addChildNode(new Wt::WTreeNode("Coach"));
node->expand();
three->addChildNode(new Wt::WTreeNode("Doc"));
three->addChildNode(new Wt::WTreeNode("Grumpy"));
three->addChildNode(new Wt::WTreeNode("Happy"));
three->addChildNode(new Wt::WTreeNode("Sneezy"));
three->addChildNode(new Wt::WTreeNode("Dopey"));
three->addChildNode(new Wt::WTreeNode("Bashful"));
three->addChildNode(new Wt::WTreeNode("Sleepy"));
return tree;
}
eedb::Home::Home(Wt::WContainerWidget * container, Wt::Auth::Login * login) : _login(login) {
// Create a navigation bar with a link to a web page.
auto navigation = new Wt::WNavigationBar(container);
@ -57,23 +97,25 @@ eedb::Home::Home(Wt::WContainerWidget * container, Wt::Auth::Login * login) : _l
sessionMenu->addItem(sessionItem);
navigation->addMenu(sessionMenu, Wt::AlignRight);
Wt::WBorderLayout * layout = new Wt::WBorderLayout();
container->setLayout(layout);
Wt::WVBoxLayout * vbox = new Wt::WVBoxLayout();
container->setLayout(vbox);
vbox->addWidget(navigation, 1);
Wt::WHBoxLayout * hbox = new Wt::WHBoxLayout();
vbox->addLayout(hbox, 30);
Wt::WStackedWidget * contents = new Wt::WStackedWidget();
layout->addWidget(navigation, Wt::WBorderLayout::North);
layout->addWidget(new Wt::WText("West"), Wt::WBorderLayout::West);
auto item = new Wt::WText(Wt::WString("East"));
item->setStyleClass("green-box");
layout->addWidget(item, Wt::WBorderLayout::East);
item = new Wt::WText(Wt::WString("South"));
item->setStyleClass("green-box");
layout->addWidget(item, Wt::WBorderLayout::South);
layout->addWidget(contents, Wt::WBorderLayout::Center);
_categoryTree = make_tree();
_categoryTree->itemSelectionChanged().connect([=](auto...) {
auto nodes = _categoryTree->selectedNodes();
for(const auto & node : nodes) {
Wt::log("notice") << "selected node:" << node->label()->text();
}
Wt::log("notice") << "Item selection changed";
});
hbox->addWidget(_categoryTree, 1);
hbox->addWidget(contents, 2);
hbox->setResizable(0, true);
}
}

View File

@ -1,5 +1,6 @@
namespace Wt {
class WContainerWidget;
class WTree;
}
namespace Wt::Auth {
class Login;
@ -12,5 +13,6 @@ class Home {
private:
const Wt::Auth::Login * _login;
Wt::WTree * _categoryTree;
};
}

View File

@ -7,7 +7,7 @@ BootstrapTheme::BootstrapTheme(Wt::WObject * parent) : _parent(parent) {}
Wt::WTheme * BootstrapTheme::create() const {
auto theme = new Wt::WBootstrapTheme(_parent);
theme->setVersion(Wt::WBootstrapTheme::Version3);
theme->setVersion(Wt::WBootstrapTheme::Version2);
// theme->setResponsive(true);
return theme;
}