Project

General

Profile

Bug #7550 » main.cpp

full example - Stefan Wegele, 05/01/2020 05:47 PM

 
1
#include <iostream>
2
#include <Wt/WApplication.h>
3
#include <Wt/WBreak.h>
4
#include <Wt/WContainerWidget.h>
5
#include <Wt/WLineEdit.h>
6
#include <Wt/WPushButton.h>
7
#include <Wt/WText.h>
8
#include <Wt/WGridLayout.h>
9
#include <Wt/WVBoxLayout.h>
10
#include <Wt/WStackedWidget.h>
11
#include <Wt/WCssDecorationStyle.h>
12

    
13
using namespace std;
14

    
15
class HelloApplication : public Wt::WApplication
16
{
17
public:
18
  HelloApplication(const Wt::WEnvironment& env) : Wt::WApplication(env)
19
  {
20
    setTitle("Hello world");
21
    Wt::WCssDecorationStyle style;
22

    
23
    auto vbox = Wt::cpp14::make_unique<Wt::WVBoxLayout>();
24
    auto contentsStack = Wt::cpp14::make_unique<Wt::WStackedWidget>();
25
    style.setBackgroundColor(Wt::WColor(230, 230, 230));
26
    contentsStack->setDecorationStyle(style);
27

    
28
    auto view = Wt::cpp14::make_unique<Wt::WContainerWidget>();
29
    style.setBackgroundColor(Wt::WColor(130, 130, 130));
30
    view->setDecorationStyle(style);
31

    
32
    auto grid = Wt::cpp14::make_unique<Wt::WGridLayout>();
33
    grid->addWidget(Wt::cpp14::make_unique<Wt::WText>("Item 1"), 0, 0);
34
    grid->addWidget(Wt::cpp14::make_unique<Wt::WText>("Item 2"), 1, 0);
35
    view->setLayout(std::move(grid));
36

    
37
    contentsStack->addWidget(std::move(view));
38

    
39
    vbox->addWidget(std::move(contentsStack));
40
    root()->setLayout(std::move(vbox));
41
  }
42
};
43

    
44
int main(int argc, char **argv)
45
{
46
  return Wt::WRun(argc, argv, [](const Wt::WEnvironment& env) {
47
    return Wt::cpp14::make_unique<HelloApplication>(env);
48
  });
49
}
50

    
51

    
(3-3/3)