glimmer-dsl-swt 4.17.10.7 → 4.18.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +42 -0
- data/LICENSE.txt +1 -1
- data/README.md +508 -60
- data/RUBY_VERSION +1 -1
- data/VERSION +1 -1
- data/bin/girb +1 -1
- data/bin/girb_runner.rb +1 -1
- data/bin/glimmer +1 -1
- data/glimmer-dsl-swt.gemspec +58 -30
- data/lib/ext/glimmer.rb +1 -1
- data/lib/ext/glimmer/config.rb +7 -7
- data/lib/glimmer-dsl-swt.rb +3 -1
- data/lib/glimmer/Rakefile +1 -1
- data/lib/glimmer/data_binding/list_selection_binding.rb +1 -1
- data/lib/glimmer/data_binding/observable_widget.rb +1 -1
- data/lib/glimmer/data_binding/shine.rb +1 -1
- data/lib/glimmer/data_binding/table_items_binding.rb +1 -1
- data/lib/glimmer/data_binding/tree_items_binding.rb +1 -1
- data/lib/glimmer/data_binding/widget_binding.rb +1 -1
- data/lib/glimmer/dsl/swt/animation_expression.rb +43 -0
- data/lib/glimmer/dsl/swt/async_exec_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/bind_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/block_property_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/checkbox_group_selection_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/color_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/column_properties_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/cursor_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/custom_widget_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/dialog_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/directory_dialog_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/display_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/dnd_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/dsl.rb +5 -4
- data/lib/glimmer/dsl/swt/exec_expression.rb +5 -5
- data/lib/glimmer/dsl/swt/expand_item_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/file_dialog_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/font_expression.rb +8 -6
- data/lib/glimmer/dsl/swt/image_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/layout_data_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/layout_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/menu_bar_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/menu_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/message_box_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/observe_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/property_expression.rb +4 -4
- data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/rgb_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/rgba_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/shape_expression.rb +56 -0
- data/lib/glimmer/dsl/swt/shell_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/swt_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/sync_exec_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/tab_item_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/table_items_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/tree_properties_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/widget_expression.rb +7 -3
- data/lib/glimmer/dsl/swt/widget_listener_expression.rb +1 -1
- data/lib/glimmer/launcher.rb +1 -1
- data/lib/glimmer/rake_task.rb +1 -1
- data/lib/glimmer/rake_task/list.rb +1 -1
- data/lib/glimmer/rake_task/package.rb +1 -1
- data/lib/glimmer/rake_task/scaffold.rb +1 -1
- data/lib/glimmer/swt/color_proxy.rb +1 -1
- data/lib/glimmer/swt/cursor_proxy.rb +1 -1
- data/lib/glimmer/swt/custom/animation.rb +116 -0
- data/lib/glimmer/swt/custom/checkbox_group.rb +1 -1
- data/lib/glimmer/swt/custom/drawable.rb +43 -0
- data/lib/glimmer/swt/custom/radio_group.rb +1 -1
- data/lib/glimmer/swt/custom/shape.rb +135 -0
- data/lib/glimmer/swt/date_time_proxy.rb +1 -1
- data/lib/glimmer/swt/directory_dialog_proxy.rb +1 -1
- data/lib/glimmer/swt/display_proxy.rb +16 -1
- data/lib/glimmer/swt/dnd_proxy.rb +1 -1
- data/lib/glimmer/swt/expand_item_proxy.rb +1 -1
- data/lib/glimmer/swt/file_dialog_proxy.rb +1 -1
- data/lib/glimmer/swt/font_proxy.rb +4 -4
- data/lib/glimmer/swt/image_proxy.rb +12 -11
- data/lib/glimmer/swt/layout_data_proxy.rb +1 -1
- data/lib/glimmer/swt/layout_proxy.rb +8 -4
- data/lib/glimmer/swt/menu_proxy.rb +10 -5
- data/lib/glimmer/swt/message_box_proxy.rb +1 -1
- data/lib/glimmer/swt/packages.rb +1 -1
- data/lib/glimmer/swt/properties.rb +49 -0
- data/lib/glimmer/swt/sash_form_proxy.rb +2 -2
- data/lib/glimmer/swt/scrolled_composite_proxy.rb +1 -1
- data/lib/glimmer/swt/shell_proxy.rb +3 -2
- data/lib/glimmer/swt/style_constantizable.rb +9 -5
- data/lib/glimmer/swt/styled_text_proxy.rb +1 -1
- data/lib/glimmer/swt/swt_proxy.rb +1 -1
- data/lib/glimmer/swt/tab_item_proxy.rb +1 -1
- data/lib/glimmer/swt/table_column_proxy.rb +1 -1
- data/lib/glimmer/swt/table_proxy.rb +1 -1
- data/lib/glimmer/swt/tree_proxy.rb +26 -22
- data/lib/glimmer/swt/widget_listener_proxy.rb +1 -1
- data/lib/glimmer/swt/widget_proxy.rb +54 -28
- data/lib/glimmer/ui/custom_shell.rb +1 -1
- data/lib/glimmer/ui/custom_widget.rb +1 -1
- data/lib/glimmer/util/proc_tracker.rb +1 -1
- data/samples/elaborate/contact_manager.rb +1 -1
- data/samples/elaborate/contact_manager/contact.rb +1 -1
- data/samples/elaborate/contact_manager/contact_manager_presenter.rb +1 -1
- data/samples/elaborate/contact_manager/contact_repository.rb +1 -1
- data/samples/elaborate/login.rb +1 -1
- data/samples/elaborate/meta_sample.rb +80 -20
- data/samples/elaborate/tic_tac_toe.rb +2 -2
- data/samples/elaborate/tic_tac_toe/board.rb +1 -1
- data/samples/elaborate/tic_tac_toe/cell.rb +1 -1
- data/samples/elaborate/user_profile.rb +1 -1
- data/samples/hello/hello_browser.rb +3 -1
- data/samples/hello/hello_button.rb +1 -1
- data/samples/hello/hello_canvas.rb +62 -0
- data/samples/hello/hello_canvas_animation.rb +66 -0
- data/samples/hello/hello_checkbox.rb +1 -1
- data/samples/hello/hello_checkbox_group.rb +1 -1
- data/samples/hello/hello_combo.rb +1 -1
- data/samples/hello/hello_computed.rb +10 -4
- data/samples/hello/hello_computed/contact.rb +1 -1
- data/samples/hello/hello_custom_shell.rb +1 -1
- data/samples/hello/hello_custom_widget.rb +1 -1
- data/samples/hello/hello_date_time.rb +1 -1
- data/samples/hello/hello_dialog.rb +78 -0
- data/samples/hello/hello_directory_dialog.rb +1 -1
- data/samples/hello/hello_drag_and_drop.rb +1 -1
- data/samples/hello/hello_expand_bar.rb +1 -1
- data/samples/hello/hello_file_dialog.rb +1 -1
- data/samples/hello/hello_group.rb +1 -1
- data/samples/hello/hello_link.rb +1 -1
- data/samples/hello/hello_list_multi_selection.rb +1 -1
- data/samples/hello/hello_list_single_selection.rb +1 -1
- data/samples/hello/hello_menu_bar.rb +185 -29
- data/samples/hello/hello_message_box.rb +10 -9
- data/samples/hello/hello_pop_up_context_menu.rb +34 -7
- data/samples/hello/hello_radio.rb +1 -1
- data/samples/hello/hello_radio_group.rb +1 -1
- data/samples/hello/hello_sash_form.rb +1 -1
- data/samples/hello/hello_spinner.rb +1 -1
- data/samples/hello/hello_styled_text.rb +1 -1
- data/samples/hello/hello_tab.rb +1 -1
- data/samples/hello/hello_table.rb +1 -1
- data/samples/hello/hello_world.rb +1 -1
- data/vendor/swt/linux/swt.jar +0 -0
- data/vendor/swt/mac/swt.jar +0 -0
- data/vendor/swt/windows/swt.jar +0 -0
- metadata +54 -32
@@ -0,0 +1,43 @@
|
|
1
|
+
# Copyright (c) 2007-2021 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
|
+
module Glimmer
|
23
|
+
module SWT
|
24
|
+
module Custom
|
25
|
+
# Represents SWT drawable controls (widgets like canvas) and display
|
26
|
+
module Drawable
|
27
|
+
def shapes
|
28
|
+
@shapes ||= []
|
29
|
+
end
|
30
|
+
|
31
|
+
def clear_shapes
|
32
|
+
shapes.dup.each do |shape|
|
33
|
+
shape.paint_listener_proxy&.unregister
|
34
|
+
shapes.delete(shape)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
# Copyright (c) 2007-2021 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/properties'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module SWT
|
26
|
+
module Custom
|
27
|
+
# Represents a shape (graphics) to be drawn on a control/widget/canvas/display
|
28
|
+
# swt_widget returns the parent (e.g. a `canvas` WidgetProxy), equivalent to `parent.swt_widget`
|
29
|
+
# That is because Shape is drawn on a parent as graphics and doesn't have an SWT widget for itself
|
30
|
+
class Shape
|
31
|
+
include Properties
|
32
|
+
# TODO support textExtent as an option
|
33
|
+
# TODO support a Pattern DSL for methods that take Pattern arguments
|
34
|
+
|
35
|
+
class << self
|
36
|
+
def valid?(parent, keyword, *args, &block)
|
37
|
+
gc_instance_methods.include?(method_name(keyword, args))
|
38
|
+
end
|
39
|
+
|
40
|
+
def gc_instance_methods
|
41
|
+
org.eclipse.swt.graphics.GC.instance_methods.map(&:to_s)
|
42
|
+
end
|
43
|
+
|
44
|
+
def arg_options(args, extract: false)
|
45
|
+
arg_options_method = extract ? :pop : :last
|
46
|
+
options = args.send(arg_options_method) if args.last.is_a?(Hash)
|
47
|
+
options.nil? ? {} : options.symbolize_keys
|
48
|
+
end
|
49
|
+
|
50
|
+
def method_name(keyword, args)
|
51
|
+
gc_instance_method_name_prefix = arg_options(args)[:fill] ? 'fill_' : 'draw_'
|
52
|
+
"#{gc_instance_method_name_prefix}#{keyword}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
attr_reader :parent, :name, :args, :options, :swt_widget, :paint_listener_proxy
|
57
|
+
|
58
|
+
def initialize(parent, keyword, *args)
|
59
|
+
@parent = parent
|
60
|
+
@name = keyword
|
61
|
+
@method_name = self.class.method_name(keyword, args)
|
62
|
+
@options = self.class.arg_options(args, extract: true)
|
63
|
+
@args = args
|
64
|
+
@swt_widget = parent.respond_to?(:swt_display) ? parent.swt_display : parent.swt_widget
|
65
|
+
@properties = {}
|
66
|
+
@parent.shapes << self
|
67
|
+
end
|
68
|
+
|
69
|
+
def fill?
|
70
|
+
!draw?
|
71
|
+
end
|
72
|
+
|
73
|
+
def draw?
|
74
|
+
!@options[:fill]
|
75
|
+
end
|
76
|
+
|
77
|
+
def post_add_content
|
78
|
+
event_handler = lambda do |event|
|
79
|
+
@properties.each do |property, args|
|
80
|
+
method_name = attribute_setter(property)
|
81
|
+
handle_conversions(method_name, args)
|
82
|
+
event.gc.send(method_name, *args)
|
83
|
+
end
|
84
|
+
event.gc.send(@method_name, *@args)
|
85
|
+
end
|
86
|
+
if parent.respond_to?(:swt_display)
|
87
|
+
@paint_listener_proxy = @parent.on_swt_paint(&event_handler)
|
88
|
+
else
|
89
|
+
@paint_listener_proxy = @parent.on_paint_control(&event_handler)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def handle_conversions(method_name, args)
|
94
|
+
the_java_method = org.eclipse.swt.graphics.GC.java_class.declared_instance_methods.detect {|m| m.name == method_name}
|
95
|
+
if args.first.is_a?(Symbol) || args.first.is_a?(String)
|
96
|
+
if the_java_method.parameter_types.first == Color.java_class
|
97
|
+
args[0] = ColorProxy.new(args[0])
|
98
|
+
end
|
99
|
+
end
|
100
|
+
if args.first.is_a?(ColorProxy)
|
101
|
+
args[0] = args[0].swt_color
|
102
|
+
end
|
103
|
+
if args.first.is_a?(Hash)
|
104
|
+
if the_java_method.parameter_types.first == Font.java_class
|
105
|
+
args[0] = FontProxy.new(args[0])
|
106
|
+
end
|
107
|
+
end
|
108
|
+
if args.first.is_a?(FontProxy)
|
109
|
+
args[0] = args[0].swt_font
|
110
|
+
end
|
111
|
+
|
112
|
+
# TODO convert SWT style symbol to integer if method takes integer
|
113
|
+
end
|
114
|
+
|
115
|
+
def has_attribute?(attribute_name, *args)
|
116
|
+
# TODO test that attribute getter responds too
|
117
|
+
self.class.gc_instance_methods.include?(attribute_setter(attribute_name))
|
118
|
+
end
|
119
|
+
|
120
|
+
def set_attribute(attribute_name, *args)
|
121
|
+
# TODO special treatment for color symbols
|
122
|
+
@properties[attribute_name] = args
|
123
|
+
end
|
124
|
+
|
125
|
+
def get_attribute(attribute_name)
|
126
|
+
@properties.symbolize_keys[attribute_name.to_s.to_sym]
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2007-
|
1
|
+
# Copyright (c) 2007-2021 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
|
@@ -20,6 +20,7 @@
|
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
22
|
require 'glimmer/swt/widget_listener_proxy'
|
23
|
+
require 'glimmer/swt/custom/drawable'
|
23
24
|
|
24
25
|
module Glimmer
|
25
26
|
module SWT
|
@@ -36,6 +37,8 @@ module Glimmer
|
|
36
37
|
# Follows the Proxy Design Pattern
|
37
38
|
class DisplayProxy
|
38
39
|
include_package 'org.eclipse.swt.widgets'
|
40
|
+
|
41
|
+
include Custom::Drawable
|
39
42
|
|
40
43
|
OBSERVED_MENU_ITEMS = ['about', 'preferences']
|
41
44
|
|
@@ -60,6 +63,18 @@ module Glimmer
|
|
60
63
|
def content(&block)
|
61
64
|
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::DisplayExpression.new, &block)
|
62
65
|
end
|
66
|
+
|
67
|
+
def async_exec(&block)
|
68
|
+
@swt_display.async_exec(&block)
|
69
|
+
end
|
70
|
+
|
71
|
+
def sync_exec(&block)
|
72
|
+
@swt_display.sync_exec(&block)
|
73
|
+
end
|
74
|
+
|
75
|
+
def timer_exec(&block)
|
76
|
+
@swt_display.timer_exec(&block)
|
77
|
+
end
|
63
78
|
|
64
79
|
def method_missing(method, *args, &block)
|
65
80
|
if can_handle_observation_request?(method)
|
@@ -1,5 +1,5 @@
|
|
1
|
-
# Copyright (c) 2007-
|
2
|
-
#
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
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
|
@@ -1,5 +1,5 @@
|
|
1
|
-
# Copyright (c) 2007-
|
2
|
-
#
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
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
|
@@ -54,9 +54,9 @@ module Glimmer
|
|
54
54
|
@args = @args.first if @args.size == 1 && @args.first.is_a?(Array)
|
55
55
|
if options&.keys&.include?(:swt_image)
|
56
56
|
@swt_image = options[:swt_image]
|
57
|
-
@image_data = @swt_image.image_data
|
57
|
+
@original_image_data = @image_data = @swt_image.image_data
|
58
58
|
elsif @file_path
|
59
|
-
@image_data = ImageData.new(input_stream || @file_path)
|
59
|
+
@original_image_data = @image_data = ImageData.new(input_stream || @file_path)
|
60
60
|
@swt_image = Image.new(DisplayProxy.instance.swt_display, @image_data)
|
61
61
|
width = options[:width]
|
62
62
|
height = options[:height]
|
@@ -65,8 +65,8 @@ module Glimmer
|
|
65
65
|
scale_to(width, height) unless width.nil? || height.nil?
|
66
66
|
else
|
67
67
|
@swt_image = Image.new(*@args)
|
68
|
-
@image_data = @swt_image.image_data
|
69
|
-
end
|
68
|
+
@original_image_data = @image_data = @swt_image.image_data
|
69
|
+
end
|
70
70
|
end
|
71
71
|
|
72
72
|
def input_stream
|
@@ -77,12 +77,13 @@ module Glimmer
|
|
77
77
|
file_input_stream = object.java_class.resource_as_stream(file_path)
|
78
78
|
else
|
79
79
|
file_input_stream = java.io.FileInputStream.new(@file_path)
|
80
|
-
end
|
80
|
+
end
|
81
81
|
java.io.BufferedInputStream.new(file_input_stream) if file_input_stream
|
82
82
|
end
|
83
83
|
|
84
84
|
def scale_to(width, height)
|
85
|
-
|
85
|
+
return if @image_data.width == width && @image_data.height == height
|
86
|
+
scaled_image_data = @original_image_data.scaledTo(width, height)
|
86
87
|
device = swt_image.device
|
87
88
|
swt_image.dispose
|
88
89
|
@swt_image = Image.new(device, scaled_image_data)
|
@@ -99,7 +100,7 @@ module Glimmer
|
|
99
100
|
|
100
101
|
def respond_to?(method, *args, &block)
|
101
102
|
super || swt_image.respond_to?(method, *args, &block)
|
102
|
-
end
|
103
|
+
end
|
103
104
|
end
|
104
105
|
end
|
105
106
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
# Copyright (c) 2007-
|
2
|
-
#
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
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
|
@@ -68,6 +68,10 @@ module Glimmer
|
|
68
68
|
@swt_layout = self.class.swt_layout_class_for(underscored_layout_name).new(*args)
|
69
69
|
@swt_layout.marginWidth = 15 if @swt_layout.respond_to?(:marginWidth)
|
70
70
|
@swt_layout.marginHeight = 15 if @swt_layout.respond_to?(:marginHeight)
|
71
|
+
@swt_layout.marginTop = 0 if @swt_layout.respond_to?(:marginTop)
|
72
|
+
@swt_layout.marginRight = 0 if @swt_layout.respond_to?(:marginRight)
|
73
|
+
@swt_layout.marginBottom = 0 if @swt_layout.respond_to?(:marginBottom)
|
74
|
+
@swt_layout.marginLeft = 0 if @swt_layout.respond_to?(:marginLeft)
|
71
75
|
@widget_proxy.swt_widget.setLayout(@swt_layout)
|
72
76
|
end
|
73
77
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2007-
|
1
|
+
# Copyright (c) 2007-2021 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
|
@@ -75,7 +75,7 @@ module Glimmer
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def has_attribute?(attribute_name, *args)
|
78
|
-
if attribute_name.to_s
|
78
|
+
if ['text', 'enabled'].include?(attribute_name.to_s)
|
79
79
|
true
|
80
80
|
else
|
81
81
|
super(attribute_name, *args)
|
@@ -83,24 +83,29 @@ module Glimmer
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def set_attribute(attribute_name, *args)
|
86
|
-
attribute_name
|
87
|
-
if attribute_name.to_s == "text"
|
86
|
+
if normalized_attribute(attribute_name) == 'text'
|
88
87
|
text_value = args[0]
|
89
88
|
@swt_menu_item.setText text_value
|
89
|
+
elsif normalized_attribute(attribute_name) == 'enabled'
|
90
|
+
value = args[0]
|
91
|
+
@swt_menu_item.setEnabled value
|
90
92
|
else
|
91
93
|
super(attribute_name, *args)
|
92
94
|
end
|
93
95
|
end
|
94
96
|
|
95
97
|
def get_attribute(attribute_name)
|
96
|
-
if attribute_name
|
98
|
+
if normalized_attribute(attribute_name) == 'text'
|
97
99
|
@swt_menu_item.getText
|
100
|
+
elsif normalized_attribute(attribute_name) == 'enabled'
|
101
|
+
@swt_menu_item.getEnabled
|
98
102
|
else
|
99
103
|
super(attribute_name)
|
100
104
|
end
|
101
105
|
end
|
102
106
|
|
103
107
|
def can_handle_observation_request?(observation_request, super_only: false)
|
108
|
+
observation_request = observation_request.to_s
|
104
109
|
super_result = super(observation_request)
|
105
110
|
if observation_request.start_with?('on_') && !super_result && !super_only
|
106
111
|
return menu_item_proxy.can_handle_observation_request?(observation_request)
|