glimmer-dsl-opal 0.7.2 → 0.9.0

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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -0
  3. data/README.md +745 -82
  4. data/VERSION +1 -1
  5. data/lib/glimmer-dsl-opal.rb +14 -1
  6. data/lib/glimmer-dsl-opal/ext/class.rb +10 -0
  7. data/lib/{file.rb → glimmer-dsl-opal/ext/file.rb} +0 -0
  8. data/lib/glimmer-dsl-opal/ext/glimmer/dsl/engine.rb +30 -0
  9. data/lib/glimmer-dsl-opal/samples/elaborate/contact_manager.rb +50 -23
  10. data/lib/glimmer-dsl-opal/samples/elaborate/login.rb +22 -5
  11. data/lib/glimmer-dsl-opal/samples/hello/hello_browser.rb +24 -1
  12. data/lib/glimmer-dsl-opal/samples/hello/hello_button.rb +46 -0
  13. data/lib/glimmer-dsl-opal/samples/hello/hello_computed.rb +27 -0
  14. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +7 -7
  15. data/lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb +62 -32
  16. data/lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb +47 -22
  17. data/lib/glimmer-dsl-opal/samples/hello/hello_menu_bar.rb +241 -0
  18. data/lib/glimmer-dsl-opal/samples/hello/hello_message_box.rb +37 -0
  19. data/lib/glimmer-dsl-opal/samples/hello/hello_pop_up_context_menu.rb +84 -0
  20. data/lib/glimmer/data_binding/observable_element.rb +1 -1
  21. data/lib/glimmer/dsl/opal/custom_widget_expression.rb +6 -0
  22. data/lib/glimmer/dsl/opal/dsl.rb +2 -0
  23. data/lib/glimmer/dsl/opal/menu_bar_expression.rb +54 -0
  24. data/lib/glimmer/dsl/opal/menu_expression.rb +61 -0
  25. data/lib/glimmer/dsl/opal/shell_expression.rb +0 -4
  26. data/lib/glimmer/dsl/opal/widget_expression.rb +3 -2
  27. data/lib/glimmer/dsl/opal/widget_listener_expression.rb +2 -2
  28. data/lib/glimmer/swt/custom/checkbox_group.rb +2 -2
  29. data/lib/glimmer/swt/custom/radio_group.rb +2 -2
  30. data/lib/glimmer/swt/date_time_proxy.rb +5 -4
  31. data/lib/glimmer/swt/display_proxy.rb +4 -4
  32. data/lib/glimmer/swt/event_listener_proxy.rb +14 -4
  33. data/lib/glimmer/swt/font_proxy.rb +4 -4
  34. data/lib/glimmer/swt/grid_layout_proxy.rb +21 -12
  35. data/lib/glimmer/swt/label_proxy.rb +17 -6
  36. data/lib/glimmer/swt/latest_message_box_proxy.rb +20 -0
  37. data/lib/glimmer/swt/layout_data_proxy.rb +6 -6
  38. data/lib/glimmer/swt/list_proxy.rb +15 -0
  39. data/lib/glimmer/swt/menu_item_proxy.rb +174 -0
  40. data/lib/glimmer/swt/menu_proxy.rb +273 -0
  41. data/lib/glimmer/swt/message_box_proxy.rb +57 -72
  42. data/lib/glimmer/swt/property_owner.rb +2 -0
  43. data/lib/glimmer/swt/radio_proxy.rb +1 -1
  44. data/lib/glimmer/swt/shell_proxy.rb +34 -189
  45. data/lib/glimmer/swt/tab_folder_proxy.rb +43 -0
  46. data/lib/glimmer/swt/table_column_proxy.rb +3 -2
  47. data/lib/glimmer/swt/table_editor.rb +1 -1
  48. data/lib/glimmer/swt/table_item_proxy.rb +7 -5
  49. data/lib/glimmer/swt/table_proxy.rb +14 -10
  50. data/lib/glimmer/swt/widget_proxy.rb +327 -33
  51. data/lib/glimmer/ui/custom_shell.rb +9 -7
  52. data/lib/glimmer/ui/custom_widget.rb +3 -3
  53. metadata +36 -4
@@ -1,41 +1,71 @@
1
- class Person
2
- attr_accessor :provinces, :provinces_options
3
-
4
- def initialize
5
- self.provinces_options=[
6
- "",
7
- "Quebec",
8
- "Ontario",
9
- "Manitoba",
10
- "Saskatchewan",
11
- "Alberta",
12
- "British Columbia",
13
- "Nova Skotia",
14
- "Newfoundland"
15
- ]
16
- self.provinces = ["Quebec", "Manitoba", "Alberta"]
17
- end
18
-
19
- def reset_provinces
20
- self.provinces = ["Quebec", "Manitoba", "Alberta"]
21
- end
22
- end
1
+ # Copyright (c) 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.
23
21
 
24
22
  class HelloListMultiSelection
23
+ class Person
24
+ attr_accessor :provinces, :provinces_options
25
+
26
+ def initialize
27
+ self.provinces_options = [
28
+ '',
29
+ 'Alberta',
30
+ 'British Columbia',
31
+ 'Manitoba',
32
+ 'New Brunswick',
33
+ 'Newfoundland and Labrador',
34
+ 'Northwest Territories',
35
+ 'Nova Scotia',
36
+ 'Nunavut',
37
+ 'Ontario',
38
+ 'Prince Edward Island',
39
+ 'Quebec',
40
+ 'Saskatchewan',
41
+ 'Yukon'
42
+ ]
43
+ reset_provinces
44
+ end
45
+
46
+ def reset_provinces
47
+ self.provinces = ['Quebec', 'Manitoba', 'Alberta']
48
+ end
49
+ end
50
+
25
51
  include Glimmer
52
+
26
53
  def launch
27
54
  person = Person.new
55
+
28
56
  shell {
29
- composite {
30
- list(:multi) {
31
- selection bind(person, :provinces)
32
- }
33
- button {
34
- text "Reset"
35
- on_widget_selected do
36
- person.reset_provinces
37
- end
38
- }
57
+ grid_layout
58
+
59
+ text 'Hello, List Multi Selection!'
60
+
61
+ list(:multi) {
62
+ selection bind(person, :provinces)
63
+ }
64
+
65
+ button {
66
+ text 'Reset Selections To Default Values'
67
+
68
+ on_widget_selected { person.reset_provinces }
39
69
  }
40
70
  }.open
41
71
  end
@@ -1,31 +1,56 @@
1
- class Person
2
- attr_accessor :country, :country_options
3
-
4
- def initialize
5
- self.country_options=["", "Canada", "US", "Mexico"]
6
- self.country = "Canada"
7
- end
8
-
9
- def reset_country
10
- self.country = "Canada"
11
- end
12
- end
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.
13
21
 
14
22
  class HelloListSingleSelection
23
+ class Person
24
+ attr_accessor :country, :country_options
25
+
26
+ def initialize
27
+ self.country_options = ['', 'Canada', 'US', 'Mexico']
28
+ reset_country
29
+ end
30
+
31
+ def reset_country
32
+ self.country = 'Canada'
33
+ end
34
+ end
35
+
15
36
  include Glimmer
37
+
16
38
  def launch
17
39
  person = Person.new
40
+
18
41
  shell {
19
- composite {
20
- list {
21
- selection bind(person, :country)
22
- }
23
- button {
24
- text "Reset"
25
- on_widget_selected do
26
- person.reset_country
27
- end
28
- }
42
+ grid_layout
43
+
44
+ text 'Hello, List Single Selection!'
45
+
46
+ list {
47
+ selection bind(person, :country)
48
+ }
49
+
50
+ button {
51
+ text 'Reset Selection To Default Value'
52
+
53
+ on_widget_selected { person.reset_country }
29
54
  }
30
55
  }.open
31
56
  end
@@ -0,0 +1,241 @@
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
+ include Glimmer
23
+
24
+ COLORS = [:white, :red, :yellow, :green, :blue, :magenta, :gray, :black]
25
+
26
+ shell {
27
+ grid_layout {
28
+ margin_width 0
29
+ margin_height 0
30
+ }
31
+
32
+ text 'Hello, Menu Bar!'
33
+
34
+ @label = label(:center) {
35
+ font height: 50
36
+ text 'Check Out The Menu Bar Above!'
37
+ }
38
+
39
+ menu_bar {
40
+ menu {
41
+ text '&File'
42
+ menu_item {
43
+ text '&New'
44
+ accelerator :command, :N
45
+
46
+ on_widget_selected {
47
+ message_box {
48
+ text 'New'
49
+ message 'New file created.'
50
+ }.open
51
+ }
52
+ }
53
+ menu_item {
54
+ text '&Open...'
55
+ accelerator :command, :O
56
+
57
+ on_widget_selected {
58
+ message_box {
59
+ text 'Open'
60
+ message 'Opening File...'
61
+ }.open
62
+ }
63
+ }
64
+ menu {
65
+ text 'Open &Recent'
66
+ menu_item {
67
+ text 'File 1'
68
+ on_widget_selected {
69
+ message_box {
70
+ text 'File 1'
71
+ message 'File 1 Contents'
72
+ }.open
73
+ }
74
+ }
75
+ menu_item {
76
+ text 'File 2'
77
+ on_widget_selected {
78
+ message_box {
79
+ text 'File 2'
80
+ message 'File 2 Contents'
81
+ }.open
82
+ }
83
+ }
84
+ }
85
+ menu_item(:separator)
86
+ menu_item {
87
+ text 'E&xit'
88
+
89
+ on_widget_selected {
90
+ exit(0)
91
+ }
92
+ }
93
+ }
94
+ menu {
95
+ text '&Edit'
96
+ menu_item {
97
+ text 'Cut'
98
+ accelerator :command, :X
99
+ }
100
+ menu_item {
101
+ text 'Copy'
102
+ accelerator :command, :C
103
+ }
104
+ menu_item {
105
+ text 'Paste'
106
+ accelerator :command, :V
107
+ }
108
+ }
109
+ menu {
110
+ text '&Options'
111
+
112
+ menu_item(:radio) {
113
+ text '&Enabled'
114
+
115
+ on_widget_selected {
116
+ @select_one_menu.enabled = true
117
+ @select_multiple_menu.enabled = true
118
+ }
119
+ }
120
+ @select_one_menu = menu {
121
+ text '&Select One'
122
+ enabled false
123
+
124
+ menu_item(:radio) {
125
+ text 'Option 1'
126
+ }
127
+ menu_item(:radio) {
128
+ text 'Option 2'
129
+ }
130
+ menu_item(:radio) {
131
+ text 'Option 3'
132
+ }
133
+ }
134
+ @select_multiple_menu = menu {
135
+ text '&Select Multiple'
136
+ enabled false
137
+
138
+ menu_item(:check) {
139
+ text 'Option 4'
140
+ }
141
+ menu_item(:check) {
142
+ text 'Option 5'
143
+ }
144
+ menu_item(:check) {
145
+ text 'Option 6'
146
+ }
147
+ }
148
+ }
149
+ menu {
150
+ text '&Format'
151
+ menu {
152
+ text '&Background Color'
153
+ COLORS.each { |color_style|
154
+ menu_item(:radio) {
155
+ text color_style.to_s.split('_').map(&:capitalize).join(' ')
156
+
157
+ on_widget_selected {
158
+ @label.background = color_style
159
+ }
160
+ }
161
+ }
162
+ }
163
+ menu {
164
+ text 'Foreground &Color'
165
+ COLORS.each { |color_style|
166
+ menu_item(:radio) {
167
+ text color_style.to_s.split('_').map(&:capitalize).join(' ')
168
+
169
+ on_widget_selected {
170
+ @label.foreground = color_style
171
+ }
172
+ }
173
+ }
174
+ }
175
+ }
176
+ menu {
177
+ text '&View'
178
+ menu_item(:radio) {
179
+ text 'Small'
180
+
181
+ on_widget_selected {
182
+ @label.font = {height: 25}
183
+ @label.parent.pack
184
+ }
185
+ }
186
+ menu_item(:radio) {
187
+ text 'Medium'
188
+ selection true
189
+
190
+ on_widget_selected {
191
+ @label.font = {height: 50}
192
+ @label.parent.pack
193
+ }
194
+ }
195
+ menu_item(:radio) {
196
+ text 'Large'
197
+
198
+ on_widget_selected {
199
+ @label.font = {height: 75}
200
+ @label.parent.pack
201
+ }
202
+ }
203
+ }
204
+ menu {
205
+ text '&Help'
206
+ menu_item {
207
+ text '&Manual'
208
+ accelerator :command, :shift, :M
209
+
210
+ on_widget_selected {
211
+ message_box {
212
+ text 'Manual'
213
+ message 'Manual Contents'
214
+ }.open
215
+ }
216
+ }
217
+ menu_item {
218
+ text '&Tutorial'
219
+ accelerator :command, :shift, :T
220
+
221
+ on_widget_selected {
222
+ message_box {
223
+ text 'Tutorial'
224
+ message 'Tutorial Contents'
225
+ }.open
226
+ }
227
+ }
228
+ menu_item(:separator)
229
+ menu_item {
230
+ text '&Report an Issue...'
231
+
232
+ on_widget_selected {
233
+ message_box {
234
+ text 'Report an Issue'
235
+ message 'Reporting an issue...'
236
+ }.open
237
+ }
238
+ }
239
+ }
240
+ }
241
+ }.open
@@ -0,0 +1,37 @@
1
+ # Copyright (c) 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
+ include Glimmer
23
+
24
+ shell {
25
+ text 'Hello, Message Box!'
26
+
27
+ button {
28
+ text 'Please Click To Win a Surprise'
29
+
30
+ on_widget_selected {
31
+ message_box {
32
+ text 'Surprise'
33
+ message "Congratulations!\n\nYou won $1,000,000!"
34
+ }.open
35
+ }
36
+ }
37
+ }.open