#include #include #include #include #include #include #include #include using namespace Wt; // ----------------------------------------------------------------------------------- std::unique_ptr createHelloApplication(const WEnvironment &env) { auto app = std::make_unique(env); auto theme = std::make_shared(); theme->setVersion(Wt::BootstrapVersion::v3); app->setTheme(theme); WHBoxLayout *mainLayout = app->root()->setLayout(std::make_unique()); auto leftCont = mainLayout->addWidget(std::make_unique(), 1); leftCont->setOverflow(Overflow::Auto); leftCont->addWidget(std::make_unique("Left Container")); auto toolsCont = leftCont->addWidget(std::make_unique()); auto toolsLayout = toolsCont->setLayout(std::make_unique()); toolsLayout->addWidget(std::make_unique("Click the right button to dipslay the popup"), 1); auto toolsPopup = std::make_unique(); toolsPopup->addItem("Long Long Long Demo Item 1"); toolsPopup->addItem("Long Long Long Demo Item 2"); toolsPopup->addItem("Long Long Long Demo Item 3"); toolsPopup->addItem("Long Long Long Demo Item 4"); toolsPopup->addItem("Long Long Long Demo Item 5"); auto popupBt = toolsLayout->addWidget(std::make_unique("Click here")); popupBt->setMenu(std::move(toolsPopup)); for (int i = 0; i < 100; i++) leftCont->addWidget(std::make_unique("Popup Error Sample Line " + std::to_string(i)))->setInline(false); auto rightCont = mainLayout->addWidget(std::make_unique()); rightCont->setWidth(200); rightCont->addWidget(std::make_unique("Right Container")); return app; } // ----------------------------------------------------------------------------------- int main(int argc, char *argv[]) { try { WServer server(argc, argv, WTHTTP_CONFIGURATION); server.addEntryPoint(EntryPointType::Application, std::bind(&createHelloApplication, std::placeholders::_1)); if (server.start()) { int sig = WServer::waitForShutdown(); std::cerr << "*** Shutdown (signal = " << sig << ")" << std::endl; server.stop(); if (sig == 1) // SIGHUP WServer::restart(argc, argv, environ); return 0; } } catch (WServer::Exception &e) { std::cerr << "*** Server Exception: " << e.what() << std::endl; } catch (std::exception &e) { std::cerr << "*** Std Exception: " << e.what() << std::endl; } }