reflexion 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.doc/ext/reflex/application.cpp +35 -76
- data/.doc/ext/reflex/defs.cpp +8 -0
- data/.doc/ext/reflex/key.cpp +38 -43
- data/.doc/ext/reflex/native.cpp +6 -4
- data/.doc/ext/reflex/points.cpp +47 -52
- data/.doc/ext/reflex/reflex.cpp +12 -13
- data/.doc/ext/reflex/view.cpp +242 -0
- data/.doc/ext/reflex/window.cpp +87 -178
- data/.gitignore +14 -0
- data/Rakefile +6 -31
- data/VERSION +1 -1
- data/examples/hello/.gitignore +2 -0
- data/examples/ruby/app.rb +2 -2
- data/examples/ruby/checker.rb +3 -3
- data/examples/ruby/fps.rb +14 -14
- data/examples/ruby/grid.rb +65 -0
- data/examples/ruby/hello.rb +19 -7
- data/examples/ruby/key.rb +4 -4
- data/examples/ruby/shapes.rb +6 -6
- data/examples/ruby/text.rb +20 -17
- data/examples/ruby/views.rb +88 -0
- data/examples/ruby/visuals.rb +27 -0
- data/ext/reflex/application.cpp +36 -76
- data/ext/reflex/defs.cpp +8 -0
- data/ext/reflex/defs.h +1 -18
- data/ext/reflex/extconf.rb +16 -8
- data/ext/reflex/key.cpp +39 -43
- data/ext/reflex/native.cpp +6 -4
- data/ext/reflex/points.cpp +48 -52
- data/ext/reflex/reflex.cpp +12 -13
- data/ext/reflex/view.cpp +260 -0
- data/ext/reflex/window.cpp +89 -178
- data/include/reflex/application.h +14 -7
- data/include/reflex/defs.h +8 -6
- data/include/reflex/exception.h +1 -1
- data/include/reflex/ruby/application.h +31 -10
- data/include/reflex/ruby/key.h +3 -3
- data/include/reflex/ruby/points.h +3 -3
- data/include/reflex/ruby/view.h +106 -0
- data/include/reflex/ruby/window.h +83 -12
- data/include/reflex/ruby.h +3 -2
- data/include/reflex/view.h +103 -0
- data/include/reflex/window.h +43 -18
- data/include/reflex.h +2 -1
- data/lib/reflex/application.rb +8 -7
- data/lib/reflex/autoinit.rb +1 -1
- data/lib/reflex/bitmap.rb +13 -0
- data/lib/reflex/bounds.rb +2 -122
- data/lib/reflex/ext.rb +5 -0
- data/lib/reflex/helpers.rb +36 -31
- data/lib/reflex/image.rb +13 -0
- data/lib/reflex/module.rb +9 -2
- data/lib/reflex/painter.rb +13 -0
- data/lib/reflex/point.rb +3 -59
- data/lib/reflex/reflex.rb +1 -1
- data/lib/reflex/texture.rb +13 -0
- data/lib/reflex/view.rb +33 -0
- data/lib/reflex/visuals/string.rb +53 -0
- data/lib/reflex/window.rb +18 -43
- data/lib/reflex.rb +3 -3
- data/reflex.gemspec +16 -42
- data/src/cocoa/application.mm +17 -23
- data/src/cocoa/applicationdata.h +3 -9
- data/src/cocoa/cocoaapplication.h +6 -4
- data/src/cocoa/cocoaapplication.mm +61 -19
- data/src/cocoa/cocoawindow.h +7 -5
- data/src/cocoa/cocoawindow.mm +109 -50
- data/src/cocoa/defs.mm +5 -2
- data/src/cocoa/window.mm +71 -41
- data/src/cocoa/windowdata.h +14 -9
- data/src/defs.cpp +1 -1
- data/src/exception.cpp +3 -18
- data/src/helpers.h +12 -0
- data/src/reflex.cpp +11 -5
- data/src/view.cpp +326 -0
- data/src/win32/application.cpp +7 -8
- data/src/win32/defs.h +1 -1
- data/src/win32/window.cpp +137 -41
- data/src/window.cpp +38 -1
- data/test/helpers.rb +2 -5
- data/test/test_application.rb +17 -0
- data/test/test_reflex.rb +4 -2
- data/test/test_view.rb +74 -0
- data/test/test_window.rb +33 -2
- metadata +157 -97
- data/include/reflex/helpers.h +0 -32
- data/test/test_bounds.rb +0 -163
- data/test/test_point.rb +0 -81
data/ext/reflex/view.cpp
ADDED
@@ -0,0 +1,260 @@
|
|
1
|
+
#include "reflex/ruby/view.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include <rucy.h>
|
5
|
+
#include <reflex/ruby/window.h>
|
6
|
+
#include "defs.h"
|
7
|
+
|
8
|
+
|
9
|
+
using namespace Rucy;
|
10
|
+
|
11
|
+
using Reflex::coord;
|
12
|
+
|
13
|
+
|
14
|
+
static Class cView;
|
15
|
+
|
16
|
+
|
17
|
+
namespace Reflex
|
18
|
+
{
|
19
|
+
|
20
|
+
|
21
|
+
Class
|
22
|
+
view_class ()
|
23
|
+
{
|
24
|
+
return cView;
|
25
|
+
}
|
26
|
+
|
27
|
+
|
28
|
+
}// Reflex
|
29
|
+
|
30
|
+
|
31
|
+
typedef Reflex::RubyView<Reflex::View> RubyView;
|
32
|
+
|
33
|
+
|
34
|
+
#define THIS to<Reflex::View*>(self)
|
35
|
+
|
36
|
+
#define CHECK RUCY_CHECK_OBJECT(self, Reflex::View, cView)
|
37
|
+
|
38
|
+
#define CALL(fun) RUCY_WRAPPER_CALL(RubyView, THIS, fun)
|
39
|
+
|
40
|
+
|
41
|
+
static
|
42
|
+
RUBY_DEF_ALLOC(alloc, klass)
|
43
|
+
{
|
44
|
+
return value(new RubyView, klass);
|
45
|
+
}
|
46
|
+
RUBY_END
|
47
|
+
|
48
|
+
static
|
49
|
+
RUBY_DEF0(show)
|
50
|
+
{
|
51
|
+
CHECK;
|
52
|
+
if (!CALL(show()))
|
53
|
+
reflex_error("failed to show view.");
|
54
|
+
return self;
|
55
|
+
}
|
56
|
+
RUBY_END
|
57
|
+
|
58
|
+
static
|
59
|
+
RUBY_DEF0(hide)
|
60
|
+
{
|
61
|
+
CHECK;
|
62
|
+
if (!CALL(hide()))
|
63
|
+
reflex_error("failed to hide view.");
|
64
|
+
return self;
|
65
|
+
}
|
66
|
+
RUBY_END
|
67
|
+
|
68
|
+
static
|
69
|
+
RUBY_DEF0(redraw)
|
70
|
+
{
|
71
|
+
CHECK;
|
72
|
+
if (!THIS->redraw())
|
73
|
+
reflex_error("failed to redraw view.");
|
74
|
+
return self;
|
75
|
+
}
|
76
|
+
RUBY_END
|
77
|
+
|
78
|
+
static
|
79
|
+
RUBY_DEF1(add_child, child)
|
80
|
+
{
|
81
|
+
CHECK;
|
82
|
+
|
83
|
+
Reflex::View* c = to<Reflex::View*>(child);
|
84
|
+
if (!c) argument_error();
|
85
|
+
|
86
|
+
if (!THIS->add_child(c))
|
87
|
+
reflex_error("failed to add child view.");
|
88
|
+
|
89
|
+
return self;
|
90
|
+
}
|
91
|
+
RUBY_END
|
92
|
+
|
93
|
+
static
|
94
|
+
RUBY_DEF1(remove_child, child)
|
95
|
+
{
|
96
|
+
CHECK;
|
97
|
+
|
98
|
+
Reflex::View* c = to<Reflex::View*>(child);
|
99
|
+
if (!c) argument_error();
|
100
|
+
|
101
|
+
if (!THIS->remove_child(c))
|
102
|
+
reflex_error("failed to remove child view.");
|
103
|
+
|
104
|
+
return self;
|
105
|
+
}
|
106
|
+
RUBY_END
|
107
|
+
|
108
|
+
static
|
109
|
+
RUBY_DEFN(find_child)
|
110
|
+
{
|
111
|
+
CHECK;
|
112
|
+
if (argc < 1 || 3 < argc)
|
113
|
+
arg_count_error("View#find_child", argc, 1, 2, 3);
|
114
|
+
|
115
|
+
const char* name = to<const char*>(argv[0]);
|
116
|
+
size_t index = (argc >= 2) ? to<size_t>(argv[1]) : 0;
|
117
|
+
bool recursive = (argc >= 3) ? to<bool>(argv[2]) : false;
|
118
|
+
|
119
|
+
Reflex::View* c = THIS->find_child(name, index, recursive);
|
120
|
+
if (!c) return Qnil;
|
121
|
+
|
122
|
+
return value(c);
|
123
|
+
}
|
124
|
+
RUBY_END
|
125
|
+
|
126
|
+
static
|
127
|
+
RUBY_DEF1(set_name, name)
|
128
|
+
{
|
129
|
+
CHECK;
|
130
|
+
if (!THIS->set_name(name.c_str()))
|
131
|
+
reflex_error("failed to set the name of view.");
|
132
|
+
return name;
|
133
|
+
}
|
134
|
+
RUBY_END
|
135
|
+
|
136
|
+
static
|
137
|
+
RUBY_DEF0(get_name)
|
138
|
+
{
|
139
|
+
CHECK;
|
140
|
+
const char* s = THIS->name();
|
141
|
+
if (!s) reflex_error("failed to get name of view.");
|
142
|
+
return value(s);
|
143
|
+
}
|
144
|
+
RUBY_END
|
145
|
+
|
146
|
+
static
|
147
|
+
RUBY_DEF4(set_bounds, x, y, width, height)
|
148
|
+
{
|
149
|
+
CHECK;
|
150
|
+
if (!THIS->set_bounds(
|
151
|
+
to<coord>(x), to<coord>(y), to<coord>(width), to<coord>(height)))
|
152
|
+
{
|
153
|
+
reflex_error("failed to set the bounds of view.");
|
154
|
+
}
|
155
|
+
return value(THIS->bounds());
|
156
|
+
}
|
157
|
+
RUBY_END
|
158
|
+
|
159
|
+
static
|
160
|
+
RUBY_DEF0(get_bounds)
|
161
|
+
{
|
162
|
+
CHECK;
|
163
|
+
return value(THIS->bounds());
|
164
|
+
}
|
165
|
+
RUBY_END
|
166
|
+
|
167
|
+
static
|
168
|
+
RUBY_DEF0(hidden)
|
169
|
+
{
|
170
|
+
CHECK;
|
171
|
+
return value(THIS->hidden());
|
172
|
+
}
|
173
|
+
RUBY_END
|
174
|
+
|
175
|
+
static
|
176
|
+
RUBY_DEF0(parent)
|
177
|
+
{
|
178
|
+
CHECK;
|
179
|
+
|
180
|
+
Reflex::View* v = THIS->parent();
|
181
|
+
if (!v) return Qnil;
|
182
|
+
|
183
|
+
return value(v);
|
184
|
+
}
|
185
|
+
RUBY_END
|
186
|
+
|
187
|
+
static
|
188
|
+
RUBY_DEF0(window)
|
189
|
+
{
|
190
|
+
CHECK;
|
191
|
+
|
192
|
+
Reflex::Window* w = THIS->window();
|
193
|
+
if (!w) return Qnil;
|
194
|
+
|
195
|
+
return value(w);
|
196
|
+
}
|
197
|
+
RUBY_END
|
198
|
+
|
199
|
+
static
|
200
|
+
RUBY_DEF1(update, dt)
|
201
|
+
{
|
202
|
+
CHECK;
|
203
|
+
CALL(update(to<float>(dt)));
|
204
|
+
return self;
|
205
|
+
}
|
206
|
+
RUBY_END
|
207
|
+
|
208
|
+
static
|
209
|
+
RUBY_DEF2(draw, painter, bounds)
|
210
|
+
{
|
211
|
+
CHECK;
|
212
|
+
CALL(draw(to<Rays::Painter*>(painter), *to<Rays::Bounds*>(bounds)));
|
213
|
+
return self;
|
214
|
+
}
|
215
|
+
RUBY_END
|
216
|
+
|
217
|
+
static
|
218
|
+
RUBY_DEF2(moved, dx, dy)
|
219
|
+
{
|
220
|
+
CHECK;
|
221
|
+
CALL(moved(to<coord>(dx), to<coord>(dy)));
|
222
|
+
return self;
|
223
|
+
}
|
224
|
+
RUBY_END
|
225
|
+
|
226
|
+
static
|
227
|
+
RUBY_DEF2(resized, dwidth, dheight)
|
228
|
+
{
|
229
|
+
CHECK;
|
230
|
+
CALL(resized(to<coord>(dwidth), to<coord>(dheight)));
|
231
|
+
return self;
|
232
|
+
}
|
233
|
+
RUBY_END
|
234
|
+
|
235
|
+
|
236
|
+
void
|
237
|
+
Init_view ()
|
238
|
+
{
|
239
|
+
Module mReflex = define_module("Reflex");
|
240
|
+
|
241
|
+
cView = mReflex.define_class("View");
|
242
|
+
cView.define_alloc_func(alloc);
|
243
|
+
cView.define_method("show", show);
|
244
|
+
cView.define_method("hide", hide);
|
245
|
+
cView.define_method("redraw", redraw);
|
246
|
+
cView.define_method("add_child", add_child);
|
247
|
+
cView.define_method("remove_child", remove_child);
|
248
|
+
cView.define_method("find_child", find_child);
|
249
|
+
cView.define_method("name=", set_name);
|
250
|
+
cView.define_method("name", get_name);
|
251
|
+
cView.define_private_method("set_bounds", set_bounds);
|
252
|
+
cView.define_private_method("get_bounds", get_bounds);
|
253
|
+
cView.define_method("hidden", hidden);
|
254
|
+
cView.define_method("parent", parent);
|
255
|
+
cView.define_method("window", window);
|
256
|
+
cView.define_method("update", update);
|
257
|
+
cView.define_method("draw", draw);
|
258
|
+
cView.define_method("moved", moved);
|
259
|
+
cView.define_method("resized", resized);
|
260
|
+
}
|
data/ext/reflex/window.cpp
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
#include <rucy.h>
|
5
|
-
#include <
|
6
|
-
#include <reflex/ruby/
|
5
|
+
#include <rays/ruby/painter.h>
|
6
|
+
#include <reflex/ruby/view.h>
|
7
7
|
#include "defs.h"
|
8
8
|
|
9
9
|
|
@@ -12,12 +12,13 @@ using namespace Rucy;
|
|
12
12
|
using Reflex::coord;
|
13
13
|
|
14
14
|
|
15
|
+
static Class cWindow;
|
16
|
+
|
17
|
+
|
15
18
|
namespace Reflex
|
16
19
|
{
|
17
20
|
|
18
21
|
|
19
|
-
static Class cWindow;
|
20
|
-
|
21
22
|
Class
|
22
23
|
window_class ()
|
23
24
|
{
|
@@ -28,120 +29,20 @@ namespace Reflex
|
|
28
29
|
}// Reflex
|
29
30
|
|
30
31
|
|
31
|
-
|
32
|
-
{
|
33
|
-
|
34
|
-
|
35
|
-
Value
|
36
|
-
value (const Reflex::Window& window)
|
37
|
-
{
|
38
|
-
return new_type<Reflex::Window>(
|
39
|
-
Reflex::window_class(), new Reflex::Window(window));
|
40
|
-
}
|
41
|
-
|
32
|
+
typedef Reflex::RubyWindow<Reflex::Window> RubyWindow;
|
42
33
|
|
43
|
-
}// Rucy
|
44
34
|
|
35
|
+
#define THIS to<Reflex::Window*>(self)
|
45
36
|
|
46
|
-
|
47
|
-
{
|
37
|
+
#define CHECK RUCY_CHECK_OBJECT(self, Reflex::Window, cWindow)
|
48
38
|
|
49
|
-
|
50
|
-
|
51
|
-
typedef Reflex::Window Super;
|
52
|
-
|
53
|
-
Value self;
|
54
|
-
|
55
|
-
void mark ()
|
56
|
-
{
|
57
|
-
self.mark();
|
58
|
-
}
|
59
|
-
|
60
|
-
virtual bool close ()
|
61
|
-
{
|
62
|
-
SYM(close);
|
63
|
-
return self.call(close);
|
64
|
-
}
|
65
|
-
|
66
|
-
virtual bool show ()
|
67
|
-
{
|
68
|
-
SYM(show);
|
69
|
-
return self.call(show);
|
70
|
-
}
|
71
|
-
|
72
|
-
virtual bool hide ()
|
73
|
-
{
|
74
|
-
SYM(hide);
|
75
|
-
return self.call(hide);
|
76
|
-
}
|
77
|
-
|
78
|
-
virtual void update ()
|
79
|
-
{
|
80
|
-
SYM(update);
|
81
|
-
self.call(update);
|
82
|
-
}
|
83
|
-
|
84
|
-
virtual void draw ()
|
85
|
-
{
|
86
|
-
SYM(draw);
|
87
|
-
self.call(draw);
|
88
|
-
}
|
89
|
-
|
90
|
-
virtual void moved (coord x, coord y)
|
91
|
-
{
|
92
|
-
SYM(moved);
|
93
|
-
self.call(moved, x, y);
|
94
|
-
}
|
95
|
-
|
96
|
-
virtual void resized (coord width, coord height)
|
97
|
-
{
|
98
|
-
SYM(resized);
|
99
|
-
self.call(resized, width, height);
|
100
|
-
}
|
101
|
-
|
102
|
-
virtual void key_down (const Reflex::Key& key)
|
103
|
-
{
|
104
|
-
SYM(key_down);
|
105
|
-
self.call(key_down, value(key));
|
106
|
-
}
|
107
|
-
|
108
|
-
virtual void key_up (const Reflex::Key& key)
|
109
|
-
{
|
110
|
-
SYM(key_up);
|
111
|
-
self.call(key_up, value(key));
|
112
|
-
}
|
113
|
-
|
114
|
-
virtual void points_down (const Reflex::Points& points)
|
115
|
-
{
|
116
|
-
SYM(points_down);
|
117
|
-
self.call(points_down, value(points));
|
118
|
-
}
|
119
|
-
|
120
|
-
virtual void points_up (const Reflex::Points& points)
|
121
|
-
{
|
122
|
-
SYM(points_up);
|
123
|
-
self.call(points_up, value(points));
|
124
|
-
}
|
125
|
-
|
126
|
-
virtual void points_moved (const Reflex::Points& points)
|
127
|
-
{
|
128
|
-
SYM(points_moved);
|
129
|
-
self.call(points_moved, value(points));
|
130
|
-
}
|
131
|
-
|
132
|
-
};// RubyWindow
|
133
|
-
|
134
|
-
|
135
|
-
#define this ((RubyWindow*) to<Reflex::Window*>(self))
|
136
|
-
|
137
|
-
#define CHECK CHECK_OBJECT(self, RubyWindow, Reflex::window_class())
|
39
|
+
#define CALL(fun) RUCY_WRAPPER_CALL(RubyWindow, THIS, fun)
|
138
40
|
|
139
41
|
|
140
42
|
static
|
141
43
|
RUBY_DEF_ALLOC(alloc, klass)
|
142
44
|
{
|
143
|
-
|
144
|
-
return win->self = new_type<RubyWindow>(klass, win, mark_type<RubyWindow>);
|
45
|
+
return value(new RubyWindow, klass);
|
145
46
|
}
|
146
47
|
RUBY_END
|
147
48
|
|
@@ -149,7 +50,7 @@ static
|
|
149
50
|
RUBY_DEF0(close)
|
150
51
|
{
|
151
52
|
CHECK;
|
152
|
-
if (!
|
53
|
+
if (!CALL(close()))
|
153
54
|
system_error("failed to close window.");
|
154
55
|
return self;
|
155
56
|
}
|
@@ -159,7 +60,7 @@ static
|
|
159
60
|
RUBY_DEF0(show)
|
160
61
|
{
|
161
62
|
CHECK;
|
162
|
-
if (!
|
63
|
+
if (!CALL(show()))
|
163
64
|
system_error("failed to show window.");
|
164
65
|
return self;
|
165
66
|
}
|
@@ -169,92 +70,102 @@ static
|
|
169
70
|
RUBY_DEF0(hide)
|
170
71
|
{
|
171
72
|
CHECK;
|
172
|
-
if (!
|
73
|
+
if (!CALL(hide()))
|
173
74
|
system_error("failed to hide window.");
|
174
75
|
return self;
|
175
76
|
}
|
176
77
|
RUBY_END
|
177
78
|
|
178
79
|
static
|
179
|
-
RUBY_DEF0(
|
80
|
+
RUBY_DEF0(redraw)
|
180
81
|
{
|
181
82
|
CHECK;
|
182
|
-
|
83
|
+
if (!THIS->redraw())
|
84
|
+
system_error("failed to redraw window.");
|
85
|
+
return self;
|
183
86
|
}
|
184
87
|
RUBY_END
|
185
88
|
|
186
89
|
static
|
187
|
-
|
90
|
+
RUBY_DEF1(set_title, title)
|
188
91
|
{
|
189
92
|
CHECK;
|
190
|
-
|
191
|
-
|
93
|
+
if (!THIS->set_title(title.c_str()))
|
94
|
+
system_error("failed to set title of window.");
|
95
|
+
return title;
|
192
96
|
}
|
193
97
|
RUBY_END
|
194
98
|
|
195
99
|
static
|
196
|
-
RUBY_DEF0(
|
100
|
+
RUBY_DEF0(get_title)
|
197
101
|
{
|
198
102
|
CHECK;
|
199
|
-
|
200
|
-
|
103
|
+
const char* s = THIS->title();
|
104
|
+
if (!s) system_error("failed to get title of window.");
|
105
|
+
return value(s);
|
201
106
|
}
|
202
107
|
RUBY_END
|
203
108
|
|
204
109
|
static
|
205
|
-
|
110
|
+
RUBY_DEF4(set_bounds, x, y, width, height)
|
206
111
|
{
|
207
112
|
CHECK;
|
208
|
-
if (!
|
209
|
-
|
210
|
-
|
113
|
+
if (!THIS->set_bounds(
|
114
|
+
to<coord>(x), to<coord>(y), to<coord>(width), to<coord>(height)))
|
115
|
+
{
|
116
|
+
system_error("failed to set bounds of window.");
|
117
|
+
}
|
118
|
+
return value(THIS->bounds());
|
211
119
|
}
|
212
120
|
RUBY_END
|
213
121
|
|
214
122
|
static
|
215
|
-
RUBY_DEF0(
|
123
|
+
RUBY_DEF0(get_bounds)
|
216
124
|
{
|
217
125
|
CHECK;
|
218
|
-
|
219
|
-
if (!this->get_title(&s))
|
220
|
-
system_error("failed to get title of window.");
|
221
|
-
return value(s.c_str());
|
126
|
+
return value(THIS->bounds());
|
222
127
|
}
|
223
128
|
RUBY_END
|
224
129
|
|
225
130
|
static
|
226
|
-
|
131
|
+
RUBY_DEF0(hidden)
|
227
132
|
{
|
228
133
|
CHECK;
|
229
|
-
|
230
|
-
system_error("failed to set title of window.");
|
231
|
-
return title;
|
134
|
+
return value(THIS->hidden());
|
232
135
|
}
|
233
136
|
RUBY_END
|
234
137
|
|
235
138
|
static
|
236
|
-
RUBY_DEF0(
|
139
|
+
RUBY_DEF0(root)
|
237
140
|
{
|
238
141
|
CHECK;
|
239
|
-
|
240
|
-
if (!this->get_bounds(&x, &y, &width, &height))
|
241
|
-
system_error("failed to get bounds of window.");
|
242
|
-
Value ret[] = {x, y, width, height};
|
243
|
-
return value(4, ret);
|
142
|
+
return value(THIS->root());
|
244
143
|
}
|
245
144
|
RUBY_END
|
246
145
|
|
247
146
|
static
|
248
|
-
|
147
|
+
RUBY_DEF0(painter)
|
249
148
|
{
|
250
149
|
CHECK;
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
150
|
+
return value(THIS->painter());
|
151
|
+
}
|
152
|
+
RUBY_END
|
153
|
+
|
154
|
+
static
|
155
|
+
RUBY_DEF1(update, dt)
|
156
|
+
{
|
157
|
+
CHECK;
|
158
|
+
CALL(update(to<float>(dt)));
|
159
|
+
return self;
|
160
|
+
}
|
161
|
+
RUBY_END
|
162
|
+
|
163
|
+
static
|
164
|
+
RUBY_DEF0(draw)
|
165
|
+
{
|
166
|
+
CHECK;
|
167
|
+
CALL(draw());
|
168
|
+
return self;
|
258
169
|
}
|
259
170
|
RUBY_END
|
260
171
|
|
@@ -262,7 +173,7 @@ static
|
|
262
173
|
RUBY_DEF2(moved, x, y)
|
263
174
|
{
|
264
175
|
CHECK;
|
265
|
-
|
176
|
+
CALL(moved(to<coord>(x), to<coord>(y)));
|
266
177
|
return self;
|
267
178
|
}
|
268
179
|
RUBY_END
|
@@ -271,7 +182,7 @@ static
|
|
271
182
|
RUBY_DEF2(resized, width, height)
|
272
183
|
{
|
273
184
|
CHECK;
|
274
|
-
|
185
|
+
CALL(resized(to<coord>(width), to<coord>(height)));
|
275
186
|
return self;
|
276
187
|
}
|
277
188
|
RUBY_END
|
@@ -282,7 +193,7 @@ RUBY_DEF1(key_down, key)
|
|
282
193
|
CHECK;
|
283
194
|
Reflex::Key* k = to<Reflex::Key*>(key);
|
284
195
|
if (!k) argument_error();
|
285
|
-
|
196
|
+
CALL(key_down(*k));
|
286
197
|
return self;
|
287
198
|
}
|
288
199
|
RUBY_END
|
@@ -293,7 +204,7 @@ RUBY_DEF1(key_up, key)
|
|
293
204
|
CHECK;
|
294
205
|
Reflex::Key* k = to<Reflex::Key*>(key);
|
295
206
|
if (!k) argument_error();
|
296
|
-
|
207
|
+
CALL(key_up(*k));
|
297
208
|
return self;
|
298
209
|
}
|
299
210
|
RUBY_END
|
@@ -304,7 +215,7 @@ RUBY_DEF1(points_down, points)
|
|
304
215
|
CHECK;
|
305
216
|
Reflex::Points* p = to<Reflex::Points*>(points);
|
306
217
|
if (!p) argument_error();
|
307
|
-
|
218
|
+
CALL(points_down(*p));
|
308
219
|
return self;
|
309
220
|
}
|
310
221
|
RUBY_END
|
@@ -315,7 +226,7 @@ RUBY_DEF1(points_up, points)
|
|
315
226
|
CHECK;
|
316
227
|
Reflex::Points* p = to<Reflex::Points*>(points);
|
317
228
|
if (!p) argument_error();
|
318
|
-
|
229
|
+
CALL(points_up(*p));
|
319
230
|
return self;
|
320
231
|
}
|
321
232
|
RUBY_END
|
@@ -326,7 +237,7 @@ RUBY_DEF1(points_moved, points)
|
|
326
237
|
CHECK;
|
327
238
|
Reflex::Points* p = to<Reflex::Points*>(points);
|
328
239
|
if (!p) argument_error();
|
329
|
-
|
240
|
+
CALL(points_moved(*p));
|
330
241
|
return self;
|
331
242
|
}
|
332
243
|
RUBY_END
|
@@ -335,28 +246,28 @@ RUBY_END
|
|
335
246
|
void
|
336
247
|
Init_window ()
|
337
248
|
{
|
338
|
-
Module
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
249
|
+
Module mReflex = define_module("Reflex");
|
250
|
+
|
251
|
+
cWindow = mReflex.define_class("Window");
|
252
|
+
cWindow.define_alloc_func(alloc);
|
253
|
+
cWindow.define_method("close", close);
|
254
|
+
cWindow.define_method("show", show);
|
255
|
+
cWindow.define_method("hide", hide);
|
256
|
+
cWindow.define_method("redraw", redraw);
|
257
|
+
cWindow.define_method("title=", set_title);
|
258
|
+
cWindow.define_method("title", get_title);
|
259
|
+
cWindow.define_private_method("set_bounds", set_bounds);
|
260
|
+
cWindow.define_private_method("get_bounds", get_bounds);
|
261
|
+
cWindow.define_method("hidden", hidden);
|
262
|
+
cWindow.define_method("root", root);
|
263
|
+
cWindow.define_method("painter", painter);
|
264
|
+
cWindow.define_method("update", update);
|
265
|
+
cWindow.define_method("draw", draw);
|
266
|
+
cWindow.define_method("moved", moved);
|
267
|
+
cWindow.define_method("resized", resized);
|
268
|
+
cWindow.define_method("key_down", key_down);
|
269
|
+
cWindow.define_method("key_up", key_up);
|
270
|
+
cWindow.define_method("points_down", points_down);
|
271
|
+
cWindow.define_method("points_up", points_up);
|
272
|
+
cWindow.define_method("points_moved", points_moved);
|
362
273
|
}
|