glimmer-dsl-swt 4.17.5.0 → 4.17.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2111fbe2df8040f64a319e5e62b15982cdc4749a6cd0c548b97f2b37f01b276
4
- data.tar.gz: 283eb8a7a8faedde6ab6224ebe06fda3fca7cdff44ec99b32baca35da9df7d04
3
+ metadata.gz: 50dd550729725e788ad32393c82aa34c1e39cbc536b0bfce60734603c052b1cf
4
+ data.tar.gz: 19cf9cb269726720dac30ebf82d458afc1c535861153be8e3fad8ba0864f4a5f
5
5
  SHA512:
6
- metadata.gz: 2cb656a29e5d9da0759b295bc5dba9f1a174e8a83a1ffa2921c4b5efb6fd10542f0a46e475807cbd884c7f14270afa0983b5e49b392f97e9ddd41a6a4ecbbf30
7
- data.tar.gz: 9283a302b3aaa99f5ec50f0d0996b951bb72ce0309ae9ca978429621d81f14c4005251286229d3555f31754c0e9a727db2f15f9245fab28f902ef1456e1fa07e
6
+ metadata.gz: f2dffb27676fc7884bd58927e1648677ec972b56b56fdd9a6162c99e252fe6018b3f135766abf739a215d46398136422bdf656a52832821b326b6c02dbed9a8a
7
+ data.tar.gz: 93c4fb967105b1271e3425155ccb3e5e71acb796d63eac3990a984fc0094708ec7be11faf0f9f0760c5c16e3168a6e477d6737bca444801c4425556458978a81
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.17.6.0
4
+
5
+ - New `radio_group` built-in Glimmer custom widget
6
+ - Hello, Radio! Sample
7
+ - Hello, Radio Group! Sample
8
+ - Hello, Checkbox! Sample
9
+
3
10
  ### 4.17.5.0
4
11
 
5
12
  - Support auto-scaling by aspect ratio of width and height (write specs)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 4.17.5.0
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 4.17.6.0
2
2
  ## JRuby Desktop Development GUI Library
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
4
4
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
@@ -14,6 +14,10 @@
14
14
 
15
15
  [Glimmer receives two updates per month](https://rubygems.org/gems/glimmer-dsl-swt/versions). You can trust [Glimmer](https://rubygems.org/gems/glimmer) with your Ruby desktop GUI development needs. Please make [Glimmer](https://rubygems.org/gems/glimmer) even better by providing feedback and [contributing](#contributing) when possible.
16
16
 
17
+ Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT.
18
+
19
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) versions 4.17.x.y come with [SWT 4.17](https://download.eclipse.org/eclipse/downloads/drops4/R-4.17-202009021800/), which was released on September 2, 2020.
20
+
17
21
  [<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
18
22
  Featured in<br />JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do)
19
23
 
@@ -343,6 +347,9 @@ Glimmer App:
343
347
  - [Hello, Sash Form!](#hello-sash-form)
344
348
  - [Hello, Styled Text!](#hello-styled-text)
345
349
  - [Hello, Expand Bar!](#hello-expand-bar)
350
+ - [Hello, Radio!](#hello-radio)
351
+ - [Hello, Radio Group!](#hello-radio-group)
352
+ - [Hello, Checkbox!](#hello-checkbox)
346
353
  - [Elaborate Samples](#elaborate-samples)
347
354
  - [User Profile](#user-profile)
348
355
  - [Login](#login)
@@ -436,11 +443,9 @@ jgem install glimmer-dsl-swt
436
443
 
437
444
  Or this command if you want a specific version:
438
445
  ```
439
- jgem install glimmer-dsl-swt -v 4.17.5.0
446
+ jgem install glimmer-dsl-swt -v 4.17.6.0
440
447
  ```
441
448
 
442
- Note: Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT.
443
-
444
449
  `jgem` is JRuby's version of `gem` command.
445
450
  RVM allows running `gem install` directly as an alias.
446
451
  Otherwise, you may also run `jruby -S gem install ...`
@@ -514,7 +519,7 @@ bin/glimmer samples
514
519
  Below are the full usage instructions that come up when running `glimmer` without args.
515
520
 
516
521
  ```
517
- Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.5.0
522
+ Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.6.0
518
523
 
519
524
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
520
525
 
@@ -991,7 +996,7 @@ Output:
991
996
 
992
997
  Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
993
998
  Opal glimmer-dsl-opal 0.4.0 AndyMaleh Glimmer DSL for Opal
994
- Swt glimmer-dsl-swt 4.17.5.0 AndyMaleh Glimmer DSL for SWT
999
+ Swt glimmer-dsl-swt 4.17.6.0 AndyMaleh Glimmer DSL for SWT
995
1000
  Tk glimmer-dsl-tk 0.0.6 AndyMaleh Glimmer DSL for Tk
996
1001
  Xml glimmer-dsl-xml 1.1.0 AndyMaleh Glimmer DSL for XML
997
1002
  ```
@@ -3643,6 +3648,42 @@ Hello, Expand Bar! Reading Expanded
3643
3648
 
3644
3649
  ![Hello Expand Bar Reading Expanded](images/glimmer-hello-expand-bar-reading-expanded.png)
3645
3650
 
3651
+ #### Hello, Radio!
3652
+
3653
+ This sample demonstrates the use of a `radio` (aka `button(:radio)`) in Glimmer.
3654
+
3655
+ Code:
3656
+
3657
+ [samples/hello/hello_radio.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_radio.rb)
3658
+
3659
+ Hello, Radio!
3660
+
3661
+ ![Hello Radio](images/glimmer-hello-radio.png)
3662
+
3663
+ #### Hello, Radio Group!
3664
+
3665
+ This sample demonstrates the use of a `radio_group` in Glimmer, which is a terser way of representing multiple radio buttons by relying on data-binding to automatically spawn the `radio` widgets based on available options on the model.
3666
+
3667
+ Code:
3668
+
3669
+ [samples/hello/hello_radio_group.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_radio_group.rb)
3670
+
3671
+ Hello, Radio Group!
3672
+
3673
+ ![Hello Radio Group](images/glimmer-hello-radio-group.png)
3674
+
3675
+ #### Hello, Checkbox!
3676
+
3677
+ This sample demonstrates the use of a `checkbox` (aka `check` or `button(:check)`) in Glimmer.
3678
+
3679
+ Code:
3680
+
3681
+ [samples/hello/hello_checkbox.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_checkbox.rb)
3682
+
3683
+ Hello, Checkbox!
3684
+
3685
+ ![Hello Checkbox](images/glimmer-hello-checkbox.png)
3686
+
3646
3687
  ### Elaborate Samples
3647
3688
 
3648
3689
  For more elaborate samples, check the following:
@@ -3955,6 +3996,7 @@ Here is a list of notable 3rd party gems used by Glimmer:
3955
3996
  - [puts_debuggerer](https://github.com/AndyObtiva/puts_debuggerer): helps in troubleshooting when adding `require 'pd'` and using the `pd` command instead of `puts` or `p` (also `#pd_inspect` or `#pdi` instead of `#inspect`)
3956
3997
  - [rake](https://github.com/ruby/rake): used to implement and execute `glimmer` commands
3957
3998
  - [rake-tui](https://github.com/AndyObtiva/rake-tui): Rake Text-based User Interface. Allows navigating rake tasks with arrow keys and filtering task list by typing to quickly find an run a rake task.
3999
+ - [rouge](https://github.com/rouge-ruby/rouge): Ruby syntax highlighter used in the `code_text` [Glimmer DSL for SWT custom widget](#custom-widgets) leveraged by the [Glimmer Meta-Sample](#samples)
3958
4000
  - [super_module](https://github.com/AndyObtiva/super_module): used to cleanly write the Glimmer::UI:CustomWidget and Glimmer::UI::CustomShell modules
3959
4001
  - [text-table](https://github.com/aptinio/text-table): renders textual data in a textual table for the command-line interface of Glimmer
3960
4002
  - [warbler](https://github.com/jruby/warbler): converts a Glimmer app into a Java JAR file during packaging
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.17.5.0
1
+ 4.17.6.0
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: glimmer-dsl-swt 4.17.5.0 ruby lib
5
+ # stub: glimmer-dsl-swt 4.17.6.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-swt".freeze
9
- s.version = "4.17.5.0"
9
+ s.version = "4.17.6.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["AndyMaleh".freeze]
14
- s.date = "2020-10-24"
14
+ s.date = "2020-10-28"
15
15
  s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Library)".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
17
  s.executables = ["glimmer".freeze, "girb".freeze]
@@ -67,6 +67,7 @@ Gem::Specification.new do |s|
67
67
  "lib/glimmer/dsl/swt/message_box_expression.rb",
68
68
  "lib/glimmer/dsl/swt/observe_expression.rb",
69
69
  "lib/glimmer/dsl/swt/property_expression.rb",
70
+ "lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb",
70
71
  "lib/glimmer/dsl/swt/rgb_expression.rb",
71
72
  "lib/glimmer/dsl/swt/rgba_expression.rb",
72
73
  "lib/glimmer/dsl/swt/shell_expression.rb",
@@ -86,6 +87,7 @@ Gem::Specification.new do |s|
86
87
  "lib/glimmer/swt/color_proxy.rb",
87
88
  "lib/glimmer/swt/cursor_proxy.rb",
88
89
  "lib/glimmer/swt/custom/code_text.rb",
90
+ "lib/glimmer/swt/custom/radio_group.rb",
89
91
  "lib/glimmer/swt/display_proxy.rb",
90
92
  "lib/glimmer/swt/dnd_proxy.rb",
91
93
  "lib/glimmer/swt/expand_item_proxy.rb",
@@ -122,6 +124,7 @@ Gem::Specification.new do |s|
122
124
  "samples/elaborate/tic_tac_toe/cell.rb",
123
125
  "samples/elaborate/user_profile.rb",
124
126
  "samples/hello/hello_browser.rb",
127
+ "samples/hello/hello_checkbox.rb",
125
128
  "samples/hello/hello_combo.rb",
126
129
  "samples/hello/hello_computed.rb",
127
130
  "samples/hello/hello_computed/contact.rb",
@@ -134,6 +137,8 @@ Gem::Specification.new do |s|
134
137
  "samples/hello/hello_menu_bar.rb",
135
138
  "samples/hello/hello_message_box.rb",
136
139
  "samples/hello/hello_pop_up_context_menu.rb",
140
+ "samples/hello/hello_radio.rb",
141
+ "samples/hello/hello_radio_group.rb",
137
142
  "samples/hello/hello_sash_form.rb",
138
143
  "samples/hello/hello_styled_text.rb",
139
144
  "samples/hello/hello_tab.rb",
@@ -153,7 +158,7 @@ Gem::Specification.new do |s|
153
158
  end
154
159
 
155
160
  if s.respond_to? :add_runtime_dependency then
156
- s.add_runtime_dependency(%q<glimmer>.freeze, ["~> 1.0.1"])
161
+ s.add_runtime_dependency(%q<glimmer>.freeze, ["~> 1.0.2"])
157
162
  s.add_runtime_dependency(%q<super_module>.freeze, ["~> 1.4.1"])
158
163
  s.add_runtime_dependency(%q<nested_inherited_jruby_include_package>.freeze, ["~> 0.3.0"])
159
164
  s.add_runtime_dependency(%q<puts_debuggerer>.freeze, ["~> 0.10.2"])
@@ -172,7 +177,7 @@ Gem::Specification.new do |s|
172
177
  s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.16.1"])
173
178
  s.add_development_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
174
179
  else
175
- s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.1"])
180
+ s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.2"])
176
181
  s.add_dependency(%q<super_module>.freeze, ["~> 1.4.1"])
177
182
  s.add_dependency(%q<nested_inherited_jruby_include_package>.freeze, ["~> 0.3.0"])
178
183
  s.add_dependency(%q<puts_debuggerer>.freeze, ["~> 0.10.2"])
@@ -26,6 +26,7 @@ require 'glimmer/dsl/top_level_expression'
26
26
  require 'glimmer/ui/custom_widget'
27
27
  require 'glimmer/ui/custom_shell'
28
28
  require 'glimmer/swt/custom/code_text'
29
+ require 'glimmer/swt/custom/radio_group'
29
30
 
30
31
  module Glimmer
31
32
  module DSL
@@ -41,6 +41,7 @@ module Glimmer
41
41
  layout
42
42
  widget_listener
43
43
  combo_selection_data_binding
44
+ radio_group_selection_data_binding
44
45
  list_selection_data_binding
45
46
  tree_items_data_binding
46
47
  table_items_data_binding
@@ -0,0 +1,61 @@
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
+ require 'glimmer/dsl/expression'
23
+ require 'glimmer/data_binding/model_binding'
24
+ require 'glimmer/data_binding/widget_binding'
25
+
26
+ module Glimmer
27
+ module DSL
28
+ module SWT
29
+ class RadioGroupSelectionDataBindingExpression < Expression
30
+
31
+ def can_interpret?(parent, keyword, *args, &block)
32
+ keyword == 'selection' and
33
+ block.nil? and
34
+ (parent.is_a?(Glimmer::SWT::Custom::RadioGroup) or (parent.is_a?(Glimmer::UI::CustomWidget) and parent.body_root.is_a?(Glimmer::SWT::Custom::RadioGroup)) ) and
35
+ args.size == 1 and
36
+ args[0].is_a?(DataBinding::ModelBinding) and
37
+ args[0].evaluate_options_property.is_a?(Array)
38
+ end
39
+
40
+ def interpret(parent, keyword, *args, &block)
41
+ model_binding = args[0]
42
+
43
+ #TODO make this options observer dependent and all similar observers in widget specific data binding handlers
44
+ # TODO consider delegating some of this work
45
+ widget_binding = DataBinding::WidgetBinding.new(parent, 'items')
46
+ widget_binding.call(model_binding.evaluate_options_property)
47
+ model = model_binding.base_model
48
+ widget_binding.observe(model, model_binding.options_property_name)
49
+
50
+ widget_binding = DataBinding::WidgetBinding.new(parent, 'selection')
51
+ widget_binding.call(model_binding.evaluate_property)
52
+ widget_binding.observe(model, model_binding.property_name_expression)
53
+
54
+ parent.on_widget_selected do
55
+ model_binding.call(widget_binding.evaluate_property)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,101 @@
1
+ require 'glimmer/ui/custom_widget'
2
+
3
+ module Glimmer
4
+ module SWT
5
+ module Custom
6
+ # CodeText is a customization of StyledText with support for Ruby Syntax Highlighting
7
+ class RadioGroup
8
+ include Glimmer::UI::CustomWidget
9
+
10
+ # TODO support setting font, background, foreground, cursor
11
+
12
+ body {
13
+ composite # just an empty composite to hold radios upon data-binding `selection`
14
+ }
15
+
16
+ def items=(text_array)
17
+ selection_value = selection
18
+ @items = Array[*text_array]
19
+ build_radios
20
+ end
21
+
22
+ def items
23
+ @items
24
+ end
25
+
26
+ def selection=(text)
27
+ radios.each do |radio|
28
+ radio.selection = radio.text == text
29
+ end
30
+ end
31
+
32
+ def selection
33
+ # TODO use labels to retrieve text since they are better customizable with fonts while maintaining alignment with radio buttons
34
+ radios.detect(&:selection)&.text.to_s
35
+ end
36
+
37
+ def selection_index=(index)
38
+ self.selection=(items[index])
39
+ end
40
+ alias select selection_index=
41
+
42
+ def selection_index
43
+ radios.index(radios.detect(&:selection)) || -1
44
+ end
45
+
46
+ def radios
47
+ @radios ||= []
48
+ end
49
+
50
+ def can_handle_observation_request?(observation_request)
51
+ radios.first&.can_handle_observation_request?(observation_request) || super(observation_request)
52
+ end
53
+
54
+ def handle_observation_request(observation_request, &block)
55
+ observation_requests << [observation_request, block]
56
+ delegate_observation_request_to_radios(observation_request, &block)
57
+ super
58
+ end
59
+
60
+ def delegate_observation_request_to_radios(observation_request, &block)
61
+ if observation_request != 'on_widget_disposed' && radios.first&.can_handle_observation_request?(observation_request)
62
+ radios.each do |radio|
63
+ radio_block = lambda do |event|
64
+ if event.widget.selection || selection_index == -1
65
+ event.widget = self.swt_widget
66
+ block.call(event)
67
+ end
68
+ end
69
+ radio.handle_observation_request(observation_request, &block)
70
+ end
71
+ end
72
+ end
73
+
74
+ def observation_requests
75
+ @observation_requests ||= Set.new
76
+ end
77
+
78
+ private
79
+
80
+ def build_radios
81
+ # TODO consider doing a diff instead of disposing and rebuilding everything in the future
82
+ # TODO add labels since they are better customizable with fonts while maintaining alignment with radio buttons
83
+ current_selection = selection
84
+ radios.each(&:dispose) # TODO take care of the fact that dispose removes the observers attached
85
+ @radios = []
86
+ items.each do |item|
87
+ body_root.content {
88
+ radios << radio {
89
+ text item
90
+ }
91
+ }
92
+ end
93
+ observation_requests.to_a.each do |observation_request, block|
94
+ delegate_observation_request_to_radios(observation_request, &block)
95
+ end
96
+ self.selection = current_selection
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
@@ -116,7 +116,7 @@ module Glimmer
116
116
  else
117
117
  menu_item_proxy.handle_observation_request(observation_request, &block)
118
118
  end
119
- end
119
+ end
120
120
  end
121
121
  end
122
122
  end
@@ -213,6 +213,7 @@ module Glimmer
213
213
  def has_instance_method?(method_name)
214
214
  respond_to?(method_name) and
215
215
  !swt_widget&.respond_to?(method_name) and
216
+ (method(method_name) rescue nil) and
216
217
  !method(method_name)&.source_location&.first&.include?('glimmer/dsl/engine.rb') and
217
218
  !method(method_name)&.source_location&.first&.include?('glimmer/swt/widget_proxy.rb')
218
219
  end
@@ -255,6 +256,8 @@ module Glimmer
255
256
  end
256
257
 
257
258
  def method_missing(method, *args, &block)
259
+ # TODO Consider supporting a glimmer error silencing option for methods defined here
260
+ # but fail the glimmer DSL for the right reason to avoid seeing noise in the log output
258
261
  if can_handle_observation_request?(method)
259
262
  handle_observation_request(method, &block)
260
263
  else
@@ -0,0 +1,85 @@
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
+ class Person
23
+ attr_accessor :skiing, :snowboarding, :snowmobiling, :snowshoeing
24
+
25
+ def initialize
26
+ reset_activities
27
+ end
28
+
29
+ def reset_activities
30
+ self.skiing = false
31
+ self.snowboarding = true
32
+ self.snowmobiling = false
33
+ self.snowshoeing = false
34
+ end
35
+ end
36
+
37
+ class HelloCheckbox
38
+ include Glimmer
39
+
40
+ def launch
41
+ person = Person.new
42
+
43
+ shell {
44
+ text 'Hello, Checkbox!'
45
+ row_layout :vertical
46
+
47
+ label {
48
+ text 'Check all snow activities you are interested in:'
49
+ font style: :bold
50
+ }
51
+
52
+ composite {
53
+ checkbox {
54
+ text 'Skiing'
55
+ selection bind(person, :skiing)
56
+ }
57
+
58
+ checkbox {
59
+ text 'Snowboarding'
60
+ selection bind(person, :snowboarding)
61
+ }
62
+
63
+ checkbox {
64
+ text 'Snowmobiling'
65
+ selection bind(person, :snowmobiling)
66
+ }
67
+
68
+ checkbox {
69
+ text 'Snowshoeing'
70
+ selection bind(person, :snowshoeing)
71
+ }
72
+ }
73
+
74
+ button {
75
+ text 'Reset Activities'
76
+
77
+ on_widget_selected do
78
+ person.reset_activities
79
+ end
80
+ }
81
+ }.open
82
+ end
83
+ end
84
+
85
+ HelloCheckbox.new.launch
@@ -0,0 +1,108 @@
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
+ class Person
23
+ attr_accessor :male, :female, :child, :teen, :adult, :senior
24
+
25
+ def initialize
26
+ reset
27
+ end
28
+
29
+ def reset
30
+ self.male = nil
31
+ self.female = nil
32
+ self.child = nil
33
+ self.teen = nil
34
+ self.adult = true
35
+ self.senior = nil
36
+ end
37
+ end
38
+
39
+ class HelloRadio
40
+ include Glimmer
41
+
42
+ def launch
43
+ person = Person.new
44
+
45
+ shell {
46
+ text 'Hello, Radio!'
47
+ row_layout :vertical
48
+
49
+ label {
50
+ text 'Gender:'
51
+ font style: :bold
52
+ }
53
+
54
+ composite {
55
+ row_layout
56
+
57
+ radio {
58
+ text 'Male'
59
+ selection bind(person, :male)
60
+ }
61
+
62
+ radio {
63
+ text 'Female'
64
+ selection bind(person, :female)
65
+ }
66
+ }
67
+
68
+ label {
69
+ text 'Age Group:'
70
+ font style: :bold
71
+ }
72
+
73
+ composite {
74
+ row_layout
75
+
76
+ radio {
77
+ text 'Child'
78
+ selection bind(person, :child)
79
+ }
80
+
81
+ radio {
82
+ text 'Teen'
83
+ selection bind(person, :teen)
84
+ }
85
+
86
+ radio {
87
+ text 'Adult'
88
+ selection bind(person, :adult)
89
+ }
90
+
91
+ radio {
92
+ text 'Senior'
93
+ selection bind(person, :senior)
94
+ }
95
+ }
96
+
97
+ button {
98
+ text 'Reset'
99
+
100
+ on_widget_selected do
101
+ person.reset
102
+ end
103
+ }
104
+ }.open
105
+ end
106
+ end
107
+
108
+ HelloRadio.new.launch
@@ -0,0 +1,84 @@
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
+ class Person
23
+ attr_accessor :gender, :age_group
24
+
25
+ def initialize
26
+ reset
27
+ end
28
+
29
+ def gender_options
30
+ ['Male', 'Female']
31
+ end
32
+
33
+ def age_group_options
34
+ ['Child', 'Teen', 'Adult', 'Senior']
35
+ end
36
+
37
+ def reset
38
+ self.gender = nil
39
+ self.age_group = 'Adult'
40
+ end
41
+ end
42
+
43
+ class HelloRadioGroup
44
+ include Glimmer
45
+
46
+ def launch
47
+ person = Person.new
48
+
49
+ shell {
50
+ text 'Hello, Radio Group!'
51
+ row_layout :vertical
52
+
53
+ label {
54
+ text 'Gender:'
55
+ font style: :bold
56
+ }
57
+
58
+ radio_group {
59
+ row_layout :horizontal
60
+ selection bind(person, :gender)
61
+ }
62
+
63
+ label {
64
+ text 'Age Group:'
65
+ font style: :bold
66
+ }
67
+
68
+ radio_group {
69
+ row_layout :horizontal
70
+ selection bind(person, :age_group)
71
+ }
72
+
73
+ button {
74
+ text 'Reset'
75
+
76
+ on_widget_selected do
77
+ person.reset
78
+ end
79
+ }
80
+ }.open
81
+ end
82
+ end
83
+
84
+ HelloRadioGroup.new.launch
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-swt
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.17.5.0
4
+ version: 4.17.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-24 00:00:00.000000000 Z
11
+ date: 2020-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 1.0.1
18
+ version: 1.0.2
19
19
  name: glimmer
20
20
  prerelease: false
21
21
  type: :runtime
@@ -23,7 +23,7 @@ dependencies:
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.1
26
+ version: 1.0.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
@@ -367,6 +367,7 @@ files:
367
367
  - lib/glimmer/dsl/swt/message_box_expression.rb
368
368
  - lib/glimmer/dsl/swt/observe_expression.rb
369
369
  - lib/glimmer/dsl/swt/property_expression.rb
370
+ - lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb
370
371
  - lib/glimmer/dsl/swt/rgb_expression.rb
371
372
  - lib/glimmer/dsl/swt/rgba_expression.rb
372
373
  - lib/glimmer/dsl/swt/shell_expression.rb
@@ -386,6 +387,7 @@ files:
386
387
  - lib/glimmer/swt/color_proxy.rb
387
388
  - lib/glimmer/swt/cursor_proxy.rb
388
389
  - lib/glimmer/swt/custom/code_text.rb
390
+ - lib/glimmer/swt/custom/radio_group.rb
389
391
  - lib/glimmer/swt/display_proxy.rb
390
392
  - lib/glimmer/swt/dnd_proxy.rb
391
393
  - lib/glimmer/swt/expand_item_proxy.rb
@@ -422,6 +424,7 @@ files:
422
424
  - samples/elaborate/tic_tac_toe/cell.rb
423
425
  - samples/elaborate/user_profile.rb
424
426
  - samples/hello/hello_browser.rb
427
+ - samples/hello/hello_checkbox.rb
425
428
  - samples/hello/hello_combo.rb
426
429
  - samples/hello/hello_computed.rb
427
430
  - samples/hello/hello_computed/contact.rb
@@ -434,6 +437,8 @@ files:
434
437
  - samples/hello/hello_menu_bar.rb
435
438
  - samples/hello/hello_message_box.rb
436
439
  - samples/hello/hello_pop_up_context_menu.rb
440
+ - samples/hello/hello_radio.rb
441
+ - samples/hello/hello_radio_group.rb
437
442
  - samples/hello/hello_sash_form.rb
438
443
  - samples/hello/hello_styled_text.rb
439
444
  - samples/hello/hello_tab.rb