reflexion 0.1.2 → 0.1.3
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.
- data/.doc/ext/reflex/application.cpp +150 -0
- data/.doc/ext/reflex/key.cpp +127 -0
- data/.doc/ext/reflex/native.cpp +26 -0
- data/.doc/ext/reflex/points.cpp +156 -0
- data/.doc/ext/reflex/reflex.cpp +72 -0
- data/.doc/ext/reflex/window.cpp +343 -0
- data/Rakefile +11 -34
- data/VERSION +1 -1
- data/ext/reflex/application.cpp +15 -10
- data/ext/reflex/{reflex.h → defs.h} +4 -13
- data/ext/reflex/extconf.rb +29 -17
- data/ext/reflex/key.cpp +15 -10
- data/ext/reflex/native.cpp +5 -1
- data/ext/reflex/points.cpp +18 -13
- data/ext/reflex/reflex.cpp +10 -17
- data/ext/reflex/window.cpp +28 -23
- data/include/reflex/application.h +3 -0
- data/include/reflex/defs.h +60 -37
- data/include/reflex/exception.h +41 -0
- data/include/reflex.h +1 -0
- data/lib/reflex/module.rb +9 -1
- data/reflex.gemspec +21 -8
- data/src/cocoa/application.mm +17 -0
- data/src/cocoa/reflex.mm +6 -23
- data/src/defs.cpp +2 -2
- data/src/exception.cpp +49 -0
- data/src/reflex.cpp +37 -0
- data/src/win32/application.cpp +111 -0
- data/src/win32/defs.cpp +287 -134
- data/src/win32/defs.h +34 -0
- data/src/win32/reflex.cpp +9 -30
- data/src/win32/window.cpp +6 -32
- metadata +37 -14
- data/support.rb +0 -52
- data/task/ext.rake +0 -42
- data/task/gem.rake +0 -33
- data/task/git.rake +0 -22
- data/task/lib.rake +0 -54
data/ext/reflex/reflex.cpp
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#include <rucy.h>
|
2
2
|
#include <reflex/reflex.h>
|
3
|
-
#include "
|
3
|
+
#include "defs.h"
|
4
4
|
|
5
5
|
|
6
6
|
using namespace Rucy;
|
@@ -10,19 +10,12 @@ namespace Reflex
|
|
10
10
|
{
|
11
11
|
|
12
12
|
|
13
|
+
static Module mReflex;
|
14
|
+
|
13
15
|
Module
|
14
16
|
reflex_module ()
|
15
17
|
{
|
16
|
-
|
17
|
-
return m;
|
18
|
-
}
|
19
|
-
|
20
|
-
Class
|
21
|
-
reflex_error_class ()
|
22
|
-
{
|
23
|
-
static Class c =
|
24
|
-
reflex_module().define_class("ReflexError", native_error_class());
|
25
|
-
return c;
|
18
|
+
return mReflex;
|
26
19
|
}
|
27
20
|
|
28
21
|
|
@@ -73,11 +66,11 @@ RUBY_END
|
|
73
66
|
void
|
74
67
|
Init_reflex ()
|
75
68
|
{
|
76
|
-
Reflex
|
69
|
+
Module m = define_module("Reflex");
|
70
|
+
Reflex::mReflex = m;
|
77
71
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
.define_singleton_method("quit", quit);
|
72
|
+
m.define_singleton_method("init!", init);
|
73
|
+
m.define_singleton_method("fin!", fin);
|
74
|
+
m.define_singleton_method("run!", run);
|
75
|
+
m.define_singleton_method("quit", quit);
|
83
76
|
}
|
data/ext/reflex/window.cpp
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
#include <rucy.h>
|
5
5
|
#include <reflex/ruby/key.h>
|
6
6
|
#include <reflex/ruby/points.h>
|
7
|
-
#include "
|
7
|
+
#include "defs.h"
|
8
8
|
|
9
9
|
|
10
10
|
using namespace Rucy;
|
@@ -16,11 +16,12 @@ namespace Reflex
|
|
16
16
|
{
|
17
17
|
|
18
18
|
|
19
|
+
static Class cWindow;
|
20
|
+
|
19
21
|
Class
|
20
22
|
window_class ()
|
21
23
|
{
|
22
|
-
|
23
|
-
return c;
|
24
|
+
return cWindow;
|
24
25
|
}
|
25
26
|
|
26
27
|
|
@@ -334,24 +335,28 @@ RUBY_END
|
|
334
335
|
void
|
335
336
|
Init_window ()
|
336
337
|
{
|
337
|
-
Reflex
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
338
|
+
Module m = define_module("Reflex");
|
339
|
+
|
340
|
+
Class c = m.define_class("Window");
|
341
|
+
Reflex::cWindow = c;
|
342
|
+
|
343
|
+
c.define_alloc_func(alloc);
|
344
|
+
c.define_method("close", close);
|
345
|
+
c.define_method("show", show);
|
346
|
+
c.define_method("hide", hide);
|
347
|
+
c.define_method("hidden", hidden);
|
348
|
+
c.define_method("update", update);
|
349
|
+
c.define_method("draw", draw);
|
350
|
+
c.define_method("redraw", redraw);
|
351
|
+
c.define_method("title", get_title);
|
352
|
+
c.define_method("title=", set_title);
|
353
|
+
c.define_private_method("get_bounds", get_bounds);
|
354
|
+
c.define_private_method("set_bounds", set_bounds);
|
355
|
+
c.define_method("moved", moved);
|
356
|
+
c.define_method("resized", resized);
|
357
|
+
c.define_method("key_down", key_down);
|
358
|
+
c.define_method("key_up", key_up);
|
359
|
+
c.define_method("points_down", points_down);
|
360
|
+
c.define_method("points_up", points_up);
|
361
|
+
c.define_method("points_moved", points_moved);
|
357
362
|
}
|
data/include/reflex/defs.h
CHANGED
@@ -4,34 +4,26 @@
|
|
4
4
|
#define __REFLEX_DEFS_H__
|
5
5
|
|
6
6
|
|
7
|
-
#include <
|
8
|
-
#include <
|
7
|
+
#include <xot/defs.h>
|
8
|
+
#include <xot/string.h>
|
9
9
|
|
10
10
|
|
11
11
|
namespace Reflex
|
12
12
|
{
|
13
13
|
|
14
14
|
|
15
|
-
|
15
|
+
using namespace Xot::Types;
|
16
16
|
|
17
|
-
|
17
|
+
using Xot::String;
|
18
18
|
|
19
|
-
typedef unsigned int uint;
|
20
|
-
|
21
|
-
typedef unsigned long ulong;
|
22
19
|
|
23
20
|
typedef float coord;
|
24
21
|
|
25
|
-
typedef std::string String;
|
26
|
-
|
27
|
-
|
28
|
-
enum {UNKNOWN = 0};
|
29
|
-
|
30
22
|
|
31
23
|
enum KeyCodes
|
32
24
|
{
|
33
25
|
|
34
|
-
KEY_NONE =
|
26
|
+
KEY_NONE = 0,
|
35
27
|
|
36
28
|
KEY_RETURN,
|
37
29
|
KEY_ENTER = KEY_RETURN,
|
@@ -64,17 +56,17 @@ namespace Reflex
|
|
64
56
|
KEY_LALT,
|
65
57
|
KEY_RALT,
|
66
58
|
|
59
|
+
KEY_WIN,
|
60
|
+
KEY_LWIN,
|
61
|
+
KEY_RWIN,
|
62
|
+
|
67
63
|
KEY_OPTION = KEY_ALT,
|
68
64
|
KEY_LOPTION = KEY_LALT,
|
69
65
|
KEY_ROPTION = KEY_RALT,
|
70
66
|
|
71
|
-
KEY_COMMAND,
|
72
|
-
KEY_LCOMMAND,
|
73
|
-
KEY_RCOMMAND,
|
74
|
-
|
75
|
-
KEY_WIN,
|
76
|
-
KEY_LWIN,
|
77
|
-
KEY_RWIN,
|
67
|
+
KEY_COMMAND = KEY_WIN,
|
68
|
+
KEY_LCOMMAND = KEY_LWIN,
|
69
|
+
KEY_RCOMMAND = KEY_RWIN,
|
78
70
|
|
79
71
|
KEY_CAPSLOCK,
|
80
72
|
KEY_NUMLOCK,
|
@@ -82,24 +74,49 @@ namespace Reflex
|
|
82
74
|
|
83
75
|
KEY_PRINTSCREEN,
|
84
76
|
KEY_PAUSE,
|
85
|
-
|
86
|
-
KEY_KANA,
|
87
|
-
KEY_KANJI,
|
77
|
+
KEY_BREAK,
|
88
78
|
|
89
79
|
KEY_SLEEP,
|
90
|
-
|
80
|
+
KEY_EXEC,//UTE,
|
91
81
|
KEY_HELP,
|
92
82
|
KEY_PRINT,
|
93
83
|
KEY_APPS,
|
94
84
|
KEY_SELECT,
|
95
|
-
KEY_ACCEPT,
|
96
|
-
KEY_CANCEL,
|
97
85
|
KEY_CLEAR,
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
86
|
+
KEY_PLAY,
|
87
|
+
KEY_ZOOM,
|
88
|
+
|
89
|
+
KEY_IME_KANA,
|
90
|
+
KEY_IME_KANJI,
|
91
|
+
KEY_IME_JUNJA,
|
92
|
+
KEY_IME_PROCESS,
|
93
|
+
KEY_IME_ACCEPT,
|
94
|
+
KEY_IME_FINAL,
|
95
|
+
KEY_IME_CONVERT,
|
96
|
+
KEY_IME_NONCONVERT,
|
97
|
+
KEY_IME_MODECHANGE,
|
98
|
+
|
99
|
+
KEY_BROWSER_BACK,
|
100
|
+
KEY_BROWSER_FORWARD,
|
101
|
+
KEY_BROWSER_REFRESH,
|
102
|
+
KEY_BROWSER_STOP,
|
103
|
+
KEY_BROWSER_SEARCH,
|
104
|
+
KEY_BROWSER_FAVORITES,
|
105
|
+
KEY_BROWSER_HOME,
|
106
|
+
|
107
|
+
KEY_VOLUME_MUTE,
|
108
|
+
KEY_VOLUME_DOWN,
|
109
|
+
KEY_VOLUME_UP,
|
110
|
+
|
111
|
+
KEY_MEDIA_NEXT_TRACK,
|
112
|
+
KEY_MEDIA_PREV_TRACK,
|
113
|
+
KEY_MEDIA_STOP,
|
114
|
+
KEY_MEDIA_PLAY_PAUSE,
|
115
|
+
|
116
|
+
KEY_LAUNCH_MAIL,
|
117
|
+
KEY_LAUNCH_MEDIA_SELECT,
|
118
|
+
KEY_LAUNCH_APP1,
|
119
|
+
KEY_LAUNCH_APP2,
|
103
120
|
|
104
121
|
KEY_F1,
|
105
122
|
KEY_F2,
|
@@ -143,7 +160,7 @@ namespace Reflex
|
|
143
160
|
enum PointTypes
|
144
161
|
{
|
145
162
|
|
146
|
-
POINT_NONE =
|
163
|
+
POINT_NONE = 0,
|
147
164
|
|
148
165
|
POINT_MOUSE_LEFT = 0x1 << 0,
|
149
166
|
|
@@ -165,17 +182,21 @@ namespace Reflex
|
|
165
182
|
enum Modifiers
|
166
183
|
{
|
167
184
|
|
168
|
-
MOD_NONE =
|
185
|
+
MOD_NONE = 0,
|
169
186
|
|
170
|
-
|
187
|
+
#ifndef MOD_SHIFT
|
188
|
+
MOD_SHIFT = 0x1 << 2,
|
171
189
|
|
172
190
|
MOD_CONTROL = 0x1 << 1,
|
173
191
|
|
174
|
-
MOD_ALT = 0x1 <<
|
192
|
+
MOD_ALT = 0x1 << 0,
|
193
|
+
|
194
|
+
MOD_WIN = 0x1 << 3,
|
195
|
+
#endif
|
175
196
|
|
176
197
|
MOD_OPTION = MOD_ALT,
|
177
198
|
|
178
|
-
MOD_COMMAND =
|
199
|
+
MOD_COMMAND = MOD_WIN,
|
179
200
|
|
180
201
|
MOD_HELP = 0x1 << 4,
|
181
202
|
|
@@ -193,10 +214,12 @@ namespace Reflex
|
|
193
214
|
|
194
215
|
String chars;
|
195
216
|
|
196
|
-
int code
|
217
|
+
int code;
|
197
218
|
|
198
219
|
uint modifiers;
|
199
220
|
|
221
|
+
int repeat;
|
222
|
+
|
200
223
|
Key ();
|
201
224
|
|
202
225
|
Key (
|
@@ -0,0 +1,41 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __REFLEX_EXCEPTION_H__
|
4
|
+
#define __REFLEX_EXCEPTION_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <stdexcept>
|
8
|
+
#include <reflex/defs.h>
|
9
|
+
|
10
|
+
|
11
|
+
namespace Reflex
|
12
|
+
{
|
13
|
+
|
14
|
+
|
15
|
+
class ReflexException : public std::runtime_error
|
16
|
+
{
|
17
|
+
|
18
|
+
typedef std::runtime_error Super;
|
19
|
+
|
20
|
+
public:
|
21
|
+
|
22
|
+
ReflexException (const char* format = NULL, ...);
|
23
|
+
|
24
|
+
~ReflexException () throw();
|
25
|
+
|
26
|
+
const char* what () const throw();
|
27
|
+
|
28
|
+
private:
|
29
|
+
|
30
|
+
String text;
|
31
|
+
|
32
|
+
};// ReflexException
|
33
|
+
|
34
|
+
|
35
|
+
void error (const char* format = NULL, ...);
|
36
|
+
|
37
|
+
|
38
|
+
}// Reflex
|
39
|
+
|
40
|
+
|
41
|
+
#endif//EOH
|
data/include/reflex.h
CHANGED
data/lib/reflex/module.rb
CHANGED
@@ -15,7 +15,15 @@ module Reflex
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def library_dirs ()
|
18
|
-
[File.join
|
18
|
+
%w[lib ext].map {|dir| File.join root_dir, dir}
|
19
|
+
end
|
20
|
+
|
21
|
+
def task_dir ()
|
22
|
+
File.join root_dir, 'task'
|
23
|
+
end
|
24
|
+
|
25
|
+
def load_tasks ()
|
26
|
+
Dir["#{task_dir}/**/*.rake"].each {|path| load path}
|
19
27
|
end
|
20
28
|
|
21
29
|
def version ()
|
data/reflex.gemspec
CHANGED
@@ -1,15 +1,21 @@
|
|
1
1
|
# -*- mode: ruby; coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
2
4
|
$: << File.join(File.dirname(__FILE__), 'lib')
|
5
|
+
|
3
6
|
require 'rake'
|
4
7
|
require 'reflex/module'
|
5
8
|
|
6
9
|
|
7
|
-
|
8
|
-
|
10
|
+
MODULE = Reflex
|
11
|
+
NAME = MODULE.name.downcase
|
12
|
+
|
13
|
+
|
14
|
+
FILES = FileList[*%W[
|
9
15
|
README
|
16
|
+
ChangeLog
|
10
17
|
Rakefile
|
11
|
-
|
12
|
-
reflex.gemspec
|
18
|
+
#{NAME}.gemspec
|
13
19
|
VERSION
|
14
20
|
task/**/*.rake
|
15
21
|
ext/**/*.rb
|
@@ -28,20 +34,27 @@ FILES = FileList[*%w[
|
|
28
34
|
test/**/*.rb
|
29
35
|
]]
|
30
36
|
|
37
|
+
RDOCS = FileList[*%W[
|
38
|
+
README
|
39
|
+
.doc/ext/**/*.cpp
|
40
|
+
]]
|
41
|
+
|
42
|
+
|
31
43
|
Gem::Specification.new do |s|
|
32
|
-
s.name =
|
44
|
+
s.name = "#{NAME}ion"
|
33
45
|
s.summary = 'A Graphical User Interface Tool Kit.'
|
34
46
|
s.description = 'This library helps you to develop interactive graphical user interface.'
|
35
|
-
s.version =
|
47
|
+
s.version = MODULE.version
|
36
48
|
|
37
49
|
s.authors = %w[snori]
|
38
50
|
s.email = 'snori@xord.org'
|
39
|
-
s.homepage =
|
51
|
+
s.homepage = "http://github.com/xord/#{NAME}"
|
40
52
|
|
41
53
|
s.platform = Gem::Platform::RUBY
|
42
54
|
s.required_ruby_version = '>=1.9.0'
|
43
55
|
s.require_paths << 'ext'
|
44
56
|
|
57
|
+
s.add_runtime_dependency 'xot'
|
45
58
|
s.add_runtime_dependency 'rucy'
|
46
59
|
s.add_runtime_dependency 'rays'
|
47
60
|
s.add_development_dependency 'rake'
|
@@ -51,7 +64,7 @@ Gem::Specification.new do |s|
|
|
51
64
|
s.test_files = FileList['test/**/test_*.rb'].to_a
|
52
65
|
|
53
66
|
s.has_rdoc = true
|
54
|
-
s.extra_rdoc_files =
|
67
|
+
s.extra_rdoc_files = RDOCS.to_a
|
55
68
|
|
56
69
|
s.extensions << 'Rakefile'
|
57
70
|
end
|
data/src/cocoa/application.mm
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
|
5
5
|
#import <Cocoa/Cocoa.h>
|
6
|
+
#include <reflex/exception.h>
|
6
7
|
#include "applicationdata.h"
|
7
8
|
#import "cocoaapplication.h"
|
8
9
|
|
@@ -11,8 +12,22 @@ namespace Reflex
|
|
11
12
|
{
|
12
13
|
|
13
14
|
|
15
|
+
static Application* instance = NULL;
|
16
|
+
|
17
|
+
|
18
|
+
Application*
|
19
|
+
app ()
|
20
|
+
{
|
21
|
+
return instance;
|
22
|
+
}
|
23
|
+
|
24
|
+
|
14
25
|
Application::Application ()
|
15
26
|
{
|
27
|
+
if (instance) error("multiple application instance.");
|
28
|
+
|
29
|
+
instance = this;
|
30
|
+
|
16
31
|
self->this_ = this;
|
17
32
|
self->self_ = NSApp ? [NSApp retain] : nil;
|
18
33
|
if (self->self_)
|
@@ -27,6 +42,8 @@ namespace Reflex
|
|
27
42
|
self->self_ = nil;
|
28
43
|
}
|
29
44
|
self->this_ = NULL;
|
45
|
+
|
46
|
+
instance = NULL;
|
30
47
|
}
|
31
48
|
|
32
49
|
bool
|
data/src/cocoa/reflex.mm
CHANGED
@@ -18,6 +18,12 @@ namespace Reflex
|
|
18
18
|
}// global
|
19
19
|
|
20
20
|
|
21
|
+
bool
|
22
|
+
initialized ()
|
23
|
+
{
|
24
|
+
return global::pool;
|
25
|
+
}
|
26
|
+
|
21
27
|
bool
|
22
28
|
init ()
|
23
29
|
{
|
@@ -41,28 +47,5 @@ namespace Reflex
|
|
41
47
|
return true;
|
42
48
|
}
|
43
49
|
|
44
|
-
bool
|
45
|
-
run (const char* name)
|
46
|
-
{
|
47
|
-
if (!global::pool || !NSApp) return false;
|
48
|
-
|
49
|
-
Application app;
|
50
|
-
if (!app) return false;
|
51
|
-
|
52
|
-
if (name && !app.set_name(name))
|
53
|
-
return false;
|
54
|
-
|
55
|
-
return app.run();
|
56
|
-
}
|
57
|
-
|
58
|
-
bool
|
59
|
-
quit ()
|
60
|
-
{
|
61
|
-
if (!global::pool || !NSApp) return false;
|
62
|
-
|
63
|
-
[NSApp terminate: nil];
|
64
|
-
return true;
|
65
|
-
}
|
66
|
-
|
67
50
|
|
68
51
|
}// Reflex
|
data/src/defs.cpp
CHANGED
@@ -6,12 +6,12 @@ namespace Reflex
|
|
6
6
|
|
7
7
|
|
8
8
|
Key::Key ()
|
9
|
-
: code(KEY_NONE),
|
9
|
+
: code(KEY_NONE), modifiers(MOD_NONE), repeat(0)
|
10
10
|
{
|
11
11
|
}
|
12
12
|
|
13
13
|
Key::Key (const char* chars, int code, uint modifiers, int repeat)
|
14
|
-
: chars(chars), code(code),
|
14
|
+
: chars(chars ? chars : ""), code(code), modifiers(modifiers), repeat(repeat)
|
15
15
|
{
|
16
16
|
}
|
17
17
|
|
data/src/exception.cpp
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
#include "reflex/exception.h"
|
2
|
+
|
3
|
+
|
4
|
+
#define VA_STRING(format, result) \
|
5
|
+
String result; \
|
6
|
+
do \
|
7
|
+
{ \
|
8
|
+
if (format) \
|
9
|
+
{ \
|
10
|
+
va_list args; \
|
11
|
+
va_start(args, format); \
|
12
|
+
result = Xot::stringf(format, args); \
|
13
|
+
va_end(args); \
|
14
|
+
} \
|
15
|
+
} \
|
16
|
+
while (false)
|
17
|
+
|
18
|
+
|
19
|
+
namespace Reflex
|
20
|
+
{
|
21
|
+
|
22
|
+
|
23
|
+
ReflexException::ReflexException (const char* format, ...)
|
24
|
+
: Super("")
|
25
|
+
{
|
26
|
+
VA_STRING(format, s);
|
27
|
+
text = s;
|
28
|
+
}
|
29
|
+
|
30
|
+
ReflexException::~ReflexException () throw()
|
31
|
+
{
|
32
|
+
}
|
33
|
+
|
34
|
+
const char*
|
35
|
+
ReflexException::what () const throw()
|
36
|
+
{
|
37
|
+
return text.c_str();
|
38
|
+
}
|
39
|
+
|
40
|
+
|
41
|
+
void
|
42
|
+
error (const char* format, ...)
|
43
|
+
{
|
44
|
+
VA_STRING(format, s);
|
45
|
+
throw ReflexException(s.c_str());
|
46
|
+
}
|
47
|
+
|
48
|
+
|
49
|
+
}// Reflex
|
data/src/reflex.cpp
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#include "reflex/reflex.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include <reflex/application.h>
|
5
|
+
|
6
|
+
|
7
|
+
namespace Reflex
|
8
|
+
{
|
9
|
+
|
10
|
+
|
11
|
+
bool initialized ();
|
12
|
+
|
13
|
+
|
14
|
+
bool
|
15
|
+
run (const char* name)
|
16
|
+
{
|
17
|
+
if (!initialized() || app()) return false;
|
18
|
+
|
19
|
+
Application a;
|
20
|
+
if (!a) return false;
|
21
|
+
|
22
|
+
if (name && !a.set_name(name))
|
23
|
+
return false;
|
24
|
+
|
25
|
+
return a.run();
|
26
|
+
}
|
27
|
+
|
28
|
+
bool
|
29
|
+
quit ()
|
30
|
+
{
|
31
|
+
if (!initialized() || !app()) return false;
|
32
|
+
|
33
|
+
return app()->quit();
|
34
|
+
}
|
35
|
+
|
36
|
+
|
37
|
+
}// Reflex
|