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.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +33 -0
  3. data/README.md +7 -5
  4. data/VERSION +1 -1
  5. data/bin/glimmer +3 -3
  6. data/docs/reference/GLIMMER_CONFIGURATION.md +7 -3
  7. data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +121 -5
  8. data/docs/reference/GLIMMER_SAMPLES.md +17 -4
  9. data/glimmer-dsl-swt.gemspec +19 -9
  10. data/lib/ext/glimmer/config.rb +3 -7
  11. data/lib/glimmer/data_binding/list_selection_binding.rb +13 -7
  12. data/lib/glimmer/data_binding/table_items_binding.rb +22 -17
  13. data/lib/glimmer/data_binding/tree_items_binding.rb +19 -15
  14. data/lib/glimmer/data_binding/widget_binding.rb +9 -27
  15. data/lib/glimmer/dsl/swt/auto_exec_expression.rb +36 -0
  16. data/lib/glimmer/dsl/swt/checkbox_group_selection_data_binding_expression.rb +9 -6
  17. data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +16 -14
  18. data/lib/glimmer/dsl/swt/data_binding_expression.rb +1 -2
  19. data/lib/glimmer/dsl/swt/exec_expression.rb +1 -1
  20. data/lib/glimmer/dsl/swt/image_expression.rb +8 -1
  21. data/lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb +11 -8
  22. data/lib/glimmer/dsl/swt/pixel_expression.rb +1 -1
  23. data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +8 -5
  24. data/lib/glimmer/dsl/swt/shape_expression.rb +1 -1
  25. data/lib/glimmer/dsl/swt/widget_expression.rb +4 -3
  26. data/lib/glimmer/launcher.rb +3 -0
  27. data/lib/glimmer/rake_task/scaffold.rb +3 -0
  28. data/lib/glimmer/swt/custom/code_text.rb +11 -11
  29. data/lib/glimmer/swt/custom/drawable.rb +4 -0
  30. data/lib/glimmer/swt/custom/shape.rb +129 -20
  31. data/lib/glimmer/swt/custom/shape/arc.rb +43 -0
  32. data/lib/glimmer/swt/custom/shape/focus.rb +43 -0
  33. data/lib/glimmer/swt/custom/shape/image.rb +86 -0
  34. data/lib/glimmer/swt/custom/shape/line.rb +58 -0
  35. data/lib/glimmer/swt/custom/shape/oval.rb +43 -0
  36. data/lib/glimmer/swt/custom/shape/point.rb +52 -0
  37. data/lib/glimmer/swt/custom/shape/polygon.rb +73 -0
  38. data/lib/glimmer/swt/custom/shape/polyline.rb +73 -0
  39. data/lib/glimmer/swt/custom/shape/rectangle.rb +87 -0
  40. data/lib/glimmer/swt/custom/shape/text.rb +73 -0
  41. data/lib/glimmer/swt/date_time_proxy.rb +9 -3
  42. data/lib/glimmer/swt/directory_dialog_proxy.rb +20 -18
  43. data/lib/glimmer/swt/display_proxy.rb +62 -2
  44. data/lib/glimmer/swt/expand_item_proxy.rb +18 -12
  45. data/lib/glimmer/swt/file_dialog_proxy.rb +20 -18
  46. data/lib/glimmer/swt/font_proxy.rb +1 -1
  47. data/lib/glimmer/swt/image_proxy.rb +1 -1
  48. data/lib/glimmer/swt/layout_data_proxy.rb +21 -15
  49. data/lib/glimmer/swt/layout_proxy.rb +19 -15
  50. data/lib/glimmer/swt/menu_proxy.rb +2 -2
  51. data/lib/glimmer/swt/message_box_proxy.rb +20 -7
  52. data/lib/glimmer/swt/scrolled_composite_proxy.rb +6 -2
  53. data/lib/glimmer/swt/shell_proxy.rb +94 -80
  54. data/lib/glimmer/swt/swt_proxy.rb +16 -0
  55. data/lib/glimmer/swt/tab_item_proxy.rb +5 -3
  56. data/lib/glimmer/swt/table_proxy.rb +32 -11
  57. data/lib/glimmer/swt/tree_proxy.rb +11 -16
  58. data/lib/glimmer/swt/widget_listener_proxy.rb +6 -2
  59. data/lib/glimmer/swt/widget_proxy.rb +200 -117
  60. data/lib/glimmer/ui.rb +5 -0
  61. data/lib/glimmer/ui/custom_shell.rb +11 -5
  62. data/lib/glimmer/ui/custom_widget.rb +4 -5
  63. data/samples/elaborate/contact_manager.rb +7 -7
  64. data/samples/elaborate/login.rb +25 -21
  65. data/samples/elaborate/mandelbrot_fractal.rb +3 -5
  66. data/samples/elaborate/tetris.rb +1 -0
  67. data/samples/elaborate/tic_tac_toe.rb +16 -14
  68. data/samples/elaborate/tic_tac_toe/board.rb +5 -5
  69. data/samples/elaborate/tic_tac_toe/cell.rb +5 -5
  70. data/samples/hello/hello_button.rb +7 -7
  71. data/samples/hello/hello_canvas.rb +43 -2
  72. data/samples/hello/hello_checkbox.rb +16 -14
  73. data/samples/hello/hello_checkbox_group.rb +11 -9
  74. data/samples/hello/hello_combo.rb +14 -12
  75. data/samples/hello/hello_computed.rb +7 -7
  76. data/samples/hello/hello_cursor.rb +2 -1
  77. data/samples/hello/hello_custom_shell.rb +17 -21
  78. data/samples/hello/hello_custom_widget.rb +4 -6
  79. data/samples/hello/hello_date_time.rb +14 -12
  80. data/samples/hello/hello_directory_dialog.rb +7 -7
  81. data/samples/hello/hello_expand_bar.rb +8 -8
  82. data/samples/hello/hello_file_dialog.rb +7 -7
  83. data/samples/hello/hello_group.rb +18 -16
  84. data/samples/hello/hello_list_multi_selection.rb +13 -11
  85. data/samples/hello/hello_list_single_selection.rb +13 -11
  86. data/samples/hello/hello_progress_bar.rb +3 -7
  87. data/samples/hello/hello_radio.rb +18 -16
  88. data/samples/hello/hello_radio_group.rb +14 -12
  89. data/samples/hello/hello_spinner.rb +7 -7
  90. data/samples/hello/hello_tab.rb +5 -5
  91. data/samples/hello/hello_table.rb +10 -5
  92. data/samples/hello/hello_tree.rb +485 -0
  93. metadata +17 -18
@@ -24,10 +24,10 @@ class HelloCheckbox
24
24
  attr_accessor :skiing, :snowboarding, :snowmobiling, :snowshoeing
25
25
 
26
26
  def initialize
27
- reset_activities
27
+ reset_activities!
28
28
  end
29
29
 
30
- def reset_activities
30
+ def reset_activities!
31
31
  self.skiing = false
32
32
  self.snowboarding = true
33
33
  self.snowmobiling = false
@@ -35,11 +35,13 @@ class HelloCheckbox
35
35
  end
36
36
  end
37
37
 
38
- include Glimmer
38
+ include Glimmer::UI::CustomShell
39
39
 
40
- def launch
41
- person = Person.new
42
-
40
+ before_body {
41
+ @person = Person.new
42
+ }
43
+
44
+ body {
43
45
  shell {
44
46
  text 'Hello, Checkbox!'
45
47
  row_layout :vertical
@@ -52,22 +54,22 @@ class HelloCheckbox
52
54
  composite {
53
55
  checkbox {
54
56
  text 'Skiing'
55
- selection bind(person, :skiing)
57
+ selection bind(@person, :skiing)
56
58
  }
57
59
 
58
60
  checkbox {
59
61
  text 'Snowboarding'
60
- selection bind(person, :snowboarding)
62
+ selection bind(@person, :snowboarding)
61
63
  }
62
64
 
63
65
  checkbox {
64
66
  text 'Snowmobiling'
65
- selection bind(person, :snowmobiling)
67
+ selection bind(@person, :snowmobiling)
66
68
  }
67
69
 
68
70
  checkbox {
69
71
  text 'Snowshoeing'
70
- selection bind(person, :snowshoeing)
72
+ selection bind(@person, :snowshoeing)
71
73
  }
72
74
  }
73
75
 
@@ -75,11 +77,11 @@ class HelloCheckbox
75
77
  text 'Reset Activities'
76
78
 
77
79
  on_widget_selected do
78
- person.reset_activities
80
+ @person.reset_activities!
79
81
  end
80
82
  }
81
- }.open
82
- end
83
+ }
84
+ }
83
85
  end
84
86
 
85
- HelloCheckbox.new.launch
87
+ HelloCheckbox.launch
@@ -39,11 +39,13 @@ class HelloCheckboxGroup
39
39
  end
40
40
  end
41
41
 
42
- include Glimmer
42
+ include Glimmer::UI::CustomShell
43
43
 
44
- def launch
45
- person = Person.new
46
-
44
+ before_body {
45
+ @person = Person.new
46
+ }
47
+
48
+ body {
47
49
  shell {
48
50
  text 'Hello, Checkbox Group!'
49
51
  row_layout :vertical
@@ -54,18 +56,18 @@ class HelloCheckboxGroup
54
56
  }
55
57
 
56
58
  checkbox_group {
57
- selection bind(person, :activities)
59
+ selection bind(@person, :activities)
58
60
  }
59
61
 
60
62
  button {
61
63
  text 'Reset Activities'
62
64
 
63
65
  on_widget_selected do
64
- person.reset_activities
66
+ @person.reset_activities
65
67
  end
66
68
  }
67
- }.open
68
- end
69
+ }
70
+ }
69
71
  end
70
72
 
71
- HelloCheckboxGroup.new.launch
73
+ HelloCheckboxGroup.launch
@@ -25,39 +25,41 @@ class HelloCombo
25
25
 
26
26
  def initialize
27
27
  self.country_options = ['', 'Canada', 'US', 'Mexico']
28
- reset_country
28
+ reset_country!
29
29
  end
30
30
 
31
- def reset_country
31
+ def reset_country!
32
32
  self.country = 'Canada'
33
33
  end
34
34
  end
35
35
 
36
- include Glimmer
36
+ include Glimmer::UI::CustomShell
37
37
 
38
- def launch
39
- person = Person.new
40
-
38
+ before_body {
39
+ @person = Person.new
40
+ }
41
+
42
+ body {
41
43
  shell {
42
44
  row_layout(:vertical) {
43
- pack false
45
+ fill true
44
46
  }
45
47
 
46
48
  text 'Hello, Combo!'
47
49
 
48
50
  combo(:read_only) {
49
- selection bind(person, :country) # also binds to country_options by convention
51
+ selection bind(@person, :country) # also binds to country_options by convention
50
52
  }
51
53
 
52
54
  button {
53
55
  text 'Reset Selection'
54
56
 
55
57
  on_widget_selected do
56
- person.reset_country
58
+ @person.reset_country!
57
59
  end
58
60
  }
59
- }.open
60
- end
61
+ }
62
+ }
61
63
  end
62
64
 
63
- HelloCombo.new.launch
65
+ HelloCombo.launch
@@ -22,17 +22,17 @@
22
22
  require_relative 'hello_computed/contact'
23
23
 
24
24
  class HelloComputed
25
- include Glimmer
25
+ include Glimmer::UI::CustomShell
26
26
 
27
- def initialize
27
+ before_body {
28
28
  @contact = Contact.new(
29
29
  first_name: 'Barry',
30
30
  last_name: 'McKibbin',
31
31
  year_of_birth: 1985
32
32
  )
33
- end
33
+ }
34
34
 
35
- def launch
35
+ body {
36
36
  shell {
37
37
  text 'Hello, Computed!'
38
38
 
@@ -89,8 +89,8 @@ class HelloComputed
89
89
  }
90
90
  }
91
91
  }
92
- }.open
93
- end
92
+ }
93
+ }
94
94
  end
95
95
 
96
- HelloComputed.new.launch
96
+ HelloComputed.launch
@@ -24,8 +24,9 @@ class HelloCursor
24
24
 
25
25
  attr_accessor :selected_cursor
26
26
 
27
+ # This method matches the name of the :selected_cursor property by convention
27
28
  def selected_cursor_options
28
- org.eclipse.swt.SWT.constants.select {|c| c.to_s.start_with?('CURSOR_')}.map {|c| c.to_s.sub('CURSOR_', '').downcase}
29
+ Glimmer::SWT::SWTProxy.cursor_options
29
30
  end
30
31
 
31
32
  after_body {
@@ -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
@@ -24,10 +24,11 @@ require 'date'
24
24
  # This class declares an `email_shell` custom shell, aka custom window (by convention)
25
25
  # Used to view an email message
26
26
  class EmailShell
27
+ # including Glimmer::UI::CustomShell enables declaring as an `email_shell` custom widget Glimmer GUI DSL keyword
27
28
  include Glimmer::UI::CustomShell
28
29
 
29
- # multiple options without default values
30
- options :date, :subject, :from, :message
30
+ # multiple options without default values
31
+ options :parent_shell, :date, :subject, :from, :message
31
32
 
32
33
  # single option with default value
33
34
  option :to, default: '"John Irwin" <john.irwin@example.com>'
@@ -38,10 +39,10 @@ class EmailShell
38
39
 
39
40
  body {
40
41
  # pass received swt_style through to shell to customize it (e.g. :dialog_trim for a blocking shell)
41
- shell(swt_style) {
42
+ shell(parent_shell, swt_style) {
42
43
  grid_layout(2, false)
43
44
 
44
- text subject
45
+ text subject
45
46
 
46
47
  label {
47
48
  text 'Date:'
@@ -78,7 +79,7 @@ class EmailShell
78
79
  }
79
80
 
80
81
  background :white
81
- text message
82
+ text message
82
83
  }
83
84
  }
84
85
  }
@@ -86,13 +87,12 @@ class EmailShell
86
87
  end
87
88
 
88
89
  class HelloCustomShell
89
- # including Glimmer enables the Glimmer DSL syntax, including auto-discovery of the `email_shell` custom widget
90
- include Glimmer
90
+ include Glimmer::UI::CustomShell
91
91
 
92
92
  Email = Struct.new(:date, :subject, :from, :message, keyword_init: true)
93
93
  EmailSystem = Struct.new(:emails, keyword_init: true)
94
94
 
95
- def initialize
95
+ before_body {
96
96
  @email_system = EmailSystem.new(
97
97
  emails: [
98
98
  Email.new(date: DateTime.new(2029, 10, 22, 11, 3, 0).strftime('%F %I:%M %p'), subject: '3rd Week Report', from: '"Dianne Tux" <dianne.tux@example.com>', message: "Hello,\n\nI was wondering if you'd like to go over the weekly report sometime this afternoon.\n\nDianne"),
@@ -103,9 +103,9 @@ class HelloCustomShell
103
103
  Email.new(date: DateTime.new(2029, 10, 2, 10, 34, 0).strftime('%F %I:%M %p'), subject: 'Glimmer Upgrade v98.0', from: '"Robert McGabbins" <robert.mcgabbins@example.com>', message: "Team,\n\nWe are upgrading to Glimmer version 98.0.\n\nEveryone pull the latest code!\n\nRegards,\n\nRobert McGabbins"),
104
104
  ]
105
105
  )
106
- end
106
+ }
107
107
 
108
- def launch
108
+ body {
109
109
  shell {
110
110
  grid_layout
111
111
 
@@ -141,15 +141,11 @@ class HelloCustomShell
141
141
 
142
142
  on_mouse_up { |event|
143
143
  email = event.table_item.get_data
144
- Thread.new do
145
- async_exec {
146
- email_shell(date: email.date, subject: email.subject, from: email.from, message: email.message).open
147
- }
148
- end
144
+ email_shell(parent_shell: self, date: email.date, subject: email.subject, from: email.from, message: email.message).open
149
145
  }
150
146
  }
151
- }.open
152
- end
147
+ }
148
+ }
153
149
  end
154
150
 
155
- HelloCustomShell.new.launch
151
+ HelloCustomShell.launch
@@ -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
@@ -42,9 +42,7 @@ class GreetingLabel
42
42
 
43
43
  Thread.new {
44
44
  colors.cycle { |color|
45
- async_exec {
46
- self.color = color
47
- }
45
+ self.color = color
48
46
  sleep(1)
49
47
  }
50
48
  }
@@ -24,12 +24,14 @@ class HelloDateTime
24
24
  attr_accessor :date_of_birth
25
25
  end
26
26
 
27
- include Glimmer
27
+ include Glimmer::UI::CustomShell
28
28
 
29
- def launch
30
- person = Person.new
31
- person.date_of_birth = DateTime.new(2013, 7, 12, 18, 37, 23)
32
-
29
+ before_body {
30
+ @person = Person.new
31
+ @person.date_of_birth = DateTime.new(2013, 7, 12, 18, 37, 23)
32
+ }
33
+
34
+ body {
33
35
  shell {
34
36
  row_layout :vertical
35
37
 
@@ -42,22 +44,22 @@ class HelloDateTime
42
44
  }
43
45
 
44
46
  date { # alias for date_time(:date)
45
- date_time bind(person, :date_of_birth)
47
+ date_time bind(@person, :date_of_birth)
46
48
  }
47
49
 
48
50
  date_drop_down { # alias for date_time(:date, :drop_down)
49
- date_time bind(person, :date_of_birth)
51
+ date_time bind(@person, :date_of_birth)
50
52
  }
51
53
 
52
54
  time { # alias for date_time(:time)
53
- date_time bind(person, :date_of_birth)
55
+ date_time bind(@person, :date_of_birth)
54
56
  }
55
57
 
56
58
  calendar { # alias for date_time(:calendar)
57
- date_time bind(person, :date_of_birth)
59
+ date_time bind(@person, :date_of_birth)
58
60
  }
59
- }.open
60
- end
61
+ }
62
+ }
61
63
  end
62
64
 
63
- HelloDateTime.new.launch
65
+ HelloDateTime.launch
@@ -20,15 +20,15 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  class HelloDirectoryDialog
23
- include Glimmer
23
+ include Glimmer::UI::CustomShell
24
24
 
25
25
  attr_accessor :selected_directory
26
26
 
27
- def initialize
27
+ before_body {
28
28
  @selected_directory = 'Please select a directory.'
29
- end
29
+ }
30
30
 
31
- def launch
31
+ body {
32
32
  shell {
33
33
  minimum_size 400, 0
34
34
  grid_layout
@@ -53,8 +53,8 @@ class HelloDirectoryDialog
53
53
  self.selected_directory = directory_dialog.open
54
54
  }
55
55
  }
56
- }.open
57
- end
56
+ }
57
+ }
58
58
  end
59
59
 
60
- HelloDirectoryDialog.new.launch
60
+ HelloDirectoryDialog.launch
@@ -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
@@ -20,9 +20,9 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  class HelloExpandBar
23
- include Glimmer
23
+ include Glimmer::UI::CustomShell
24
24
 
25
- def launch
25
+ body {
26
26
  shell {
27
27
  grid_layout(1, false) {
28
28
  margin_width 0
@@ -103,8 +103,8 @@ class HelloExpandBar
103
103
  }
104
104
 
105
105
  }
106
- }.open
107
- end
106
+ }
107
+ }
108
108
  end
109
109
 
110
- HelloExpandBar.new.launch
110
+ HelloExpandBar.launch