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.
Files changed (225) hide show
  1. checksums.yaml +7 -0
  2. data/.doc/ext/reflex/application.cpp +54 -39
  3. data/.doc/ext/reflex/capture_event.cpp +87 -0
  4. data/.doc/ext/reflex/draw_event.cpp +103 -0
  5. data/.doc/ext/reflex/event.cpp +73 -0
  6. data/.doc/ext/reflex/focus_event.cpp +98 -0
  7. data/.doc/ext/reflex/frame_event.cpp +133 -0
  8. data/.doc/ext/reflex/image_view.cpp +74 -0
  9. data/.doc/ext/reflex/key_event.cpp +124 -0
  10. data/.doc/ext/reflex/native.cpp +45 -6
  11. data/.doc/ext/reflex/pointer_event.cpp +181 -0
  12. data/.doc/ext/reflex/reflex.cpp +17 -41
  13. data/.doc/ext/reflex/scroll_event.cpp +141 -0
  14. data/.doc/ext/reflex/selector.cpp +135 -0
  15. data/.doc/ext/reflex/style.cpp +253 -0
  16. data/.doc/ext/reflex/style_length.cpp +133 -0
  17. data/.doc/ext/reflex/style_length2.cpp +149 -0
  18. data/.doc/ext/reflex/style_length4.cpp +192 -0
  19. data/.doc/ext/reflex/update_event.cpp +77 -0
  20. data/.doc/ext/reflex/view.cpp +408 -88
  21. data/.doc/ext/reflex/wheel_event.cpp +146 -0
  22. data/.doc/ext/reflex/window.cpp +95 -92
  23. data/Rakefile +6 -5
  24. data/VERSION +1 -1
  25. data/ext/reflex/application.cpp +67 -49
  26. data/ext/reflex/capture_event.cpp +92 -0
  27. data/ext/reflex/draw_event.cpp +110 -0
  28. data/ext/reflex/event.cpp +77 -0
  29. data/ext/reflex/extconf.rb +18 -68
  30. data/ext/reflex/focus_event.cpp +104 -0
  31. data/ext/reflex/frame_event.cpp +143 -0
  32. data/ext/reflex/image_view.cpp +77 -0
  33. data/ext/reflex/key_event.cpp +133 -0
  34. data/ext/reflex/native.cpp +45 -6
  35. data/ext/reflex/pointer_event.cpp +195 -0
  36. data/ext/reflex/reflex.cpp +21 -47
  37. data/ext/reflex/scroll_event.cpp +152 -0
  38. data/ext/reflex/selector.cpp +144 -0
  39. data/ext/reflex/style.cpp +277 -0
  40. data/ext/reflex/style_length.cpp +140 -0
  41. data/ext/reflex/style_length2.cpp +157 -0
  42. data/ext/reflex/style_length4.cpp +204 -0
  43. data/ext/reflex/update_event.cpp +81 -0
  44. data/ext/reflex/view.cpp +469 -114
  45. data/ext/reflex/wheel_event.cpp +158 -0
  46. data/ext/reflex/window.cpp +130 -123
  47. data/include/reflex/application.h +12 -7
  48. data/include/reflex/defs.h +13 -89
  49. data/include/reflex/event.h +260 -0
  50. data/include/reflex/exception.h +17 -11
  51. data/include/reflex/image_view.h +45 -0
  52. data/include/reflex/reflex.h +2 -6
  53. data/include/reflex/ruby/application.h +40 -13
  54. data/include/reflex/ruby/event.h +72 -0
  55. data/include/reflex/ruby/image_view.h +25 -0
  56. data/include/reflex/ruby/selector.h +27 -0
  57. data/include/reflex/ruby/style.h +27 -0
  58. data/include/reflex/ruby/style_length.h +37 -0
  59. data/include/reflex/ruby/view.h +193 -38
  60. data/include/reflex/ruby/window.h +123 -39
  61. data/include/reflex/ruby.h +3 -2
  62. data/include/reflex/selector.h +64 -0
  63. data/include/reflex/style.h +144 -0
  64. data/include/reflex/style_length.h +147 -0
  65. data/include/reflex/view.h +182 -19
  66. data/include/reflex/window.h +35 -19
  67. data/include/reflex.h +7 -0
  68. data/lib/reflex/application.rb +14 -5
  69. data/lib/reflex/arc_shape.rb +20 -0
  70. data/lib/reflex/button.rb +75 -0
  71. data/lib/reflex/capture_event.rb +37 -0
  72. data/lib/reflex/color.rb +13 -0
  73. data/lib/reflex/color_space.rb +13 -0
  74. data/lib/reflex/draw_event.rb +19 -0
  75. data/lib/reflex/ellipse_shape.rb +20 -0
  76. data/lib/reflex/ext.rb +1 -1
  77. data/lib/reflex/flags.rb +18 -0
  78. data/lib/reflex/focus_event.rb +38 -0
  79. data/lib/reflex/font.rb +13 -0
  80. data/lib/reflex/frame_event.rb +42 -0
  81. data/lib/reflex/helper.rb +87 -30
  82. data/lib/reflex/image_view.rb +25 -0
  83. data/lib/reflex/key_event.rb +38 -0
  84. data/lib/reflex/line_shape.rb +20 -0
  85. data/lib/reflex/list_view.rb +15 -0
  86. data/lib/reflex/model.rb +149 -0
  87. data/lib/reflex/model_owner.rb +57 -0
  88. data/lib/reflex/model_view.rb +22 -0
  89. data/lib/reflex/module.rb +11 -7
  90. data/lib/reflex/pointer_event.rb +85 -0
  91. data/lib/reflex/rect_shape.rb +20 -0
  92. data/lib/reflex/reflex.rb +13 -2
  93. data/lib/reflex/scroll_event.rb +19 -0
  94. data/lib/reflex/selector.rb +31 -0
  95. data/lib/reflex/shader.rb +13 -0
  96. data/lib/reflex/shape.rb +34 -0
  97. data/lib/reflex/style.rb +55 -0
  98. data/lib/reflex/style_length.rb +30 -0
  99. data/lib/reflex/style_length2.rb +34 -0
  100. data/lib/reflex/style_length4.rb +38 -0
  101. data/lib/reflex/text_view.rb +55 -0
  102. data/lib/reflex/update_event.rb +19 -0
  103. data/lib/reflex/view.rb +38 -4
  104. data/lib/reflex/wheel_event.rb +19 -0
  105. data/lib/reflex/window.rb +7 -5
  106. data/lib/reflex.rb +38 -1
  107. data/lib/reflexion/include.rb +5 -0
  108. data/lib/reflexion.rb +100 -0
  109. data/reflex.gemspec +3 -4
  110. data/samples/app.rb +13 -0
  111. data/samples/bats.rb +91 -0
  112. data/samples/checker.rb +36 -0
  113. data/{examples/ruby/shapes.rb → samples/fans.rb} +12 -16
  114. data/samples/fps.rb +46 -0
  115. data/samples/grid.rb +60 -0
  116. data/{examples/ruby → samples}/hello.rb +14 -16
  117. data/samples/image.rb +44 -0
  118. data/samples/ios/hello/hello/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
  119. data/samples/ios/hello/hello/Images.xcassets/LaunchImage.launchimage/Contents.json +51 -0
  120. data/samples/ios/hello/hello/en.lproj/InfoPlist.strings +2 -0
  121. data/samples/ios/hello/hello/hello-Info.plist +47 -0
  122. data/samples/ios/hello/hello/hello-Prefix.pch +10 -0
  123. data/samples/ios/hello/hello/main.cpp +79 -0
  124. data/samples/ios/hello/hello.xcodeproj/project.pbxproj +725 -0
  125. data/{examples/ruby → samples}/key.rb +11 -14
  126. data/samples/layout.rb +89 -0
  127. data/samples/model.rb +86 -0
  128. data/samples/osx/hello/hello/Images.xcassets/AppIcon.appiconset/Contents.json +58 -0
  129. data/samples/osx/hello/hello/en.lproj/Credits.rtf +29 -0
  130. data/samples/osx/hello/hello/en.lproj/InfoPlist.strings +2 -0
  131. data/samples/osx/hello/hello/hello-Info.plist +32 -0
  132. data/samples/osx/hello/hello/hello-Prefix.pch +3 -0
  133. data/samples/osx/hello/hello/main.cpp +79 -0
  134. data/samples/osx/hello/hello.xcodeproj/project.pbxproj +725 -0
  135. data/samples/reflexion/hello.rb +24 -0
  136. data/samples/reflexion/paint.rb +40 -0
  137. data/samples/reflexion/pulse.rb +34 -0
  138. data/samples/repl.rb +69 -0
  139. data/samples/shader.rb +41 -0
  140. data/samples/shapes.rb +30 -0
  141. data/{examples/ruby → samples}/text.rb +7 -8
  142. data/samples/tree.rb +71 -0
  143. data/samples/views.rb +41 -0
  144. data/samples/visuals.rb +22 -0
  145. data/src/event.cpp +225 -0
  146. data/src/exception.cpp +24 -15
  147. data/src/image_view.cpp +70 -0
  148. data/src/ios/app_delegate.h +17 -0
  149. data/src/ios/app_delegate.mm +120 -0
  150. data/src/ios/application.mm +116 -0
  151. data/src/{cocoa/applicationdata.h → ios/application_data.h} +6 -6
  152. data/src/ios/event.h +26 -0
  153. data/src/ios/event.mm +31 -0
  154. data/src/ios/native_window.h +37 -0
  155. data/src/ios/native_window.mm +220 -0
  156. data/src/ios/opengl_view.h +13 -0
  157. data/src/ios/opengl_view.mm +131 -0
  158. data/src/{cocoa → ios}/reflex.mm +8 -12
  159. data/src/ios/window.mm +303 -0
  160. data/src/ios/window_data.h +75 -0
  161. data/src/osx/app_delegate.h +17 -0
  162. data/src/{cocoa/cocoaapplication.mm → osx/app_delegate.mm} +90 -48
  163. data/src/osx/application.mm +132 -0
  164. data/src/osx/application_data.h +45 -0
  165. data/src/osx/event.h +42 -0
  166. data/src/osx/event.mm +112 -0
  167. data/src/osx/native_window.h +26 -0
  168. data/src/osx/native_window.mm +322 -0
  169. data/src/{cocoa/openglview.h → osx/opengl_view.h} +0 -4
  170. data/src/{cocoa/openglview.mm → osx/opengl_view.mm} +66 -23
  171. data/src/osx/reflex.mm +50 -0
  172. data/src/osx/window.mm +308 -0
  173. data/src/osx/window_data.h +75 -0
  174. data/src/selector.cpp +121 -0
  175. data/src/style.cpp +576 -0
  176. data/src/style_length.cpp +341 -0
  177. data/src/view.cpp +1228 -129
  178. data/src/win32/application.cpp +1 -1
  179. data/src/window.cpp +54 -26
  180. data/test/helper.rb +8 -4
  181. data/test/test_capture_event.rb +41 -0
  182. data/test/test_event.rb +20 -0
  183. data/test/test_has_frame.rb +45 -0
  184. data/test/test_model.rb +9 -0
  185. data/test/test_model_owner.rb +9 -0
  186. data/test/test_selector.rb +75 -0
  187. data/test/test_style.rb +70 -0
  188. data/test/test_style_length.rb +38 -0
  189. data/test/test_style_length2.rb +50 -0
  190. data/test/test_style_length4.rb +56 -0
  191. data/test/test_view.rb +97 -23
  192. data/test/test_window.rb +54 -46
  193. metadata +205 -84
  194. data/.doc/ext/reflex/defs.cpp +0 -8
  195. data/.doc/ext/reflex/key.cpp +0 -122
  196. data/.doc/ext/reflex/points.cpp +0 -151
  197. data/.gitignore +0 -14
  198. data/ChangeLog +0 -8
  199. data/examples/hello/.gitignore +0 -2
  200. data/examples/hello/Rakefile +0 -41
  201. data/examples/hello/main.cpp +0 -18
  202. data/examples/ruby/app.rb +0 -13
  203. data/examples/ruby/checker.rb +0 -41
  204. data/examples/ruby/fps.rb +0 -49
  205. data/examples/ruby/grid.rb +0 -65
  206. data/examples/ruby/views.rb +0 -88
  207. data/examples/ruby/visuals.rb +0 -27
  208. data/ext/reflex/defs.cpp +0 -8
  209. data/ext/reflex/key.cpp +0 -129
  210. data/ext/reflex/points.cpp +0 -161
  211. data/include/reflex/ruby/key.h +0 -39
  212. data/include/reflex/ruby/points.h +0 -39
  213. data/lib/reflex/visuals/string.rb +0 -53
  214. data/src/cocoa/application.mm +0 -101
  215. data/src/cocoa/cocoaapplication.h +0 -21
  216. data/src/cocoa/cocoawindow.h +0 -46
  217. data/src/cocoa/cocoawindow.mm +0 -230
  218. data/src/cocoa/defs.h +0 -34
  219. data/src/cocoa/defs.mm +0 -87
  220. data/src/cocoa/window.mm +0 -148
  221. data/src/cocoa/windowdata.h +0 -56
  222. data/src/defs.cpp +0 -47
  223. data/src/helper.h +0 -12
  224. data/src/reflex.cpp +0 -43
  225. /data/{README → README.md} +0 -0
@@ -0,0 +1,131 @@
1
+ // -*- objc -*-
2
+ #import "opengl_view.h"
3
+
4
+
5
+ #include <rays/opengl.h>
6
+ #include <rays/exception.h>
7
+ #include "reflex/exception.h"
8
+ #import "native_window.h"
9
+
10
+
11
+ //#define TRANSPARENT_BACKGROUND
12
+
13
+
14
+ @implementation OpenGLViewController
15
+
16
+ - (void) viewDidLoad
17
+ {
18
+ [super viewDidLoad];
19
+
20
+ context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES1];
21
+ if (!context)
22
+ Reflex::reflex_error(__FILE__, __LINE__, "failed to create OpenGL context.");
23
+
24
+ GLKView* view = (GLKView*) self.view;
25
+ view.context = context;
26
+ view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
27
+ view.drawableMultisample = GLKViewDrawableMultisample4X;
28
+
29
+ //self.preferredFramesPerSecond = 60;
30
+
31
+ [self setupOpenGL];
32
+ }
33
+
34
+ - (void) dealloc
35
+ {
36
+ [self teardownOpenGL];
37
+ [super dealloc];
38
+ }
39
+
40
+ - (void) didReceiveMemoryWarning
41
+ {
42
+ [super didReceiveMemoryWarning];
43
+
44
+ if ([self isViewLoaded] && self.view.window == nil)
45
+ {
46
+ self.view = nil;
47
+ [self teardownOpenGL];
48
+ }
49
+ }
50
+
51
+ - (void) activateContext
52
+ {
53
+ [EAGLContext setCurrentContext: context];
54
+ }
55
+
56
+ - (void) setupOpenGL
57
+ {
58
+ [self activateContext];
59
+ }
60
+
61
+ - (void) teardownOpenGL
62
+ {
63
+ [self activateContext];
64
+
65
+ if (context && [EAGLContext currentContext] == context)
66
+ {
67
+ [EAGLContext setCurrentContext: nil];
68
+ context = nil;
69
+ }
70
+ }
71
+
72
+ - (void) glkView: (GLKView*) view drawInRect: (CGRect) rect
73
+ {
74
+ NativeWindow* win = (NativeWindow*) self.view.window;
75
+ if (!win) return;
76
+
77
+ [self activateContext];
78
+ [win draw];
79
+ }
80
+
81
+ - (void) keyDown: (UIEvent*) event
82
+ {
83
+ //[self interpretKeyEvents: [NSArray arrayWithObject: event]];
84
+
85
+ NativeWindow* win = (NativeWindow*) self.view.window;
86
+ if (!win) return;
87
+
88
+ [win keyDown: event];
89
+ }
90
+
91
+ - (void) keyUp: (UIEvent*) event
92
+ {
93
+ NativeWindow* win = (NativeWindow*) self.view.window;
94
+ if (!win) return;
95
+
96
+ [win keyUp: event];
97
+ }
98
+
99
+ - (void) touchesBegan: (NSSet*) touches withEvent: (UIEvent*) event
100
+ {
101
+ NativeWindow* win = (NativeWindow*) self.view.window;
102
+ if (!win) return;
103
+
104
+ [win touchesBegan: touches withEvent: event];
105
+ }
106
+
107
+ - (void) touchesEnded: (NSSet*) touches withEvent: (UIEvent*) event
108
+ {
109
+ NativeWindow* win = (NativeWindow*) self.view.window;
110
+ if (!win) return;
111
+
112
+ [win touchesEnded: touches withEvent: event];
113
+ }
114
+
115
+ - (void) touchesCancelled: (NSSet*) touches withEvent: (UIEvent*) event
116
+ {
117
+ NativeWindow* win = (NativeWindow*) self.view.window;
118
+ if (!win) return;
119
+
120
+ [win touchesCancelled: touches withEvent: event];
121
+ }
122
+
123
+ - (void) touchesMoved: (NSSet*) touches withEvent: (UIEvent*) event
124
+ {
125
+ NativeWindow* win = (NativeWindow*) self.view.window;
126
+ if (!win) return;
127
+
128
+ [win touchesMoved: touches withEvent: event];
129
+ }
130
+
131
+ @end// OpenGLViewController
@@ -2,8 +2,8 @@
2
2
  #include "reflex/reflex.h"
3
3
 
4
4
 
5
- #import <Cocoa/Cocoa.h>
6
- #import "cocoaapplication.h"
5
+ #include "reflex/exception.h"
6
+ #import "app_delegate.h"
7
7
 
8
8
 
9
9
  namespace Reflex
@@ -24,27 +24,23 @@ namespace Reflex
24
24
  return global::pool;
25
25
  }
26
26
 
27
- bool
27
+ void
28
28
  init ()
29
29
  {
30
- if (global::pool) return false;
30
+ if (global::pool)
31
+ reflex_error(__FILE__, __LINE__, "already initialized.");
31
32
 
32
33
  global::pool = [[NSAutoreleasePool alloc] init];
33
-
34
- [CocoaApplication sharedApplication];
35
-
36
- return true;
37
34
  }
38
35
 
39
- bool
36
+ void
40
37
  fin ()
41
38
  {
42
- if (!global::pool) return false;
39
+ if (!global::pool)
40
+ reflex_error(__FILE__, __LINE__, "not initialized.");
43
41
 
44
42
  [global::pool release];
45
43
  global::pool = nil;
46
-
47
- return true;
48
44
  }
49
45
 
50
46
 
data/src/ios/window.mm ADDED
@@ -0,0 +1,303 @@
1
+ // -*- objc -*-
2
+ #include "reflex/window.h"
3
+
4
+
5
+ #include <rays/bounds.h>
6
+ #include "reflex/event.h"
7
+ #include "reflex/exception.h"
8
+ #include "window_data.h"
9
+ #import "native_window.h"
10
+
11
+
12
+ namespace Reflex
13
+ {
14
+
15
+
16
+ void set_window (View* view, Window* window);
17
+
18
+ void call_key_event (View* v, const KeyEvent& e);
19
+
20
+ void call_pointer_event (View* v, const PointerEvent& e);
21
+
22
+ void call_wheel_event (View* v, const WheelEvent& e);
23
+
24
+
25
+ void
26
+ set_focus (Window* window, View* view)
27
+ {
28
+ if (!window || !view)
29
+ argument_error(__FILE__, __LINE__);
30
+
31
+ View* current = window->self->focus.get();
32
+ if (current == view) return;
33
+
34
+ window->self->focus.reset(view);
35
+
36
+ FocusEvent e(FocusEvent::BLUR, view, current);
37
+
38
+ if (current)
39
+ {
40
+ current->on_blur(&e);
41
+ current->redraw();
42
+ }
43
+
44
+ if (view)
45
+ {
46
+ e.type = FocusEvent::FOCUS;
47
+ view->on_focus(&e);
48
+ view->redraw();
49
+ }
50
+ }
51
+
52
+ void
53
+ register_capture (View* view)
54
+ {
55
+ if (!view)
56
+ argument_error(__FILE__, __LINE__);
57
+
58
+ const Window* window = view->window();
59
+ if (!window)
60
+ invalid_state_error(__FILE__, __LINE__, "this view does not belong to any Window.");
61
+
62
+ window->self->capturing_views[view] = true;
63
+ }
64
+
65
+ void
66
+ unregister_capture (View* view)
67
+ {
68
+ if (!view)
69
+ argument_error(__FILE__, __LINE__);
70
+
71
+ const Window* window = view->window();
72
+ if (!window) return;
73
+
74
+ CapturingViews::iterator it = window->self->capturing_views.find(view);
75
+ if (it == window->self->capturing_views.end()) return;
76
+
77
+ it->second = false;
78
+ }
79
+
80
+ void
81
+ cleanup_capturing_views (Window* window)
82
+ {
83
+ CapturingViews::iterator end = window->self->capturing_views.end();
84
+ for (CapturingViews::iterator it = window->self->capturing_views.begin(); it != end;)
85
+ {
86
+ CapturingViews::iterator t = it++;
87
+ if (!t->second) window->self->capturing_views.erase(t);
88
+ }
89
+ }
90
+
91
+
92
+ Window::Window ()
93
+ {
94
+ [[[NativeWindow alloc] init] bind: this];
95
+
96
+ set_window(self->root.get(), this);
97
+
98
+ self->painter.canvas(0, 0, 1, 1);
99
+ }
100
+
101
+ Window::~Window ()
102
+ {
103
+ //close();
104
+
105
+ set_window(self->root.get(), NULL);
106
+ }
107
+
108
+ void
109
+ Window::show ()
110
+ {
111
+ if (!*this)
112
+ invalid_state_error(__FILE__, __LINE__);
113
+
114
+ if (--self->hide_count == 0)
115
+ [self->native makeKeyAndVisible];
116
+ }
117
+
118
+ void
119
+ Window::hide ()
120
+ {
121
+ if (!*this)
122
+ invalid_state_error(__FILE__, __LINE__);
123
+
124
+ if (++self->hide_count == 1)
125
+ not_implemented_error(__FILE__, __LINE__);
126
+ }
127
+
128
+ void
129
+ Window::close ()
130
+ {
131
+ if (!*this)
132
+ invalid_state_error(__FILE__, __LINE__);
133
+
134
+ not_implemented_error(__FILE__, __LINE__);
135
+ }
136
+
137
+ void
138
+ Window::redraw ()
139
+ {
140
+ if (!*this)
141
+ invalid_state_error(__FILE__, __LINE__);
142
+
143
+ self->redraw = true;
144
+ }
145
+
146
+ void
147
+ Window::set_title (const char* title)
148
+ {
149
+ if (!title)
150
+ argument_error(__FILE__, __LINE__);
151
+
152
+ if (!*this)
153
+ invalid_state_error(__FILE__, __LINE__);
154
+
155
+ self->title = title;
156
+ }
157
+
158
+ const char*
159
+ Window::title () const
160
+ {
161
+ if (!*this)
162
+ invalid_state_error(__FILE__, __LINE__);
163
+
164
+ return self->title.c_str();
165
+ }
166
+
167
+ void
168
+ Window::set_frame (coord x, coord y, coord width, coord height)
169
+ {
170
+ if (!*this)
171
+ invalid_state_error(__FILE__, __LINE__);
172
+
173
+ self->native.frame = [NativeWindow frameRectForContentRect: CGRectMake(x, y, width, height)];
174
+ }
175
+
176
+ void
177
+ Window::set_frame (const Bounds& bounds)
178
+ {
179
+ set_frame(bounds.x, bounds.y, bounds.width, bounds.height);
180
+ }
181
+
182
+ Bounds
183
+ Window::frame () const
184
+ {
185
+ if (!*this)
186
+ invalid_state_error(__FILE__, __LINE__);
187
+
188
+ CGRect rect = self->native.frame;
189
+ return Bounds(
190
+ rect.origin.x,
191
+ rect.origin.y,
192
+ rect.size.width,
193
+ rect.size.height);
194
+ }
195
+
196
+ bool
197
+ Window::hidden () const
198
+ {
199
+ if (!*this)
200
+ invalid_state_error(__FILE__, __LINE__);
201
+
202
+ return self->hide_count > 0;
203
+ }
204
+
205
+ View*
206
+ Window::root ()
207
+ {
208
+ if (!*this)
209
+ invalid_state_error(__FILE__, __LINE__);
210
+
211
+ return self->root.get();
212
+ }
213
+
214
+ View*
215
+ Window::focus ()
216
+ {
217
+ if (!*this)
218
+ invalid_state_error(__FILE__, __LINE__);
219
+
220
+ return self->focus.get();
221
+ }
222
+
223
+ Painter*
224
+ Window::painter ()
225
+ {
226
+ if (!*this)
227
+ invalid_state_error(__FILE__, __LINE__);
228
+
229
+ return &self->painter;
230
+ }
231
+
232
+ void
233
+ Window::on_key (KeyEvent* e)
234
+ {
235
+ if (!e)
236
+ argument_error(__FILE__, __LINE__);
237
+
238
+ switch (e->type)
239
+ {
240
+ case KeyEvent::DOWN: on_key_down(e); break;
241
+ case KeyEvent::UP: on_key_up(e); break;
242
+ case KeyEvent::NONE: break;
243
+ }
244
+
245
+ CapturingViews::iterator end = self->capturing_views.end();
246
+ for (CapturingViews::iterator it = self->capturing_views.begin(); it != end; ++it)
247
+ {
248
+ KeyEvent event = *e;
249
+ event.capture = true;
250
+ call_key_event(const_cast<View*>(it->first.get()), event);
251
+ }
252
+
253
+ if (self->focus)
254
+ call_key_event(self->focus.get(), *e);
255
+
256
+ cleanup_capturing_views(this);
257
+ }
258
+
259
+ void
260
+ Window::on_pointer (PointerEvent* e)
261
+ {
262
+ if (!e)
263
+ argument_error(__FILE__, __LINE__);
264
+
265
+ switch (e->type)
266
+ {
267
+ case PointerEvent::DOWN: on_pointer_down(e); break;
268
+ case PointerEvent::UP: on_pointer_up(e); break;
269
+ case PointerEvent::MOVE: on_pointer_move(e); break;
270
+ case PointerEvent::NONE: break;
271
+ }
272
+
273
+ CapturingViews::iterator end = self->capturing_views.end();
274
+ for (CapturingViews::iterator it = self->capturing_views.begin(); it != end; ++it)
275
+ {
276
+ PointerEvent event = *e;
277
+ event.capture = true;
278
+ for (size_t i = 0; i < event.size; ++i)
279
+ event[i] = it->first.get()->from_window(event[i]);
280
+ call_pointer_event(const_cast<View*>(it->first.get()), event);
281
+ }
282
+
283
+ call_pointer_event(root(), *e);
284
+
285
+ cleanup_capturing_views(this);
286
+ }
287
+
288
+ void
289
+ Window::on_wheel (WheelEvent* e)
290
+ {
291
+ if (!e)
292
+ argument_error(__FILE__, __LINE__);
293
+
294
+ call_wheel_event(root(), *e);
295
+ }
296
+
297
+ Window::operator bool () const
298
+ {
299
+ return self && *self;
300
+ }
301
+
302
+
303
+ }// Reflex
@@ -0,0 +1,75 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __REFLEX_IOS_WINDOW_DATA_H__
4
+ #define __REFLEX_IOS_WINDOW_DATA_H__
5
+
6
+
7
+ #include <map>
8
+ #include <xot/time.h>
9
+ #include <rays/point.h>
10
+ #include <rays/painter.h>
11
+ #include <reflex/window.h>
12
+ #include <reflex/view.h>
13
+
14
+
15
+ @class NativeWindow;
16
+
17
+
18
+ namespace Reflex
19
+ {
20
+
21
+
22
+ typedef std::map<View::Ref, bool> CapturingViews;
23
+
24
+
25
+ struct Window::Data
26
+ {
27
+
28
+ NativeWindow* native;
29
+
30
+ String title;
31
+
32
+ int hide_count;
33
+
34
+ bool redraw;
35
+
36
+ Painter painter;
37
+
38
+ View::Ref root, focus;
39
+
40
+ Rays::Point prev_position, prev_size;
41
+
42
+ double prev_time_update, prev_time_draw, prev_fps;
43
+
44
+ CapturingViews capturing_views;
45
+
46
+ Data ()
47
+ : native(nil), hide_count(1), redraw(true), root(create_root_view()), prev_fps(0)
48
+ {
49
+ prev_time_update = prev_time_draw = Xot::time();
50
+ }
51
+
52
+ operator bool () const
53
+ {
54
+ return native;
55
+ }
56
+
57
+ bool operator ! () const
58
+ {
59
+ return !operator bool();
60
+ }
61
+
62
+ static View* create_root_view ()
63
+ {
64
+ View* v = new View;
65
+ v->set_name("ROOT");
66
+ return v;
67
+ }
68
+
69
+ };// Window::Data
70
+
71
+
72
+ }// Reflex
73
+
74
+
75
+ #endif//EOH
@@ -0,0 +1,17 @@
1
+ // -*- objc -*-
2
+ #import <AppKit/NSApplication.h>
3
+ #include <reflex/application.h>
4
+
5
+
6
+ @interface AppDelegate : NSObject <NSApplicationDelegate>
7
+
8
+ {
9
+ @private
10
+ Reflex::Application::Ref* pref;
11
+ }
12
+
13
+ - (void) bind: (Reflex::Application*) instance;
14
+
15
+ - (void) unbind: (Reflex::Application*) instance;
16
+
17
+ @end// AppDelegate