#include #include #include #include #include #include #include #include void showDialog(const bool percentage) { Wt::WDialog *dialog = new Wt::WDialog("Layout Test"); if (percentage) dialog->setMaximumSize(Wt::WLength(50, Wt::WLength::Percentage), Wt::WLength(50, Wt::WLength::Percentage)); else dialog->setMaximumSize(Wt::WLength(400), Wt::WLength(400)); Wt::WContainerWidget* form = dialog->contents(); form->setOverflow(Wt::WContainerWidget::OverflowAuto); for (int i = 0; i < 100; ++i) { Wt::WString str("

Row {1}

"); form->addWidget(new Wt::WText(str.arg(i))); } Wt::WPushButton *ok = new Wt::WPushButton("OK", dialog->footer()); ok->setDefault(true); Wt::WPushButton *cancel = new Wt::WPushButton("Cancel", dialog->footer()); dialog->rejectWhenEscapePressed(); ok->clicked().connect(dialog, &Wt::WDialog::accept); cancel->clicked().connect(dialog, &Wt::WDialog::reject); dialog->finished().connect(std::bind([=]() { delete dialog; })); dialog->show(); } class TestApplication : public Wt::WApplication { public: TestApplication(const Wt::WEnvironment& env); }; TestApplication::TestApplication(const Wt::WEnvironment& env) : WApplication(env) { Wt::WBootstrapTheme *bootstrapTheme = new Wt::WBootstrapTheme(this); bootstrapTheme->setVersion(Wt::WBootstrapTheme::Version3); bootstrapTheme->setResponsive(true); this->setTheme(bootstrapTheme); // load the default bootstrap3 (sub-)theme this->useStyleSheet("resources/themes/bootstrap/3/bootstrap-theme.min.css"); this->useStyleSheet("resources/font-awesome/css/font-awesome.min.css"); setTitle("WDialog Test"); const auto cerateButton = [this](const Wt::WString& name, const bool percentage) { Wt::WPushButton *button = new Wt::WPushButton(name, root()); button->setMargin(5); button->clicked().connect(std::bind([=]() { showDialog(percentage); })); }; cerateButton("Dialog Percentage", true); cerateButton("Dialog Absolute", false); } Wt::WApplication *createApplication(const Wt::WEnvironment& env) { /* * You could read information from the environment to decide whether * the user has permission to start a new application */ return new TestApplication(env); } int main(int argc, char **argv) { /* * Your main method may set up some shared resources, but should then * start the server application (FastCGI or httpd) that starts listening * for requests, and handles all of the application life cycles. * * The last argument to WRun specifies the function that will instantiate * new application objects. That function is executed when a new user surfs * to the Wt application, and after the library has negotiated browser * support. The function should return a newly instantiated application * object. */ return Wt::WRun(argc, argv, &createApplication); }