1
|
#include <Wt/WApplication.h>
|
2
|
#include <Wt/WColor.h>
|
3
|
#include <Wt/WContainerWidget.h>
|
4
|
#include <Wt/WCssDecorationStyle.h>
|
5
|
#include <Wt/WHBoxLayout.h>
|
6
|
#include <Wt/WText.h>
|
7
|
#include <Wt/WVBoxLayout.h>
|
8
|
|
9
|
#include <memory>
|
10
|
|
11
|
class Application final : public Wt::WApplication {
|
12
|
public:
|
13
|
explicit Application(const Wt::WEnvironment& env);
|
14
|
|
15
|
void initialize() override;
|
16
|
};
|
17
|
|
18
|
Application::Application(const Wt::WEnvironment &env)
|
19
|
: Wt::WApplication(env)
|
20
|
{}
|
21
|
|
22
|
void Application::initialize()
|
23
|
{
|
24
|
auto vLayout = root()->setLayout(std::make_unique<Wt::WVBoxLayout>());
|
25
|
|
26
|
vLayout->setContentsMargins(0, 0, 0, 0);
|
27
|
vLayout->setSpacing(0);
|
28
|
|
29
|
auto description = vLayout->addWidget(std::make_unique<Wt::WText>(), 0);
|
30
|
description->setTextFormat(Wt::TextFormat::XHTML);
|
31
|
description->setText(Wt::utf8(
|
32
|
"<h1>Box layout inconsistency</h1>"
|
33
|
"<p>Note the difference between flex implementation (top), "
|
34
|
"and JS implementation (bottom)</p>"));
|
35
|
|
36
|
auto top = vLayout->addWidget(std::make_unique<Wt::WContainerWidget>(), 1);
|
37
|
auto bottom = vLayout->addWidget(std::make_unique<Wt::WContainerWidget>(), 1);
|
38
|
|
39
|
for (auto& container : {top, bottom}){
|
40
|
auto layout = container->setLayout(std::make_unique<Wt::WHBoxLayout>());
|
41
|
|
42
|
if (container == bottom) {
|
43
|
layout->setPreferredImplementation(Wt::LayoutImplementation::JavaScript);
|
44
|
}
|
45
|
|
46
|
layout->setContentsMargins(0, 0, 0, 0);
|
47
|
layout->setSpacing(40);
|
48
|
|
49
|
auto container1 = layout->addWidget(std::make_unique<Wt::WContainerWidget>());
|
50
|
auto container2 = layout->addWidget(std::make_unique<Wt::WContainerWidget>());
|
51
|
auto container3 = layout->addWidget(std::make_unique<Wt::WContainerWidget>());
|
52
|
|
53
|
container1->decorationStyle().setBackgroundColor(Wt::StandardColor::Red);
|
54
|
container2->decorationStyle().setBackgroundColor(Wt::StandardColor::Green);
|
55
|
container3->decorationStyle().setBackgroundColor(Wt::StandardColor::Blue);
|
56
|
}
|
57
|
}
|
58
|
|
59
|
int main(int argc, char** argv)
|
60
|
{
|
61
|
return Wt::WRun(argc, argv, [](const Wt::WEnvironment& env) {
|
62
|
return std::make_unique<Application>(env);
|
63
|
});
|
64
|
}
|