|
#include <Wt/WApplication>
|
|
#include <Wt/WContainerWidget>
|
|
#include <Wt/WInPlaceEdit>
|
|
#include <Wt/WLength>
|
|
#include <Wt/WSuggestionPopup>
|
|
#include <Wt/WStandardItemModel>
|
|
#include <Wt/WLineEdit>
|
|
#include <Wt/WText>
|
|
#include <Wt/WString>
|
|
#include <Wt/WTableView>
|
|
#include <Wt/WTreeView>
|
|
#include <Wt/WStandardItem>
|
|
#include <Wt/WItemDelegate>
|
|
#include <Wt/WDialog>
|
|
#include <Wt/WPushButton>
|
|
#include <Wt/WAbstractProxyModel>
|
|
#include <Wt/WEvent>
|
|
#include <Wt/WSignal>
|
|
#include <Wt/WModelIndex>
|
|
#include <Wt/WHBoxLayout>
|
|
#include <Wt/WVBoxLayout>
|
|
#include <Wt/WGroupBox>
|
|
#include <Wt/WTemplate>
|
|
#include <Wt/WStackedWidget>
|
|
#include <Wt/WMenu>
|
|
#include <Wt/WServer>
|
|
#include <Wt/WSubMenuItem>
|
|
#include <Wt/WMenuItem>
|
|
#include <Wt/WTabWidget>
|
|
#include <Wt/WSpinBox>
|
|
#include <Wt/WRadioButton>
|
|
|
|
#include <boost/bind.hpp>
|
|
#include <boost/foreach.hpp>
|
|
#include <Wt/WPainter>
|
|
#include <Wt/WPaintDevice>
|
|
#include <Wt/WPaintedWidget>
|
|
|
|
using namespace Wt;
|
|
using namespace boost;
|
|
|
|
using std::string;
|
|
|
|
class MyApplication: public WApplication {
|
|
public:
|
|
MyApplication(const Wt::WEnvironment& env);
|
|
void sort_menu();
|
|
void test_button();
|
|
WMenu *menu_;
|
|
WMenuItem *m1_;
|
|
WMenuItem *m2_;
|
|
WStackedWidget *stack_;
|
|
int test_;
|
|
WText *test_text__;
|
|
WContainerWidget *upper_page_;
|
|
WContainerWidget *lower_page_;
|
|
};
|
|
|
|
MyApplication::MyApplication(const Wt::WEnvironment& env)
|
|
: Wt::WApplication(env)
|
|
{
|
|
// enable updates
|
|
this->enableUpdates(true);
|
|
|
|
// test counter -> so we can see the page is not frozen
|
|
test_ = 0;
|
|
test_text__ = new WText();
|
|
test_text__->setText(asString(test_));
|
|
|
|
// our layout
|
|
WHBoxLayout *layout = new WHBoxLayout();
|
|
|
|
// our menu and associated stackedwidget
|
|
stack_ = new WStackedWidget();
|
|
|
|
menu_ = new WMenu(stack_, Vertical);
|
|
menu_->setRenderAsList(true);
|
|
menu_->setInternalPathEnabled();
|
|
menu_->setInternalBasePath("test");
|
|
|
|
// menu for item 1
|
|
// item 1 has a top and lower content container
|
|
// the tabs are in the top container, but their contents should be in the lower container
|
|
WMenu *menu1__ = new WMenu(stack_, Vertical);
|
|
menu1__->setRenderAsList(true);
|
|
|
|
WContainerWidget *m1_container_ = new WContainerWidget();
|
|
WTemplate *upper_lower_page_template__ = new WTemplate("${top_contents}${lower_contents}", m1_container_);
|
|
upper_page_ = new WContainerWidget();
|
|
lower_page_ = new WContainerWidget();
|
|
upper_lower_page_template__->bindWidget("top_contents", upper_page_);
|
|
upper_lower_page_template__->bindWidget("lower_contents", lower_page_);
|
|
WTabWidget *tabwidget_ = new WTabWidget(upper_page_);
|
|
WStackedWidget *stacked_widget__ = tabwidget_->contentsStack();
|
|
WContainerWidget *lower_container__ = dynamic_cast<WContainerWidget *>(stacked_widget__);
|
|
lower_page_->addWidget(lower_container__);
|
|
WContainerWidget *tab_container_ = new WContainerWidget();
|
|
tab_container_->addWidget(new WText("tabitem"));
|
|
WSpinBox *m1_spinbox__ = new WSpinBox();
|
|
tabwidget_->addTab(tab_container_, "eerste tabke");
|
|
// we want the spinbox tab to be first, so remove the current one
|
|
// add the spinbox one, and re-add it afterwards again
|
|
tabwidget_->removeTab(tab_container_);
|
|
tabwidget_->addTab(m1_spinbox__, "eerste tabke 2");
|
|
tabwidget_->addTab(tab_container_, "tweede tabke");
|
|
|
|
m1_ = new WMenuItem("WMenuItem1", m1_container_);
|
|
menu_->addItem(m1_);
|
|
|
|
// create item 2
|
|
m2_ = new WMenuItem("WSubMenuItem2", new WText("WSubMenuItem2"));
|
|
menu_->addItem(m2_);
|
|
|
|
// create a button for removing and adding item2
|
|
WPushButton *button__ = new WPushButton("sort menu");
|
|
button__->clicked().connect(boost::bind(&MyApplication::sort_menu, this));
|
|
|
|
// create a button to test whether we are frozen
|
|
WPushButton *test__ = new WPushButton("test freeze");
|
|
test__->clicked().connect(boost::bind(&MyApplication::test_button, this));
|
|
|
|
// add everything to the layout
|
|
layout->addWidget(menu_);
|
|
layout->addWidget(stack_);
|
|
layout->addWidget(button__);
|
|
layout->addWidget(test__);
|
|
layout->addWidget(test_text__);
|
|
root()->setLayout(layout);
|
|
}
|
|
|
|
void MyApplication::test_button()
|
|
{
|
|
test_ = test_+1;
|
|
test_text__->setText(asString(test_));
|
|
}
|
|
|
|
void MyApplication::sort_menu()
|
|
{
|
|
// sort all items
|
|
menu_->removeItem(m1_);
|
|
menu_->addItem(m1_);
|
|
menu_->removeItem(m2_);
|
|
menu_->addItem(m2_);
|
|
// notify client
|
|
WApplication::instance()->triggerUpdate();
|
|
}
|
|
|
|
|
|
WApplication* createApplication(const Wt::WEnvironment& env)
|
|
{
|
|
WApplication* app = new MyApplication(env);
|
|
return app;
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
return Wt::WRun(argc, argv, &createApplication);
|
|
}
|