shoes-swt 4.0.0.pre6 → 4.0.0.pre7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +1 -1
- data/lib/shoes/swt.rb +8 -0
- data/lib/shoes/swt/app.rb +5 -7
- data/lib/shoes/swt/arc.rb +3 -28
- data/lib/shoes/swt/arc_painter.rb +34 -0
- data/lib/shoes/swt/arrow.rb +35 -0
- data/lib/shoes/swt/arrow_painter.rb +59 -0
- data/lib/shoes/swt/background.rb +1 -0
- data/lib/shoes/swt/border.rb +1 -0
- data/lib/shoes/swt/check_button.rb +17 -17
- data/lib/shoes/swt/click_listener.rb +6 -6
- data/lib/shoes/swt/common/painter.rb +4 -2
- data/lib/shoes/swt/common/translate.rb +15 -0
- data/lib/shoes/swt/{generate-backend.rb → generate_backend.rb} +1 -3
- data/lib/shoes/swt/gradient.rb +3 -4
- data/lib/shoes/swt/key_listener.rb +9 -7
- data/lib/shoes/swt/line.rb +5 -13
- data/lib/shoes/swt/line_painter.rb +16 -0
- data/lib/shoes/swt/link.rb +4 -0
- data/lib/shoes/swt/link_segment.rb +1 -1
- data/lib/shoes/swt/oval.rb +2 -21
- data/lib/shoes/swt/oval_painter.rb +27 -0
- data/lib/shoes/swt/packager.rb +1 -1
- data/lib/shoes/swt/radio_group.rb +1 -1
- data/lib/shoes/swt/rect.rb +1 -0
- data/lib/shoes/swt/rect_painter.rb +27 -9
- data/lib/shoes/swt/redrawing_aspect.rb +30 -17
- data/lib/shoes/swt/shape.rb +13 -18
- data/lib/shoes/swt/shape_painter.rb +13 -0
- data/lib/shoes/swt/shoes_layout.rb +1 -1
- data/lib/shoes/swt/slot.rb +12 -1
- data/lib/shoes/swt/sound.rb +21 -23
- data/lib/shoes/swt/star.rb +2 -46
- data/lib/shoes/swt/star_painter.rb +51 -0
- data/lib/shoes/swt/text_block.rb +4 -3
- data/lib/shoes/swt/text_block/fitter.rb +3 -4
- data/lib/shoes/swt/text_block/text_font_factory.rb +1 -1
- data/lib/shoes/swt/text_block/text_segment.rb +8 -3
- data/lib/shoes/swt/text_block/text_segment_collection.rb +1 -1
- data/lib/shoes/swt/text_block/text_style_factory.rb +1 -3
- data/lib/shoes/swt/timer.rb +1 -3
- data/lib/shoes/swt/version.rb +3 -1
- data/shoes-swt.gemspec +1 -1
- data/spec/shoes/cli_spec.rb +2 -2
- data/spec/shoes/swt/animation_spec.rb +4 -3
- data/spec/shoes/swt/app_spec.rb +17 -17
- data/spec/shoes/swt/arc_painter_spec.rb +80 -0
- data/spec/shoes/swt/arc_spec.rb +7 -68
- data/spec/shoes/swt/arrow_painter_spec.rb +37 -0
- data/spec/shoes/swt/arrow_spec.rb +27 -0
- data/spec/shoes/swt/background_spec.rb +13 -11
- data/spec/shoes/swt/border_spec.rb +8 -5
- data/spec/shoes/swt/button_spec.rb +4 -4
- data/spec/shoes/swt/check_spec.rb +19 -8
- data/spec/shoes/swt/click_listener_spec.rb +1 -1
- data/spec/shoes/swt/common/painter_spec.rb +29 -14
- data/spec/shoes/swt/common/remove_spec.rb +2 -2
- data/spec/shoes/swt/dialog_spec.rb +1 -1
- data/spec/shoes/swt/flow_spec.rb +5 -3
- data/spec/shoes/swt/font_spec.rb +1 -1
- data/spec/shoes/swt/gradient_spec.rb +6 -3
- data/spec/shoes/swt/image_spec.rb +9 -9
- data/spec/shoes/swt/input_box_spec.rb +20 -15
- data/spec/shoes/swt/integration_spec.rb +1 -1
- data/spec/shoes/swt/key_listener_spec.rb +34 -33
- data/spec/shoes/swt/line_painter_spec.rb +26 -0
- data/spec/shoes/swt/line_spec.rb +2 -25
- data/spec/shoes/swt/link_segment_spec.rb +20 -18
- data/spec/shoes/swt/link_spec.rb +11 -8
- data/spec/shoes/swt/list_box_spec.rb +15 -11
- data/spec/shoes/swt/mouse_move_listener_spec.rb +55 -39
- data/spec/shoes/swt/oval_painter_spec.rb +40 -0
- data/spec/shoes/swt/oval_spec.rb +3 -34
- data/spec/shoes/swt/progress_spec.rb +2 -2
- data/spec/shoes/swt/radio_group_spec.rb +1 -1
- data/spec/shoes/swt/radio_spec.rb +7 -4
- data/spec/shoes/swt/rect_painter_spec.rb +13 -8
- data/spec/shoes/swt/rect_spec.rb +2 -4
- data/spec/shoes/swt/shape_painter_spec.rb +27 -0
- data/spec/shoes/swt/shape_spec.rb +7 -24
- data/spec/shoes/swt/shared_examples/clickable.rb +2 -2
- data/spec/shoes/swt/shared_examples/swt_app_context.rb +21 -12
- data/spec/shoes/swt/shell_control_listener_spec.rb +9 -9
- data/spec/shoes/swt/shoes_layout_spec.rb +18 -13
- data/spec/shoes/swt/slot_spec.rb +15 -4
- data/spec/shoes/swt/spec_helper.rb +1 -1
- data/spec/shoes/swt/star_painter_spec.rb +36 -0
- data/spec/shoes/swt/star_spec.rb +0 -25
- data/spec/shoes/swt/text_block/centered_text_segment_spec.rb +2 -2
- data/spec/shoes/swt/text_block/cursor_painter_spec.rb +17 -13
- data/spec/shoes/swt/text_block/fitter_spec.rb +25 -18
- data/spec/shoes/swt/text_block/painter_spec.rb +7 -4
- data/spec/shoes/swt/text_block/text_font_factory_spec.rb +3 -3
- data/spec/shoes/swt/text_block/text_segment_collection_spec.rb +22 -15
- data/spec/shoes/swt/text_block/text_segment_spec.rb +15 -12
- data/spec/shoes/swt/text_block_spec.rb +12 -10
- data/spec/spec_helper.rb +3 -1
- metadata +30 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e578292fc72374cb908da4b2a44e2b72703d8f8e
|
4
|
+
data.tar.gz: 67cb5ed10dd725f3346f060e223f90d333cdfeb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef6ccf0aaa4e412776b246ea1875b1c10d895a703efb2ea6062ad7d8303a6dfacd27e2590d2228bb47f3c4e817116c17b302b8c3f5447c99c37f0bad7890ae79
|
7
|
+
data.tar.gz: 0bf3f70d2c0c0f78e3ae64ef542972b0f73f6e2e185b251ab647ade8513441996d1ed950d484c0cef6cf4dcc469c50145f4506b0a06390eedc80f7c3bcc629b2
|
data/Guardfile
CHANGED
data/lib/shoes/swt.rb
CHANGED
@@ -66,10 +66,17 @@ class Shoes
|
|
66
66
|
require 'shoes/swt/common/visibility'
|
67
67
|
require 'shoes/swt/common/selection_listener'
|
68
68
|
require 'shoes/swt/common/stroke'
|
69
|
+
require 'shoes/swt/common/translate'
|
69
70
|
require 'shoes/swt/common/update_position'
|
70
71
|
|
71
72
|
require 'shoes/swt/input_box'
|
73
|
+
require 'shoes/swt/arc_painter.rb'
|
74
|
+
require 'shoes/swt/arrow_painter.rb'
|
75
|
+
require 'shoes/swt/line_painter.rb'
|
76
|
+
require 'shoes/swt/oval_painter.rb'
|
72
77
|
require 'shoes/swt/rect_painter.rb'
|
78
|
+
require 'shoes/swt/shape_painter.rb'
|
79
|
+
require 'shoes/swt/star_painter.rb'
|
73
80
|
require 'shoes/swt/swt_button'
|
74
81
|
require 'shoes/swt/check_button'
|
75
82
|
require 'shoes/swt/radio_group'
|
@@ -78,6 +85,7 @@ class Shoes
|
|
78
85
|
require 'shoes/swt/app'
|
79
86
|
require 'shoes/swt/animation'
|
80
87
|
require 'shoes/swt/arc'
|
88
|
+
require 'shoes/swt/arrow'
|
81
89
|
require 'shoes/swt/background'
|
82
90
|
require 'shoes/swt/border'
|
83
91
|
require 'shoes/swt/button'
|
data/lib/shoes/swt/app.rb
CHANGED
@@ -87,9 +87,7 @@ class Shoes
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def flush
|
90
|
-
if @dsl.top_slot
|
91
|
-
@real.layout
|
92
|
-
end
|
90
|
+
@real.layout if @dsl.top_slot
|
93
91
|
end
|
94
92
|
|
95
93
|
def scroll_top
|
@@ -157,8 +155,8 @@ class Shoes
|
|
157
155
|
# just one color for now
|
158
156
|
background_color = Shoes.display.getSystemColor(::Swt::SWT::COLOR_WIDGET_BACKGROUND)
|
159
157
|
::Shoes::DSL.define_shoes_color(:system_background, background_color.red,
|
160
|
-
|
161
|
-
|
158
|
+
background_color.green,
|
159
|
+
background_color.blue)
|
162
160
|
end
|
163
161
|
|
164
162
|
private
|
@@ -209,7 +207,7 @@ class Shoes
|
|
209
207
|
|
210
208
|
@shell = ::Swt::Widgets::Shell.new(::Swt.display, main_window_style)
|
211
209
|
@shell.image = @image
|
212
|
-
@shell.text =
|
210
|
+
@shell.text = @dsl.app_title
|
213
211
|
@shell.background_mode = ::Swt::SWT::INHERIT_DEFAULT
|
214
212
|
@shell.background = @background.real
|
215
213
|
end
|
@@ -245,7 +243,7 @@ class Shoes
|
|
245
243
|
def unregister_app
|
246
244
|
proc do |_event|
|
247
245
|
::Shoes::Swt.unregister(self)
|
248
|
-
::Shoes.unregister(
|
246
|
+
::Shoes.unregister(dsl.app)
|
249
247
|
end
|
250
248
|
end
|
251
249
|
|
data/lib/shoes/swt/arc.rb
CHANGED
@@ -7,6 +7,7 @@ class Shoes
|
|
7
7
|
include Common::PainterUpdatesPosition
|
8
8
|
include Common::Visibility
|
9
9
|
include Common::Remove
|
10
|
+
include Common::Translate
|
10
11
|
include ::Shoes::BackendDimensionsDelegations
|
11
12
|
|
12
13
|
attr_reader :dsl, :app, :transform
|
@@ -18,7 +19,8 @@ class Shoes
|
|
18
19
|
def initialize(dsl, app)
|
19
20
|
@dsl = dsl
|
20
21
|
@app = app
|
21
|
-
|
22
|
+
|
23
|
+
@painter = ArcPainter.new(self)
|
22
24
|
@app.add_paint_listener @painter
|
23
25
|
end
|
24
26
|
|
@@ -39,33 +41,6 @@ class Shoes
|
|
39
41
|
def radians_to_degrees(radians)
|
40
42
|
radians * 180 / ::Shoes::PI
|
41
43
|
end
|
42
|
-
|
43
|
-
class Painter < Common::Painter
|
44
|
-
def fill(graphics_context)
|
45
|
-
if @obj.wedge?
|
46
|
-
graphics_context.fill_arc(@obj.element_left, @obj.element_top,
|
47
|
-
@obj.element_width, @obj.element_height,
|
48
|
-
@obj.angle1, @obj.angle2 * -1)
|
49
|
-
else
|
50
|
-
path = ::Swt::Path.new(::Swt.display)
|
51
|
-
path.add_arc(@obj.element_left, @obj.element_top,
|
52
|
-
@obj.element_width, @obj.element_height,
|
53
|
-
@obj.angle1, @obj.angle2 * -1)
|
54
|
-
graphics_context.fill_path(path)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def draw(graphics_context)
|
59
|
-
sw = graphics_context.get_line_width
|
60
|
-
if @obj.element_left && @obj.element_top && @obj.element_width && @obj.element_height
|
61
|
-
graphics_context.draw_arc(@obj.element_left + sw / 2,
|
62
|
-
@obj.element_top + sw / 2,
|
63
|
-
@obj.element_width - sw,
|
64
|
-
@obj.element_height - sw,
|
65
|
-
@obj.angle1, @obj.angle2 * -1)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
44
|
end
|
70
45
|
end
|
71
46
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Shoes
|
2
|
+
module Swt
|
3
|
+
class ArcPainter < Common::Painter
|
4
|
+
def fill(graphics_context)
|
5
|
+
if @obj.wedge?
|
6
|
+
graphics_context.fill_arc(@obj.translate_left + @obj.element_left,
|
7
|
+
@obj.translate_top + @obj.element_top,
|
8
|
+
@obj.element_width,
|
9
|
+
@obj.element_height,
|
10
|
+
@obj.angle1, @obj.angle2 * -1)
|
11
|
+
else
|
12
|
+
path = ::Swt::Path.new(::Swt.display)
|
13
|
+
path.add_arc(@obj.translate_left + @obj.element_left,
|
14
|
+
@obj.translate_top + @obj.element_top,
|
15
|
+
@obj.element_width,
|
16
|
+
@obj.element_height,
|
17
|
+
@obj.angle1, @obj.angle2 * -1)
|
18
|
+
graphics_context.fill_path(path)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def draw(graphics_context)
|
23
|
+
sw = graphics_context.get_line_width
|
24
|
+
if @obj.element_left && @obj.element_top && @obj.element_width && @obj.element_height
|
25
|
+
graphics_context.draw_arc(@obj.translate_left + @obj.element_left + sw / 2,
|
26
|
+
@obj.translate_top + @obj.element_top + sw / 2,
|
27
|
+
@obj.element_width - sw,
|
28
|
+
@obj.element_height - sw,
|
29
|
+
@obj.angle1, @obj.angle2 * -1)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class Shoes
|
2
|
+
module Swt
|
3
|
+
class Arrow
|
4
|
+
extend Forwardable
|
5
|
+
include Common::Fill
|
6
|
+
include Common::Stroke
|
7
|
+
include Common::Clickable
|
8
|
+
include Common::PainterUpdatesPosition
|
9
|
+
include Common::Visibility
|
10
|
+
include Common::Remove
|
11
|
+
include Common::Translate
|
12
|
+
include ::Shoes::BackendDimensionsDelegations
|
13
|
+
|
14
|
+
def_delegators :dsl, :angle
|
15
|
+
|
16
|
+
attr_reader :dsl, :app, :transform, :path, :painter
|
17
|
+
|
18
|
+
def initialize(dsl, app)
|
19
|
+
@dsl = dsl
|
20
|
+
@app = app
|
21
|
+
|
22
|
+
@painter = ArrowPainter.new(self)
|
23
|
+
@app.add_paint_listener @painter
|
24
|
+
end
|
25
|
+
|
26
|
+
def update_position
|
27
|
+
@painter.clear_path
|
28
|
+
end
|
29
|
+
|
30
|
+
def dispose
|
31
|
+
@painter.dispose
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class Shoes
|
2
|
+
module Swt
|
3
|
+
class ArrowPainter < Common::Painter
|
4
|
+
def fill(gc)
|
5
|
+
gc.fill_path(path)
|
6
|
+
end
|
7
|
+
|
8
|
+
def draw(gc)
|
9
|
+
gc.draw_path(path)
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
@path ||= begin
|
14
|
+
#
|
15
|
+
# body_right
|
16
|
+
#
|
17
|
+
# head_top body_left |\
|
18
|
+
# | \
|
19
|
+
# body_top |---------------| \ head_right
|
20
|
+
# | \
|
21
|
+
# body_middle | (l,t) |
|
22
|
+
# | /
|
23
|
+
# body_bottom |---------------| /
|
24
|
+
# | /
|
25
|
+
# head_bottom |/
|
26
|
+
#
|
27
|
+
|
28
|
+
body_left = @obj.translate_left + @obj.left - @obj.width * 0.5
|
29
|
+
body_right = @obj.translate_left + @obj.left + @obj.width * 0.1
|
30
|
+
body_top = @obj.translate_top + @obj.top - @obj.width * 0.2
|
31
|
+
body_bottom = @obj.translate_top + @obj.top + @obj.width * 0.2
|
32
|
+
|
33
|
+
middle = @obj.translate_top + @obj.top
|
34
|
+
|
35
|
+
head_right = @obj.translate_left + @obj.left + @obj.width * 0.5
|
36
|
+
head_top = @obj.translate_top + @obj.top - @obj.width * 0.4
|
37
|
+
head_bottom = @obj.translate_top + @obj.top + @obj.width * 0.4
|
38
|
+
|
39
|
+
path = ::Swt::Path.new(::Swt.display)
|
40
|
+
path.move_to(body_left, middle)
|
41
|
+
path.line_to(body_left, body_top)
|
42
|
+
path.line_to(body_right, body_top)
|
43
|
+
path.line_to(body_right, head_top)
|
44
|
+
path.line_to(head_right, middle)
|
45
|
+
path.line_to(body_right, head_bottom)
|
46
|
+
path.line_to(body_right, body_bottom)
|
47
|
+
path.line_to(body_left, body_bottom)
|
48
|
+
path.line_to(body_left, middle)
|
49
|
+
|
50
|
+
path
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def clear_path
|
55
|
+
@path = nil
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/shoes/swt/background.rb
CHANGED
data/lib/shoes/swt/border.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
class Shoes
|
2
|
-
module Swt
|
3
|
-
class CheckButton < SwtButton
|
4
|
-
def initialize(dsl, app, type)
|
5
|
-
super(dsl, app, type)
|
6
|
-
end
|
7
|
-
|
8
|
-
def checked?
|
9
|
-
@real.get_selection
|
10
|
-
end
|
11
|
-
|
12
|
-
def checked=(bool)
|
13
|
-
@real.set_selection bool
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
1
|
+
class Shoes
|
2
|
+
module Swt
|
3
|
+
class CheckButton < SwtButton
|
4
|
+
def initialize(dsl, app, type)
|
5
|
+
super(dsl, app, type)
|
6
|
+
end
|
7
|
+
|
8
|
+
def checked?
|
9
|
+
@real.get_selection
|
10
|
+
end
|
11
|
+
|
12
|
+
def checked=(bool)
|
13
|
+
@real.set_selection bool
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -38,14 +38,14 @@ class Shoes
|
|
38
38
|
|
39
39
|
def handle_event(event)
|
40
40
|
handlers = case event.type
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
when ::Swt::SWT::MouseDown then @clicks
|
42
|
+
when ::Swt::SWT::MouseUp then @releases
|
43
|
+
end
|
44
44
|
return if handlers.nil? || handlers.empty?
|
45
45
|
|
46
|
-
handlers = handlers.to_a
|
47
|
-
|
48
|
-
|
46
|
+
handlers = handlers.to_a
|
47
|
+
.select { |dsl, _| !dsl.hidden? }
|
48
|
+
.select { |dsl, _| dsl.in_bounds?(event.x, event.y) }
|
49
49
|
|
50
50
|
# Take the last handler as an approximation of the "top-most" element
|
51
51
|
# since we don't have a true z-index. For layouts that aren't too
|
@@ -9,7 +9,7 @@ class Shoes
|
|
9
9
|
curve: ::Swt::SWT::CAP_ROUND,
|
10
10
|
rect: ::Swt::SWT::CAP_FLAT,
|
11
11
|
project: ::Swt::SWT::CAP_SQUARE
|
12
|
-
}
|
12
|
+
}.freeze
|
13
13
|
|
14
14
|
def initialize(obj)
|
15
15
|
@obj = obj
|
@@ -72,7 +72,9 @@ class Shoes
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def set_rotate(graphics_context, angle, left, top)
|
75
|
-
angle
|
75
|
+
angle = angle.to_i
|
76
|
+
left = left.to_i
|
77
|
+
top = top.to_i
|
76
78
|
if block_given?
|
77
79
|
begin
|
78
80
|
transform = ::Swt::Transform.new Shoes.display
|
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'rbconfig'
|
2
2
|
|
3
3
|
def generate_backend(path)
|
4
|
-
if RbConfig::CONFIG["host_os"] =~ /darwin/
|
5
|
-
options = "-J-XstartOnFirstThread"
|
6
|
-
end
|
4
|
+
options = "-J-XstartOnFirstThread" if RbConfig::CONFIG["host_os"] =~ /darwin/
|
7
5
|
|
8
6
|
"jruby #{options} #{path}/shoes-swt"
|
9
7
|
end
|
data/lib/shoes/swt/gradient.rb
CHANGED
@@ -45,9 +45,8 @@ class Shoes
|
|
45
45
|
width = dsl.element_width * 0.5
|
46
46
|
height = dsl.element_height * 0.5
|
47
47
|
angle = normalize_angle(-dsl.angle)
|
48
|
-
left, top, width, height
|
49
|
-
|
50
|
-
width, height)
|
48
|
+
left, top, width, height = determine_args_based_on_angle(angle, dsl.element_left,
|
49
|
+
dsl.element_top, width, height)
|
51
50
|
|
52
51
|
pattern = ::Swt::Pattern.new Shoes.display, left, top, width, height,
|
53
52
|
color1.real, color2.real
|
@@ -84,7 +83,7 @@ class Shoes
|
|
84
83
|
end
|
85
84
|
my_angle = angle % (Math::PI * 0.5)
|
86
85
|
length = Math.sqrt(my_width**2 + my_height**2)
|
87
|
-
b =
|
86
|
+
b = my_height.zero? && my_width.zero? ? 0 : Math.atan(my_height / my_width)
|
88
87
|
c = Math::PI * 0.5 - my_angle - b
|
89
88
|
r = length * Math.cos(c.abs)
|
90
89
|
x = r * Math.cos(b + c)
|
@@ -7,12 +7,13 @@ class Shoes
|
|
7
7
|
::Swt::SWT.const_get name
|
8
8
|
end
|
9
9
|
|
10
|
-
SPECIAL_KEY_NAMES =
|
10
|
+
SPECIAL_KEY_NAMES = Hash[
|
11
|
+
%w(TAB PAGE_UP PAGE_DOWN HOME END F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12
|
12
|
+
F13 F14 F15).map do |key|
|
13
|
+
[get_swt_constant(key), key.downcase]
|
14
|
+
end
|
15
|
+
]
|
11
16
|
|
12
|
-
%w(TAB PAGE_UP PAGE_DOWN HOME END F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12
|
13
|
-
F13 F14 F15).each do|key|
|
14
|
-
SPECIAL_KEY_NAMES[get_swt_constant key] = key.downcase
|
15
|
-
end
|
16
17
|
%w(UP DOWN LEFT RIGHT).each do |key|
|
17
18
|
SPECIAL_KEY_NAMES[get_swt_constant "ARROW_#{key}"] = key.downcase
|
18
19
|
end
|
@@ -22,6 +23,8 @@ class Shoes
|
|
22
23
|
SPECIAL_KEY_NAMES[::Swt::SWT::ESC] = "escape"
|
23
24
|
SPECIAL_KEY_NAMES[::Swt::SWT::CR] = "\n"
|
24
25
|
|
26
|
+
SPECIAL_KEY_NAMES.freeze
|
27
|
+
|
25
28
|
MODIFIER_KEYS = %w(CTRL SHIFT ALT CAPS_LOCK COMMAND).map do |key|
|
26
29
|
get_swt_constant key
|
27
30
|
end
|
@@ -44,7 +47,7 @@ class Shoes
|
|
44
47
|
@app.remove_key_listener(self)
|
45
48
|
end
|
46
49
|
|
47
|
-
BUTTON_EXCLUDES = ["\n", " "]
|
50
|
+
BUTTON_EXCLUDES = ["\n", " "].freeze
|
48
51
|
COMBO_EXCLUDES = %w(up down) + BUTTON_EXCLUDES
|
49
52
|
|
50
53
|
# For a variety of SWT controls, certain characters should not be passed
|
@@ -104,7 +107,6 @@ class Shoes
|
|
104
107
|
(event.stateMask & key) == key
|
105
108
|
end
|
106
109
|
|
107
|
-
|
108
110
|
def character_key(event)
|
109
111
|
return '' if current_key_is_modifier?(event)
|
110
112
|
if special_key?(event)
|