reflexion 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.doc/ext/reflex/application.cpp +54 -39
- data/.doc/ext/reflex/capture_event.cpp +87 -0
- data/.doc/ext/reflex/draw_event.cpp +103 -0
- data/.doc/ext/reflex/event.cpp +73 -0
- data/.doc/ext/reflex/focus_event.cpp +98 -0
- data/.doc/ext/reflex/frame_event.cpp +133 -0
- data/.doc/ext/reflex/image_view.cpp +74 -0
- data/.doc/ext/reflex/key_event.cpp +124 -0
- data/.doc/ext/reflex/native.cpp +45 -6
- data/.doc/ext/reflex/pointer_event.cpp +181 -0
- data/.doc/ext/reflex/reflex.cpp +17 -41
- data/.doc/ext/reflex/scroll_event.cpp +141 -0
- data/.doc/ext/reflex/selector.cpp +135 -0
- data/.doc/ext/reflex/style.cpp +253 -0
- data/.doc/ext/reflex/style_length.cpp +133 -0
- data/.doc/ext/reflex/style_length2.cpp +149 -0
- data/.doc/ext/reflex/style_length4.cpp +192 -0
- data/.doc/ext/reflex/update_event.cpp +77 -0
- data/.doc/ext/reflex/view.cpp +408 -88
- data/.doc/ext/reflex/wheel_event.cpp +146 -0
- data/.doc/ext/reflex/window.cpp +95 -92
- data/Rakefile +6 -5
- data/VERSION +1 -1
- data/ext/reflex/application.cpp +67 -49
- data/ext/reflex/capture_event.cpp +92 -0
- data/ext/reflex/draw_event.cpp +110 -0
- data/ext/reflex/event.cpp +77 -0
- data/ext/reflex/extconf.rb +18 -68
- data/ext/reflex/focus_event.cpp +104 -0
- data/ext/reflex/frame_event.cpp +143 -0
- data/ext/reflex/image_view.cpp +77 -0
- data/ext/reflex/key_event.cpp +133 -0
- data/ext/reflex/native.cpp +45 -6
- data/ext/reflex/pointer_event.cpp +195 -0
- data/ext/reflex/reflex.cpp +21 -47
- data/ext/reflex/scroll_event.cpp +152 -0
- data/ext/reflex/selector.cpp +144 -0
- data/ext/reflex/style.cpp +277 -0
- data/ext/reflex/style_length.cpp +140 -0
- data/ext/reflex/style_length2.cpp +157 -0
- data/ext/reflex/style_length4.cpp +204 -0
- data/ext/reflex/update_event.cpp +81 -0
- data/ext/reflex/view.cpp +469 -114
- data/ext/reflex/wheel_event.cpp +158 -0
- data/ext/reflex/window.cpp +130 -123
- data/include/reflex/application.h +12 -7
- data/include/reflex/defs.h +13 -89
- data/include/reflex/event.h +260 -0
- data/include/reflex/exception.h +17 -11
- data/include/reflex/image_view.h +45 -0
- data/include/reflex/reflex.h +2 -6
- data/include/reflex/ruby/application.h +40 -13
- data/include/reflex/ruby/event.h +72 -0
- data/include/reflex/ruby/image_view.h +25 -0
- data/include/reflex/ruby/selector.h +27 -0
- data/include/reflex/ruby/style.h +27 -0
- data/include/reflex/ruby/style_length.h +37 -0
- data/include/reflex/ruby/view.h +193 -38
- data/include/reflex/ruby/window.h +123 -39
- data/include/reflex/ruby.h +3 -2
- data/include/reflex/selector.h +64 -0
- data/include/reflex/style.h +144 -0
- data/include/reflex/style_length.h +147 -0
- data/include/reflex/view.h +182 -19
- data/include/reflex/window.h +35 -19
- data/include/reflex.h +7 -0
- data/lib/reflex/application.rb +14 -5
- data/lib/reflex/arc_shape.rb +20 -0
- data/lib/reflex/button.rb +75 -0
- data/lib/reflex/capture_event.rb +37 -0
- data/lib/reflex/color.rb +13 -0
- data/lib/reflex/color_space.rb +13 -0
- data/lib/reflex/draw_event.rb +19 -0
- data/lib/reflex/ellipse_shape.rb +20 -0
- data/lib/reflex/ext.rb +1 -1
- data/lib/reflex/flags.rb +18 -0
- data/lib/reflex/focus_event.rb +38 -0
- data/lib/reflex/font.rb +13 -0
- data/lib/reflex/frame_event.rb +42 -0
- data/lib/reflex/helper.rb +87 -30
- data/lib/reflex/image_view.rb +25 -0
- data/lib/reflex/key_event.rb +38 -0
- data/lib/reflex/line_shape.rb +20 -0
- data/lib/reflex/list_view.rb +15 -0
- data/lib/reflex/model.rb +149 -0
- data/lib/reflex/model_owner.rb +57 -0
- data/lib/reflex/model_view.rb +22 -0
- data/lib/reflex/module.rb +11 -7
- data/lib/reflex/pointer_event.rb +85 -0
- data/lib/reflex/rect_shape.rb +20 -0
- data/lib/reflex/reflex.rb +13 -2
- data/lib/reflex/scroll_event.rb +19 -0
- data/lib/reflex/selector.rb +31 -0
- data/lib/reflex/shader.rb +13 -0
- data/lib/reflex/shape.rb +34 -0
- data/lib/reflex/style.rb +55 -0
- data/lib/reflex/style_length.rb +30 -0
- data/lib/reflex/style_length2.rb +34 -0
- data/lib/reflex/style_length4.rb +38 -0
- data/lib/reflex/text_view.rb +55 -0
- data/lib/reflex/update_event.rb +19 -0
- data/lib/reflex/view.rb +38 -4
- data/lib/reflex/wheel_event.rb +19 -0
- data/lib/reflex/window.rb +7 -5
- data/lib/reflex.rb +38 -1
- data/lib/reflexion/include.rb +5 -0
- data/lib/reflexion.rb +100 -0
- data/reflex.gemspec +3 -4
- data/samples/app.rb +13 -0
- data/samples/bats.rb +91 -0
- data/samples/checker.rb +36 -0
- data/{examples/ruby/shapes.rb → samples/fans.rb} +12 -16
- data/samples/fps.rb +46 -0
- data/samples/grid.rb +60 -0
- data/{examples/ruby → samples}/hello.rb +14 -16
- data/samples/image.rb +44 -0
- data/samples/ios/hello/hello/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- data/samples/ios/hello/hello/Images.xcassets/LaunchImage.launchimage/Contents.json +51 -0
- data/samples/ios/hello/hello/en.lproj/InfoPlist.strings +2 -0
- data/samples/ios/hello/hello/hello-Info.plist +47 -0
- data/samples/ios/hello/hello/hello-Prefix.pch +10 -0
- data/samples/ios/hello/hello/main.cpp +79 -0
- data/samples/ios/hello/hello.xcodeproj/project.pbxproj +725 -0
- data/{examples/ruby → samples}/key.rb +11 -14
- data/samples/layout.rb +89 -0
- data/samples/model.rb +86 -0
- data/samples/osx/hello/hello/Images.xcassets/AppIcon.appiconset/Contents.json +58 -0
- data/samples/osx/hello/hello/en.lproj/Credits.rtf +29 -0
- data/samples/osx/hello/hello/en.lproj/InfoPlist.strings +2 -0
- data/samples/osx/hello/hello/hello-Info.plist +32 -0
- data/samples/osx/hello/hello/hello-Prefix.pch +3 -0
- data/samples/osx/hello/hello/main.cpp +79 -0
- data/samples/osx/hello/hello.xcodeproj/project.pbxproj +725 -0
- data/samples/reflexion/hello.rb +24 -0
- data/samples/reflexion/paint.rb +40 -0
- data/samples/reflexion/pulse.rb +34 -0
- data/samples/repl.rb +69 -0
- data/samples/shader.rb +41 -0
- data/samples/shapes.rb +30 -0
- data/{examples/ruby → samples}/text.rb +7 -8
- data/samples/tree.rb +71 -0
- data/samples/views.rb +41 -0
- data/samples/visuals.rb +22 -0
- data/src/event.cpp +225 -0
- data/src/exception.cpp +24 -15
- data/src/image_view.cpp +70 -0
- data/src/ios/app_delegate.h +17 -0
- data/src/ios/app_delegate.mm +120 -0
- data/src/ios/application.mm +116 -0
- data/src/{cocoa/applicationdata.h → ios/application_data.h} +6 -6
- data/src/ios/event.h +26 -0
- data/src/ios/event.mm +31 -0
- data/src/ios/native_window.h +37 -0
- data/src/ios/native_window.mm +220 -0
- data/src/ios/opengl_view.h +13 -0
- data/src/ios/opengl_view.mm +131 -0
- data/src/{cocoa → ios}/reflex.mm +8 -12
- data/src/ios/window.mm +303 -0
- data/src/ios/window_data.h +75 -0
- data/src/osx/app_delegate.h +17 -0
- data/src/{cocoa/cocoaapplication.mm → osx/app_delegate.mm} +90 -48
- data/src/osx/application.mm +132 -0
- data/src/osx/application_data.h +45 -0
- data/src/osx/event.h +42 -0
- data/src/osx/event.mm +112 -0
- data/src/osx/native_window.h +26 -0
- data/src/osx/native_window.mm +322 -0
- data/src/{cocoa/openglview.h → osx/opengl_view.h} +0 -4
- data/src/{cocoa/openglview.mm → osx/opengl_view.mm} +66 -23
- data/src/osx/reflex.mm +50 -0
- data/src/osx/window.mm +308 -0
- data/src/osx/window_data.h +75 -0
- data/src/selector.cpp +121 -0
- data/src/style.cpp +576 -0
- data/src/style_length.cpp +341 -0
- data/src/view.cpp +1228 -129
- data/src/win32/application.cpp +1 -1
- data/src/window.cpp +54 -26
- data/test/helper.rb +8 -4
- data/test/test_capture_event.rb +41 -0
- data/test/test_event.rb +20 -0
- data/test/test_has_frame.rb +45 -0
- data/test/test_model.rb +9 -0
- data/test/test_model_owner.rb +9 -0
- data/test/test_selector.rb +75 -0
- data/test/test_style.rb +70 -0
- data/test/test_style_length.rb +38 -0
- data/test/test_style_length2.rb +50 -0
- data/test/test_style_length4.rb +56 -0
- data/test/test_view.rb +97 -23
- data/test/test_window.rb +54 -46
- metadata +205 -84
- data/.doc/ext/reflex/defs.cpp +0 -8
- data/.doc/ext/reflex/key.cpp +0 -122
- data/.doc/ext/reflex/points.cpp +0 -151
- data/.gitignore +0 -14
- data/ChangeLog +0 -8
- data/examples/hello/.gitignore +0 -2
- data/examples/hello/Rakefile +0 -41
- data/examples/hello/main.cpp +0 -18
- data/examples/ruby/app.rb +0 -13
- data/examples/ruby/checker.rb +0 -41
- data/examples/ruby/fps.rb +0 -49
- data/examples/ruby/grid.rb +0 -65
- data/examples/ruby/views.rb +0 -88
- data/examples/ruby/visuals.rb +0 -27
- data/ext/reflex/defs.cpp +0 -8
- data/ext/reflex/key.cpp +0 -129
- data/ext/reflex/points.cpp +0 -161
- data/include/reflex/ruby/key.h +0 -39
- data/include/reflex/ruby/points.h +0 -39
- data/lib/reflex/visuals/string.rb +0 -53
- data/src/cocoa/application.mm +0 -101
- data/src/cocoa/cocoaapplication.h +0 -21
- data/src/cocoa/cocoawindow.h +0 -46
- data/src/cocoa/cocoawindow.mm +0 -230
- data/src/cocoa/defs.h +0 -34
- data/src/cocoa/defs.mm +0 -87
- data/src/cocoa/window.mm +0 -148
- data/src/cocoa/windowdata.h +0 -56
- data/src/defs.cpp +0 -47
- data/src/helper.h +0 -12
- data/src/reflex.cpp +0 -43
- /data/{README → README.md} +0 -0
data/src/style.cpp
ADDED
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
#include "reflex/style.h"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#include <boost/noncopyable.hpp>
|
|
5
|
+
#include "reflex/view.h"
|
|
6
|
+
#include "reflex/exception.h"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
namespace Reflex
|
|
10
|
+
{
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
template <typename T>
|
|
14
|
+
class StyleValue
|
|
15
|
+
{
|
|
16
|
+
|
|
17
|
+
typedef StyleValue<T> This;
|
|
18
|
+
|
|
19
|
+
typedef T Value;
|
|
20
|
+
|
|
21
|
+
class Wrapper : public boost::noncopyable, public Xot::RefCountable<>
|
|
22
|
+
{
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
|
|
26
|
+
Wrapper () {}
|
|
27
|
+
|
|
28
|
+
Wrapper (const Value& value) : value(value) {}
|
|
29
|
+
|
|
30
|
+
void reset (const Value& value_) {value = value_;}
|
|
31
|
+
|
|
32
|
+
Value& get () {return value;}
|
|
33
|
+
|
|
34
|
+
const Value& get () const {return value;}
|
|
35
|
+
|
|
36
|
+
private:
|
|
37
|
+
|
|
38
|
+
Value value;
|
|
39
|
+
|
|
40
|
+
};// Wrapper
|
|
41
|
+
|
|
42
|
+
public:
|
|
43
|
+
|
|
44
|
+
StyleValue ()
|
|
45
|
+
: pwrapper(NULL)
|
|
46
|
+
{
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
StyleValue (const Value& value)
|
|
50
|
+
: pwrapper(NULL)
|
|
51
|
+
{
|
|
52
|
+
operator=(value);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
StyleValue (const This& obj)
|
|
56
|
+
: pwrapper(NULL)
|
|
57
|
+
{
|
|
58
|
+
operator=(obj);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
This& operator = (const Value& value)
|
|
62
|
+
{
|
|
63
|
+
reset(new Wrapper(value));
|
|
64
|
+
return *this;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
This& operator = (const This& obj)
|
|
68
|
+
{
|
|
69
|
+
if (&obj != this) reset(obj.pwrapper);
|
|
70
|
+
return *this;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
~StyleValue ()
|
|
74
|
+
{
|
|
75
|
+
clear();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
void clear ()
|
|
79
|
+
{
|
|
80
|
+
reset();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
Value& value (bool create = false)
|
|
84
|
+
{
|
|
85
|
+
Wrapper* p = pointer();
|
|
86
|
+
if (!p)
|
|
87
|
+
{
|
|
88
|
+
if (create)
|
|
89
|
+
p = reset(new Wrapper());
|
|
90
|
+
else
|
|
91
|
+
invalid_state_error(__FILE__, __LINE__);
|
|
92
|
+
}
|
|
93
|
+
return p->get();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const Value& value (bool create = false) const
|
|
97
|
+
{
|
|
98
|
+
return const_cast<This*>(this)->value(create);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
void set_inherited (bool state = true)
|
|
102
|
+
{
|
|
103
|
+
if (pointer()) pwrapper = Xot::set_pointer_flag(pwrapper, state);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
bool is_inherited () const
|
|
107
|
+
{
|
|
108
|
+
return get_pointer_flag(pwrapper);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
operator bool () const {return pointer() != NULL;}
|
|
112
|
+
|
|
113
|
+
bool operator ! () const {return !operator bool();}
|
|
114
|
+
|
|
115
|
+
private:
|
|
116
|
+
|
|
117
|
+
Wrapper* pwrapper;
|
|
118
|
+
|
|
119
|
+
Wrapper* reset (Wrapper* ptr = NULL)
|
|
120
|
+
{
|
|
121
|
+
Wrapper* p = pointer();
|
|
122
|
+
if (ptr != p)
|
|
123
|
+
{
|
|
124
|
+
if (p) p->release();
|
|
125
|
+
pwrapper = p = ptr;
|
|
126
|
+
if (p) p->retain();
|
|
127
|
+
}
|
|
128
|
+
return p;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
Wrapper* pointer () {return Xot::set_pointer_flag(pwrapper, false);}
|
|
132
|
+
|
|
133
|
+
const Wrapper* pointer () const {return const_cast<StyleValue*>(this)->pointer();}
|
|
134
|
+
|
|
135
|
+
};// StyleValue
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
struct Style::Data : public Xot::RefCountable<>
|
|
139
|
+
{
|
|
140
|
+
|
|
141
|
+
typedef StyleValue<bool> Bool;
|
|
142
|
+
|
|
143
|
+
typedef StyleValue<int> Int;
|
|
144
|
+
|
|
145
|
+
typedef StyleValue<double> Float;
|
|
146
|
+
|
|
147
|
+
typedef StyleValue<StyleLength> Length;
|
|
148
|
+
|
|
149
|
+
typedef StyleValue<StyleLength2> Length2;
|
|
150
|
+
|
|
151
|
+
typedef StyleValue<StyleLength4> Length4;
|
|
152
|
+
|
|
153
|
+
typedef StyleValue<Rays::Color> Color;
|
|
154
|
+
|
|
155
|
+
typedef StyleValue<Rays::Image> Image;
|
|
156
|
+
|
|
157
|
+
View* owner;
|
|
158
|
+
|
|
159
|
+
Selector selector;
|
|
160
|
+
|
|
161
|
+
Int flow_main, flow_sub;
|
|
162
|
+
|
|
163
|
+
Length2 size;
|
|
164
|
+
|
|
165
|
+
Length4 position, offset, margin, padding;
|
|
166
|
+
|
|
167
|
+
Color background_color;
|
|
168
|
+
|
|
169
|
+
Image background_image;
|
|
170
|
+
|
|
171
|
+
Data () : owner(NULL) {}
|
|
172
|
+
|
|
173
|
+
};// Style::Data
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
namespace Zero
|
|
177
|
+
{
|
|
178
|
+
|
|
179
|
+
static const StyleLength length;
|
|
180
|
+
|
|
181
|
+
static const StyleLength2 length2;
|
|
182
|
+
|
|
183
|
+
static const StyleLength4 length4;
|
|
184
|
+
|
|
185
|
+
static const Color color(0);
|
|
186
|
+
|
|
187
|
+
static const Image image;
|
|
188
|
+
|
|
189
|
+
}// Zero
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
static Style::Data*
|
|
193
|
+
get_data (Style* this_, bool create = false)
|
|
194
|
+
{
|
|
195
|
+
if (!this_)
|
|
196
|
+
argument_error(__FILE__, __LINE__);
|
|
197
|
+
|
|
198
|
+
if (create && !this_->ref)
|
|
199
|
+
this_->ref.reset(new Style::Data());
|
|
200
|
+
|
|
201
|
+
return this_->ref.get();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
static const Style::Data*
|
|
205
|
+
get_data (const Style* this_)
|
|
206
|
+
{
|
|
207
|
+
return get_data(const_cast<Style*>(this_));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
Style::Style (const char* name)
|
|
212
|
+
{
|
|
213
|
+
if (name) set_name(name);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
Style::Style (const This& obj)
|
|
217
|
+
: ref(obj.ref)
|
|
218
|
+
{
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
Style&
|
|
222
|
+
Style::operator = (const This& obj)
|
|
223
|
+
{
|
|
224
|
+
if (&obj != this) ref = obj.ref;
|
|
225
|
+
return *this;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
Style::~Style ()
|
|
229
|
+
{
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
void
|
|
233
|
+
Style::set_name (const char* name)
|
|
234
|
+
{
|
|
235
|
+
get_data(this, true)->selector.set_name(name);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const char*
|
|
239
|
+
Style::name () const
|
|
240
|
+
{
|
|
241
|
+
const Data* data = get_data(this);
|
|
242
|
+
return data ? data->selector.name() : NULL;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
void
|
|
246
|
+
Style::add_tag (const char* tag)
|
|
247
|
+
{
|
|
248
|
+
get_data(this, true)->selector.add_tag(tag);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
void
|
|
252
|
+
Style::remove_tag (const char* tag)
|
|
253
|
+
{
|
|
254
|
+
Data* data = get_data(this);
|
|
255
|
+
if (!data) return;
|
|
256
|
+
|
|
257
|
+
data->selector.remove_tag(tag);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
static Selector::TagSet empty_tags;
|
|
261
|
+
|
|
262
|
+
Selector::iterator
|
|
263
|
+
Style::tag_begin ()
|
|
264
|
+
{
|
|
265
|
+
Data* data = get_data(this);
|
|
266
|
+
return data ? data->selector.begin() : empty_tags.begin();
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
Selector::const_iterator
|
|
270
|
+
Style::tag_begin () const
|
|
271
|
+
{
|
|
272
|
+
const Data* data = get_data(this);
|
|
273
|
+
return data ? data->selector.begin() : empty_tags.begin();
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
Selector::iterator
|
|
277
|
+
Style::tag_end ()
|
|
278
|
+
{
|
|
279
|
+
Data* data = get_data(this);
|
|
280
|
+
return data ? data->selector.end() : empty_tags.end();
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
Selector::const_iterator
|
|
284
|
+
Style::tag_end () const
|
|
285
|
+
{
|
|
286
|
+
const Data* data = get_data(this);
|
|
287
|
+
return data ? data->selector.end() : empty_tags.end();
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
void
|
|
291
|
+
Style::set_selector (const Selector& selector)
|
|
292
|
+
{
|
|
293
|
+
get_data(this, true)->selector = selector;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
Selector&
|
|
297
|
+
Style::selector ()
|
|
298
|
+
{
|
|
299
|
+
return get_data(this, true)->selector;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const Selector&
|
|
303
|
+
Style::selector () const
|
|
304
|
+
{
|
|
305
|
+
static const Selector EMPTY;
|
|
306
|
+
|
|
307
|
+
const Data* data = get_data(this);
|
|
308
|
+
return data ? data->selector : EMPTY;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
enum FlowDir {FLOW_INVALID = 0, FLOW_H, FLOW_V};
|
|
312
|
+
|
|
313
|
+
static FlowDir
|
|
314
|
+
get_flow_dir (Style::Flow flow)
|
|
315
|
+
{
|
|
316
|
+
switch (flow)
|
|
317
|
+
{
|
|
318
|
+
case Style::FLOW_LEFT:
|
|
319
|
+
case Style::FLOW_RIGHT: return FLOW_H;
|
|
320
|
+
case Style::FLOW_UP:
|
|
321
|
+
case Style::FLOW_DOWN: return FLOW_V;
|
|
322
|
+
}
|
|
323
|
+
return FLOW_INVALID;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
void
|
|
327
|
+
Style::set_flow (Flow main, Flow sub)
|
|
328
|
+
{
|
|
329
|
+
if (
|
|
330
|
+
main < FLOW_NONE || FLOW_LAST <= main ||
|
|
331
|
+
sub < FLOW_NONE || FLOW_LAST <= sub ||
|
|
332
|
+
(main != FLOW_NONE && (get_flow_dir(main) == get_flow_dir(sub))) ||
|
|
333
|
+
(main == FLOW_NONE && sub != FLOW_NONE))
|
|
334
|
+
{
|
|
335
|
+
argument_error(__FILE__, __LINE__);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
Data* data = get_data(this, true);
|
|
339
|
+
data->flow_main = main;
|
|
340
|
+
data->flow_sub = sub;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
void
|
|
344
|
+
Style::get_flow (Flow* main, Flow* sub) const
|
|
345
|
+
{
|
|
346
|
+
if (!main && !sub)
|
|
347
|
+
argument_error(__FILE__, __LINE__);
|
|
348
|
+
|
|
349
|
+
const Data* data = get_data(this);
|
|
350
|
+
if (!data || (!data->flow_main && !data->flow_sub))
|
|
351
|
+
{
|
|
352
|
+
if (main) *main = FLOW_DOWN;
|
|
353
|
+
if (sub) *sub = FLOW_NONE;
|
|
354
|
+
}
|
|
355
|
+
else if (data->flow_main && data->flow_sub)
|
|
356
|
+
{
|
|
357
|
+
if (main) *main = (Flow) data->flow_main.value();
|
|
358
|
+
if (sub) *sub = (Flow) data->flow_sub.value();
|
|
359
|
+
}
|
|
360
|
+
else
|
|
361
|
+
invalid_state_error(__FILE__, __LINE__);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
void
|
|
365
|
+
Style::set_size (const StyleLength2& size)
|
|
366
|
+
{
|
|
367
|
+
get_data(this, true)->size = size;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
void
|
|
371
|
+
Style::set_width (const StyleLength& width)
|
|
372
|
+
{
|
|
373
|
+
get_data(this, true)->size.value(true).set_width(width);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
void
|
|
377
|
+
Style::set_height (const StyleLength& height)
|
|
378
|
+
{
|
|
379
|
+
get_data(this, true)->size.value(true).set_height(height);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const StyleLength2&
|
|
383
|
+
Style::size () const
|
|
384
|
+
{
|
|
385
|
+
const Data* data = get_data(this);
|
|
386
|
+
return data && data->size ? data->size.value() : Zero::length2;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
void
|
|
390
|
+
Style::set_position (const StyleLength4& position)
|
|
391
|
+
{
|
|
392
|
+
get_data(this, true)->position = position;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
void
|
|
396
|
+
Style::set_left (const StyleLength& left)
|
|
397
|
+
{
|
|
398
|
+
get_data(this, true)->position.value(true).set_left(left);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
void
|
|
402
|
+
Style::set_top (const StyleLength& top)
|
|
403
|
+
{
|
|
404
|
+
get_data(this, true)->position.value(true).set_top(top);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
void
|
|
408
|
+
Style::set_right (const StyleLength& right)
|
|
409
|
+
{
|
|
410
|
+
get_data(this, true)->position.value(true).set_right(right);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
void
|
|
414
|
+
Style::set_bottom (const StyleLength& bottom)
|
|
415
|
+
{
|
|
416
|
+
get_data(this, true)->position.value(true).set_bottom(bottom);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
const StyleLength4&
|
|
420
|
+
Style::position () const
|
|
421
|
+
{
|
|
422
|
+
const Data* data = get_data(this);
|
|
423
|
+
return data && data->position ? data->position.value() : Zero::length4;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
void
|
|
427
|
+
Style::set_offset (const StyleLength4& offset)
|
|
428
|
+
{
|
|
429
|
+
get_data(this, true)->offset = offset;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
void
|
|
433
|
+
Style::set_offset_left (const StyleLength& left)
|
|
434
|
+
{
|
|
435
|
+
get_data(this, true)->offset.value(true).set_left(left);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
void
|
|
439
|
+
Style::set_offset_top (const StyleLength& top)
|
|
440
|
+
{
|
|
441
|
+
get_data(this, true)->offset.value(true).set_top(top);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
void
|
|
445
|
+
Style::set_offset_right (const StyleLength& right)
|
|
446
|
+
{
|
|
447
|
+
get_data(this, true)->offset.value(true).set_right(right);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
void
|
|
451
|
+
Style::set_offset_bottom (const StyleLength& bottom)
|
|
452
|
+
{
|
|
453
|
+
get_data(this, true)->offset.value(true).set_bottom(bottom);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
const StyleLength4&
|
|
457
|
+
Style::offset () const
|
|
458
|
+
{
|
|
459
|
+
const Data* data = get_data(this);
|
|
460
|
+
return data && data->offset ? data->offset.value() : Zero::length4;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
void
|
|
464
|
+
Style::set_margin (const StyleLength4& margin)
|
|
465
|
+
{
|
|
466
|
+
get_data(this, true)->margin = margin;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
void
|
|
470
|
+
Style::set_margin_left (const StyleLength& left)
|
|
471
|
+
{
|
|
472
|
+
get_data(this, true)->margin.value(true).set_left(left);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
void
|
|
476
|
+
Style::set_margin_top (const StyleLength& top)
|
|
477
|
+
{
|
|
478
|
+
get_data(this, true)->margin.value(true).set_top(top);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
void
|
|
482
|
+
Style::set_margin_right (const StyleLength& right)
|
|
483
|
+
{
|
|
484
|
+
get_data(this, true)->margin.value(true).set_right(right);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
void
|
|
488
|
+
Style::set_margin_bottom (const StyleLength& bottom)
|
|
489
|
+
{
|
|
490
|
+
get_data(this, true)->margin.value(true).set_bottom(bottom);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
const StyleLength4&
|
|
494
|
+
Style::margin () const
|
|
495
|
+
{
|
|
496
|
+
const Data* data = get_data(this);
|
|
497
|
+
return data && data->margin ? data->margin.value() : Zero::length4;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
void
|
|
501
|
+
Style::set_padding (const StyleLength4& padding)
|
|
502
|
+
{
|
|
503
|
+
get_data(this, true)->padding = padding;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
void
|
|
507
|
+
Style::set_padding_left (const StyleLength& left)
|
|
508
|
+
{
|
|
509
|
+
get_data(this, true)->padding.value(true).set_left(left);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
void
|
|
513
|
+
Style::set_padding_top (const StyleLength& top)
|
|
514
|
+
{
|
|
515
|
+
get_data(this, true)->padding.value(true).set_top(top);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
void
|
|
519
|
+
Style::set_padding_right (const StyleLength& right)
|
|
520
|
+
{
|
|
521
|
+
get_data(this, true)->padding.value(true).set_right(right);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
void
|
|
525
|
+
Style::set_padding_bottom (const StyleLength& bottom)
|
|
526
|
+
{
|
|
527
|
+
get_data(this, true)->padding.value(true).set_bottom(bottom);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
const StyleLength4&
|
|
531
|
+
Style::padding () const
|
|
532
|
+
{
|
|
533
|
+
const Data* data = get_data(this);
|
|
534
|
+
return data && data->padding ? data->padding.value() : Zero::length4;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
void
|
|
538
|
+
Style::set_background_color (const Color& value)
|
|
539
|
+
{
|
|
540
|
+
get_data(this, true)->background_color = value;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
const Color&
|
|
544
|
+
Style::background_color () const
|
|
545
|
+
{
|
|
546
|
+
const Data* data = get_data(this);
|
|
547
|
+
return data && data->background_color ? data->background_color.value() : Zero::color;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
void
|
|
551
|
+
Style::set_background_image (const Image& value)
|
|
552
|
+
{
|
|
553
|
+
get_data(this, true)->background_image = value;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
const Image&
|
|
557
|
+
Style::background_image () const
|
|
558
|
+
{
|
|
559
|
+
const Data* data = get_data(this);
|
|
560
|
+
return data && data->background_image ? data->background_image.value() : Zero::image;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
bool
|
|
564
|
+
operator == (const Style& lhs, const Style& rhs)
|
|
565
|
+
{
|
|
566
|
+
return lhs.ref == rhs.ref;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
bool
|
|
570
|
+
operator != (const Style& lhs, const Style& rhs)
|
|
571
|
+
{
|
|
572
|
+
return !operator==(lhs, rhs);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
}// Reflex
|