Project

General

Profile

Bug #7396 » forum_16637.cpp

Roel Standaert, 01/30/2020 04:33 PM

 
1
#include <Wt/WApplication.h>
2
#include <Wt/WBootstrapTheme.h>
3
#include <Wt/WContainerWidget.h>
4
#include <Wt/WDateEdit.h>
5
#include <Wt/WDialog.h>
6
#include <Wt/WPanel.h>
7
#include <Wt/WText.h>
8

    
9
#include <memory>
10

    
11
// set to 1 to test with a dialog instead
12
#define DIALOG 0
13

    
14
int main(int argc, char *argv[])
15
{
16
  return Wt::WRun(argc, argv, [](const Wt::WEnvironment &env) {
17
    auto app = std::make_unique<Wt::WApplication>(env);
18

    
19
    auto theme = std::make_shared<Wt::WBootstrapTheme>();
20
    theme->setVersion(Wt::BootstrapVersion::v3);
21
    app->setTheme(theme);
22

    
23
#if DIALOG
24
    Wt::WDialog *dialog = app->addChild(std::make_unique<Wt::WDialog>());
25
    dialog->resize(300, 150);
26
    dialog->setTitleBarEnabled(true);
27
    dialog->titleBar()->addNew<Wt::WText>("Titlebar");
28
    dialog->contents()->addNew<Wt::WDateEdit>();
29

    
30
    dialog->show();
31
#else
32
    Wt::WPanel *panel = app->root()->addNew<Wt::WPanel>();
33
    panel->setTitle(Wt::utf8("Titlebar"));
34
    auto containerPtr = std::make_unique<Wt::WContainerWidget>();
35
    auto container = containerPtr.get();
36
    panel->setCentralWidget(std::move(containerPtr));
37

    
38
    container->addNew<Wt::WDateEdit>();
39
#endif
40

    
41
    return app;
42
  });
43
}
(3-3/4)