|
#include <Wt/WApplication>
|
|
#include <Wt/WBreak>
|
|
#include <Wt/WContainerWidget>
|
|
#include <Wt/WTreeNode>
|
|
#include <Wt/WTree>
|
|
#include <Wt/WText>
|
|
#include <Wt/WPushButton>
|
|
|
|
using namespace Wt;
|
|
|
|
class HelloApplication : public WApplication
|
|
{
|
|
public:
|
|
HelloApplication(const WEnvironment& env);
|
|
|
|
private:
|
|
|
|
void hsCoach();
|
|
bool showCoach_;
|
|
WTreeNode *coach_;
|
|
void hsChair();
|
|
bool showChair_;
|
|
WTreeNode *chair_;
|
|
};
|
|
|
|
HelloApplication::HelloApplication(const WEnvironment& env)
|
|
: WApplication(env),
|
|
showCoach_(false),
|
|
coach_(0),
|
|
showChair_(false),
|
|
chair_(0)
|
|
{
|
|
WTree *tree = new WTree(root());
|
|
tree->setSelectionMode(ExtendedSelection);
|
|
|
|
WTreeNode *node = new WTreeNode("Furniture");
|
|
tree->setTreeRoot(node);
|
|
node->label()->setTextFormat(PlainText);
|
|
node->setLoadPolicy(WTreeNode::NextLevelLoading);
|
|
node->addChildNode(new WTreeNode("Table"));
|
|
node->addChildNode(new WTreeNode("Cupboard"));
|
|
|
|
chair_ = new WTreeNode("Chair");
|
|
node->addChildNode(chair_);
|
|
coach_ = new WTreeNode("Coach");
|
|
node->addChildNode(coach_);
|
|
node->expand();
|
|
coach_->addChildNode(new WTreeNode("Doc"));
|
|
coach_->addChildNode(new WTreeNode("Grumpy"));
|
|
coach_->addChildNode(new WTreeNode("Happy"));
|
|
|
|
WPushButton *hsco = new WPushButton("hide/show coach", root());
|
|
hsco->clicked().connect(this, &HelloApplication::hsCoach);
|
|
showCoach_ = false;
|
|
|
|
WPushButton *hsch = new WPushButton("hide/show chair", root());
|
|
hsch->clicked().connect(this, &HelloApplication::hsChair);
|
|
showChair_ = false;
|
|
}
|
|
|
|
void HelloApplication::hsCoach()
|
|
{
|
|
coach_->setNodeVisible(showCoach_);
|
|
showCoach_ = !showCoach_;
|
|
}
|
|
|
|
void HelloApplication::hsChair()
|
|
{
|
|
chair_->setNodeVisible(showChair_);
|
|
showChair_ = !showChair_;
|
|
}
|
|
|
|
WApplication *createApplication(const WEnvironment& env)
|
|
{
|
|
return new HelloApplication(env);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
return WRun(argc, argv, &createApplication);
|
|
}
|
|
|