Disable stack execution on plugins
[claws.git] / src / plugins / litehtml_viewer / litehtml / borders.h
blobe690db6d34d331fd8dae1e71c6c266c7e363e07a
1 #ifndef LH_BORDERS_H
2 #define LH_BORDERS_H
4 #include "css_length.h"
5 #include "types.h"
6 #include "web_color.h"
8 namespace litehtml
10 struct css_border
12 css_length width;
13 border_style style;
14 web_color color;
16 css_border()
18 style = border_style_none;
21 css_border(const css_border& val)
23 width = val.width;
24 style = val.style;
25 color = val.color;
28 css_border& operator=(const css_border& val)
30 width = val.width;
31 style = val.style;
32 color = val.color;
33 return *this;
36 string to_string() const;
39 struct border
41 int width;
42 border_style style;
43 web_color color;
45 border()
47 width = 0;
49 border(const border& val)
51 width = val.width;
52 style = val.style;
53 color = val.color;
55 border(const css_border& val)
57 width = (int) val.width.val();
58 style = val.style;
59 color = val.color;
61 border& operator=(const border& val)
63 width = val.width;
64 style = val.style;
65 color = val.color;
66 return *this;
68 border& operator=(const css_border& val)
70 width = (int) val.width.val();
71 style = val.style;
72 color = val.color;
73 return *this;
77 struct border_radiuses
79 int top_left_x;
80 int top_left_y;
82 int top_right_x;
83 int top_right_y;
85 int bottom_right_x;
86 int bottom_right_y;
88 int bottom_left_x;
89 int bottom_left_y;
91 border_radiuses()
93 top_left_x = 0;
94 top_left_y = 0;
95 top_right_x = 0;
96 top_right_y = 0;
97 bottom_right_x = 0;
98 bottom_right_y = 0;
99 bottom_left_x = 0;
100 bottom_left_y = 0;
102 border_radiuses(const border_radiuses& val)
104 top_left_x = val.top_left_x;
105 top_left_y = val.top_left_y;
106 top_right_x = val.top_right_x;
107 top_right_y = val.top_right_y;
108 bottom_right_x = val.bottom_right_x;
109 bottom_right_y = val.bottom_right_y;
110 bottom_left_x = val.bottom_left_x;
111 bottom_left_y = val.bottom_left_y;
113 border_radiuses& operator = (const border_radiuses& val)
115 top_left_x = val.top_left_x;
116 top_left_y = val.top_left_y;
117 top_right_x = val.top_right_x;
118 top_right_y = val.top_right_y;
119 bottom_right_x = val.bottom_right_x;
120 bottom_right_y = val.bottom_right_y;
121 bottom_left_x = val.bottom_left_x;
122 bottom_left_y = val.bottom_left_y;
123 return *this;
125 void operator += (const margins& mg)
127 top_left_x += mg.left;
128 top_left_y += mg.top;
129 top_right_x += mg.right;
130 top_right_y += mg.top;
131 bottom_right_x += mg.right;
132 bottom_right_y += mg.bottom;
133 bottom_left_x += mg.left;
134 bottom_left_y += mg.bottom;
135 fix_values();
137 void operator -= (const margins& mg)
139 top_left_x -= mg.left;
140 top_left_y -= mg.top;
141 top_right_x -= mg.right;
142 top_right_y -= mg.top;
143 bottom_right_x -= mg.right;
144 bottom_right_y -= mg.bottom;
145 bottom_left_x -= mg.left;
146 bottom_left_y -= mg.bottom;
147 fix_values();
149 void fix_values()
151 if (top_left_x < 0) top_left_x = 0;
152 if (top_left_y < 0) top_left_y = 0;
153 if (top_right_x < 0) top_right_x = 0;
154 if (top_right_y < 0) top_right_y = 0;
155 if (bottom_right_x < 0) bottom_right_x = 0;
156 if (bottom_right_y < 0) bottom_right_y = 0;
157 if (bottom_left_x < 0) bottom_left_x = 0;
158 if (bottom_left_y < 0) bottom_left_y = 0;
162 struct css_border_radius
164 css_length top_left_x;
165 css_length top_left_y;
167 css_length top_right_x;
168 css_length top_right_y;
170 css_length bottom_right_x;
171 css_length bottom_right_y;
173 css_length bottom_left_x;
174 css_length bottom_left_y;
176 css_border_radius()
181 css_border_radius(const css_border_radius& val)
183 top_left_x = val.top_left_x;
184 top_left_y = val.top_left_y;
185 top_right_x = val.top_right_x;
186 top_right_y = val.top_right_y;
187 bottom_left_x = val.bottom_left_x;
188 bottom_left_y = val.bottom_left_y;
189 bottom_right_x = val.bottom_right_x;
190 bottom_right_y = val.bottom_right_y;
193 css_border_radius& operator=(const css_border_radius& val)
195 top_left_x = val.top_left_x;
196 top_left_y = val.top_left_y;
197 top_right_x = val.top_right_x;
198 top_right_y = val.top_right_y;
199 bottom_left_x = val.bottom_left_x;
200 bottom_left_y = val.bottom_left_y;
201 bottom_right_x = val.bottom_right_x;
202 bottom_right_y = val.bottom_right_y;
203 return *this;
205 border_radiuses calc_percents(int width, int height) const
207 border_radiuses ret;
208 ret.bottom_left_x = bottom_left_x.calc_percent(width);
209 ret.bottom_left_y = bottom_left_y.calc_percent(height);
210 ret.top_left_x = top_left_x.calc_percent(width);
211 ret.top_left_y = top_left_y.calc_percent(height);
212 ret.top_right_x = top_right_x.calc_percent(width);
213 ret.top_right_y = top_right_y.calc_percent(height);
214 ret.bottom_right_x = bottom_right_x.calc_percent(width);
215 ret.bottom_right_y = bottom_right_y.calc_percent(height);
216 return ret;
220 struct css_borders
222 css_border left;
223 css_border top;
224 css_border right;
225 css_border bottom;
226 css_border_radius radius;
228 css_borders() = default;
230 bool is_visible() const
232 return left.width.val() != 0 || right.width.val() != 0 || top.width.val() != 0 || bottom.width.val() != 0;
235 css_borders(const css_borders& val)
237 left = val.left;
238 right = val.right;
239 top = val.top;
240 bottom = val.bottom;
241 radius = val.radius;
244 css_borders& operator=(const css_borders& val)
246 left = val.left;
247 right = val.right;
248 top = val.top;
249 bottom = val.bottom;
250 radius = val.radius;
251 return *this;
253 string to_string() const
255 return "left: " + left.to_string() +
256 ", top: " + top.to_string() +
257 ", right: " + top.to_string() +
258 ", bottom: " + bottom.to_string();
262 struct borders
264 border left;
265 border top;
266 border right;
267 border bottom;
268 border_radiuses radius;
270 borders() = default;
272 borders(const borders& val)
274 left = val.left;
275 right = val.right;
276 top = val.top;
277 bottom = val.bottom;
278 radius = val.radius;
281 borders(const css_borders& val)
283 left = val.left;
284 right = val.right;
285 top = val.top;
286 bottom = val.bottom;
289 bool is_visible() const
291 return left.width != 0 || right.width != 0 || top.width != 0 || bottom.width != 0;
294 borders& operator=(const borders& val)
296 left = val.left;
297 right = val.right;
298 top = val.top;
299 bottom = val.bottom;
300 radius = val.radius;
301 return *this;
304 borders& operator=(const css_borders& val)
306 left = val.left;
307 right = val.right;
308 top = val.top;
309 bottom = val.bottom;
310 return *this;
315 #endif // LH_BORDERS_H