reflexion 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- 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,20 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require 'reflex/shape'
|
5
|
+
|
6
|
+
|
7
|
+
module Reflex
|
8
|
+
|
9
|
+
|
10
|
+
class ArcShape < Shape
|
11
|
+
|
12
|
+
def on_draw (e)
|
13
|
+
p, b = e.painter, e.bounds
|
14
|
+
attach_color_and_border(p) {p.arc b}
|
15
|
+
end
|
16
|
+
|
17
|
+
end# ArcShape
|
18
|
+
|
19
|
+
|
20
|
+
end# Reflex
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require 'reflex/view'
|
5
|
+
|
6
|
+
|
7
|
+
module Reflex
|
8
|
+
|
9
|
+
|
10
|
+
class Button < View
|
11
|
+
|
12
|
+
has_model
|
13
|
+
|
14
|
+
attr_accessor :text
|
15
|
+
|
16
|
+
def initialize (*args, &block)
|
17
|
+
self.data = false
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def content_size ()
|
22
|
+
f = window.painter.font
|
23
|
+
return f.width(@text) + 2, f.height + 2
|
24
|
+
end
|
25
|
+
|
26
|
+
def on_press (e)
|
27
|
+
end
|
28
|
+
|
29
|
+
def on_draw (e)
|
30
|
+
e.painter.color (pressing? ? :white : :none), :white do |p|
|
31
|
+
p.rect e.bounds
|
32
|
+
|
33
|
+
if @text
|
34
|
+
p.fill pressing? ? :black : :white
|
35
|
+
x = (e.bounds.w - p.font.w(@text)) / 2
|
36
|
+
y = (e.bounds.h - p.font.h) / 2
|
37
|
+
p.text @text, x, y
|
38
|
+
end
|
39
|
+
|
40
|
+
p.fill :none
|
41
|
+
p.rect e.bounds
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def on_pointer (e)
|
46
|
+
case e.type
|
47
|
+
when :down
|
48
|
+
self.capture += [:pointer]
|
49
|
+
redraw
|
50
|
+
when :up
|
51
|
+
if pressing?
|
52
|
+
self.capture -= [:pointer]
|
53
|
+
if frame.move_to(0, 0).include? e.position
|
54
|
+
self.data = true
|
55
|
+
self.data = false
|
56
|
+
end
|
57
|
+
redraw
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def on_data_update (e)
|
63
|
+
on_press({}) if e.data
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def pressing? ()
|
69
|
+
capturing? :pointer
|
70
|
+
end
|
71
|
+
|
72
|
+
end# Button
|
73
|
+
|
74
|
+
|
75
|
+
end# Reflex
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require 'reflex/flags'
|
5
|
+
|
6
|
+
|
7
|
+
module Reflex
|
8
|
+
|
9
|
+
|
10
|
+
class CaptureEvent
|
11
|
+
|
12
|
+
def begin ()
|
13
|
+
CAPTURE_FLAG.bits2symbols get_begin
|
14
|
+
end
|
15
|
+
|
16
|
+
def begin? (*symbols)
|
17
|
+
bits = CAPTURE_FLAG.symbols2bits *symbols
|
18
|
+
(bits & get_begin) == bits
|
19
|
+
end
|
20
|
+
|
21
|
+
def end ()
|
22
|
+
CAPTURE_FLAG.bits2symbols get_end
|
23
|
+
end
|
24
|
+
|
25
|
+
def end? (*symbols)
|
26
|
+
bits = CAPTURE_FLAG.symbols2bits *symbols
|
27
|
+
(bits & get_end) == bits
|
28
|
+
end
|
29
|
+
|
30
|
+
def inspect ()
|
31
|
+
"#<Reflex::CaptureEvent begin:#{self.begin} end:#{self.end}}>"
|
32
|
+
end
|
33
|
+
|
34
|
+
end# CaptureEvent
|
35
|
+
|
36
|
+
|
37
|
+
end# Reflex
|
data/lib/reflex/color.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require 'reflex/ext'
|
5
|
+
|
6
|
+
|
7
|
+
module Reflex
|
8
|
+
|
9
|
+
|
10
|
+
class DrawEvent
|
11
|
+
|
12
|
+
def inspect ()
|
13
|
+
"#<Reflex::DrawEvent painter:#{painter} bounds:#{bounds} dt:#{dt} fps:#{fps}>"
|
14
|
+
end
|
15
|
+
|
16
|
+
end# DrawEvent
|
17
|
+
|
18
|
+
|
19
|
+
end# Reflex
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require 'reflex/shape'
|
5
|
+
|
6
|
+
|
7
|
+
module Reflex
|
8
|
+
|
9
|
+
|
10
|
+
class EllipseShape < Shape
|
11
|
+
|
12
|
+
def on_draw (e)
|
13
|
+
p, b = e.painter, e.bounds
|
14
|
+
attach_color_and_border(p) {p.ellipse b}
|
15
|
+
end
|
16
|
+
|
17
|
+
end# EllipseShape
|
18
|
+
|
19
|
+
|
20
|
+
end# Reflex
|
data/lib/reflex/ext.rb
CHANGED
data/lib/reflex/flags.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require 'xot/bit_flag'
|
5
|
+
require 'reflex/ext'
|
6
|
+
|
7
|
+
|
8
|
+
module Reflex
|
9
|
+
|
10
|
+
|
11
|
+
CAPTURE_FLAG = Xot::BitFlag.new do
|
12
|
+
flag :key, View::CAPTURE_KEY
|
13
|
+
flag :pointer, View::CAPTURE_POINTER
|
14
|
+
flag :all, View::CAPTURE_ALL
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
end# Reflex
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require 'reflex/ext'
|
5
|
+
|
6
|
+
|
7
|
+
module Reflex
|
8
|
+
|
9
|
+
|
10
|
+
class FocusEvent
|
11
|
+
|
12
|
+
def type ()
|
13
|
+
TYPE2SYM[get_type] || :none
|
14
|
+
end
|
15
|
+
|
16
|
+
def focus? ()
|
17
|
+
get_type == TYPE_FOCUS
|
18
|
+
end
|
19
|
+
|
20
|
+
def blur? ()
|
21
|
+
get_type == TYPE_BLUR
|
22
|
+
end
|
23
|
+
|
24
|
+
def inspect ()
|
25
|
+
"#<Reflex::FocusEvent type:#{type} focus:#{focus} last:#{last}>"
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
TYPE2SYM = {
|
31
|
+
TYPE_FOCUS => :focus,
|
32
|
+
TYPE_BLUR => :blur,
|
33
|
+
}
|
34
|
+
|
35
|
+
end# FocusEvent
|
36
|
+
|
37
|
+
|
38
|
+
end# Reflex
|
data/lib/reflex/font.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require 'reflex/ext'
|
5
|
+
|
6
|
+
|
7
|
+
module Reflex
|
8
|
+
|
9
|
+
|
10
|
+
class FrameEvent
|
11
|
+
|
12
|
+
alias dw dwidth
|
13
|
+
alias dh dheight
|
14
|
+
alias dpos dposition
|
15
|
+
|
16
|
+
def x ()
|
17
|
+
frame.x
|
18
|
+
end
|
19
|
+
|
20
|
+
def y ()
|
21
|
+
frame.y
|
22
|
+
end
|
23
|
+
|
24
|
+
def width ()
|
25
|
+
frame.width
|
26
|
+
end
|
27
|
+
|
28
|
+
def height ()
|
29
|
+
frame.height
|
30
|
+
end
|
31
|
+
|
32
|
+
alias w width
|
33
|
+
alias h height
|
34
|
+
|
35
|
+
def inspect ()
|
36
|
+
"#<Reflex::FrameEvent x:#{x} y:#{y} w:#{w} h:#{h} dx:#{dx} dy:#{dy} dw:#{dw} dh:#{dh}>"
|
37
|
+
end
|
38
|
+
|
39
|
+
end# FrameEvent
|
40
|
+
|
41
|
+
|
42
|
+
end# Reflex
|
data/lib/reflex/helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
|
4
|
+
require 'xot/hookable'
|
4
5
|
require 'reflex/point'
|
5
6
|
require 'reflex/bounds'
|
6
7
|
|
@@ -8,50 +9,106 @@ require 'reflex/bounds'
|
|
8
9
|
module Reflex
|
9
10
|
|
10
11
|
|
11
|
-
module
|
12
|
+
module Hookable
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
include Xot::Hookable
|
15
|
+
|
16
|
+
def hook (name, &block)
|
17
|
+
super "on_#{name}".intern, &block
|
18
|
+
end
|
19
|
+
|
20
|
+
end# Hookable
|
21
|
+
|
22
|
+
|
23
|
+
module HasFrame
|
24
|
+
|
25
|
+
def frame= (*args)
|
26
|
+
set_frame args.flatten
|
27
|
+
get_frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def frame (*args)
|
31
|
+
send :frame=, *args unless args.empty?
|
32
|
+
get_frame
|
33
|
+
end
|
34
|
+
|
35
|
+
def move_to (*args)
|
36
|
+
self.frame = get_frame.move_to *args
|
37
|
+
self
|
38
|
+
end
|
39
|
+
|
40
|
+
def move_by (*args)
|
41
|
+
self.frame = get_frame.move_by *args
|
42
|
+
self
|
43
|
+
end
|
44
|
+
|
45
|
+
def resize_to (*args)
|
46
|
+
self.frame = get_frame.resize_to *args
|
47
|
+
self
|
17
48
|
end
|
18
49
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
50
|
+
def resize_by (*args)
|
51
|
+
self.frame = get_frame.resize_by *args
|
52
|
+
self
|
53
|
+
end
|
54
|
+
|
55
|
+
def inset_by (*args)
|
56
|
+
self.frame = get_frame.inset_by *args
|
57
|
+
self
|
58
|
+
end
|
59
|
+
|
60
|
+
%w[
|
61
|
+
x y z w h d width height depth
|
62
|
+
left top back right bottom front
|
63
|
+
left_top right_top left_bottom right_bottom
|
64
|
+
lt rt lb rb
|
65
|
+
position pos size center
|
66
|
+
].each do |name|
|
67
|
+
name_assign = "#{name}=".intern
|
68
|
+
name = name.intern
|
69
|
+
|
70
|
+
define_method name do |*args|
|
71
|
+
send name_assign, *args unless args.empty?
|
72
|
+
get_frame.send name
|
73
|
+
end
|
74
|
+
|
75
|
+
define_method name_assign do |*args|
|
76
|
+
b = get_frame
|
77
|
+
ret = b.send name_assign, *args
|
78
|
+
set_frame b
|
79
|
+
ret
|
29
80
|
end
|
30
81
|
end
|
31
82
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
83
|
+
end# HasFrame
|
84
|
+
|
85
|
+
|
86
|
+
module HasTags
|
87
|
+
|
88
|
+
def tag= (*tags)
|
89
|
+
clear_tags
|
90
|
+
tag *tags.flatten
|
91
|
+
end
|
92
|
+
|
93
|
+
alias tags= tag=
|
94
|
+
|
95
|
+
def tag (*tags)
|
96
|
+
tags.each {|tag| add_tag tag}
|
36
97
|
end
|
37
98
|
|
38
|
-
def
|
39
|
-
|
40
|
-
move_to b.x + dx, b.y + dy
|
99
|
+
def untag (*tags)
|
100
|
+
tags.each {|tag| remove_tag tag}
|
41
101
|
end
|
42
102
|
|
43
|
-
def
|
44
|
-
|
45
|
-
b.width, b.height = width, height
|
46
|
-
self.bounds = b
|
103
|
+
def tags ()
|
104
|
+
to_enum :each_tag
|
47
105
|
end
|
48
106
|
|
49
|
-
def
|
50
|
-
|
51
|
-
resize_to b.width + dwidth, b.height + dheight
|
107
|
+
def clear_tags ()
|
108
|
+
untag *tags.to_a
|
52
109
|
end
|
53
110
|
|
54
|
-
end#
|
111
|
+
end# HasTags
|
55
112
|
|
56
113
|
|
57
114
|
end# Reflex
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require 'reflex/view'
|
5
|
+
|
6
|
+
|
7
|
+
module Reflex
|
8
|
+
|
9
|
+
|
10
|
+
class ImageView < View
|
11
|
+
|
12
|
+
has_model
|
13
|
+
|
14
|
+
def image= (image)
|
15
|
+
self.data = image
|
16
|
+
end
|
17
|
+
|
18
|
+
def on_data_update (e)
|
19
|
+
set_image self.data
|
20
|
+
end
|
21
|
+
|
22
|
+
end# ImageView
|
23
|
+
|
24
|
+
|
25
|
+
end# Reflex
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require 'reflex/ext'
|
5
|
+
|
6
|
+
|
7
|
+
module Reflex
|
8
|
+
|
9
|
+
|
10
|
+
class KeyEvent
|
11
|
+
|
12
|
+
def type ()
|
13
|
+
TYPE2SYM[get_type] || :none
|
14
|
+
end
|
15
|
+
|
16
|
+
def down? ()
|
17
|
+
get_type == TYPE_DOWN
|
18
|
+
end
|
19
|
+
|
20
|
+
def up? ()
|
21
|
+
get_type == TYPE_UP
|
22
|
+
end
|
23
|
+
|
24
|
+
def inspect ()
|
25
|
+
"#<Reflex::KeyEvent type:#{type} chars:'#{chars}' code:#{code} mod:#{modifiers} repeat:#{repeat} capture?:#{capture?}>"
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
TYPE2SYM = {
|
31
|
+
TYPE_DOWN => :down,
|
32
|
+
TYPE_UP => :up,
|
33
|
+
}
|
34
|
+
|
35
|
+
end# KeyEvent
|
36
|
+
|
37
|
+
|
38
|
+
end# Reflex
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require 'reflex/shape'
|
5
|
+
|
6
|
+
|
7
|
+
module Reflex
|
8
|
+
|
9
|
+
|
10
|
+
class LineShape < Shape
|
11
|
+
|
12
|
+
def on_draw (e)
|
13
|
+
p, b = e.painter, e.bounds
|
14
|
+
attach_color_and_border(p) {p.line b.lt, b.rb}
|
15
|
+
end
|
16
|
+
|
17
|
+
end# LineShape
|
18
|
+
|
19
|
+
|
20
|
+
end# Reflex
|