-
Notifications
You must be signed in to change notification settings - Fork 388
Expand file tree
/
Copy pathWBootstrapTheme.C
More file actions
166 lines (138 loc) · 4.01 KB
/
WBootstrapTheme.C
File metadata and controls
166 lines (138 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
* Copyright (C) 2012 Emweb bv, Herent, Belgium.
*
* See the LICENSE file for terms of use.
*/
#include "Wt/WBootstrapTheme.h"
#include "Wt/WBootstrap2Theme.h"
#include "Wt/WBootstrap3Theme.h"
#include "Wt/WLinkedCssStyleSheet.h"
#include <cassert>
#include <memory>
namespace Wt {
WBootstrapTheme::WBootstrapTheme()
: impl_(std::make_unique<WBootstrap2Theme>()),
version_(BootstrapVersion::v2),
formControlStyle_(true)
{ }
WBootstrapTheme::~WBootstrapTheme()
{ }
std::string WBootstrapTheme::name() const
{
return impl_->name();
}
std::string WBootstrapTheme::resourcesUrl() const
{
return impl_->resourcesUrl();
}
std::vector<WLinkedCssStyleSheet> WBootstrapTheme::styleSheets() const
{
return impl_->styleSheets();
}
void WBootstrapTheme::init(WApplication *app) const
{
impl_->init(app);
}
void WBootstrapTheme::apply(WWidget *widget, WWidget *child, int widgetRole)
const
{
impl_->apply(widget, child, widgetRole);
}
void WBootstrapTheme::apply(WWidget *widget, DomElement& element,
int elementRole) const
{
impl_->apply(widget, element, elementRole);
}
std::string WBootstrapTheme::disabledClass() const
{
return impl_->disabledClass();
}
std::string WBootstrapTheme::activeClass() const
{
return impl_->activeClass();
}
std::string WBootstrapTheme::utilityCssClass(int utilityCssClassRole) const
{
return impl_->utilityCssClass(utilityCssClassRole);
}
bool WBootstrapTheme::canStyleAnchorAsButton() const
{
return impl_->canStyleAnchorAsButton();
}
void WBootstrapTheme::loadValidationStyling(WApplication* app) const
{
impl_->loadValidationStyling(app);
}
void WBootstrapTheme
::applyValidationStyle(WWidget *widget,
const Wt::WValidator::Result& validation,
WFlags<ValidationStyleFlag> styles) const
{
impl_->applyValidationStyle(widget, validation, styles);
}
bool WBootstrapTheme::canBorderBoxElement(const DomElement& element) const
{
return impl_->canBorderBoxElement(element);
}
void WBootstrapTheme::setVersion(BootstrapVersion version)
{
if (version_ == version)
return;
if (version == BootstrapVersion::v2) {
auto bootstrap2 = std::make_unique<WBootstrap2Theme>();
bootstrap2->setResponsive(responsive());
impl_ = std::move(bootstrap2);
} else {
auto bootstrap3 = std::make_unique<WBootstrap3Theme>();
bootstrap3->setResponsive(responsive());
bootstrap3->setFormControlStyleEnabled(formControlStyle_);
impl_ = std::move(bootstrap3);
}
version_ = version;
}
void WBootstrapTheme::setResponsive(bool enabled)
{
if (version() == BootstrapVersion::v2) {
auto bootstrap2 = dynamic_cast<WBootstrap2Theme*>(impl_.get());
assert(bootstrap2);
bootstrap2->setResponsive(enabled);
} else {
auto bootstrap3 = dynamic_cast<WBootstrap3Theme*>(impl_.get());
assert(bootstrap3);
bootstrap3->setResponsive(enabled);
}
}
bool WBootstrapTheme::responsive() const
{
if (version() == BootstrapVersion::v2) {
auto bootstrap2 = dynamic_cast<const WBootstrap2Theme*>(impl_.get());
assert(bootstrap2);
return bootstrap2->responsive();
} else {
auto bootstrap3 = dynamic_cast<const WBootstrap3Theme*>(impl_.get());
assert(bootstrap3);
return bootstrap3->responsive();
}
}
void WBootstrapTheme::setFormControlStyleEnabled(bool enabled)
{
formControlStyle_ = enabled;
if (version() == BootstrapVersion::v3) {
auto bootstrap3 = dynamic_cast<WBootstrap3Theme*>(impl_.get());
assert(bootstrap3);
bootstrap3->setFormControlStyleEnabled(enabled);
}
}
void WBootstrapTheme::applyFunctionalStyling(WWidget *widget,
WWidget *child,
int widgetRole) const
{
impl_->applyFunctionalStyling(widget, child, widgetRole);
}
void WBootstrapTheme::applyOptionalStyling(WWidget *widget,
WWidget *child,
int widgetRole) const
{
impl_->applyOptionalStyling(widget, child, widgetRole);
}
}