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
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
#include "reflex/ruby/selector.h"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#include <rucy.h>
|
|
5
|
+
#include "defs.h"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
using namespace Rucy;
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
static Class cSelector;
|
|
12
|
+
|
|
13
|
+
RUCY_DEFINE_VALUE_FROM_TO(Reflex::Selector, cSelector)
|
|
14
|
+
|
|
15
|
+
#define THIS to<Reflex::Selector*>(self)
|
|
16
|
+
|
|
17
|
+
#define CHECK RUCY_CHECK_OBJ(Reflex::Selector, cSelector, self)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
static
|
|
21
|
+
VALUE alloc(VALUE klass)
|
|
22
|
+
{
|
|
23
|
+
return new_type<Reflex::Selector>(klass);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static
|
|
27
|
+
VALUE initialize_copy(VALUE self, VALUE obj)
|
|
28
|
+
{
|
|
29
|
+
CHECK;
|
|
30
|
+
*THIS = to<Reflex::Selector&>(obj);
|
|
31
|
+
return self;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static
|
|
35
|
+
VALUE set_name(VALUE self, VALUE name)
|
|
36
|
+
{
|
|
37
|
+
CHECK;
|
|
38
|
+
THIS->set_name(name.is_nil() ? NULL : name.c_str());
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static
|
|
42
|
+
VALUE get_name(VALUE self)
|
|
43
|
+
{
|
|
44
|
+
CHECK;
|
|
45
|
+
return THIS->name() ? value(THIS->name()) : nil();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static
|
|
49
|
+
VALUE add_tag(VALUE self, VALUE tag)
|
|
50
|
+
{
|
|
51
|
+
CHECK;
|
|
52
|
+
THIS->add_tag(tag.c_str());
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static
|
|
56
|
+
VALUE remove_tag(VALUE self, VALUE tag)
|
|
57
|
+
{
|
|
58
|
+
CHECK;
|
|
59
|
+
THIS->remove_tag(tag.c_str());
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static
|
|
63
|
+
VALUE each_tag(VALUE self)
|
|
64
|
+
{
|
|
65
|
+
CHECK;
|
|
66
|
+
|
|
67
|
+
Value ret;
|
|
68
|
+
Reflex::Selector::iterator end = THIS->end();
|
|
69
|
+
for (Reflex::Selector::iterator it = THIS->begin(); it != end; ++it)
|
|
70
|
+
ret = rb_yield(value(*it));
|
|
71
|
+
return ret;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static
|
|
75
|
+
VALUE match(VALUE self, VALUE selector)
|
|
76
|
+
{
|
|
77
|
+
CHECK;
|
|
78
|
+
return value(THIS->match(to<Reflex::Selector&>(selector)));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static
|
|
82
|
+
VALUE equal(VALUE self, VALUE selector)
|
|
83
|
+
{
|
|
84
|
+
CHECK;
|
|
85
|
+
return value(*THIS == to<Reflex::Selector&>(selector));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
void
|
|
90
|
+
Init_selector ()
|
|
91
|
+
{
|
|
92
|
+
Module mReflex = rb_define_module("Reflex");
|
|
93
|
+
|
|
94
|
+
cSelector = rb_define_class_under(mReflex, "Selector", rb_cObject);
|
|
95
|
+
rb_define_alloc_func(cSelector, alloc);
|
|
96
|
+
rb_define_private_method(cSelector, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
|
97
|
+
rb_define_method(cSelector, "name=", RUBY_METHOD_FUNC(set_name), 1);
|
|
98
|
+
rb_define_method(cSelector, "name", RUBY_METHOD_FUNC(get_name), 0);
|
|
99
|
+
rb_define_method(cSelector, "add_tag", RUBY_METHOD_FUNC(add_tag), 1);
|
|
100
|
+
rb_define_method(cSelector, "remove_tag", RUBY_METHOD_FUNC(remove_tag), 1);
|
|
101
|
+
rb_define_method(cSelector, "each_tag", RUBY_METHOD_FUNC(each_tag), 0);
|
|
102
|
+
rb_define_method(cSelector, "match", RUBY_METHOD_FUNC(match), 1);
|
|
103
|
+
cSelector.define_method("==", equal);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
namespace Rucy
|
|
108
|
+
{
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
template <> Reflex::Selector
|
|
112
|
+
value_to<Reflex::Selector> (Value value, bool convert)
|
|
113
|
+
{
|
|
114
|
+
if (convert && (value.is_s() || value.is_sym()))
|
|
115
|
+
return Reflex::Selector(value.c_str());
|
|
116
|
+
|
|
117
|
+
return value_to<Reflex::Selector&>(value, convert);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
}// Rucy
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
namespace Reflex
|
|
125
|
+
{
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
Class
|
|
129
|
+
selector_class ()
|
|
130
|
+
{
|
|
131
|
+
return cSelector;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
}// Reflex
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
#include "reflex/ruby/style.h"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#include <rucy.h>
|
|
5
|
+
#include "rays/ruby/color.h"
|
|
6
|
+
#include "rays/ruby/image.h"
|
|
7
|
+
#include "reflex/ruby/selector.h"
|
|
8
|
+
#include "reflex/ruby/style_length.h"
|
|
9
|
+
#include "defs.h"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
using namespace Rucy;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
static Class cStyle;
|
|
16
|
+
|
|
17
|
+
RUCY_DEFINE_VALUE_FROM_TO(Reflex::Style, cStyle)
|
|
18
|
+
|
|
19
|
+
#define THIS to<Reflex::Style*>(self)
|
|
20
|
+
|
|
21
|
+
#define CHECK RUCY_CHECK_OBJ(Reflex::Style, cStyle, self)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
static
|
|
25
|
+
VALUE alloc(VALUE klass)
|
|
26
|
+
{
|
|
27
|
+
return new_type<Reflex::Style>(klass);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static
|
|
31
|
+
VALUE initialize_copy(VALUE self, VALUE obj)
|
|
32
|
+
{
|
|
33
|
+
CHECK;
|
|
34
|
+
*THIS = to<Reflex::Style&>(obj);
|
|
35
|
+
return self;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static
|
|
39
|
+
VALUE set_name(VALUE self, VALUE name)
|
|
40
|
+
{
|
|
41
|
+
CHECK;
|
|
42
|
+
THIS->set_name(name.is_nil() ? NULL : name.c_str());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static
|
|
46
|
+
VALUE get_name(VALUE self)
|
|
47
|
+
{
|
|
48
|
+
CHECK;
|
|
49
|
+
return THIS->name() ? value(THIS->name()) : nil();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static
|
|
53
|
+
VALUE add_tag(VALUE self, VALUE tag)
|
|
54
|
+
{
|
|
55
|
+
CHECK;
|
|
56
|
+
THIS->add_tag(tag.c_str());
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static
|
|
60
|
+
VALUE remove_tag(VALUE self, VALUE tag)
|
|
61
|
+
{
|
|
62
|
+
CHECK;
|
|
63
|
+
THIS->remove_tag(tag.c_str());
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static
|
|
67
|
+
VALUE each_tag(VALUE self)
|
|
68
|
+
{
|
|
69
|
+
CHECK;
|
|
70
|
+
|
|
71
|
+
Value ret;
|
|
72
|
+
Reflex::Style::tag_iterator end = THIS->tag_end();
|
|
73
|
+
for (Reflex::Style::tag_iterator it = THIS->tag_begin(); it != end; ++it)
|
|
74
|
+
ret = rb_yield(value(*it));
|
|
75
|
+
return ret;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static
|
|
79
|
+
VALUE set_selector(VALUE self, VALUE selector)
|
|
80
|
+
{
|
|
81
|
+
CHECK;
|
|
82
|
+
THIS->set_selector(to<Reflex::Selector>(selector));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static
|
|
86
|
+
VALUE get_selector(VALUE self)
|
|
87
|
+
{
|
|
88
|
+
CHECK;
|
|
89
|
+
return value(THIS->selector());
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static
|
|
93
|
+
VALUE set_flow(VALUE self)
|
|
94
|
+
{
|
|
95
|
+
CHECK;
|
|
96
|
+
check_arg_count(__FILE__, __LINE__, "Style#set_flow", argc, 1, 2);
|
|
97
|
+
|
|
98
|
+
THIS->set_flow(
|
|
99
|
+
argc >= 1 ? (Reflex::Style::Flow) argv[0].as_i() : Reflex::Style::FLOW_DOWN,
|
|
100
|
+
argc >= 2 ? (Reflex::Style::Flow) argv[1].as_i() : Reflex::Style::FLOW_NONE);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static
|
|
104
|
+
VALUE get_flow(VALUE self)
|
|
105
|
+
{
|
|
106
|
+
CHECK;
|
|
107
|
+
Reflex::Style::Flow main, sub;
|
|
108
|
+
THIS->get_flow(&main, &sub);
|
|
109
|
+
return array(main, sub);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
static
|
|
113
|
+
VALUE set_size(VALUE self, VALUE size)
|
|
114
|
+
{
|
|
115
|
+
CHECK;
|
|
116
|
+
THIS->set_size(to<Reflex::StyleLength2>(size));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
static
|
|
120
|
+
VALUE get_size(VALUE self)
|
|
121
|
+
{
|
|
122
|
+
CHECK;
|
|
123
|
+
return value(THIS->size());
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
static
|
|
127
|
+
VALUE set_position(VALUE self, VALUE position)
|
|
128
|
+
{
|
|
129
|
+
CHECK;
|
|
130
|
+
THIS->set_position(to<Reflex::StyleLength4>(position));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
static
|
|
134
|
+
VALUE get_position(VALUE self)
|
|
135
|
+
{
|
|
136
|
+
CHECK;
|
|
137
|
+
return value(THIS->position());
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
static
|
|
141
|
+
VALUE set_margin(VALUE self, VALUE margin)
|
|
142
|
+
{
|
|
143
|
+
CHECK;
|
|
144
|
+
THIS->set_margin(to<Reflex::StyleLength4>(margin));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
static
|
|
148
|
+
VALUE get_margin(VALUE self)
|
|
149
|
+
{
|
|
150
|
+
CHECK;
|
|
151
|
+
return value(THIS->margin());
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
static
|
|
155
|
+
VALUE set_padding(VALUE self, VALUE padding)
|
|
156
|
+
{
|
|
157
|
+
CHECK;
|
|
158
|
+
THIS->set_padding(to<Reflex::StyleLength4>(padding));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
static
|
|
162
|
+
VALUE get_padding(VALUE self)
|
|
163
|
+
{
|
|
164
|
+
CHECK;
|
|
165
|
+
return value(THIS->padding());
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
static
|
|
169
|
+
VALUE set_background_color(VALUE self, VALUE color)
|
|
170
|
+
{
|
|
171
|
+
CHECK;
|
|
172
|
+
THIS->set_background_color(to<Reflex::Color&>(color));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
static
|
|
176
|
+
VALUE get_background_color(VALUE self)
|
|
177
|
+
{
|
|
178
|
+
CHECK;
|
|
179
|
+
return value(THIS->background_color());
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
static
|
|
183
|
+
VALUE set_background_image(VALUE self, VALUE image)
|
|
184
|
+
{
|
|
185
|
+
CHECK;
|
|
186
|
+
THIS->set_background_image(to<Reflex::Image&>(image));
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
static
|
|
190
|
+
VALUE get_background_image(VALUE self)
|
|
191
|
+
{
|
|
192
|
+
CHECK;
|
|
193
|
+
return THIS->background_image() ? value(THIS->background_image()) : nil();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
static
|
|
197
|
+
VALUE equal(VALUE self, VALUE style)
|
|
198
|
+
{
|
|
199
|
+
CHECK;
|
|
200
|
+
return value(*THIS == to<Reflex::Style&>(style));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
void
|
|
205
|
+
Init_style ()
|
|
206
|
+
{
|
|
207
|
+
Module mReflex = rb_define_module("Reflex");
|
|
208
|
+
|
|
209
|
+
cStyle = rb_define_class_under(mReflex, "Style", rb_cObject);
|
|
210
|
+
rb_define_alloc_func(cStyle, alloc);
|
|
211
|
+
rb_define_private_method(cStyle, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
|
212
|
+
rb_define_method(cStyle, "name=", RUBY_METHOD_FUNC(set_name), 1);
|
|
213
|
+
rb_define_method(cStyle, "name", RUBY_METHOD_FUNC(get_name), 0);
|
|
214
|
+
rb_define_method(cStyle, "add_tag", RUBY_METHOD_FUNC(add_tag), 1);
|
|
215
|
+
rb_define_method(cStyle, "remove_tag", RUBY_METHOD_FUNC(remove_tag), 1);
|
|
216
|
+
rb_define_method(cStyle, "each_tag", RUBY_METHOD_FUNC(each_tag), 0);
|
|
217
|
+
rb_define_method(cStyle, "selector=", RUBY_METHOD_FUNC(set_selector), 1);
|
|
218
|
+
rb_define_method(cStyle, "selector", RUBY_METHOD_FUNC(get_selector), 0);
|
|
219
|
+
rb_define_method(cStyle, "set_flow", RUBY_METHOD_FUNC(set_flow), -1);
|
|
220
|
+
rb_define_method(cStyle, "get_flow", RUBY_METHOD_FUNC(get_flow), 0);
|
|
221
|
+
rb_define_method(cStyle, "size=", RUBY_METHOD_FUNC(set_size), 1);
|
|
222
|
+
rb_define_method(cStyle, "size", RUBY_METHOD_FUNC(get_size), 0);
|
|
223
|
+
rb_define_method(cStyle, "position=", RUBY_METHOD_FUNC(set_position), 1);
|
|
224
|
+
rb_define_method(cStyle, "position", RUBY_METHOD_FUNC(get_position), 0);
|
|
225
|
+
rb_define_method(cStyle, "margin=", RUBY_METHOD_FUNC(set_margin), 1);
|
|
226
|
+
rb_define_method(cStyle, "margin", RUBY_METHOD_FUNC(get_margin), 0);
|
|
227
|
+
rb_define_method(cStyle, "padding=", RUBY_METHOD_FUNC(set_padding), 1);
|
|
228
|
+
rb_define_method(cStyle, "padding", RUBY_METHOD_FUNC(get_padding), 0);
|
|
229
|
+
rb_define_method(cStyle, "background_color=", RUBY_METHOD_FUNC(set_background_color), 1);
|
|
230
|
+
rb_define_method(cStyle, "background_color", RUBY_METHOD_FUNC(get_background_color), 0);
|
|
231
|
+
rb_define_method(cStyle, "background_image=", RUBY_METHOD_FUNC(set_background_image), 1);
|
|
232
|
+
rb_define_method(cStyle, "background_image", RUBY_METHOD_FUNC(get_background_image), 0);
|
|
233
|
+
cStyle.define_method("==", equal);
|
|
234
|
+
cStyle.define_const("FLOW_NONE", Reflex::Style::FLOW_NONE);
|
|
235
|
+
cStyle.define_const("FLOW_DOWN", Reflex::Style::FLOW_DOWN);
|
|
236
|
+
cStyle.define_const("FLOW_RIGHT", Reflex::Style::FLOW_RIGHT);
|
|
237
|
+
cStyle.define_const("FLOW_UP", Reflex::Style::FLOW_UP);
|
|
238
|
+
cStyle.define_const("FLOW_LEFT", Reflex::Style::FLOW_LEFT);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
namespace Reflex
|
|
243
|
+
{
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
Class
|
|
247
|
+
style_class ()
|
|
248
|
+
{
|
|
249
|
+
return cStyle;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
}// Reflex
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
#include "reflex/ruby/style_length.h"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#include <rucy.h>
|
|
5
|
+
#include "defs.h"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
using namespace Rucy;
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
static Class cStyleLength;
|
|
12
|
+
|
|
13
|
+
RUCY_DEFINE_VALUE_FROM_TO(Reflex::StyleLength, cStyleLength)
|
|
14
|
+
|
|
15
|
+
#define THIS to<Reflex::StyleLength*>(self)
|
|
16
|
+
|
|
17
|
+
#define CHECK RUCY_CHECK_OBJ(Reflex::StyleLength, cStyleLength, self)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
static
|
|
21
|
+
VALUE alloc(VALUE klass)
|
|
22
|
+
{
|
|
23
|
+
return new_type<Reflex::StyleLength>(klass);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static
|
|
27
|
+
VALUE setup_num(VALUE self, VALUE value, VALUE unit)
|
|
28
|
+
{
|
|
29
|
+
CHECK;
|
|
30
|
+
|
|
31
|
+
const char* str = unit.as_s(true);
|
|
32
|
+
Reflex::StyleLength::Unit u = Reflex::StyleLength::NONE;
|
|
33
|
+
if (strcasecmp(str, "px") == 0) u = Reflex::StyleLength::PIXEL;
|
|
34
|
+
else if (strcasecmp(str, "%") == 0) u = Reflex::StyleLength::PERCENT;
|
|
35
|
+
else argument_error(__FILE__, __LINE__);
|
|
36
|
+
THIS->reset(value.as_f(true), u);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static
|
|
40
|
+
VALUE setup_str(VALUE self, VALUE str)
|
|
41
|
+
{
|
|
42
|
+
CHECK;
|
|
43
|
+
THIS->reset(str.c_str());
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static
|
|
47
|
+
VALUE initialize_copy(VALUE self, VALUE obj)
|
|
48
|
+
{
|
|
49
|
+
CHECK;
|
|
50
|
+
*THIS = to<Reflex::StyleLength&>(obj).copy();
|
|
51
|
+
return self;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static
|
|
55
|
+
VALUE get_value(VALUE self)
|
|
56
|
+
{
|
|
57
|
+
CHECK;
|
|
58
|
+
return value(THIS->value());
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static
|
|
62
|
+
VALUE get_unit(VALUE self)
|
|
63
|
+
{
|
|
64
|
+
CHECK;
|
|
65
|
+
|
|
66
|
+
RUCY_SYMBOL(pixel, "px");
|
|
67
|
+
RUCY_SYMBOL(percent, "%");
|
|
68
|
+
switch (THIS->unit())
|
|
69
|
+
{
|
|
70
|
+
case Reflex::StyleLength::PIXEL: return pixel.value();
|
|
71
|
+
case Reflex::StyleLength::PERCENT: return percent.value();
|
|
72
|
+
default: return nil();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static
|
|
77
|
+
VALUE to_s(VALUE self)
|
|
78
|
+
{
|
|
79
|
+
CHECK;
|
|
80
|
+
return value(THIS->to_s());
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
void
|
|
85
|
+
Init_style_length ()
|
|
86
|
+
{
|
|
87
|
+
Module mReflex = rb_define_module("Reflex");
|
|
88
|
+
|
|
89
|
+
cStyleLength = rb_define_class_under(mReflex, "StyleLength", rb_cObject);
|
|
90
|
+
rb_define_alloc_func(cStyleLength, alloc);
|
|
91
|
+
rb_define_private_method(cStyleLength, "setup_num", RUBY_METHOD_FUNC(setup_num), 2);
|
|
92
|
+
rb_define_private_method(cStyleLength, "setup_str", RUBY_METHOD_FUNC(setup_str), 1);
|
|
93
|
+
rb_define_private_method(cStyleLength, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
|
94
|
+
rb_define_method(cStyleLength, "value", RUBY_METHOD_FUNC(get_value), 0);
|
|
95
|
+
rb_define_method(cStyleLength, "unit", RUBY_METHOD_FUNC(get_unit), 0);
|
|
96
|
+
rb_define_method(cStyleLength, "to_s", RUBY_METHOD_FUNC(to_s), 0);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
namespace Rucy
|
|
101
|
+
{
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
template <> Reflex::StyleLength
|
|
105
|
+
value_to<Reflex::StyleLength> (Value value, bool convert)
|
|
106
|
+
{
|
|
107
|
+
if (convert)
|
|
108
|
+
{
|
|
109
|
+
if (value.is_nil()) return Reflex::StyleLength();
|
|
110
|
+
else if (value.is_i()) return Reflex::StyleLength(value.as_i());
|
|
111
|
+
else if (value.is_f()) return Reflex::StyleLength(value.as_f());
|
|
112
|
+
else if (value.is_s()) return Reflex::StyleLength(value.c_str());
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return value_to<Reflex::StyleLength&>(value, convert);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
}// Rucy
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
namespace Reflex
|
|
123
|
+
{
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
Class
|
|
127
|
+
style_length_class ()
|
|
128
|
+
{
|
|
129
|
+
return cStyleLength;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
}// Reflex
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
#include "reflex/ruby/style_length.h"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#include <rucy.h>
|
|
5
|
+
#include "defs.h"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
using namespace Rucy;
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
static Class cStyleLength2;
|
|
12
|
+
|
|
13
|
+
RUCY_DEFINE_VALUE_FROM_TO(Reflex::StyleLength2, cStyleLength2)
|
|
14
|
+
|
|
15
|
+
#define THIS to<Reflex::StyleLength2*>(self)
|
|
16
|
+
|
|
17
|
+
#define CHECK RUCY_CHECK_OBJ(Reflex::StyleLength2, cStyleLength2, self)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
static
|
|
21
|
+
VALUE alloc(VALUE klass)
|
|
22
|
+
{
|
|
23
|
+
return new_type<Reflex::StyleLength2>(klass);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static
|
|
27
|
+
VALUE initialize_copy(VALUE self, VALUE obj)
|
|
28
|
+
{
|
|
29
|
+
CHECK;
|
|
30
|
+
*THIS = to<Reflex::StyleLength2&>(obj).copy();
|
|
31
|
+
return self;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static
|
|
35
|
+
VALUE set_width(VALUE self, VALUE width)
|
|
36
|
+
{
|
|
37
|
+
CHECK;
|
|
38
|
+
THIS->set_width(to<Reflex::StyleLength>(width));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static
|
|
42
|
+
VALUE get_width(VALUE self)
|
|
43
|
+
{
|
|
44
|
+
CHECK;
|
|
45
|
+
return value(THIS->width());
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static
|
|
49
|
+
VALUE set_height(VALUE self, VALUE height)
|
|
50
|
+
{
|
|
51
|
+
CHECK;
|
|
52
|
+
THIS->set_height(to<Reflex::StyleLength>(height));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static
|
|
56
|
+
VALUE get_height(VALUE self)
|
|
57
|
+
{
|
|
58
|
+
CHECK;
|
|
59
|
+
return value(THIS->height());
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static
|
|
63
|
+
VALUE set_at(VALUE self, VALUE index, VALUE length)
|
|
64
|
+
{
|
|
65
|
+
CHECK;
|
|
66
|
+
|
|
67
|
+
int i = index.as_i(), size = (int) THIS->size();
|
|
68
|
+
while (i < 0) i += size;
|
|
69
|
+
|
|
70
|
+
if (i >= size)
|
|
71
|
+
index_error(__FILE__, __LINE__);
|
|
72
|
+
|
|
73
|
+
(*THIS)[i] = to<Reflex::StyleLength>(length);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static
|
|
77
|
+
VALUE get_at(VALUE self, VALUE index)
|
|
78
|
+
{
|
|
79
|
+
CHECK;
|
|
80
|
+
|
|
81
|
+
int i = index.as_i(), size = (int) THIS->size();
|
|
82
|
+
while (i < 0) i += size;
|
|
83
|
+
|
|
84
|
+
if (i >= size)
|
|
85
|
+
index_error(__FILE__, __LINE__);
|
|
86
|
+
|
|
87
|
+
return value((*THIS)[i]);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
void
|
|
92
|
+
Init_style_length2 ()
|
|
93
|
+
{
|
|
94
|
+
Module mReflex = rb_define_module("Reflex");
|
|
95
|
+
|
|
96
|
+
cStyleLength2 = rb_define_class_under(mReflex, "StyleLength2", rb_cObject);
|
|
97
|
+
rb_define_alloc_func(cStyleLength2, alloc);
|
|
98
|
+
rb_define_private_method(cStyleLength2, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
|
99
|
+
rb_define_method(cStyleLength2, "width=", RUBY_METHOD_FUNC(set_width), 1);
|
|
100
|
+
rb_define_method(cStyleLength2, "width", RUBY_METHOD_FUNC(get_width), 0);
|
|
101
|
+
rb_define_method(cStyleLength2, "height=", RUBY_METHOD_FUNC(set_height), 1);
|
|
102
|
+
rb_define_method(cStyleLength2, "height", RUBY_METHOD_FUNC(get_height), 0);
|
|
103
|
+
cStyleLength2.define_method("[]=", set_at);
|
|
104
|
+
cStyleLength2.define_method("[]", get_at);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
namespace Rucy
|
|
109
|
+
{
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
template <> Reflex::StyleLength2
|
|
113
|
+
value_to<Reflex::StyleLength2> (Value value, bool convert)
|
|
114
|
+
{
|
|
115
|
+
if (convert && value.is_array())
|
|
116
|
+
{
|
|
117
|
+
Value* a = value.as_array();
|
|
118
|
+
switch (value.size())
|
|
119
|
+
{
|
|
120
|
+
case 1: return Reflex::StyleLength2(
|
|
121
|
+
to<Reflex::StyleLength>(a[0]));
|
|
122
|
+
|
|
123
|
+
case 2: return Reflex::StyleLength2(
|
|
124
|
+
to<Reflex::StyleLength>(a[0]),
|
|
125
|
+
to<Reflex::StyleLength>(a[1]));
|
|
126
|
+
|
|
127
|
+
default: argument_error(__FILE__, __LINE__);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return value_to<Reflex::StyleLength2&>(value, convert);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
}// Rucy
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
namespace Reflex
|
|
139
|
+
{
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
Class
|
|
143
|
+
style_length2_class ()
|
|
144
|
+
{
|
|
145
|
+
return cStyleLength2;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
}// Reflex
|