/* * Copyright (C) 2008 Emweb bvba, Heverlee, Belgium. * * See the LICENSE file for terms of use. */ #include #include #include #include #include #include #include #include #include class HelloApplication : public Wt::WApplication { public: HelloApplication(const Wt::WEnvironment& env); void switchStacked(); private: Wt::WStackedWidget *m_pStack; }; HelloApplication::HelloApplication(const Wt::WEnvironment& env) : WApplication(env) { setTitle("Hello world"); Wt::WContainerWidget *pCont1 = root()->addWidget(Wt::cpp14::make_unique()); pCont1->setWidth(Wt::WLength(100, Wt::WLength::Unit::Percentage)); pCont1->setHeight(70); pCont1->decorationStyle().setBackgroundColor(Wt::WColor("Yellow")); m_pStack = pCont1->addWidget(Wt::cpp14::make_unique()); Wt::WContainerWidget *pContStack1 = m_pStack->addWidget(Wt::cpp14::make_unique()); #ifdef THIS_WORKS Wt::WContainerWidget *pContStack11 = pContStack1->addWidget(Wt::cpp14::make_unique()); #endif Wt::WContainerWidget *pContStack2 = m_pStack->addWidget(Wt::cpp14::make_unique()); #ifndef THIS_WORKS Wt::WHBoxLayout *pLayout1 = pContStack1->setLayout(Wt::cpp14::make_unique()); #else Wt::WHBoxLayout *pLayout1 = pContStack11->setLayout(Wt::cpp14::make_unique()); #endif Wt::WContainerWidget *pButton1 = pLayout1->addWidget(Wt::cpp14::make_unique()); pButton1->decorationStyle().setBackgroundColor(Wt::WColor("Blue")); pButton1->setWidth(100); pButton1->setHeight(25); Wt::WContainerWidget *pButton2 = pLayout1->addWidget(Wt::cpp14::make_unique()); pButton2->decorationStyle().setBackgroundColor(Wt::WColor("Red")); pButton2->setWidth(100); pButton2->setHeight(25); Wt::WContainerWidget *pButton3 = pLayout1->addWidget(Wt::cpp14::make_unique()); pButton3->decorationStyle().setBackgroundColor(Wt::WColor("Green")); pButton3->setWidth(100); pButton3->setHeight(25); Wt::WText *pText1 = pLayout1->addWidget(Wt::cpp14::make_unique("Hallo")); auto button1 = root()->addWidget(Wt::cpp14::make_unique("Switch")); button1->clicked().connect(std::bind(&HelloApplication::switchStacked, this)); } void HelloApplication::switchStacked() { auto i = m_pStack->currentIndex(); if (i) m_pStack->setCurrentIndex(0); else m_pStack->setCurrentIndex(1); } int main(int argc, char **argv) { return Wt::WRun(argc, argv, [](const Wt::WEnvironment &env) { return Wt::cpp14::make_unique(env); }); }