glimmer-dsl-swt 0.3.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,7 +31,7 @@ module Glimmer
31
31
  begin
32
32
  @swt_layout_data = swt_layout_data_class.new(*args)
33
33
  rescue => e
34
- Glimmer::Config.logger&.debug "#{e.message}\n#{e.backtrace.join("\n")}"
34
+ Glimmer::Config.logger.debug {"#{e.message}\n#{e.backtrace.join("\n")}"}
35
35
  @swt_layout_data = args.first if args.count == 1
36
36
  end
37
37
  @widget_proxy.swt_widget.setLayoutData(@swt_layout_data)
@@ -34,8 +34,8 @@ module Glimmer
34
34
  end
35
35
  swt_layout_class
36
36
  rescue => e
37
- Glimmer::Config.logger&.debug e.message
38
- # Glimmer::Config.logger&.debug "#{e.message}\n#{e.backtrace.join("\n")}"
37
+ Glimmer::Config.logger.debug {e.message}
38
+ # Glimmer::Config.logger.debug {"#{e.message}\n#{e.backtrace.join("\n")}"}
39
39
  raise e
40
40
  end
41
41
  end
@@ -15,11 +15,13 @@ module Glimmer
15
15
 
16
16
  def initialize(parent, style)
17
17
  parent = parent.swt_widget if parent.respond_to?(:swt_widget) && parent.swt_widget.is_a?(Shell)
18
+ @temporary_parent = parent = Glimmer::SWT::ShellProxy.new.swt_widget if parent.nil?
18
19
  @swt_widget = MessageBox.new(parent, style)
19
20
  end
20
21
 
21
22
  def open
22
23
  @swt_widget.open
24
+ @temporary_parent&.dispose
23
25
  end
24
26
 
25
27
  # TODO refactor the following methods to put in a JavaBean mixin or somethin (perhaps contribute to OSS project too)
@@ -40,9 +40,10 @@ module Glimmer
40
40
  end
41
41
  args = args.compact
42
42
  @swt_widget = Shell.new(*args)
43
+ @swt_widget.set_data('proxy', self)
43
44
  @swt_widget.setLayout(FillLayout.new)
44
45
  @swt_widget.setMinimumSize(WIDTH_MIN, HEIGHT_MIN)
45
- on_event_show do
46
+ on_swt_show do
46
47
  Thread.new do
47
48
  sleep(0.25)
48
49
  async_exec do
@@ -83,10 +84,6 @@ module Glimmer
83
84
  @swt_widget.setVisible(false)
84
85
  end
85
86
 
86
- def close
87
- @swt_widget.close
88
- end
89
-
90
87
  def visible?
91
88
  @swt_widget.isDisposed ? false : @swt_widget.isVisible
92
89
  end
@@ -130,7 +127,11 @@ module Glimmer
130
127
  # This method is not needed except in rare circumstances where there is a need to start the SWT Event Loop before opening the shell.
131
128
  def start_event_loop
132
129
  until @swt_widget.isDisposed
133
- @display.sleep unless @display.readAndDispatch
130
+ begin
131
+ @display.sleep unless @display.readAndDispatch
132
+ rescue => e
133
+ Glimmer::Config.logger.debug {e.full_message}
134
+ end
134
135
  end
135
136
  end
136
137
 
@@ -140,9 +141,9 @@ module Glimmer
140
141
  visibility_notifier = proc do
141
142
  observer.call(visible?)
142
143
  end
143
- on_event_show(&visibility_notifier)
144
- on_event_hide(&visibility_notifier)
145
- on_event_close(&visibility_notifier)
144
+ on_swt_show(&visibility_notifier)
145
+ on_swt_hide(&visibility_notifier)
146
+ on_swt_close(&visibility_notifier)
146
147
  else
147
148
  super
148
149
  end
@@ -61,12 +61,12 @@ module Glimmer
61
61
  negative ? ~bit_value : bit_value
62
62
  rescue => e
63
63
  begin
64
- # Glimmer::Config.logger&.debug(e.full_message)
64
+ # Glimmer::Config.logger.debug {e.full_message}
65
65
  alternative_swt_constant_symbol = constant_source_class.constants.find {|c| c.to_s.upcase == swt_constant_symbol.to_s.upcase}
66
66
  bit_value = constant_source_class.const_get(alternative_swt_constant_symbol)
67
67
  negative ? ~bit_value : bit_value
68
68
  rescue => e
69
- # Glimmer::Config.logger&.debug(e.full_message)
69
+ # Glimmer::Config.logger.debug {e.full_message}
70
70
  bit_value = extra_styles[swt_constant_symbol]
71
71
  if bit_value
72
72
  negative ? ~bit_value : bit_value
@@ -3,7 +3,7 @@ require 'glimmer/swt/widget_proxy'
3
3
  module Glimmer
4
4
  module SWT
5
5
  class TableColumnProxy < Glimmer::SWT::WidgetProxy
6
- attr_reader :no_sort, :sort_property
6
+ attr_reader :no_sort, :sort_property, :editor
7
7
  alias no_sort? no_sort
8
8
  attr_accessor :sort_block, :sort_by_block
9
9
 
@@ -19,6 +19,10 @@ module Glimmer
19
19
  @sort_property = args unless args.empty?
20
20
  end
21
21
 
22
+ def editor=(args)
23
+ @editor = args
24
+ end
25
+
22
26
  end
23
27
  end
24
28
  end
@@ -1,4 +1,4 @@
1
- require 'glimmer/swt/widget_proxy'
1
+ require 'glimmer/swt/widget_proxy'
2
2
 
3
3
  module Glimmer
4
4
  module SWT
@@ -23,8 +23,8 @@ module Glimmer
23
23
  def find_table_item_and_column_index
24
24
  {}.tap do |result|
25
25
  if respond_to?(:x) && respond_to?(:y)
26
- result[:table_item] = widget.getItems.detect do |ti|
27
- result[:column_index] = widget.getColumnCount.times.to_a.detect do |ci|
26
+ result[:table_item] = widget.items.detect do |ti|
27
+ result[:column_index] = widget.column_count.times.to_a.detect do |ci|
28
28
  ti.getBounds(ci).contains(x, y)
29
29
  end
30
30
  end
@@ -33,7 +33,61 @@ module Glimmer
33
33
  end
34
34
  end
35
35
 
36
- attr_reader :table_editor, :table_editor_text_proxy, :sort_property, :sort_direction, :sort_block, :sort_type, :sort_by_block, :additional_sort_properties
36
+ class << self
37
+ def editors
38
+ @editors ||= {
39
+ text: {
40
+ widget_value_property: :text,
41
+ editor_gui: lambda do |args, model, property, table_proxy|
42
+ table_proxy.table_editor.minimumHeight = 20
43
+ table_editor_widget_proxy = text(*args) {
44
+ text model.send(property)
45
+ focus true
46
+ on_focus_lost {
47
+ table_proxy.finish_edit!
48
+ }
49
+ on_key_pressed { |key_event|
50
+ if key_event.keyCode == swt(:cr)
51
+ table_proxy.finish_edit!
52
+ elsif key_event.keyCode == swt(:esc)
53
+ table_proxy.cancel_edit!
54
+ end
55
+ }
56
+ }
57
+ table_editor_widget_proxy.swt_widget.selectAll
58
+ table_editor_widget_proxy
59
+ end,
60
+ },
61
+ combo: {
62
+ widget_value_property: :text,
63
+ editor_gui: lambda do |args, model, property, table_proxy|
64
+ table_proxy.table_editor.minimumHeight = 25
65
+ table_editor_widget_proxy = combo(*args) {
66
+ items model.send("#{property}_options")
67
+ text model.send(property)
68
+ focus true
69
+ on_focus_lost {
70
+ table_proxy.finish_edit!
71
+ }
72
+ on_key_pressed { |key_event|
73
+ if key_event.keyCode == swt(:cr)
74
+ table_proxy.finish_edit!
75
+ elsif key_event.keyCode == swt(:esc)
76
+ table_proxy.cancel_edit!
77
+ end
78
+ }
79
+ on_widget_selected {
80
+ table_proxy.finish_edit!
81
+ }
82
+ }
83
+ table_editor_widget_proxy
84
+ end,
85
+ }
86
+ }
87
+ end
88
+ end
89
+
90
+ attr_reader :table_editor, :table_editor_widget_proxy, :sort_property, :sort_direction, :sort_block, :sort_type, :sort_by_block, :additional_sort_properties, :editor
37
91
  attr_accessor :column_properties
38
92
 
39
93
  def initialize(underscored_widget_name, parent, args)
@@ -46,7 +100,7 @@ module Glimmer
46
100
 
47
101
  def model_binding
48
102
  swt_widget.data
49
- end
103
+ end
50
104
 
51
105
  def sort_by_column(table_column_proxy)
52
106
  index = swt_widget.columns.to_a.index(table_column_proxy.swt_widget)
@@ -100,6 +154,10 @@ module Glimmer
100
154
  @additional_sort_properties = args unless args.empty?
101
155
  end
102
156
 
157
+ def editor=(args)
158
+ @editor = args
159
+ end
160
+
103
161
  def sort
104
162
  return unless sort_property && (sort_type || sort_block || sort_by_block)
105
163
  array = model_binding.evaluate_property
@@ -152,6 +210,14 @@ module Glimmer
152
210
  })
153
211
  end
154
212
 
213
+ def post_initialize_child(table_column_proxy)
214
+ table_column_proxies << table_column_proxy
215
+ end
216
+
217
+ def table_column_proxies
218
+ @table_column_proxies ||= []
219
+ end
220
+
155
221
  # Indicates if table is in edit mode, thus displaying a text widget for a table item cell
156
222
  def edit_mode?
157
223
  !!@edit_mode
@@ -177,58 +243,62 @@ module Glimmer
177
243
 
178
244
  def edit_table_item(table_item, column_index, before_write: nil, after_write: nil, after_cancel: nil)
179
245
  return if table_item.nil?
246
+ model = table_item.data
247
+ property = column_properties[column_index]
180
248
  @cancel_edit&.call if @edit_mode
249
+ action_taken = false
181
250
  @edit_mode = true
182
- content {
183
- @table_editor_text_proxy = text {
184
- focus true
185
- text table_item.getText(column_index)
186
- action_taken = false
187
- @cancel_edit = lambda do
188
- @cancel_in_progress = true
189
- @table_editor_text_proxy&.swt_widget&.dispose
190
- @table_editor_text_proxy = nil
191
- after_cancel&.call
251
+
252
+ editor_config = table_column_proxies[column_index].editor || editor
253
+ editor_config = editor_config.to_a
254
+ editor_widget_options = editor_config.last.is_a?(Hash) ? editor_config.last : {}
255
+ editor_widget_arg_last_index = editor_config.last.is_a?(Hash) ? -2 : -1
256
+ editor_widget = editor_config[0] || :text
257
+ editor_widget_args = editor_config[1..editor_widget_arg_last_index]
258
+ model_editing_property = editor_widget_options[:property] || property
259
+ widget_value_property = TableProxy::editors[editor_widget][:widget_value_property]
260
+
261
+ @cancel_edit = lambda do |event=nil|
262
+ @cancel_in_progress = true
263
+ @table_editor_widget_proxy&.swt_widget&.dispose
264
+ @table_editor_widget_proxy = nil
265
+ after_cancel&.call
266
+ @edit_in_progress = false
267
+ @cancel_in_progress = false
268
+ @cancel_edit = nil
269
+ @edit_mode = false
270
+ end
271
+
272
+ @finish_edit = lambda do |event=nil|
273
+ new_value = @table_editor_widget_proxy&.swt_widget&.send(widget_value_property)
274
+ if table_item.isDisposed
275
+ @cancel_edit.call
276
+ elsif new_value && !action_taken && !@edit_in_progress && !@cancel_in_progress
277
+ action_taken = true
278
+ @edit_in_progress = true
279
+ if new_value == model.send(model_editing_property)
280
+ @cancel_edit.call
281
+ else
282
+ before_write&.call
283
+ model.send("#{model_editing_property}=", new_value) # makes table update itself, so must search for selected table item again
284
+ # Table refresh happens here because of model update triggering observers, so must retrieve table item again
285
+ edited_table_item = search { |ti| ti.getData == model }.first
286
+ swt_widget.showItem(edited_table_item)
287
+ @table_editor_widget_proxy&.swt_widget&.dispose
288
+ @table_editor_widget_proxy = nil
289
+ after_write&.call(edited_table_item)
192
290
  @edit_in_progress = false
193
- @cancel_in_progress = false
194
- @cancel_edit = nil
195
- @edit_mode = false
196
- end
197
- @finish_edit = lambda do |event=nil|
198
- if table_item.isDisposed
199
- @cancel_edit.call
200
- elsif !action_taken && !@edit_in_progress && !@cancel_in_progress
201
- action_taken = true
202
- @edit_in_progress = true
203
- new_text = @table_editor_text_proxy.swt_widget.getText
204
- if new_text == table_item.getText(column_index)
205
- @cancel_edit.call
206
- else
207
- before_write&.call
208
- table_item.setText(column_index, new_text)
209
- model = table_item.getData
210
- model.send("#{column_properties[column_index]}=", new_text) # makes table update itself, so must search for selected table item again
211
- edited_table_item = search { |ti| ti.getData == model }.first
212
- swt_widget.showItem(edited_table_item)
213
- @table_editor_text_proxy&.swt_widget&.dispose
214
- @table_editor_text_proxy = nil
215
- after_write&.call(edited_table_item)
216
- @edit_in_progress = false
217
- end
218
- end
219
291
  end
220
- on_focus_lost(&@finish_edit)
221
- on_key_pressed { |key_event|
222
- if key_event.keyCode == swt(:cr)
223
- @finish_edit.call(key_event)
224
- elsif key_event.keyCode == swt(:esc)
225
- @cancel_edit.call
226
- end
227
- }
228
- }
229
- @table_editor_text_proxy.swt_widget.selectAll
292
+ end
293
+ end
294
+
295
+ content {
296
+ @table_editor_widget_proxy = TableProxy::editors[editor_widget][:editor_gui].call(editor_widget_args, model, model_editing_property, self)
230
297
  }
231
- @table_editor.setEditor(@table_editor_text_proxy.swt_widget, table_item, column_index)
298
+ @table_editor.setEditor(@table_editor_widget_proxy.swt_widget, table_item, column_index)
299
+ rescue => e
300
+ Glimmer::Config.logger.error {e.full_message}
301
+ raise e
232
302
  end
233
303
 
234
304
  def add_listener(underscored_listener_name, &block)
@@ -3,7 +3,6 @@ require 'glimmer/swt/color_proxy'
3
3
  require 'glimmer/swt/font_proxy'
4
4
  require 'glimmer/swt/swt_proxy'
5
5
  require 'glimmer/swt/dnd_proxy'
6
- require 'glimmer/data_binding/observable_widget'
7
6
 
8
7
  # TODO refactor to make file smaller and extract sub-widget-proxies out of this
9
8
 
@@ -20,11 +19,10 @@ module Glimmer
20
19
  # Follows the Proxy Design Pattern
21
20
  class WidgetProxy
22
21
  include Packages
23
- include DataBinding::ObservableWidget
24
22
 
25
23
  DEFAULT_STYLES = {
26
24
  "text" => [:border],
27
- "table" => [:border],
25
+ "table" => [:virtual, :border],
28
26
  "tree" => [:virtual, :border, :h_scroll, :v_scroll],
29
27
  "spinner" => [:border],
30
28
  "styled_text" => [:border],
@@ -60,6 +58,7 @@ module Glimmer
60
58
  styles, extra_options = extract_args(underscored_widget_name, args)
61
59
  swt_widget_class = self.class.swt_widget_class_for(underscored_widget_name)
62
60
  @swt_widget = swt_widget_class.new(parent.swt_widget, style(underscored_widget_name, styles), *extra_options)
61
+ @swt_widget.set_data('proxy', self)
63
62
  DEFAULT_INITIALIZERS[underscored_widget_name]&.call(@swt_widget)
64
63
  parent.post_initialize_child(self)
65
64
  end
@@ -176,44 +175,44 @@ module Glimmer
176
175
  }
177
176
  end,
178
177
  :caret_position => lambda do |observer|
179
- on_event_keydown { |event|
178
+ on_swt_keydown { |event|
180
179
  observer.call(@swt_widget.getCaretPosition)
181
180
  }
182
- on_event_keyup { |event|
181
+ on_swt_keyup { |event|
183
182
  observer.call(@swt_widget.getCaretPosition)
184
183
  }
185
- on_event_mousedown { |event|
184
+ on_swt_mousedown { |event|
186
185
  observer.call(@swt_widget.getCaretPosition)
187
186
  }
188
- on_event_mouseup { |event|
187
+ on_swt_mouseup { |event|
189
188
  observer.call(@swt_widget.getCaretPosition)
190
189
  }
191
190
  end,
192
191
  :selection => lambda do |observer|
193
- on_event_keydown { |event|
192
+ on_swt_keydown { |event|
194
193
  observer.call(@swt_widget.getSelection)
195
194
  }
196
- on_event_keyup { |event|
195
+ on_swt_keyup { |event|
197
196
  observer.call(@swt_widget.getSelection)
198
197
  }
199
- on_event_mousedown { |event|
198
+ on_swt_mousedown { |event|
200
199
  observer.call(@swt_widget.getSelection)
201
200
  }
202
- on_event_mouseup { |event|
201
+ on_swt_mouseup { |event|
203
202
  observer.call(@swt_widget.getSelection)
204
203
  }
205
204
  end,
206
205
  :selection_count => lambda do |observer|
207
- on_event_keydown { |event|
206
+ on_swt_keydown { |event|
208
207
  observer.call(@swt_widget.getSelectionCount)
209
208
  }
210
- on_event_keyup { |event|
209
+ on_swt_keyup { |event|
211
210
  observer.call(@swt_widget.getSelectionCount)
212
211
  }
213
- on_event_mousedown { |event|
212
+ on_swt_mousedown { |event|
214
213
  observer.call(@swt_widget.getSelectionCount)
215
214
  }
216
- on_event_mouseup { |event|
215
+ on_swt_mouseup { |event|
217
216
  observer.call(@swt_widget.getSelectionCount)
218
217
  }
219
218
  end,
@@ -267,17 +266,17 @@ module Glimmer
267
266
  swt_widget_name = underscored_widget_name.camelcase(:upper)
268
267
  swt_widget_class = eval(swt_widget_name)
269
268
  unless swt_widget_class.ancestors.include?(org.eclipse.swt.widgets.Widget)
270
- Glimmer::Config.logger&.debug("Class #{swt_widget_class} matching #{underscored_widget_name} is not a subclass of org.eclipse.swt.widgets.Widget")
269
+ Glimmer::Config.logger.debug {"Class #{swt_widget_class} matching #{underscored_widget_name} is not a subclass of org.eclipse.swt.widgets.Widget"}
271
270
  return nil
272
271
  end
273
272
  swt_widget_class
274
- rescue NameError => e
275
- Glimmer::Config.logger&.debug e.full_message
276
- # Glimmer::Config.logger&.debug("#{e.message}\n#{e.backtrace.join("\n")}")
273
+ rescue SyntaxError, NameError => e
274
+ Glimmer::Config.logger.debug {e.full_message}
275
+ # Glimmer::Config.logger.debug {"#{e.message}\n#{e.backtrace.join("\n")}"}
277
276
  nil
278
277
  rescue => e
279
- Glimmer::Config.logger&.debug e.full_message
280
- # Glimmer::Config.logger&.debug("#{e.message}\n#{e.backtrace.join("\n")}")
278
+ Glimmer::Config.logger.debug {e.full_message}
279
+ # Glimmer::Config.logger.debug {"#{e.message}\n#{e.backtrace.join("\n")}"}
281
280
  nil
282
281
  end
283
282
 
@@ -336,10 +335,10 @@ module Glimmer
336
335
 
337
336
  # TODO eliminate duplication in the following methods perhaps by relying on exceptions
338
337
 
339
- def can_handle_observation_request?(observation_request)
338
+ def can_handle_observation_request?(observation_request)
340
339
  observation_request = observation_request.to_s
341
- if observation_request.start_with?('on_event_')
342
- constant_name = observation_request.sub(/^on_event_/, '')
340
+ if observation_request.start_with?('on_swt_')
341
+ constant_name = observation_request.sub(/^on_swt_/, '')
343
342
  SWTProxy.has_constant?(constant_name)
344
343
  elsif observation_request.start_with?('on_')
345
344
  event = observation_request.sub(/^on_/, '')
@@ -357,6 +356,9 @@ module Glimmer
357
356
  @drag_source_proxy = nil
358
357
  end
359
358
  end
359
+ rescue => e
360
+ Glimmer::Config.logger.debug {e.full_message}
361
+ false
360
362
  end
361
363
 
362
364
  def can_handle_drop_observation_request?(observation_request)
@@ -372,8 +374,9 @@ module Glimmer
372
374
  end
373
375
 
374
376
  def handle_observation_request(observation_request, &block)
375
- if observation_request.start_with?('on_event_')
376
- constant_name = observation_request.sub(/^on_event_/, '')
377
+ observation_request = observation_request.to_s
378
+ if observation_request.start_with?('on_swt_')
379
+ constant_name = observation_request.sub(/^on_swt_/, '')
377
380
  add_swt_event_listener(constant_name, &block)
378
381
  elsif observation_request.start_with?('on_')
379
382
  event = observation_request.sub(/^on_/, '')
@@ -392,6 +395,23 @@ module Glimmer
392
395
  Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::WidgetExpression.new, &block)
393
396
  end
394
397
 
398
+ def method_missing(method, *args, &block)
399
+ if can_handle_observation_request?(method)
400
+ handle_observation_request(method, &block)
401
+ else
402
+ swt_widget.send(method, *args, &block)
403
+ end
404
+ rescue => e
405
+ Glimmer::Config.logger.debug {"Neither WidgetProxy nor #{swt_widget.class.name} can handle the method ##{method}"}
406
+ super
407
+ end
408
+
409
+ def respond_to?(method, *args, &block)
410
+ super ||
411
+ can_handle_observation_request?(method) ||
412
+ swt_widget.respond_to?(method, *args, &block)
413
+ end
414
+
395
415
  private
396
416
 
397
417
  def style(underscored_widget_name, styles)
@@ -437,7 +457,7 @@ module Glimmer
437
457
  def add_listener(underscored_listener_name, &block)
438
458
  widget_add_listener_method, listener_class, listener_method = self.class.find_listener(@swt_widget.getClass, underscored_listener_name)
439
459
  widget_listener_proxy = nil
440
- safe_block = lambda { |event| block.call(event) unless @swt_widget.isDisposed }
460
+ safe_block = lambda { |*args| block.call(*args) unless @swt_widget.isDisposed }
441
461
  listener = listener_class.new(listener_method => safe_block)
442
462
  @swt_widget.send(widget_add_listener_method, listener)
443
463
  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)
@@ -479,9 +499,9 @@ module Glimmer
479
499
  listener_class.define_method('initialize') do |event_method_block_mapping|
480
500
  @event_method_block_mapping = event_method_block_mapping
481
501
  end
482
- listener_type.getMethods.each do |event_method|
483
- listener_class.define_method(event_method.getName) do |event|
484
- @event_method_block_mapping[event_method.getName]&.call(event)
502
+ listener_type.getMethods.each do |event_method|
503
+ listener_class.define_method(event_method.getName) do |*args|
504
+ @event_method_block_mapping[event_method.getName]&.call(*args)
485
505
  end
486
506
  end
487
507
  end
@@ -492,7 +512,7 @@ module Glimmer
492
512
  def add_swt_event_listener(swt_constant, &block)
493
513
  event_type = SWTProxy[swt_constant]
494
514
  widget_listener_proxy = nil
495
- safe_block = lambda { |event| block.call(event) unless @swt_widget.isDisposed }
515
+ safe_block = lambda { |*args| block.call(*args) unless @swt_widget.isDisposed }
496
516
  @swt_widget.addListener(event_type, &safe_block)
497
517
  widget_listener_proxy = WidgetListenerProxy.new(swt_widget: @swt_widget, swt_listener: @swt_widget.getListeners(event_type).last, event_type: event_type, swt_constant: swt_constant)
498
518
  end
@@ -579,7 +599,7 @@ module Glimmer
579
599
  end
580
600
  image_data = ImageData.new(value)
581
601
  # TODO in the future, look into unregistering this listener when no longer needed
582
- on_event_Resize do |resize_event|
602
+ on_swt_Resize do |resize_event|
583
603
  new_image_data = image_data.scaledTo(@swt_widget.getSize.x, @swt_widget.getSize.y)
584
604
  @swt_widget.getBackgroundImage&.dispose
585
605
  @swt_widget.setBackgroundImage(Image.new(@swt_widget.getDisplay, new_image_data))