glimmer-dsl-swt 4.18.4.11 → 4.18.5.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 +33 -0
- data/README.md +7 -5
- data/VERSION +1 -1
- data/bin/glimmer +3 -3
- data/docs/reference/GLIMMER_CONFIGURATION.md +7 -3
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +121 -5
- data/docs/reference/GLIMMER_SAMPLES.md +17 -4
- data/glimmer-dsl-swt.gemspec +19 -9
- data/lib/ext/glimmer/config.rb +3 -7
- data/lib/glimmer/data_binding/list_selection_binding.rb +13 -7
- data/lib/glimmer/data_binding/table_items_binding.rb +22 -17
- data/lib/glimmer/data_binding/tree_items_binding.rb +19 -15
- data/lib/glimmer/data_binding/widget_binding.rb +9 -27
- data/lib/glimmer/dsl/swt/auto_exec_expression.rb +36 -0
- data/lib/glimmer/dsl/swt/checkbox_group_selection_data_binding_expression.rb +9 -6
- data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +16 -14
- data/lib/glimmer/dsl/swt/data_binding_expression.rb +1 -2
- data/lib/glimmer/dsl/swt/exec_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/image_expression.rb +8 -1
- data/lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb +11 -8
- data/lib/glimmer/dsl/swt/pixel_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +8 -5
- data/lib/glimmer/dsl/swt/shape_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/widget_expression.rb +4 -3
- data/lib/glimmer/launcher.rb +3 -0
- data/lib/glimmer/rake_task/scaffold.rb +3 -0
- data/lib/glimmer/swt/custom/code_text.rb +11 -11
- data/lib/glimmer/swt/custom/drawable.rb +4 -0
- data/lib/glimmer/swt/custom/shape.rb +129 -20
- data/lib/glimmer/swt/custom/shape/arc.rb +43 -0
- data/lib/glimmer/swt/custom/shape/focus.rb +43 -0
- data/lib/glimmer/swt/custom/shape/image.rb +86 -0
- data/lib/glimmer/swt/custom/shape/line.rb +58 -0
- data/lib/glimmer/swt/custom/shape/oval.rb +43 -0
- data/lib/glimmer/swt/custom/shape/point.rb +52 -0
- data/lib/glimmer/swt/custom/shape/polygon.rb +73 -0
- data/lib/glimmer/swt/custom/shape/polyline.rb +73 -0
- data/lib/glimmer/swt/custom/shape/rectangle.rb +87 -0
- data/lib/glimmer/swt/custom/shape/text.rb +73 -0
- data/lib/glimmer/swt/date_time_proxy.rb +9 -3
- data/lib/glimmer/swt/directory_dialog_proxy.rb +20 -18
- data/lib/glimmer/swt/display_proxy.rb +62 -2
- data/lib/glimmer/swt/expand_item_proxy.rb +18 -12
- data/lib/glimmer/swt/file_dialog_proxy.rb +20 -18
- data/lib/glimmer/swt/font_proxy.rb +1 -1
- data/lib/glimmer/swt/image_proxy.rb +1 -1
- data/lib/glimmer/swt/layout_data_proxy.rb +21 -15
- data/lib/glimmer/swt/layout_proxy.rb +19 -15
- data/lib/glimmer/swt/menu_proxy.rb +2 -2
- data/lib/glimmer/swt/message_box_proxy.rb +20 -7
- data/lib/glimmer/swt/scrolled_composite_proxy.rb +6 -2
- data/lib/glimmer/swt/shell_proxy.rb +94 -80
- data/lib/glimmer/swt/swt_proxy.rb +16 -0
- data/lib/glimmer/swt/tab_item_proxy.rb +5 -3
- data/lib/glimmer/swt/table_proxy.rb +32 -11
- data/lib/glimmer/swt/tree_proxy.rb +11 -16
- data/lib/glimmer/swt/widget_listener_proxy.rb +6 -2
- data/lib/glimmer/swt/widget_proxy.rb +200 -117
- data/lib/glimmer/ui.rb +5 -0
- data/lib/glimmer/ui/custom_shell.rb +11 -5
- data/lib/glimmer/ui/custom_widget.rb +4 -5
- data/samples/elaborate/contact_manager.rb +7 -7
- data/samples/elaborate/login.rb +25 -21
- data/samples/elaborate/mandelbrot_fractal.rb +3 -5
- data/samples/elaborate/tetris.rb +1 -0
- data/samples/elaborate/tic_tac_toe.rb +16 -14
- data/samples/elaborate/tic_tac_toe/board.rb +5 -5
- data/samples/elaborate/tic_tac_toe/cell.rb +5 -5
- data/samples/hello/hello_button.rb +7 -7
- data/samples/hello/hello_canvas.rb +43 -2
- data/samples/hello/hello_checkbox.rb +16 -14
- data/samples/hello/hello_checkbox_group.rb +11 -9
- data/samples/hello/hello_combo.rb +14 -12
- data/samples/hello/hello_computed.rb +7 -7
- data/samples/hello/hello_cursor.rb +2 -1
- data/samples/hello/hello_custom_shell.rb +17 -21
- data/samples/hello/hello_custom_widget.rb +4 -6
- data/samples/hello/hello_date_time.rb +14 -12
- data/samples/hello/hello_directory_dialog.rb +7 -7
- data/samples/hello/hello_expand_bar.rb +8 -8
- data/samples/hello/hello_file_dialog.rb +7 -7
- data/samples/hello/hello_group.rb +18 -16
- data/samples/hello/hello_list_multi_selection.rb +13 -11
- data/samples/hello/hello_list_single_selection.rb +13 -11
- data/samples/hello/hello_progress_bar.rb +3 -7
- data/samples/hello/hello_radio.rb +18 -16
- data/samples/hello/hello_radio_group.rb +14 -12
- data/samples/hello/hello_spinner.rb +7 -7
- data/samples/hello/hello_tab.rb +5 -5
- data/samples/hello/hello_table.rb +10 -5
- data/samples/hello/hello_tree.rb +485 -0
- metadata +17 -18
@@ -0,0 +1,73 @@
|
|
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/custom/shape'
|
23
|
+
require 'glimmer/swt/swt_proxy'
|
24
|
+
require 'glimmer/swt/display_proxy'
|
25
|
+
require 'glimmer/swt/color_proxy'
|
26
|
+
require 'glimmer/swt/font_proxy'
|
27
|
+
require 'glimmer/swt/transform_proxy'
|
28
|
+
|
29
|
+
module Glimmer
|
30
|
+
module SWT
|
31
|
+
module Custom
|
32
|
+
# Represents a shape (graphics) to be drawn on a control/widget/canvas/display
|
33
|
+
# That is because Shape is drawn on a parent as graphics and doesn't have an SWT widget for itself
|
34
|
+
class Shape
|
35
|
+
class Text < Shape
|
36
|
+
def parameter_names
|
37
|
+
@parameter_names || text_parameter_names
|
38
|
+
end
|
39
|
+
|
40
|
+
def possible_parameter_names
|
41
|
+
# TODO refactor and improve this method through meta-programming (and share across other shapes)
|
42
|
+
(text_parameter_names + text_transparent_parameter_names + text_flags_parameter_names).uniq
|
43
|
+
end
|
44
|
+
|
45
|
+
def text_parameter_names
|
46
|
+
[:text, :x, :y]
|
47
|
+
end
|
48
|
+
|
49
|
+
def text_transparent_parameter_names
|
50
|
+
[:text, :x, :y, :is_transparent]
|
51
|
+
end
|
52
|
+
|
53
|
+
def text_flags_parameter_names
|
54
|
+
[:text, :x, :y, :flags]
|
55
|
+
end
|
56
|
+
|
57
|
+
def set_parameter_attribute(attribute_name, *args)
|
58
|
+
return super if @parameter_names.to_a.map(&:to_s).include?(attribute_name.to_s)
|
59
|
+
if text_parameter_names.map(&:to_s).include?(attribute_name.to_s)
|
60
|
+
@parameter_names = text_parameter_names
|
61
|
+
elsif text_transparent_parameter_names.map(&:to_s).include?(attribute_name.to_s)
|
62
|
+
@parameter_names = text_transparent_parameter_names
|
63
|
+
elsif text_flags_parameter_names.map(&:to_s).include?(attribute_name.to_s)
|
64
|
+
@parameter_names = text_flags_parameter_names
|
65
|
+
end
|
66
|
+
super
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -43,7 +43,9 @@ module Glimmer
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def date=(date_value)
|
46
|
-
|
46
|
+
auto_exec do
|
47
|
+
swt_widget.setDate(date_value.year, date_value.month - 1, date_value.day)
|
48
|
+
end
|
47
49
|
end
|
48
50
|
|
49
51
|
def time
|
@@ -58,11 +60,15 @@ module Glimmer
|
|
58
60
|
end
|
59
61
|
|
60
62
|
def month
|
61
|
-
|
63
|
+
auto_exec do
|
64
|
+
swt_widget.month + 1
|
65
|
+
end
|
62
66
|
end
|
63
67
|
|
64
68
|
def month=(new_value)
|
65
|
-
|
69
|
+
auto_exec do
|
70
|
+
swt_widget.month = new_value - 1
|
71
|
+
end
|
66
72
|
end
|
67
73
|
|
68
74
|
def set_attribute(attribute_name, *args)
|
@@ -38,25 +38,27 @@ module Glimmer
|
|
38
38
|
include_package 'org.eclipse.swt.widgets'
|
39
39
|
|
40
40
|
def initialize(*args, swt_widget: nil)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
auto_exec do
|
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.respond_to?(:swt_widget) && args.first.swt_widget.is_a?(Shell)
|
52
|
+
args[0] = args[0].swt_widget
|
53
|
+
end
|
54
|
+
if !args.first.is_a?(Shell)
|
55
|
+
current_shell = DisplayProxy.instance.swt_display.shells.first
|
56
|
+
args.unshift(current_shell.nil? ? ShellProxy.new : current_shell)
|
57
|
+
end
|
58
|
+
parent = args[0]
|
59
|
+
@parent_proxy = parent.is_a?(Shell) ? ShellProxy.new(swt_widget: parent) : parent
|
60
|
+
@swt_widget = DirectoryDialog.new(*args)
|
49
61
|
end
|
50
|
-
if args.first.respond_to?(:swt_widget) && args.first.swt_widget.is_a?(Shell)
|
51
|
-
args[0] = args[0].swt_widget
|
52
|
-
end
|
53
|
-
if !args.first.is_a?(Shell)
|
54
|
-
current_shell = DisplayProxy.instance.swt_display.shells.first
|
55
|
-
args.unshift(current_shell.nil? ? ShellProxy.new : current_shell)
|
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
62
|
end
|
61
63
|
end
|
62
64
|
|
@@ -58,10 +58,16 @@ module Glimmer
|
|
58
58
|
# Returns singleton instance
|
59
59
|
def instance(*args)
|
60
60
|
if @instance.nil? || @instance.swt_display.nil? || @instance.swt_display.isDisposed
|
61
|
+
@thread = Thread.current
|
61
62
|
@instance = new(*args)
|
62
63
|
end
|
63
64
|
@instance
|
64
65
|
end
|
66
|
+
|
67
|
+
def thread
|
68
|
+
instance # ensure instance
|
69
|
+
@thread
|
70
|
+
end
|
65
71
|
end
|
66
72
|
|
67
73
|
# SWT Display object wrapped
|
@@ -71,6 +77,7 @@ module Glimmer
|
|
71
77
|
Display.app_name ||= 'Glimmer'
|
72
78
|
@swt_display = Display.new(*args)
|
73
79
|
@swt_display.set_data('proxy', self)
|
80
|
+
@execs_in_progress = {}
|
74
81
|
on_swt_Dispose {
|
75
82
|
clear_shapes
|
76
83
|
}
|
@@ -80,18 +87,71 @@ module Glimmer
|
|
80
87
|
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::DisplayExpression.new, &block)
|
81
88
|
end
|
82
89
|
|
90
|
+
# asynchronously executes the block (required from threads other than first GUI thread)
|
91
|
+
# does not return the value produced by the block since it is async, running after the return
|
83
92
|
def async_exec(&block)
|
84
|
-
@swt_display.asyncExec
|
93
|
+
@swt_display.asyncExec do
|
94
|
+
execs_in_progress << :async_exec
|
95
|
+
begin
|
96
|
+
result = block.call
|
97
|
+
ensure
|
98
|
+
execs_in_progress.pop
|
99
|
+
end
|
100
|
+
end
|
85
101
|
end
|
86
102
|
|
103
|
+
# synchronously executes the block (required from threads other than first GUI thread)
|
104
|
+
# returns the value produced by the block
|
87
105
|
def sync_exec(&block)
|
88
|
-
|
106
|
+
result = nil
|
107
|
+
@swt_display.syncExec do
|
108
|
+
execs_in_progress << :sync_exec
|
109
|
+
begin
|
110
|
+
result = block.call
|
111
|
+
ensure
|
112
|
+
execs_in_progress.pop
|
113
|
+
end
|
114
|
+
end
|
115
|
+
result
|
89
116
|
end
|
90
117
|
|
91
118
|
def timer_exec(delay_in_millis, &block)
|
92
119
|
@swt_display.timerExec(delay_in_millis, &block)
|
93
120
|
end
|
94
121
|
|
122
|
+
# Indicates whether `sync_exec` is required because of running in a different thread from the GUI thread
|
123
|
+
# `async_exec` could be used as an alternative to `sync_exec` when required.
|
124
|
+
def sync_exec_required?
|
125
|
+
Thread.current != DisplayProxy.thread
|
126
|
+
end
|
127
|
+
|
128
|
+
def async_exec_in_progress?
|
129
|
+
execs_in_progress.last == :async_exec
|
130
|
+
end
|
131
|
+
|
132
|
+
def sync_exec_in_progress?
|
133
|
+
execs_in_progress.include?(:sync_exec)
|
134
|
+
end
|
135
|
+
|
136
|
+
def execs_in_progress
|
137
|
+
@execs_in_progress[Thread.current] ||= []
|
138
|
+
end
|
139
|
+
|
140
|
+
# Invoke block with `sync_exec` only when necessary (running from a separate thread)
|
141
|
+
# Override sync_exec as `true` to force using or `false` to force avoiding
|
142
|
+
# Override async_exec as `true` to force using or `:unless_in_progress` to force using only if no `async_exec` is in progress
|
143
|
+
# Disable auto execution of `sync_exec` via `Glimmer::Config.auto_sync_exec = false`
|
144
|
+
# Otherwise, runs normally, thus allowing SWT to decide how to batch/optimize GUI updates
|
145
|
+
def auto_exec(override_sync_exec: nil, override_async_exec: nil, &block)
|
146
|
+
if override_sync_exec || override_sync_exec.nil? && !override_async_exec && sync_exec_required? && Config.auto_sync_exec? && !sync_exec_in_progress? && !async_exec_in_progress?
|
147
|
+
sync_exec(&block)
|
148
|
+
elsif override_async_exec || override_async_exec.to_s == 'unless_in_progress' && !async_exec_in_progress?
|
149
|
+
async_exec(&block)
|
150
|
+
else
|
151
|
+
block.call
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
95
155
|
def on_widget_disposed(&block)
|
96
156
|
on_swt_Dispose(&block)
|
97
157
|
end
|
@@ -1,5 +1,5 @@
|
|
1
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
|
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
|
@@ -52,15 +52,19 @@ module Glimmer
|
|
52
52
|
layout.marginWidth = 0
|
53
53
|
layout.marginHeight = 0
|
54
54
|
layout.spacing = 0
|
55
|
-
swt_widget.layout = layout
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
55
|
+
swt_widget.layout = layout
|
56
|
+
auto_exec do
|
57
|
+
@widget_proxy = SWT::WidgetProxy.new('expand_item', parent, style)
|
58
|
+
@swt_expand_item = @widget_proxy.swt_widget
|
59
|
+
@swt_expand_item.control = swt_widget
|
60
|
+
@swt_expand_item.expanded = true
|
61
|
+
end
|
60
62
|
end
|
61
63
|
|
62
64
|
def post_add_content
|
63
|
-
|
65
|
+
auto_exec do
|
66
|
+
@swt_expand_item.setHeight(swt_widget.computeSize(SWTProxy[:default], SWTProxy[:default]).y) unless @swt_expand_item.getHeight > 0
|
67
|
+
end
|
64
68
|
end
|
65
69
|
|
66
70
|
def has_attribute?(attribute_name, *args)
|
@@ -88,9 +92,11 @@ module Glimmer
|
|
88
92
|
end
|
89
93
|
|
90
94
|
def dispose
|
91
|
-
|
92
|
-
|
93
|
-
|
95
|
+
auto_exec do
|
96
|
+
swt_expand_item.setControl(nil)
|
97
|
+
swt_widget.dispose
|
98
|
+
swt_expand_item.dispose
|
99
|
+
end
|
94
100
|
end
|
95
101
|
end
|
96
102
|
end
|
@@ -39,25 +39,27 @@ module Glimmer
|
|
39
39
|
include_package 'org.eclipse.swt.widgets'
|
40
40
|
|
41
41
|
def initialize(*args, swt_widget: nil)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
42
|
+
auto_exec do
|
43
|
+
if swt_widget
|
44
|
+
@swt_widget = swt_widget
|
45
|
+
else
|
46
|
+
style_args = args.select {|arg| arg.is_a?(Symbol) || arg.is_a?(String)}
|
47
|
+
if style_args.any?
|
48
|
+
style_arg_start_index = args.index(style_args.first)
|
49
|
+
style_arg_last_index = args.index(style_args.last)
|
50
|
+
args[style_arg_start_index..style_arg_last_index] = SWTProxy[style_args]
|
51
|
+
end
|
52
|
+
if args.first.respond_to?(:swt_widget) && args.first.swt_widget.is_a?(Shell)
|
53
|
+
args[0] = args[0].swt_widget
|
54
|
+
end
|
55
|
+
if !args.first.is_a?(Shell)
|
56
|
+
current_shell = DisplayProxy.instance.swt_display.shells.first
|
57
|
+
args.unshift(current_shell.nil? ? ShellProxy.new : current_shell)
|
58
|
+
end
|
59
|
+
parent = args[0]
|
60
|
+
@parent_proxy = parent.is_a?(Shell) ? ShellProxy.new(swt_widget: parent) : parent
|
61
|
+
@swt_widget = FileDialog.new(*args)
|
50
62
|
end
|
51
|
-
if args.first.respond_to?(:swt_widget) && args.first.swt_widget.is_a?(Shell)
|
52
|
-
args[0] = args[0].swt_widget
|
53
|
-
end
|
54
|
-
if !args.first.is_a?(Shell)
|
55
|
-
current_shell = DisplayProxy.instance.swt_display.shells.first
|
56
|
-
args.unshift(current_shell.nil? ? ShellProxy.new : current_shell)
|
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
63
|
end
|
62
64
|
end
|
63
65
|
|
@@ -79,7 +79,7 @@ module Glimmer
|
|
79
79
|
private
|
80
80
|
|
81
81
|
def font_datum
|
82
|
-
@font_datum ||= @widget_proxy ? @widget_proxy.swt_widget.getFont.getFontData[0] : FontData.new
|
82
|
+
@font_datum ||= DisplayProxy.instance.auto_exec { @widget_proxy ? @widget_proxy.swt_widget.getFont.getFontData[0] : FontData.new }
|
83
83
|
end
|
84
84
|
|
85
85
|
def detect_invalid_font_property(font_properties)
|
@@ -132,7 +132,7 @@ module Glimmer
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def scale_to(width, height)
|
135
|
-
return if @image_data.width == width && @image_data.height == height
|
135
|
+
return self if @image_data.width == width && @image_data.height == height
|
136
136
|
scaled_image_data = @original_image_data.scaledTo(width, height)
|
137
137
|
device = swt_image.device
|
138
138
|
swt_image.dispose
|
@@ -47,15 +47,17 @@ module Glimmer
|
|
47
47
|
|
48
48
|
# Inititalizes with owning widget proxy and layout data arguments
|
49
49
|
def initialize(widget_proxy, args)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
50
|
+
DisplayProxy.instance.auto_exec do
|
51
|
+
@widget_proxy = widget_proxy
|
52
|
+
args = SWTProxy.constantify_args(args)
|
53
|
+
begin
|
54
|
+
@swt_layout_data = swt_layout_data_class.new(*args)
|
55
|
+
rescue => e
|
56
|
+
Glimmer::Config.logger.debug {"#{e.message}\n#{e.backtrace.join("\n")}"}
|
57
|
+
@swt_layout_data = args.first if args.count == 1
|
58
|
+
end
|
59
|
+
@widget_proxy.swt_widget.setLayoutData(@swt_layout_data)
|
57
60
|
end
|
58
|
-
@widget_proxy.swt_widget.setLayoutData(@swt_layout_data)
|
59
61
|
end
|
60
62
|
|
61
63
|
# This figures out the right SWT layout data class name
|
@@ -72,9 +74,11 @@ module Glimmer
|
|
72
74
|
# - org.eclipse.swt.layout.GridData for org.eclipse.swt.layout.GridLayout
|
73
75
|
#
|
74
76
|
def swt_layout_data_class
|
75
|
-
|
76
|
-
|
77
|
-
|
77
|
+
DisplayProxy.instance.auto_exec do
|
78
|
+
parent_layout_class_name = @widget_proxy.swt_widget.getParent.getLayout.class.name
|
79
|
+
layout_data_class_name = parent_layout_class_name.sub(/Layout$/, 'Data')
|
80
|
+
eval(layout_data_class_name)
|
81
|
+
end
|
78
82
|
end
|
79
83
|
|
80
84
|
def has_attribute?(attribute_name, *args)
|
@@ -82,10 +86,12 @@ module Glimmer
|
|
82
86
|
end
|
83
87
|
|
84
88
|
def set_attribute(attribute_name, *args)
|
85
|
-
|
86
|
-
|
87
|
-
@swt_layout_data.send(
|
88
|
-
|
89
|
+
DisplayProxy.instance.auto_exec do
|
90
|
+
args = SWTProxy.constantify_args(args)
|
91
|
+
if args.first != @swt_layout_data.send(attribute_getter(attribute_name))
|
92
|
+
@swt_layout_data.send(attribute_setter(attribute_name), *args)
|
93
|
+
@widget_proxy.swt_widget.getShell.pack
|
94
|
+
end
|
89
95
|
end
|
90
96
|
end
|
91
97
|
|
@@ -62,19 +62,21 @@ module Glimmer
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def initialize(underscored_layout_name, widget_proxy, args)
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
65
|
+
DisplayProxy.instance.auto_exec do
|
66
|
+
@underscored_layout_name = underscored_layout_name
|
67
|
+
@widget_proxy = widget_proxy
|
68
|
+
args = SWTProxy.constantify_args(args)
|
69
|
+
@swt_layout = self.class.swt_layout_class_for(underscored_layout_name).new(*args)
|
70
|
+
@swt_layout.marginWidth = 15 if @swt_layout.respond_to?(:marginWidth)
|
71
|
+
@swt_layout.marginHeight = 15 if @swt_layout.respond_to?(:marginHeight)
|
72
|
+
@swt_layout.marginTop = 0 if @swt_layout.respond_to?(:marginTop)
|
73
|
+
@swt_layout.marginRight = 0 if @swt_layout.respond_to?(:marginRight)
|
74
|
+
@swt_layout.marginBottom = 0 if @swt_layout.respond_to?(:marginBottom)
|
75
|
+
@swt_layout.marginLeft = 0 if @swt_layout.respond_to?(:marginLeft)
|
76
|
+
old_layout = @widget_proxy.swt_widget.getLayout
|
77
|
+
@widget_proxy.swt_widget.setLayout(@swt_layout)
|
78
|
+
@widget_proxy.swt_widget.layout if old_layout
|
79
|
+
end
|
78
80
|
end
|
79
81
|
|
80
82
|
def has_attribute?(attribute_name, *args)
|
@@ -82,11 +84,13 @@ module Glimmer
|
|
82
84
|
end
|
83
85
|
|
84
86
|
def set_attribute(attribute_name, *args)
|
85
|
-
|
86
|
-
|
87
|
+
DisplayProxy.instance.auto_exec do
|
88
|
+
apply_property_type_converters(attribute_name, args)
|
89
|
+
if args.first != @swt_layout.send(attribute_getter(attribute_name))
|
87
90
|
@swt_layout.send(attribute_setter(attribute_name), *args)
|
88
91
|
@widget_proxy.swt_widget.layout
|
89
92
|
@widget_proxy.swt_widget.getShell.layout
|
93
|
+
end
|
90
94
|
end
|
91
95
|
end
|
92
96
|
|