glimmer-dsl-swt 4.17.4.2 → 4.17.8.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +38 -2
- data/README.md +307 -105
- data/VERSION +1 -1
- data/glimmer-dsl-swt.gemspec +23 -5
- data/lib/glimmer/data_binding/tree_items_binding.rb +20 -2
- data/lib/glimmer/dsl/swt/checkbox_group_selection_data_binding_expression.rb +61 -0
- data/lib/glimmer/dsl/swt/custom_widget_expression.rb +2 -0
- data/lib/glimmer/dsl/swt/dialog_expression.rb +1 -0
- data/lib/glimmer/dsl/swt/directory_dialog_expression.rb +48 -0
- data/lib/glimmer/dsl/swt/dsl.rb +2 -0
- data/lib/glimmer/dsl/swt/expand_item_expression.rb +60 -0
- data/lib/glimmer/dsl/swt/file_dialog_expression.rb +48 -0
- data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +61 -0
- data/lib/glimmer/dsl/swt/shell_expression.rb +3 -3
- data/lib/glimmer/dsl/swt/widget_expression.rb +8 -8
- data/lib/glimmer/swt/custom/checkbox_group.rb +160 -0
- data/lib/glimmer/swt/custom/code_text.rb +39 -31
- data/lib/glimmer/swt/custom/radio_group.rb +155 -0
- data/lib/glimmer/swt/directory_dialog_proxy.rb +65 -0
- data/lib/glimmer/swt/expand_item_proxy.rb +97 -0
- data/lib/glimmer/swt/file_dialog_proxy.rb +66 -0
- data/lib/glimmer/swt/image_proxy.rb +2 -0
- data/lib/glimmer/swt/menu_proxy.rb +4 -4
- data/lib/glimmer/swt/shell_proxy.rb +5 -5
- data/lib/glimmer/swt/tab_item_proxy.rb +1 -1
- data/lib/glimmer/swt/widget_proxy.rb +27 -26
- data/lib/glimmer/ui/custom_shell.rb +3 -3
- data/lib/glimmer/ui/custom_widget.rb +3 -0
- data/samples/elaborate/meta_sample.rb +36 -31
- data/samples/hello/hello_checkbox.rb +85 -0
- data/samples/hello/hello_checkbox_group.rb +68 -0
- data/samples/hello/hello_combo.rb +12 -12
- data/samples/hello/hello_directory_dialog.rb +60 -0
- data/samples/hello/hello_expand_bar.rb +110 -0
- data/samples/hello/hello_file_dialog.rb +60 -0
- data/samples/hello/hello_list_multi_selection.rb +23 -23
- data/samples/hello/hello_list_single_selection.rb +18 -17
- data/samples/hello/hello_radio.rb +108 -0
- data/samples/hello/hello_radio_group.rb +84 -0
- data/samples/hello/hello_styled_text.rb +138 -0
- data/samples/hello/hello_world.rb +3 -3
- metadata +22 -4
@@ -0,0 +1,65 @@
|
|
1
|
+
# Copyright (c) 2007-2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/swt/swt_proxy'
|
23
|
+
require 'glimmer/swt/widget_proxy'
|
24
|
+
require 'glimmer/swt/display_proxy'
|
25
|
+
|
26
|
+
module Glimmer
|
27
|
+
module SWT
|
28
|
+
# Proxy for org.eclipse.swt.widgets.DirectoryDialog
|
29
|
+
#
|
30
|
+
# Automatically uses the current shell if one is open.
|
31
|
+
# Otherwise, it instantiates a new shell parent
|
32
|
+
#
|
33
|
+
# Optionally takes a shell as an argument
|
34
|
+
#
|
35
|
+
# Follows the Proxy Design Pattern
|
36
|
+
class DirectoryDialogProxy < WidgetProxy
|
37
|
+
# TODO write rspec tests
|
38
|
+
include_package 'org.eclipse.swt.widgets'
|
39
|
+
|
40
|
+
def initialize(*args, swt_widget: nil)
|
41
|
+
if swt_widget
|
42
|
+
@swt_widget = swt_widget
|
43
|
+
else
|
44
|
+
style_args = args.select {|arg| arg.is_a?(Symbol) || arg.is_a?(String)}
|
45
|
+
if style_args.any?
|
46
|
+
style_arg_start_index = args.index(style_args.first)
|
47
|
+
style_arg_last_index = args.index(style_args.last)
|
48
|
+
args[style_arg_start_index..style_arg_last_index] = SWTProxy[style_args]
|
49
|
+
end
|
50
|
+
if !args.first.is_a?(Shell)
|
51
|
+
current_shell = DisplayProxy.instance.swt_display.shells.first
|
52
|
+
args.unshift(current_shell.nil? ? ShellProxy.new : current_shell)
|
53
|
+
end
|
54
|
+
if args.first.is_a?(ShellProxy)
|
55
|
+
args[0] = args[0].swt_widget
|
56
|
+
end
|
57
|
+
parent = args[0]
|
58
|
+
@parent_proxy = parent.is_a?(Shell) ? ShellProxy.new(swt_widget: parent) : parent
|
59
|
+
@swt_widget = DirectoryDialog.new(*args)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# Copyright (c) 2007-2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/swt/widget_proxy'
|
23
|
+
require 'glimmer/swt/swt_proxy'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module SWT
|
27
|
+
# Proxy for org.eclipse.swt.widgets.ExpandItem
|
28
|
+
#
|
29
|
+
# Functions differently from other widget proxies.
|
30
|
+
#
|
31
|
+
# Glimmer instantiates an SWT Composite alongside the SWT ExpandItem
|
32
|
+
# and returns it for `#swt_widget` to allow adding widgets into it.
|
33
|
+
#
|
34
|
+
# In order to get the SWT ExpandItem object, one must call `#swt_expand_item`.
|
35
|
+
#
|
36
|
+
# Behind the scenes, this creates a tab item widget proxy separately from a composite that
|
37
|
+
# is set as the control of the tab item and `#swt_widget`.
|
38
|
+
#
|
39
|
+
# In order to retrieve the tab item widget proxy, one must call `#widget_proxy`
|
40
|
+
#
|
41
|
+
# Follows the Proxy Design Pattern
|
42
|
+
class ExpandItemProxy < WidgetProxy
|
43
|
+
ATTRIBUTES = ['text', 'height', 'expanded']
|
44
|
+
|
45
|
+
include_package 'org.eclipse.swt.widgets'
|
46
|
+
|
47
|
+
attr_reader :widget_proxy, :swt_expand_item
|
48
|
+
|
49
|
+
def initialize(parent, style, &contents)
|
50
|
+
super("composite", parent, style, &contents)
|
51
|
+
layout = FillLayout.new(SWTProxy[:vertical])
|
52
|
+
layout.marginWidth = 0
|
53
|
+
layout.marginHeight = 0
|
54
|
+
layout.spacing = 0
|
55
|
+
swt_widget.layout = layout
|
56
|
+
@widget_proxy = SWT::WidgetProxy.new('expand_item', parent, style)
|
57
|
+
@swt_expand_item = @widget_proxy.swt_widget
|
58
|
+
@swt_expand_item.control = swt_widget
|
59
|
+
@swt_expand_item.expanded = true
|
60
|
+
end
|
61
|
+
|
62
|
+
def post_add_content
|
63
|
+
@swt_expand_item.setHeight(swt_widget.computeSize(SWTProxy[:default], SWTProxy[:default]).y) unless @swt_expand_item.getHeight > 0
|
64
|
+
end
|
65
|
+
|
66
|
+
def has_attribute?(attribute_name, *args)
|
67
|
+
if ATTRIBUTES.include?(attribute_name.to_s)
|
68
|
+
true
|
69
|
+
else
|
70
|
+
super(attribute_name, *args)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def set_attribute(attribute_name, *args)
|
75
|
+
if ATTRIBUTES.include?(attribute_name.to_s)
|
76
|
+
@widget_proxy.set_attribute(attribute_name, *args)
|
77
|
+
else
|
78
|
+
super(attribute_name, *args)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def get_attribute(attribute_name)
|
83
|
+
if ATTRIBUTES.include?(attribute_name.to_s)
|
84
|
+
@widget_proxy.get_attribute(attribute_name)
|
85
|
+
else
|
86
|
+
super(attribute_name)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def dispose
|
91
|
+
swt_expand_item.setControl(nil)
|
92
|
+
swt_widget.dispose
|
93
|
+
swt_expand_item.dispose
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Copyright (c) 2007-2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/swt/swt_proxy'
|
23
|
+
require 'glimmer/swt/widget_proxy'
|
24
|
+
require 'glimmer/swt/display_proxy'
|
25
|
+
|
26
|
+
module Glimmer
|
27
|
+
module SWT
|
28
|
+
# Proxy for org.eclipse.swt.widgets.FileDialog
|
29
|
+
#
|
30
|
+
# Automatically uses the current shell if one is open.
|
31
|
+
# Otherwise, it instantiates a new shell parent
|
32
|
+
#
|
33
|
+
# Optionally takes a shell as an argument
|
34
|
+
#
|
35
|
+
# Follows the Proxy Design Pattern
|
36
|
+
class FileDialogProxy < WidgetProxy
|
37
|
+
# TODO write rspec tests
|
38
|
+
# TODO consider refactoring and sharing code with DirectoryDialogProxy (and do the same with their expressions)
|
39
|
+
include_package 'org.eclipse.swt.widgets'
|
40
|
+
|
41
|
+
def initialize(*args, swt_widget: nil)
|
42
|
+
if swt_widget
|
43
|
+
@swt_widget = swt_widget
|
44
|
+
else
|
45
|
+
style_args = args.select {|arg| arg.is_a?(Symbol) || arg.is_a?(String)}
|
46
|
+
if style_args.any?
|
47
|
+
style_arg_start_index = args.index(style_args.first)
|
48
|
+
style_arg_last_index = args.index(style_args.last)
|
49
|
+
args[style_arg_start_index..style_arg_last_index] = SWTProxy[style_args]
|
50
|
+
end
|
51
|
+
if !args.first.is_a?(Shell)
|
52
|
+
current_shell = DisplayProxy.instance.swt_display.shells.first
|
53
|
+
args.unshift(current_shell.nil? ? ShellProxy.new : current_shell)
|
54
|
+
end
|
55
|
+
if args.first.is_a?(ShellProxy)
|
56
|
+
args[0] = args[0].swt_widget
|
57
|
+
end
|
58
|
+
parent = args[0]
|
59
|
+
@parent_proxy = parent.is_a?(Shell) ? ShellProxy.new(swt_widget: parent) : parent
|
60
|
+
@swt_widget = FileDialog.new(*args)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -60,6 +60,8 @@ module Glimmer
|
|
60
60
|
@swt_image = Image.new(DisplayProxy.instance.swt_display, @image_data)
|
61
61
|
width = options[:width]
|
62
62
|
height = options[:height]
|
63
|
+
height = (@image_data.height.to_f / @image_data.width.to_f)*width.to_f if !width.nil? && height.nil?
|
64
|
+
width = (@image_data.width.to_f / @image_data.height.to_f)*height.to_f if !height.nil? && width.nil?
|
63
65
|
scale_to(width, height) unless width.nil? || height.nil?
|
64
66
|
else
|
65
67
|
@swt_image = Image.new(*@args)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2007-2020 Andy Maleh
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
5
5
|
# "Software"), to deal in the Software without restriction, including
|
@@ -7,10 +7,10 @@
|
|
7
7
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
8
|
# permit persons to whom the Software is furnished to do so, subject to
|
9
9
|
# the following conditions:
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# The above copyright notice and this permission notice shall be
|
12
12
|
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
15
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
16
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -116,7 +116,7 @@ module Glimmer
|
|
116
116
|
else
|
117
117
|
menu_item_proxy.handle_observation_request(observation_request, &block)
|
118
118
|
end
|
119
|
-
end
|
119
|
+
end
|
120
120
|
end
|
121
121
|
end
|
122
122
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2007-2020 Andy Maleh
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
5
5
|
# "Software"), to deal in the Software without restriction, including
|
@@ -7,10 +7,10 @@
|
|
7
7
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
8
|
# permit persons to whom the Software is furnished to do so, subject to
|
9
9
|
# the following conditions:
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# The above copyright notice and this permission notice shall be
|
12
12
|
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
15
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
16
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -65,7 +65,7 @@ module Glimmer
|
|
65
65
|
@swt_widget.setMinimumSize(WIDTH_MIN, HEIGHT_MIN)
|
66
66
|
# TODO make this an option not the default
|
67
67
|
on_swt_show do
|
68
|
-
Thread.new do
|
68
|
+
Thread.new do
|
69
69
|
sleep(0.25)
|
70
70
|
async_exec do
|
71
71
|
@swt_widget.setActive unless @swt_widget.isDisposed
|
@@ -130,7 +130,7 @@ module Glimmer
|
|
130
130
|
@swt_widget.pack
|
131
131
|
@swt_widget.removeControlListener(listener.swt_listener)
|
132
132
|
@swt_widget.setMinimumSize(minimum_size)
|
133
|
-
elsif OS.linux?
|
133
|
+
elsif OS.linux?
|
134
134
|
@swt_widget.layout(true, true)
|
135
135
|
@swt_widget.setBounds(bounds)
|
136
136
|
end
|
@@ -47,7 +47,7 @@ module Glimmer
|
|
47
47
|
super("composite", parent, style, &contents)
|
48
48
|
@widget_proxy = SWT::WidgetProxy.new('tab_item', parent, style)
|
49
49
|
@swt_tab_item = @widget_proxy.swt_widget
|
50
|
-
@
|
50
|
+
@swt_tab_item.control = swt_widget
|
51
51
|
end
|
52
52
|
|
53
53
|
def has_attribute?(attribute_name, *args)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2007-2020 Andy Maleh
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
5
5
|
# "Software"), to deal in the Software without restriction, including
|
@@ -7,10 +7,10 @@
|
|
7
7
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
8
|
# permit persons to whom the Software is furnished to do so, subject to
|
9
9
|
# the following conditions:
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# The above copyright notice and this permission notice shall be
|
12
12
|
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
15
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
16
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -50,6 +50,7 @@ module Glimmer
|
|
50
50
|
'check' => [:check],
|
51
51
|
'drag_source' => [:drop_copy],
|
52
52
|
'drop_target' => [:drop_copy],
|
53
|
+
'expand_bar' => [:v_scroll],
|
53
54
|
'list' => [:border, :v_scroll],
|
54
55
|
'menu_item' => [:push],
|
55
56
|
'radio' => [:radio],
|
@@ -90,11 +91,11 @@ module Glimmer
|
|
90
91
|
}
|
91
92
|
|
92
93
|
KEYWORD_ALIASES = {
|
93
|
-
'
|
94
|
+
'arrow' => 'button',
|
94
95
|
'checkbox' => 'button',
|
95
96
|
'check' => 'button',
|
97
|
+
'radio' => 'button',
|
96
98
|
'toggle' => 'button',
|
97
|
-
'arrow' => 'button',
|
98
99
|
}
|
99
100
|
|
100
101
|
class << self
|
@@ -107,7 +108,7 @@ module Glimmer
|
|
107
108
|
if init_args.empty?
|
108
109
|
selected_widget_proxy_class.new(swt_widget: swt_widget)
|
109
110
|
else
|
110
|
-
selected_widget_proxy_class.new(*init_args)
|
111
|
+
selected_widget_proxy_class.new(*init_args)
|
111
112
|
end
|
112
113
|
end
|
113
114
|
|
@@ -118,11 +119,11 @@ module Glimmer
|
|
118
119
|
Glimmer::SWT.const_get(class_name)
|
119
120
|
rescue
|
120
121
|
Glimmer::SWT::WidgetProxy
|
121
|
-
end
|
122
|
+
end
|
122
123
|
end
|
123
124
|
|
124
125
|
def underscored_widget_name(swt_widget)
|
125
|
-
swt_widget.class.name.split(/::|\./).last.underscore
|
126
|
+
swt_widget.class.name.split(/::|\./).last.underscore
|
126
127
|
end
|
127
128
|
end
|
128
129
|
|
@@ -130,7 +131,7 @@ module Glimmer
|
|
130
131
|
|
131
132
|
# Initializes a new SWT Widget
|
132
133
|
#
|
133
|
-
# It is preferred to use `::create` method instead since it instantiates the
|
134
|
+
# It is preferred to use `::create` method instead since it instantiates the
|
134
135
|
# right subclass per widget keyword
|
135
136
|
#
|
136
137
|
# keyword, parent, swt_widget_args (including styles)
|
@@ -151,7 +152,7 @@ module Glimmer
|
|
151
152
|
@parent_proxy = parent.get_data('proxy') || parent_proxy_class.new(swt_widget: parent)
|
152
153
|
end
|
153
154
|
if @swt_widget&.get_data('proxy').nil?
|
154
|
-
@swt_widget.set_data('proxy', self)
|
155
|
+
@swt_widget.set_data('proxy', self)
|
155
156
|
DEFAULT_INITIALIZERS[underscored_widget_name]&.call(@swt_widget)
|
156
157
|
@parent_proxy.post_initialize_child(self)
|
157
158
|
end
|
@@ -375,7 +376,7 @@ module Glimmer
|
|
375
376
|
observer.call(@last_top_index)
|
376
377
|
end
|
377
378
|
}
|
378
|
-
end,
|
379
|
+
end,
|
379
380
|
:top_pixel => lambda do |observer|
|
380
381
|
@last_top_pixel = @swt_widget.getTopPixel
|
381
382
|
on_paint_control { |event|
|
@@ -479,13 +480,13 @@ module Glimmer
|
|
479
480
|
proxy.set_attribute(:transfer, :text)
|
480
481
|
proxy.on_drag_enter { |event|
|
481
482
|
event.detail = DNDProxy[:drop_copy]
|
482
|
-
}
|
483
|
+
}
|
483
484
|
end
|
484
485
|
end
|
485
486
|
|
486
487
|
# TODO eliminate duplication in the following methods perhaps by relying on exceptions
|
487
488
|
|
488
|
-
def can_handle_observation_request?(observation_request)
|
489
|
+
def can_handle_observation_request?(observation_request)
|
489
490
|
observation_request = observation_request.to_s
|
490
491
|
if observation_request.start_with?('on_swt_')
|
491
492
|
constant_name = observation_request.sub(/^on_swt_/, '')
|
@@ -508,7 +509,7 @@ module Glimmer
|
|
508
509
|
end
|
509
510
|
rescue => e
|
510
511
|
Glimmer::Config.logger.debug {e.full_message}
|
511
|
-
false
|
512
|
+
false
|
512
513
|
end
|
513
514
|
|
514
515
|
def can_handle_drop_observation_request?(observation_request)
|
@@ -546,7 +547,7 @@ module Glimmer
|
|
546
547
|
end
|
547
548
|
|
548
549
|
def method_missing(method, *args, &block)
|
549
|
-
if can_handle_observation_request?(method)
|
550
|
+
if can_handle_observation_request?(method)
|
550
551
|
handle_observation_request(method, &block)
|
551
552
|
else
|
552
553
|
swt_widget.send(method, *args, &block)
|
@@ -558,7 +559,7 @@ module Glimmer
|
|
558
559
|
end
|
559
560
|
|
560
561
|
def respond_to?(method, *args, &block)
|
561
|
-
super ||
|
562
|
+
super ||
|
562
563
|
can_handle_observation_request?(method) ||
|
563
564
|
swt_widget.respond_to?(method, *args, &block)
|
564
565
|
end
|
@@ -566,7 +567,7 @@ module Glimmer
|
|
566
567
|
private
|
567
568
|
|
568
569
|
def style(underscored_widget_name, styles)
|
569
|
-
styles = [styles].flatten.compact
|
570
|
+
styles = [styles].flatten.compact
|
570
571
|
styles = default_style(underscored_widget_name) if styles.empty?
|
571
572
|
interpret_style(*styles)
|
572
573
|
end
|
@@ -602,9 +603,9 @@ module Glimmer
|
|
602
603
|
end
|
603
604
|
|
604
605
|
def add_listener(underscored_listener_name, &block)
|
605
|
-
widget_add_listener_method, listener_class, listener_method = self.class.find_listener(@swt_widget.getClass, underscored_listener_name)
|
606
|
+
widget_add_listener_method, listener_class, listener_method = self.class.find_listener(@swt_widget.getClass, underscored_listener_name)
|
606
607
|
widget_listener_proxy = nil
|
607
|
-
safe_block = lambda { |*args| block.call(*args) unless @swt_widget.isDisposed }
|
608
|
+
safe_block = lambda { |*args| block.call(*args) unless @swt_widget.isDisposed }
|
608
609
|
listener = listener_class.new(listener_method => safe_block)
|
609
610
|
@swt_widget.send(widget_add_listener_method, listener)
|
610
611
|
widget_listener_proxy = WidgetListenerProxy.new(swt_widget: @swt_widget, swt_listener: listener, widget_add_listener_method: widget_add_listener_method, swt_listener_class: listener_class, swt_listener_method: listener_method)
|
@@ -646,7 +647,7 @@ module Glimmer
|
|
646
647
|
listener_class.define_method('initialize') do |event_method_block_mapping|
|
647
648
|
@event_method_block_mapping = event_method_block_mapping
|
648
649
|
end
|
649
|
-
listener_type.getMethods.each do |event_method|
|
650
|
+
listener_type.getMethods.each do |event_method|
|
650
651
|
listener_class.define_method(event_method.getName) do |*args|
|
651
652
|
@event_method_block_mapping[event_method.getName]&.call(*args)
|
652
653
|
end
|
@@ -677,9 +678,9 @@ module Glimmer
|
|
677
678
|
},
|
678
679
|
'selection_count' => {
|
679
680
|
getter: {name: 'getSelectionCount'},
|
680
|
-
setter: {name: 'setSelection', invoker: lambda { |widget, args|
|
681
|
+
setter: {name: 'setSelection', invoker: lambda { |widget, args|
|
681
682
|
caret_position = @swt_widget.respond_to?(:getCaretPosition) ? @swt_widget.getCaretPosition : @swt_widget.getCaretOffset
|
682
|
-
@swt_widget.setSelection(caret_position, caret_position + args.first) if args.first
|
683
|
+
@swt_widget.setSelection(caret_position, caret_position + args.first) if args.first
|
683
684
|
}},
|
684
685
|
},
|
685
686
|
}
|
@@ -772,13 +773,13 @@ module Glimmer
|
|
772
773
|
sleep(delayTime)
|
773
774
|
end
|
774
775
|
};
|
775
|
-
image_proxy = nil
|
776
|
+
image_proxy = nil
|
776
777
|
else
|
777
778
|
on_swt_Resize do |resize_event|
|
778
779
|
image_proxy.scale_to(@swt_widget.getSize.x, @swt_widget.getSize.y)
|
779
|
-
@swt_widget.setBackgroundImage(image_proxy.swt_image)
|
780
|
-
end
|
781
|
-
end
|
780
|
+
@swt_widget.setBackgroundImage(image_proxy.swt_image)
|
781
|
+
end
|
782
|
+
end
|
782
783
|
|
783
784
|
image_proxy&.swt_image
|
784
785
|
end,
|