glimmer-dsl-swt 4.17.10.8 → 4.18.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +52 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +529 -60
  5. data/RUBY_VERSION +1 -1
  6. data/VERSION +1 -1
  7. data/bin/girb +1 -1
  8. data/bin/girb_runner.rb +1 -1
  9. data/bin/glimmer +1 -1
  10. data/glimmer-dsl-swt.gemspec +58 -30
  11. data/lib/ext/glimmer.rb +1 -1
  12. data/lib/ext/glimmer/config.rb +7 -7
  13. data/lib/glimmer-dsl-swt.rb +3 -1
  14. data/lib/glimmer/Rakefile +1 -1
  15. data/lib/glimmer/data_binding/list_selection_binding.rb +1 -1
  16. data/lib/glimmer/data_binding/observable_widget.rb +1 -1
  17. data/lib/glimmer/data_binding/shine.rb +1 -1
  18. data/lib/glimmer/data_binding/table_items_binding.rb +1 -1
  19. data/lib/glimmer/data_binding/tree_items_binding.rb +1 -1
  20. data/lib/glimmer/data_binding/widget_binding.rb +1 -1
  21. data/lib/glimmer/dsl/swt/animation_expression.rb +43 -0
  22. data/lib/glimmer/dsl/swt/async_exec_expression.rb +1 -1
  23. data/lib/glimmer/dsl/swt/bind_expression.rb +1 -1
  24. data/lib/glimmer/dsl/swt/block_property_expression.rb +1 -1
  25. data/lib/glimmer/dsl/swt/checkbox_group_selection_data_binding_expression.rb +1 -1
  26. data/lib/glimmer/dsl/swt/color_expression.rb +1 -1
  27. data/lib/glimmer/dsl/swt/column_properties_expression.rb +1 -1
  28. data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +1 -1
  29. data/lib/glimmer/dsl/swt/cursor_expression.rb +1 -1
  30. data/lib/glimmer/dsl/swt/custom_widget_expression.rb +1 -1
  31. data/lib/glimmer/dsl/swt/data_binding_expression.rb +1 -1
  32. data/lib/glimmer/dsl/swt/dialog_expression.rb +1 -1
  33. data/lib/glimmer/dsl/swt/directory_dialog_expression.rb +1 -1
  34. data/lib/glimmer/dsl/swt/display_expression.rb +1 -1
  35. data/lib/glimmer/dsl/swt/dnd_expression.rb +1 -1
  36. data/lib/glimmer/dsl/swt/dsl.rb +5 -4
  37. data/lib/glimmer/dsl/swt/exec_expression.rb +5 -5
  38. data/lib/glimmer/dsl/swt/expand_item_expression.rb +1 -1
  39. data/lib/glimmer/dsl/swt/file_dialog_expression.rb +1 -1
  40. data/lib/glimmer/dsl/swt/font_expression.rb +8 -6
  41. data/lib/glimmer/dsl/swt/image_expression.rb +1 -1
  42. data/lib/glimmer/dsl/swt/layout_data_expression.rb +1 -1
  43. data/lib/glimmer/dsl/swt/layout_expression.rb +1 -1
  44. data/lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb +1 -1
  45. data/lib/glimmer/dsl/swt/menu_bar_expression.rb +1 -1
  46. data/lib/glimmer/dsl/swt/menu_expression.rb +1 -1
  47. data/lib/glimmer/dsl/swt/message_box_expression.rb +1 -1
  48. data/lib/glimmer/dsl/swt/observe_expression.rb +1 -1
  49. data/lib/glimmer/dsl/swt/property_expression.rb +4 -4
  50. data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +1 -1
  51. data/lib/glimmer/dsl/swt/rgb_expression.rb +1 -1
  52. data/lib/glimmer/dsl/swt/rgba_expression.rb +1 -1
  53. data/lib/glimmer/dsl/swt/shape_expression.rb +56 -0
  54. data/lib/glimmer/dsl/swt/shell_expression.rb +1 -1
  55. data/lib/glimmer/dsl/swt/swt_expression.rb +1 -1
  56. data/lib/glimmer/dsl/swt/sync_exec_expression.rb +1 -1
  57. data/lib/glimmer/dsl/swt/tab_item_expression.rb +1 -1
  58. data/lib/glimmer/dsl/swt/table_items_data_binding_expression.rb +1 -1
  59. data/lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb +1 -1
  60. data/lib/glimmer/dsl/swt/tree_properties_expression.rb +1 -1
  61. data/lib/glimmer/dsl/swt/widget_expression.rb +7 -3
  62. data/lib/glimmer/dsl/swt/widget_listener_expression.rb +1 -1
  63. data/lib/glimmer/launcher.rb +1 -1
  64. data/lib/glimmer/rake_task.rb +1 -1
  65. data/lib/glimmer/rake_task/list.rb +6 -6
  66. data/lib/glimmer/rake_task/package.rb +1 -1
  67. data/lib/glimmer/rake_task/scaffold.rb +33 -34
  68. data/lib/glimmer/swt/color_proxy.rb +1 -1
  69. data/lib/glimmer/swt/cursor_proxy.rb +1 -1
  70. data/lib/glimmer/swt/custom/animation.rb +120 -0
  71. data/lib/glimmer/swt/custom/checkbox_group.rb +1 -1
  72. data/lib/glimmer/swt/custom/drawable.rb +43 -0
  73. data/lib/glimmer/swt/custom/radio_group.rb +1 -1
  74. data/lib/glimmer/swt/custom/shape.rb +154 -0
  75. data/lib/glimmer/swt/date_time_proxy.rb +1 -1
  76. data/lib/glimmer/swt/directory_dialog_proxy.rb +1 -1
  77. data/lib/glimmer/swt/display_proxy.rb +17 -1
  78. data/lib/glimmer/swt/dnd_proxy.rb +1 -1
  79. data/lib/glimmer/swt/expand_item_proxy.rb +1 -1
  80. data/lib/glimmer/swt/file_dialog_proxy.rb +1 -1
  81. data/lib/glimmer/swt/font_proxy.rb +4 -4
  82. data/lib/glimmer/swt/image_proxy.rb +12 -11
  83. data/lib/glimmer/swt/layout_data_proxy.rb +1 -1
  84. data/lib/glimmer/swt/layout_proxy.rb +8 -4
  85. data/lib/glimmer/swt/menu_proxy.rb +10 -5
  86. data/lib/glimmer/swt/message_box_proxy.rb +1 -1
  87. data/lib/glimmer/swt/packages.rb +1 -1
  88. data/lib/glimmer/swt/properties.rb +49 -0
  89. data/lib/glimmer/swt/sash_form_proxy.rb +2 -2
  90. data/lib/glimmer/swt/scrolled_composite_proxy.rb +1 -1
  91. data/lib/glimmer/swt/shell_proxy.rb +3 -2
  92. data/lib/glimmer/swt/style_constantizable.rb +9 -5
  93. data/lib/glimmer/swt/styled_text_proxy.rb +1 -1
  94. data/lib/glimmer/swt/swt_proxy.rb +1 -1
  95. data/lib/glimmer/swt/tab_item_proxy.rb +1 -1
  96. data/lib/glimmer/swt/table_column_proxy.rb +1 -1
  97. data/lib/glimmer/swt/table_proxy.rb +1 -1
  98. data/lib/glimmer/swt/tree_proxy.rb +26 -22
  99. data/lib/glimmer/swt/widget_listener_proxy.rb +1 -1
  100. data/lib/glimmer/swt/widget_proxy.rb +54 -28
  101. data/lib/glimmer/ui/custom_shell.rb +1 -1
  102. data/lib/glimmer/ui/custom_widget.rb +1 -1
  103. data/lib/glimmer/util/proc_tracker.rb +1 -1
  104. data/samples/elaborate/contact_manager.rb +1 -1
  105. data/samples/elaborate/contact_manager/contact.rb +1 -1
  106. data/samples/elaborate/contact_manager/contact_manager_presenter.rb +1 -1
  107. data/samples/elaborate/contact_manager/contact_repository.rb +1 -1
  108. data/samples/elaborate/login.rb +1 -1
  109. data/samples/elaborate/meta_sample.rb +40 -16
  110. data/samples/elaborate/tic_tac_toe.rb +2 -2
  111. data/samples/elaborate/tic_tac_toe/board.rb +1 -1
  112. data/samples/elaborate/tic_tac_toe/cell.rb +1 -1
  113. data/samples/elaborate/user_profile.rb +1 -1
  114. data/samples/hello/hello_browser.rb +1 -1
  115. data/samples/hello/hello_button.rb +1 -1
  116. data/samples/hello/hello_canvas.rb +43 -0
  117. data/samples/hello/hello_canvas_animation.rb +66 -0
  118. data/samples/hello/hello_checkbox.rb +1 -1
  119. data/samples/hello/hello_checkbox_group.rb +1 -1
  120. data/samples/hello/hello_combo.rb +1 -1
  121. data/samples/hello/hello_computed.rb +1 -1
  122. data/samples/hello/hello_computed/contact.rb +1 -1
  123. data/samples/hello/hello_custom_shell.rb +1 -1
  124. data/samples/hello/hello_custom_widget.rb +1 -1
  125. data/samples/hello/hello_date_time.rb +1 -1
  126. data/samples/hello/hello_dialog.rb +78 -0
  127. data/samples/hello/hello_directory_dialog.rb +1 -1
  128. data/samples/hello/hello_drag_and_drop.rb +1 -1
  129. data/samples/hello/hello_expand_bar.rb +1 -1
  130. data/samples/hello/hello_file_dialog.rb +1 -1
  131. data/samples/hello/hello_group.rb +1 -1
  132. data/samples/hello/hello_link.rb +1 -1
  133. data/samples/hello/hello_list_multi_selection.rb +1 -1
  134. data/samples/hello/hello_list_single_selection.rb +1 -1
  135. data/samples/hello/hello_menu_bar.rb +185 -29
  136. data/samples/hello/hello_message_box.rb +1 -1
  137. data/samples/hello/hello_pop_up_context_menu.rb +1 -1
  138. data/samples/hello/hello_radio.rb +1 -1
  139. data/samples/hello/hello_radio_group.rb +1 -1
  140. data/samples/hello/hello_sash_form.rb +1 -1
  141. data/samples/hello/hello_spinner.rb +1 -1
  142. data/samples/hello/hello_styled_text.rb +1 -1
  143. data/samples/hello/hello_tab.rb +1 -1
  144. data/samples/hello/hello_table.rb +1 -1
  145. data/samples/hello/hello_world.rb +1 -1
  146. data/vendor/swt/linux/swt.jar +0 -0
  147. data/vendor/swt/mac/swt.jar +0 -0
  148. data/vendor/swt/windows/swt.jar +0 -0
  149. metadata +54 -32
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007-2020 Andy Maleh
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
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007-2020 Andy Maleh
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
@@ -0,0 +1,120 @@
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 an animation declaratively
28
+ class Animation
29
+ include Properties # TODO rename to Properties
30
+
31
+ attr_reader :parent, :options, :frame_index, :cycle
32
+ alias current_frame_index frame_index
33
+ attr_accessor :frame_block, :every, :cycle_count, :frame_count, :started
34
+ # TODO consider supporting an async: false option
35
+
36
+ def initialize(parent)
37
+ @parent = parent
38
+ @started = true
39
+ @frame_index = 0
40
+ end
41
+
42
+ def post_add_content
43
+ @parent.on_widget_disposed { stop }
44
+ start if @started
45
+ end
46
+
47
+ def start
48
+ swt_display = DisplayProxy.instance.swt_display
49
+ Thread.new do
50
+ if cycle_count.is_a?(Integer) && cycle.is_a?(Array)
51
+ (cycle_count * cycle.length).times do
52
+ break unless draw_frame(swt_display)
53
+ end
54
+ else
55
+ loop do
56
+ # this code has to be duplicated to break from a loop (break keyword only works when literally in a loop block)
57
+ break unless draw_frame(swt_display)
58
+ end
59
+ end
60
+ @started = false
61
+ end
62
+ end
63
+
64
+ def stop
65
+ @started = false
66
+ end
67
+
68
+ def has_attribute?(attribute_name, *args)
69
+ respond_to?(ruby_attribute_setter(attribute_name)) && respond_to?(ruby_attribute_getter(attribute_name))
70
+ end
71
+
72
+ def set_attribute(attribute_name, *args)
73
+ send(ruby_attribute_setter(attribute_name), *args)
74
+ end
75
+
76
+ def get_attribute(attribute_name)
77
+ send(ruby_attribute_getter(attribute_name))
78
+ end
79
+
80
+ def cycle=(*args)
81
+ if args.size == 1
82
+ if args.first.is_a?(Array)
83
+ @cycle = args.first
84
+ else
85
+ @cycle = [args.first]
86
+ end
87
+ elsif args.size > 1
88
+ @cycle = args
89
+ end
90
+ end
91
+
92
+ private
93
+
94
+ # Returns true on success of painting a frame and false otherwise
95
+ def draw_frame(swt_display)
96
+ return false if !@started || (@frame_count.is_a?(Integer) && @frame_index == @frame_count)
97
+ block_args = [@frame_index]
98
+ block_args << @cycle[@frame_index % @cycle.length] if @cycle.is_a?(Array)
99
+ swt_display.async_exec do
100
+ @parent.clear_shapes
101
+ @parent.content {
102
+ frame_block.call(*block_args)
103
+ }
104
+ @parent.redraw
105
+ end
106
+ @frame_index += 1
107
+ sleep(every) if every.is_a?(Numeric)
108
+ true
109
+ rescue => e
110
+ Glimmer::Config.logger.error {e}
111
+ false
112
+ end
113
+
114
+ end
115
+
116
+ end
117
+
118
+ end
119
+
120
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007-2020 Andy Maleh
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
@@ -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
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007-2020 Andy Maleh
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
@@ -0,0 +1,154 @@
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, &property_block)
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
+ post_add_content if property_block.nil?
68
+ end
69
+
70
+ def fill?
71
+ !draw?
72
+ end
73
+
74
+ def draw?
75
+ !@options[:fill]
76
+ end
77
+
78
+ def post_add_content
79
+ event_handler = lambda do |event|
80
+ @properties['background'] = [DisplayProxy.instance.get_system_color(SWTProxy(:color_widget_background))] if fill? && !@properties.keys.map(&:to_s).include?('background')
81
+ @properties['foreground'] = [ColorProxy.new(0, 0, 0)] if draw? && !@properties.keys.map(&:to_s).include?('foreground')
82
+ @properties.each do |property, args|
83
+ method_name = attribute_setter(property)
84
+ apply_property_arg_conversions(method_name, args)
85
+ event.gc.send(method_name, *args)
86
+ end
87
+ apply_shape_arg_conversions(@method_name, @args)
88
+ apply_shape_arg_defaults(@method_name, @args)
89
+ event.gc.send(@method_name, *@args)
90
+ end
91
+ if parent.respond_to?(:swt_display)
92
+ @paint_listener_proxy = @parent.on_swt_paint(&event_handler)
93
+ else
94
+ @paint_listener_proxy = @parent.on_paint_control(&event_handler)
95
+ end
96
+ end
97
+
98
+ def apply_property_arg_conversions(method_name, args)
99
+ the_java_method = org.eclipse.swt.graphics.GC.java_class.declared_instance_methods.detect {|m| m.name == method_name}
100
+ if (args.first.is_a?(Symbol) || args.first.is_a?(String))
101
+ if the_java_method.parameter_types.first == Color.java_class
102
+ args[0] = ColorProxy.new(args[0])
103
+ end
104
+ if the_java_method.parameter_types.first == Java::int.java_class
105
+ args[0] = SWTProxy[args[0]]
106
+ end
107
+ end
108
+ if args.first.is_a?(ColorProxy)
109
+ args[0] = args[0].swt_color
110
+ end
111
+ if args.first.is_a?(Hash) && the_java_method.parameter_types.first == Font.java_class
112
+ args[0] = FontProxy.new(args[0])
113
+ end
114
+ if args.first.is_a?(FontProxy)
115
+ args[0] = args[0].swt_font
116
+ end
117
+ end
118
+
119
+ def apply_shape_arg_conversions(method_name, args)
120
+ if args.size > 1 && (method_name.include?('polygon') || method_name.include?('polyline'))
121
+ args[0] = args.dup
122
+ args[1..-1] = []
123
+ end
124
+ end
125
+
126
+ def apply_shape_arg_defaults(method_name, args)
127
+ if method_name.include?('round_rectangle') && args.size.between?(4, 5)
128
+ (6 - args.size).times {args << 60}
129
+ elsif method_name.include?('gradient_rectangle') && args.size == 4
130
+ args << true
131
+ end
132
+ end
133
+
134
+ def has_attribute?(attribute_name, *args)
135
+ # TODO test that attribute getter responds too
136
+ self.class.gc_instance_methods.include?(attribute_setter(attribute_name))
137
+ end
138
+
139
+ def set_attribute(attribute_name, *args)
140
+ # TODO special treatment for color symbols
141
+ @properties[attribute_name] = args
142
+ end
143
+
144
+ def get_attribute(attribute_name)
145
+ @properties.symbolize_keys[attribute_name.to_s.to_sym]
146
+ end
147
+
148
+ end
149
+
150
+ end
151
+
152
+ end
153
+
154
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007-2020 Andy Maleh
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
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007-2020 Andy Maleh
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
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007-2020 Andy Maleh
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
 
@@ -53,6 +56,7 @@ module Glimmer
53
56
  attr_reader :swt_display
54
57
 
55
58
  def initialize(*args)
59
+ Display.app_name ||= 'Glimmer'
56
60
  @swt_display = Display.new(*args)
57
61
  @swt_display.set_data('proxy', self)
58
62
  end
@@ -60,6 +64,18 @@ module Glimmer
60
64
  def content(&block)
61
65
  Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::DisplayExpression.new, &block)
62
66
  end
67
+
68
+ def async_exec(&block)
69
+ @swt_display.async_exec(&block)
70
+ end
71
+
72
+ def sync_exec(&block)
73
+ @swt_display.sync_exec(&block)
74
+ end
75
+
76
+ def timer_exec(&block)
77
+ @swt_display.timer_exec(&block)
78
+ end
63
79
 
64
80
  def method_missing(method, *args, &block)
65
81
  if can_handle_observation_request?(method)
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007-2020 Andy Maleh
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
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007-2020 Andy Maleh
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
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007-2020 Andy Maleh
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
@@ -1,5 +1,5 @@
1
- # Copyright (c) 2007-2020 Andy Maleh
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