reflexion 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,111 @@
|
|
1
|
+
#include "reflex/application.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include <windows.h>
|
5
|
+
#include <reflex/exception.h>
|
6
|
+
|
7
|
+
|
8
|
+
namespace Reflex
|
9
|
+
{
|
10
|
+
|
11
|
+
|
12
|
+
static Application* instance = NULL;
|
13
|
+
|
14
|
+
|
15
|
+
Application*
|
16
|
+
app ()
|
17
|
+
{
|
18
|
+
return instance;
|
19
|
+
}
|
20
|
+
|
21
|
+
|
22
|
+
struct Application::Data
|
23
|
+
{
|
24
|
+
|
25
|
+
String name;
|
26
|
+
|
27
|
+
operator bool () const
|
28
|
+
{
|
29
|
+
return true;
|
30
|
+
}
|
31
|
+
|
32
|
+
};// Application::Data
|
33
|
+
|
34
|
+
|
35
|
+
Application::Application ()
|
36
|
+
{
|
37
|
+
if (instance) error("multiple application instance.");
|
38
|
+
|
39
|
+
instance = this;
|
40
|
+
}
|
41
|
+
|
42
|
+
Application::~Application ()
|
43
|
+
{
|
44
|
+
instance = NULL;
|
45
|
+
}
|
46
|
+
|
47
|
+
bool
|
48
|
+
Application::run ()
|
49
|
+
{
|
50
|
+
if (!*this) return false;
|
51
|
+
|
52
|
+
MSG msg;
|
53
|
+
while (GetMessage(&msg, NULL, 0, 0))
|
54
|
+
{
|
55
|
+
TranslateMessage(&msg);
|
56
|
+
DispatchMessage(&msg);
|
57
|
+
}
|
58
|
+
|
59
|
+
return msg.wParam == 0;
|
60
|
+
}
|
61
|
+
|
62
|
+
bool
|
63
|
+
Application::quit ()
|
64
|
+
{
|
65
|
+
if (!*this) return false;
|
66
|
+
|
67
|
+
PostQuitMessage(0);
|
68
|
+
return true;
|
69
|
+
}
|
70
|
+
|
71
|
+
bool
|
72
|
+
Application::preference ()
|
73
|
+
{
|
74
|
+
return *this;
|
75
|
+
}
|
76
|
+
|
77
|
+
bool
|
78
|
+
Application::about ()
|
79
|
+
{
|
80
|
+
return *this;
|
81
|
+
}
|
82
|
+
|
83
|
+
bool
|
84
|
+
Application::get_name (String* name) const
|
85
|
+
{
|
86
|
+
if (!*this || !name) return false;
|
87
|
+
*name = self->name;
|
88
|
+
return true;
|
89
|
+
}
|
90
|
+
|
91
|
+
bool
|
92
|
+
Application::set_name (const char* name)
|
93
|
+
{
|
94
|
+
if (!*this || !name) return false;
|
95
|
+
self->name = name;
|
96
|
+
return true;
|
97
|
+
}
|
98
|
+
|
99
|
+
Application::operator bool () const
|
100
|
+
{
|
101
|
+
return self && *self;
|
102
|
+
}
|
103
|
+
|
104
|
+
bool
|
105
|
+
Application::operator ! () const
|
106
|
+
{
|
107
|
+
return !operator bool();
|
108
|
+
}
|
109
|
+
|
110
|
+
|
111
|
+
}// Reflex
|
data/src/win32/defs.cpp
CHANGED
@@ -1,150 +1,303 @@
|
|
1
|
-
#include "
|
1
|
+
#include "defs.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include <windowsx.h>
|
5
|
+
|
6
|
+
|
7
|
+
#ifndef VK_BROWSER_BACK
|
8
|
+
#define VK_BROWSER_BACK 0xa6
|
9
|
+
#define VK_BROWSER_FORWARD 0xa7
|
10
|
+
#define VK_BROWSER_REFRESH 0xa8
|
11
|
+
#define VK_BROWSER_STOP 0xa9
|
12
|
+
#define VK_BROWSER_SEARCH 0xaa
|
13
|
+
#define VK_BROWSER_FAVORITES 0xab
|
14
|
+
#define VK_BROWSER_HOME 0xac
|
15
|
+
#define VK_VOLUME_MUTE 0xad
|
16
|
+
#define VK_VOLUME_DOWN 0xae
|
17
|
+
#define VK_VOLUME_UP 0xaf
|
18
|
+
#define VK_MEDIA_NEXT_TRACK 0xb0
|
19
|
+
#define VK_MEDIA_PREV_TRACK 0xb1
|
20
|
+
#define VK_MEDIA_STOP 0xb2
|
21
|
+
#define VK_MEDIA_PLAY_PAUSE 0xb3
|
22
|
+
#define VK_LAUNCH_MAIL 0xb4
|
23
|
+
#define VK_LAUNCH_MEDIA_SELECT 0xb5
|
24
|
+
#define VK_LAUNCH_APP1 0xb6
|
25
|
+
#define VK_LAUNCH_APP2 0xb7
|
26
|
+
#endif
|
2
27
|
|
3
28
|
|
4
29
|
namespace Reflex
|
5
30
|
{
|
6
31
|
|
7
32
|
|
8
|
-
bool
|
9
|
-
|
33
|
+
static bool
|
34
|
+
get_modifiers (uint* modifiers)
|
10
35
|
{
|
11
|
-
if (!
|
12
|
-
|
36
|
+
if (!modifiers) return false;
|
37
|
+
|
38
|
+
*modifiers |=
|
39
|
+
GetKeyState(VK_SHIFT) ? MOD_SHIFT : 0 |
|
40
|
+
GetKeyState(VK_CONTROL) ? MOD_CONTROL : 0 |
|
41
|
+
GetKeyState(VK_MENU) ? MOD_ALT : 0 |
|
42
|
+
GetKeyState(VK_LWIN) ? MOD_WIN : 0 |
|
43
|
+
GetKeyState(VK_RWIN) ? MOD_WIN : 0 |
|
44
|
+
GetKeyState(VK_CAPITAL) ? MOD_CAPS : 0 |
|
45
|
+
GetKeyState(VK_NUMLOCK) ? MOD_NUMPAD : 0;
|
46
|
+
|
47
|
+
return true;
|
48
|
+
}
|
49
|
+
|
50
|
+
static bool
|
51
|
+
get_keypress (Key* key, UINT msg, WPARAM wp, LPARAM lp)
|
52
|
+
{
|
53
|
+
if (!key) return false;
|
54
|
+
|
55
|
+
String& s = key->chars;
|
56
|
+
int& c = key->code;
|
57
|
+
uint& m = key->modifiers;
|
13
58
|
|
14
|
-
switch (
|
59
|
+
switch (wp)
|
15
60
|
{
|
16
|
-
case VK_CANCEL:
|
17
|
-
case VK_BACK:
|
18
|
-
case VK_TAB:
|
19
|
-
case VK_CLEAR:
|
20
|
-
case VK_RETURN:
|
21
|
-
case VK_SHIFT:
|
22
|
-
case VK_CONTROL:
|
23
|
-
case VK_MENU:
|
24
|
-
case VK_PAUSE:
|
25
|
-
case VK_CAPITAL:
|
26
|
-
case VK_KANA:
|
27
|
-
case VK_JUNJA:
|
28
|
-
case VK_FINAL:
|
29
|
-
case VK_KANJI:
|
30
|
-
case VK_ESCAPE:
|
31
|
-
case VK_CONVERT:
|
32
|
-
case VK_NONCONVERT:
|
33
|
-
case VK_ACCEPT:
|
34
|
-
case VK_MODECHANGE:
|
35
|
-
case VK_SPACE:
|
36
|
-
case VK_PRIOR:
|
37
|
-
case VK_NEXT:
|
38
|
-
case VK_END:
|
39
|
-
case VK_HOME:
|
40
|
-
case VK_LEFT:
|
41
|
-
case VK_UP:
|
42
|
-
case VK_RIGHT:
|
43
|
-
case VK_DOWN:
|
44
|
-
case VK_SELECT:
|
45
|
-
case VK_PRINT:
|
46
|
-
case VK_EXECUTE:
|
47
|
-
case
|
48
|
-
case VK_INSERT:
|
49
|
-
case VK_DELETE:
|
50
|
-
case VK_HELP:
|
51
|
-
case VK_LWIN:
|
52
|
-
case VK_RWIN:
|
53
|
-
case VK_APPS:
|
54
|
-
case VK_SLEEP:
|
55
|
-
case VK_NUMPAD0:
|
56
|
-
case VK_NUMPAD1:
|
57
|
-
case VK_NUMPAD2:
|
58
|
-
case VK_NUMPAD3:
|
59
|
-
case VK_NUMPAD4:
|
60
|
-
case VK_NUMPAD5:
|
61
|
-
case VK_NUMPAD6:
|
62
|
-
case VK_NUMPAD7:
|
63
|
-
case VK_NUMPAD8:
|
64
|
-
case VK_NUMPAD9:
|
65
|
-
case VK_MULTIPLY:
|
66
|
-
case VK_ADD:
|
67
|
-
case VK_SEPARATOR:
|
68
|
-
case VK_SUBTRACT:
|
69
|
-
case VK_DECIMAL:
|
70
|
-
case
|
71
|
-
case VK_F1:
|
72
|
-
case VK_F2:
|
73
|
-
case VK_F3:
|
74
|
-
case VK_F4:
|
75
|
-
case VK_F5:
|
76
|
-
case VK_F6:
|
77
|
-
case VK_F7:
|
78
|
-
case VK_F8:
|
79
|
-
case VK_F9:
|
80
|
-
case VK_F10:
|
81
|
-
case VK_F11:
|
82
|
-
case VK_F12:
|
83
|
-
case VK_F13:
|
84
|
-
case VK_F14:
|
85
|
-
case VK_F15:
|
86
|
-
case VK_F16:
|
87
|
-
case VK_F17:
|
88
|
-
case VK_F18:
|
89
|
-
case VK_F19:
|
90
|
-
case VK_F20:
|
91
|
-
case VK_F21:
|
92
|
-
case VK_F22:
|
93
|
-
case VK_F23:
|
94
|
-
case VK_F24:
|
95
|
-
case VK_NUMLOCK:
|
96
|
-
case VK_SCROLL:
|
97
|
-
case VK_LSHIFT:
|
98
|
-
case VK_RSHIFT:
|
99
|
-
case VK_LCONTROL:
|
100
|
-
case VK_RCONTROL:
|
101
|
-
case VK_LMENU:
|
102
|
-
case VK_RMENU:
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
61
|
+
case VK_CANCEL: c = KEY_BREAK; return true;
|
62
|
+
case VK_BACK: c = KEY_BACKSPACE; return true;
|
63
|
+
case VK_TAB: c = KEY_TAB; return true;
|
64
|
+
case VK_CLEAR: c = KEY_CLEAR; return true;
|
65
|
+
case VK_RETURN: c = KEY_RETURN; return true;
|
66
|
+
case VK_SHIFT: c = KEY_SHIFT; return true;
|
67
|
+
case VK_CONTROL: c = KEY_CONTROL; return true;
|
68
|
+
case VK_MENU: c = KEY_ALT; return true;
|
69
|
+
case VK_PAUSE: c = KEY_PAUSE; return true;
|
70
|
+
case VK_CAPITAL: c = KEY_CAPSLOCK; return true;
|
71
|
+
case VK_KANA: c = KEY_IME_KANA; return true;
|
72
|
+
case VK_JUNJA: c = KEY_IME_JUNJA; return true;
|
73
|
+
case VK_FINAL: c = KEY_IME_FINAL; return true;
|
74
|
+
case VK_KANJI: c = KEY_IME_KANJI; return true;
|
75
|
+
case VK_ESCAPE: c = KEY_ESCAPE; return true;
|
76
|
+
case VK_CONVERT: c = KEY_IME_CONVERT; return true;
|
77
|
+
case VK_NONCONVERT: c = KEY_IME_NONCONVERT; return true;
|
78
|
+
case VK_ACCEPT: c = KEY_IME_ACCEPT; return true;
|
79
|
+
case VK_MODECHANGE: c = KEY_IME_MODECHANGE; return true;
|
80
|
+
case VK_SPACE: c = KEY_SPACE; return true;
|
81
|
+
case VK_PRIOR: c = KEY_PAGEUP; return true;
|
82
|
+
case VK_NEXT: c = KEY_PAGEDOWN; return true;
|
83
|
+
case VK_END: c = KEY_END; return true;
|
84
|
+
case VK_HOME: c = KEY_HOME; return true;
|
85
|
+
case VK_LEFT: c = KEY_LEFT; return true;
|
86
|
+
case VK_UP: c = KEY_UP; return true;
|
87
|
+
case VK_RIGHT: c = KEY_RIGHT; return true;
|
88
|
+
case VK_DOWN: c = KEY_DOWN; return true;
|
89
|
+
case VK_SELECT: c = KEY_SELECT; return true;
|
90
|
+
case VK_PRINT: c = KEY_PRINT; return true;
|
91
|
+
case VK_EXECUTE: c = KEY_EXECUTE; return true;
|
92
|
+
case VK_SNAPSHOT: c = KEY_PRINTSCREEN; return true;
|
93
|
+
case VK_INSERT: c = KEY_INSERT; return true;
|
94
|
+
case VK_DELETE: c = KEY_DELETE; return true;
|
95
|
+
case VK_HELP: c = KEY_HELP; return true;
|
96
|
+
case VK_LWIN: c = KEY_LWIN; return true;
|
97
|
+
case VK_RWIN: c = KEY_RWIN; return true;
|
98
|
+
case VK_APPS: c = KEY_APPS; return true;
|
99
|
+
case VK_SLEEP: c = KEY_SLEEP; return true;
|
100
|
+
case VK_NUMPAD0: s = "0"; m = MOD_NUMPAD; return true;
|
101
|
+
case VK_NUMPAD1: s = "1"; m = MOD_NUMPAD; return true;
|
102
|
+
case VK_NUMPAD2: s = "2"; m = MOD_NUMPAD; return true;
|
103
|
+
case VK_NUMPAD3: s = "3"; m = MOD_NUMPAD; return true;
|
104
|
+
case VK_NUMPAD4: s = "4"; m = MOD_NUMPAD; return true;
|
105
|
+
case VK_NUMPAD5: s = "5"; m = MOD_NUMPAD; return true;
|
106
|
+
case VK_NUMPAD6: s = "6"; m = MOD_NUMPAD; return true;
|
107
|
+
case VK_NUMPAD7: s = "7"; m = MOD_NUMPAD; return true;
|
108
|
+
case VK_NUMPAD8: s = "8"; m = MOD_NUMPAD; return true;
|
109
|
+
case VK_NUMPAD9: s = "9"; m = MOD_NUMPAD; return true;
|
110
|
+
case VK_MULTIPLY: s = "*"; m = MOD_NUMPAD; return true;
|
111
|
+
case VK_ADD: s = "+"; m = MOD_NUMPAD; return true;
|
112
|
+
case VK_SEPARATOR: s = ":"; m = MOD_NUMPAD; return true;
|
113
|
+
case VK_SUBTRACT: s = "-"; m = MOD_NUMPAD; return true;
|
114
|
+
case VK_DECIMAL: s = "."; m = MOD_NUMPAD; return true;
|
115
|
+
case VK_DIVIDE: s = "/"; m = MOD_NUMPAD; return true;
|
116
|
+
case VK_F1: c = KEY_F1; m = MOD_FUNCTION; return true;
|
117
|
+
case VK_F2: c = KEY_F2; m = MOD_FUNCTION; return true;
|
118
|
+
case VK_F3: c = KEY_F3; m = MOD_FUNCTION; return true;
|
119
|
+
case VK_F4: c = KEY_F4; m = MOD_FUNCTION; return true;
|
120
|
+
case VK_F5: c = KEY_F5; m = MOD_FUNCTION; return true;
|
121
|
+
case VK_F6: c = KEY_F6; m = MOD_FUNCTION; return true;
|
122
|
+
case VK_F7: c = KEY_F7; m = MOD_FUNCTION; return true;
|
123
|
+
case VK_F8: c = KEY_F8; m = MOD_FUNCTION; return true;
|
124
|
+
case VK_F9: c = KEY_F9; m = MOD_FUNCTION; return true;
|
125
|
+
case VK_F10: c = KEY_F10; m = MOD_FUNCTION; return true;
|
126
|
+
case VK_F11: c = KEY_F11; m = MOD_FUNCTION; return true;
|
127
|
+
case VK_F12: c = KEY_F12; m = MOD_FUNCTION; return true;
|
128
|
+
case VK_F13: c = KEY_F13; m = MOD_FUNCTION; return true;
|
129
|
+
case VK_F14: c = KEY_F14; m = MOD_FUNCTION; return true;
|
130
|
+
case VK_F15: c = KEY_F15; m = MOD_FUNCTION; return true;
|
131
|
+
case VK_F16: c = KEY_F16; m = MOD_FUNCTION; return true;
|
132
|
+
case VK_F17: c = KEY_F17; m = MOD_FUNCTION; return true;
|
133
|
+
case VK_F18: c = KEY_F18; m = MOD_FUNCTION; return true;
|
134
|
+
case VK_F19: c = KEY_F19; m = MOD_FUNCTION; return true;
|
135
|
+
case VK_F20: c = KEY_F20; m = MOD_FUNCTION; return true;
|
136
|
+
case VK_F21: c = KEY_F21; m = MOD_FUNCTION; return true;
|
137
|
+
case VK_F22: c = KEY_F22; m = MOD_FUNCTION; return true;
|
138
|
+
case VK_F23: c = KEY_F23; m = MOD_FUNCTION; return true;
|
139
|
+
case VK_F24: c = KEY_F24; m = MOD_FUNCTION; return true;
|
140
|
+
case VK_NUMLOCK: c = KEY_NUMLOCK; return true;
|
141
|
+
case VK_SCROLL: c = KEY_SCROLLLOCK; return true;
|
142
|
+
case VK_LSHIFT: c = KEY_LSHIFT; return true;
|
143
|
+
case VK_RSHIFT: c = KEY_RSHIFT; return true;
|
144
|
+
case VK_LCONTROL: c = KEY_LCONTROL; return true;
|
145
|
+
case VK_RCONTROL: c = KEY_RCONTROL; return true;
|
146
|
+
case VK_LMENU: c = KEY_LALT; return true;
|
147
|
+
case VK_RMENU: c = KEY_RALT; return true;
|
148
|
+
case VK_BROWSER_BACK: c = KEY_BROWSER_BACK; return true;
|
149
|
+
case VK_BROWSER_FORWARD: c = KEY_BROWSER_FORWARD; return true;
|
150
|
+
case VK_BROWSER_REFRESH: c = KEY_BROWSER_REFRESH; return true;
|
151
|
+
case VK_BROWSER_STOP: c = KEY_BROWSER_STOP; return true;
|
152
|
+
case VK_BROWSER_SEARCH: c = KEY_BROWSER_SEARCH; return true;
|
153
|
+
case VK_BROWSER_FAVORITES: c = KEY_BROWSER_FAVORITES; return true;
|
154
|
+
case VK_BROWSER_HOME: c = KEY_BROWSER_HOME; return true;
|
155
|
+
case VK_VOLUME_MUTE: c = KEY_VOLUME_MUTE; return true;
|
156
|
+
case VK_VOLUME_DOWN: c = KEY_VOLUME_DOWN; return true;
|
157
|
+
case VK_VOLUME_UP: c = KEY_VOLUME_UP; return true;
|
158
|
+
case VK_MEDIA_NEXT_TRACK: c = KEY_MEDIA_NEXT_TRACK; return true;
|
159
|
+
case VK_MEDIA_PREV_TRACK: c = KEY_MEDIA_PREV_TRACK; return true;
|
160
|
+
case VK_MEDIA_STOP: c = KEY_MEDIA_STOP; return true;
|
161
|
+
case VK_MEDIA_PLAY_PAUSE: c = KEY_MEDIA_PLAY_PAUSE; return true;
|
162
|
+
case VK_LAUNCH_MAIL: c = KEY_LAUNCH_MAIL; return true;
|
163
|
+
case VK_LAUNCH_MEDIA_SELECT: c = KEY_LAUNCH_MEDIA_SELECT; return true;
|
164
|
+
case VK_LAUNCH_APP1: c = KEY_LAUNCH_APP1; return true;
|
165
|
+
case VK_LAUNCH_APP2: c = KEY_LAUNCH_APP2; return true;
|
166
|
+
#if 0
|
167
|
+
case VK_OEM_1: s = ","; return true;
|
168
|
+
case VK_OEM_PLUS: s = "},"; return true;
|
169
|
+
case VK_OEM_COMMA: s = ","; return true;
|
170
|
+
case VK_OEM_MINUS: s = "-"; return true;
|
171
|
+
case VK_OEM_PERIOD: s = "."; return true;
|
172
|
+
case VK_OEM_2: s = "/"; return true;
|
173
|
+
case VK_OEM_3: s = "@"; return true;
|
174
|
+
case VK_OEM_4: s = "["; return true;
|
175
|
+
case VK_OEM_5: s = "\\"; return true;
|
176
|
+
case VK_OEM_6: s = "]"; return true;
|
177
|
+
case VK_OEM_7: s = "^"; return true;
|
178
|
+
case VK_OEM_8: c = KEY_OEM_8; return true;
|
179
|
+
case VK_OEM_AX: c = KEY_KEY_OEM_AX; return true;
|
180
|
+
case VK_OEM_102: s = "\\"; return true;
|
181
|
+
case VK_ICO_HELP: c = KEY_ICO_HELP; return true;
|
182
|
+
case VK_ICO_OO: c = KEY_ICO_OO; return true;
|
183
|
+
#endif
|
184
|
+
case VK_PROCESSKEY: c = KEY_IME_PROCESS; return true;
|
185
|
+
#if 0
|
186
|
+
case VK_ICO_CLEAR: c = KEY_ICO_CLEAR; return true;
|
187
|
+
case VK_PACKET: c = KEY_PACKET; return true;
|
188
|
+
case VK_OEM_RESET: c = KEY_OEM_RESET; return true;
|
189
|
+
case VK_OEM_JUMP: c = KEY_OEM_JUMP; return true;
|
190
|
+
case VK_OEM_PA1: c = KEY_OEM_PA1; return true;
|
191
|
+
case VK_OEM_PA2: c = KEY_OEM_PA2; return true;
|
192
|
+
case VK_OEM_PA3: c = KEY_OEM_PA3; return true;
|
193
|
+
case VK_OEM_WSCTRL: c = KEY_OEM_WSCTRL; return true;
|
194
|
+
case VK_OEM_CUSEL: c = KEY_OEM_CUSEL; return true;
|
195
|
+
case VK_OEM_ATTN: c = KEY_OEM_ATTN; return true;
|
196
|
+
case VK_OEM_FINISH: c = KEY_OEM_FINISH; return true;
|
197
|
+
case VK_OEM_COPY: c = KEY_OEM_COPY; return true;
|
198
|
+
case VK_OEM_AUTO: c = KEY_OEM_AUTO; return true;
|
199
|
+
case VK_OEM_ENLW: c = KEY_OEM_ENLW; return true;
|
200
|
+
case VK_OEM_BACKTAB: c = KEY_OEM_BACKTAB; return true;
|
201
|
+
case VK_ATTN: c = KEY_ATTN; return true;
|
202
|
+
case VK_CRSEL: c = KEY_CRSEL; return true;
|
203
|
+
case VK_EXSEL: c = KEY_EXSEL; return true;
|
204
|
+
case VK_EREOF: c = KEY_EREOF; return true;
|
205
|
+
#endif
|
206
|
+
case VK_PLAY: c = KEY_PLAY; return true;
|
207
|
+
case VK_ZOOM: c = KEY_ZOOM; return true;
|
208
|
+
#if 0
|
209
|
+
case VK_NONAME: c = KEY_NONAME; return true;
|
210
|
+
case VK_PA1: c = KEY_PA1; return true;
|
211
|
+
case VK_OEM_CLEAR: c = KEY_OEM_CLEAR; return true;
|
212
|
+
#endif
|
144
213
|
}
|
145
214
|
|
146
215
|
return false;
|
147
216
|
}
|
148
217
|
|
218
|
+
static bool
|
219
|
+
get_chars (Key* key, UINT msg, WPARAM wp, LPARAM lp)
|
220
|
+
{
|
221
|
+
if (!key) return false;
|
222
|
+
|
223
|
+
key->chars += (char) wp;
|
224
|
+
return true;
|
225
|
+
}
|
226
|
+
|
227
|
+
static bool
|
228
|
+
get_key (Key* key, UINT msg, WPARAM wp, LPARAM lp)
|
229
|
+
{
|
230
|
+
if (!key || !get_modifiers(&key->modifiers))
|
231
|
+
return false;
|
232
|
+
|
233
|
+
bool ret = true;
|
234
|
+
|
235
|
+
if (
|
236
|
+
msg == WM_KEYDOWN || msg == WM_KEYUP ||
|
237
|
+
msg == WM_SYSKEYDOWN || msg == WM_SYSKEYUP)
|
238
|
+
{
|
239
|
+
ret &= get_keypress(key, msg, wp, lp);
|
240
|
+
}
|
241
|
+
else if (
|
242
|
+
msg == WM_CHAR || msg == WM_SYSCHAR ||
|
243
|
+
msg == WM_DEADCHAR || msg == WM_SYSDEADCHAR)
|
244
|
+
{
|
245
|
+
ret &= get_chars(key, msg, wp, lp);
|
246
|
+
}
|
247
|
+
|
248
|
+
key->repeat = lp & 0xff;
|
249
|
+
ret &= get_modifiers(&key->modifiers);
|
250
|
+
|
251
|
+
return ret;
|
252
|
+
}
|
253
|
+
|
254
|
+
static int
|
255
|
+
get_points (Points* points, UINT msg, WPARAM wp, LPARAM lp)
|
256
|
+
{
|
257
|
+
if (!points) return false;
|
258
|
+
|
259
|
+
switch (msg)
|
260
|
+
{
|
261
|
+
case WM_LBUTTONDBLCLK:
|
262
|
+
points->count += 1;
|
263
|
+
case WM_LBUTTONDOWN:
|
264
|
+
case WM_LBUTTONUP:
|
265
|
+
points->type = POINT_MOUSE_LEFT;
|
266
|
+
points->count += 1;
|
267
|
+
break;
|
268
|
+
|
269
|
+
case WM_RBUTTONDBLCLK:
|
270
|
+
points->count += 1;
|
271
|
+
case WM_RBUTTONDOWN:
|
272
|
+
case WM_RBUTTONUP:
|
273
|
+
points->type = POINT_MOUSE_RIGHT;
|
274
|
+
points->count += 1;
|
275
|
+
break;
|
276
|
+
|
277
|
+
case WM_MBUTTONDBLCLK:
|
278
|
+
points->count += 1;
|
279
|
+
case WM_MBUTTONDOWN:
|
280
|
+
case WM_MBUTTONUP:
|
281
|
+
points->type = POINT_MOUSE_MIDDLE;
|
282
|
+
points->count += 1;
|
283
|
+
break;
|
284
|
+
}
|
285
|
+
|
286
|
+
return get_modifiers(&points->modifiers);
|
287
|
+
}
|
288
|
+
|
289
|
+
|
290
|
+
Win32Key::Win32Key (UINT msg, WPARAM wp, LPARAM lp)
|
291
|
+
{
|
292
|
+
get_key(this, msg, wp, lp);
|
293
|
+
}
|
294
|
+
|
295
|
+
|
296
|
+
Win32Points::Win32Points (UINT msg, WPARAM wp, LPARAM lp)
|
297
|
+
: Points(POINT_NONE, GET_X_LPARAM(lp), GET_Y_LPARAM(lp))
|
298
|
+
{
|
299
|
+
get_points(this, msg, wp, lp);
|
300
|
+
}
|
301
|
+
|
149
302
|
|
150
303
|
}// Reflex
|
data/src/win32/defs.h
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __REFLEX_WIN32_DEFS_H__
|
4
|
+
#define __REFLEX_WIN32_DEFS_H__
|
5
|
+
|
6
|
+
|
7
|
+
#import <windows.h>
|
8
|
+
#include <reflex/defs.h>
|
9
|
+
|
10
|
+
|
11
|
+
namespace Reflex
|
12
|
+
{
|
13
|
+
|
14
|
+
|
15
|
+
struct Win32Key : public Key
|
16
|
+
{
|
17
|
+
|
18
|
+
Win32Key (UINT msg, WPARAM wp, LPARAM lp);
|
19
|
+
|
20
|
+
};// Win32Key
|
21
|
+
|
22
|
+
|
23
|
+
struct Win32Points : public Points
|
24
|
+
{
|
25
|
+
|
26
|
+
Win32Points (UINT msg, WPARAM wp, LPARAM lp);
|
27
|
+
|
28
|
+
};// Win32Points
|
29
|
+
|
30
|
+
|
31
|
+
}// Reflex
|
32
|
+
|
33
|
+
|
34
|
+
#endif//EOH
|
data/src/win32/reflex.cpp
CHANGED
@@ -11,53 +11,32 @@ namespace Reflex
|
|
11
11
|
namespace global
|
12
12
|
{
|
13
13
|
|
14
|
-
|
15
|
-
static bool initialized = false, running = false;
|
16
|
-
|
14
|
+
static bool init = false;
|
17
15
|
|
18
16
|
}// global
|
19
17
|
|
20
18
|
|
21
19
|
bool
|
22
|
-
|
20
|
+
initialized ()
|
23
21
|
{
|
24
|
-
|
25
|
-
global::initialized = true;
|
26
|
-
|
27
|
-
return true;
|
22
|
+
return global::init;
|
28
23
|
}
|
29
24
|
|
30
25
|
bool
|
31
|
-
|
26
|
+
init ()
|
32
27
|
{
|
33
|
-
if (
|
34
|
-
global::initialized = false;
|
28
|
+
if (global::init) return false;
|
35
29
|
|
30
|
+
global::init = true;
|
36
31
|
return true;
|
37
32
|
}
|
38
33
|
|
39
34
|
bool
|
40
|
-
|
41
|
-
{
|
42
|
-
if (!global::initialized || global::running) return false;
|
43
|
-
global::running = true;
|
44
|
-
|
45
|
-
MSG msg;
|
46
|
-
while (GetMessage(&msg, NULL, 0, 0))
|
47
|
-
{
|
48
|
-
TranslateMessage(&msg);
|
49
|
-
DispatchMessage(&msg);
|
50
|
-
}
|
51
|
-
|
52
|
-
return msg.wParam == 0;
|
53
|
-
}
|
54
|
-
|
55
|
-
bool
|
56
|
-
quit ()
|
35
|
+
fin ()
|
57
36
|
{
|
58
|
-
if (!global::
|
37
|
+
if (!global::init) return false;
|
59
38
|
|
60
|
-
|
39
|
+
global::init = false;
|
61
40
|
return true;
|
62
41
|
}
|
63
42
|
|