Project

General

Profile

Bug #7396 » forum_16637_2.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
#include <Wt/WVBoxLayout.h>
9
#include <Wt/WLabel.h>
10

    
11

    
12
#include <memory>
13

    
14
// set to 1 to test with a dialog instead
15
#define DIALOG 0
16

    
17
using namespace Wt;
18

    
19

    
20
int main(int argc, char *argv[])
21
{
22
  return Wt::WRun(argc, argv, [](const Wt::WEnvironment &env) {
23
    auto app = std::make_unique<Wt::WApplication>(env);
24

    
25
    auto theme = std::make_shared<Wt::WBootstrapTheme>();
26
    theme->setVersion(Wt::BootstrapVersion::v3);
27
    app->setTheme(theme);
28

    
29
#if DIALOG
30
    Wt::WDialog *dialog = app->addChild(std::make_unique<Wt::WDialog>());
31
    dialog->resize(300, 150);
32
    dialog->setTitleBarEnabled(true);
33
    dialog->titleBar()->addNew<Wt::WText>("Titlebar");
34
    dialog->contents()->addNew<Wt::WDateEdit>();
35

    
36
    dialog->show();
37
#else
38
    WVBoxLayout *mainLayout;
39

    
40
    auto layout = std::make_unique<WVBoxLayout>();
41
    mainLayout = layout.get();
42

    
43
    app->root()->setLayout(std::move(layout));
44

    
45
    auto mainContainer = mainLayout->addWidget(std::make_unique<WContainerWidget>());
46
    auto rightLayout = mainContainer->setLayout(std::make_unique<WVBoxLayout>());
47

    
48

    
49
    Wt::WPanel *panel = rightLayout->addWidget(std::make_unique<WPanel>());
50
    panel->setTitle(Wt::utf8("Titlebar"));
51
    auto containerPtr = std::make_unique<Wt::WContainerWidget>();
52
    auto container = containerPtr.get();
53
    container->setMargin(50);
54
    panel->setCentralWidget(std::move(containerPtr));
55
    container->addNew<Wt::WDateEdit>();
56

    
57
    rightLayout->addWidget(std::make_unique<WText>("Popup Cut Off Example"));
58
    rightLayout->addWidget(std::make_unique<WLabel>(), 1);
59

    
60

    
61
#endif
62

    
63
    return app;
64
  });
65
}
(4-4/4)