glimmer-dsl-swt 4.20.14.1 → 4.20.15.2

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: ec68532348a4c8220d559e24a66c7cc99267435e0b72c4f8a679892dd7694f25
4
- data.tar.gz: aa9aa58f9016734f4fa8357c6002f8be6243e474163b612922cc7127bd349dd9
3
+ metadata.gz: dda4e5ffd1bd606b7a442ed334df93dfe00bcbd69c24bb9aa76ef367e1c23f0b
4
+ data.tar.gz: 94836b2214a7db325c43a5ddb456eb6769f5f1c004005a7d16a14af5840398c0
5
5
  SHA512:
6
- metadata.gz: 0e8174b81dd1ce045649be34d1c46507020b659904fb981c51175920c0909d1bfa1f68d3e9087a3fe6c3d7509da030abe166bbbb4eea44d297a6ad1fc93c33f7
7
- data.tar.gz: 698085d81b8f2e071101fcb0ed58a5b14a346a80f15ad3a195048278a54737c1550e3cc4007a4c75649fef23689e25b2f8721ab66fb40300d9d3c76f47a71078
6
+ metadata.gz: 44fed7644c47f57da144bce6338af41e7af8752dbe3e3e44c403f81a6ef95dfad58db43b5b9fbcc1229ff9efe1dde6ccbb378fd03203758e6b0d660169ed6c0a
7
+ data.tar.gz: cb7a1a73c59fde48269685d858b8ec0a8e43a4b14ed87478bac5022da3d1a2cc91144c83670ebf95276d410a1d33b492bd8cee70e46137a6540405666f8e9adc
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.20.15.2
4
+
5
+ - Fixed `widget#print` support and Hello, Print Dialog! handling of cancellation of printing
6
+
7
+ ### 4.20.15.1
8
+
9
+ - Glimmer Clock elaborate sample
10
+
11
+ ### 4.20.15.0
12
+
13
+ - Hello, Print Dialog!
14
+ - Hello, Print!
15
+ - `widget#print` method that automates work in Hello, Print Dialog! and is used in Hello, Print!
16
+
17
+ ### 4.20.14.2
18
+
19
+ - Hello, Toggle!
20
+
3
21
  ### 4.20.14.1
4
22
 
5
23
  - Upgrade to Glimmer 2.1.1
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.20.14.1
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.20.15.2
2
2
  ## JRuby Desktop Development GUI Framework
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)
@@ -15,7 +15,7 @@
15
15
  [<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
16
16
  Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) and [Chalmers/Gothenburg University Software Engineering Master's Lecture Material](http://www.cse.chalmers.se/~bergert/slides/guest_lecture_DSLs.pdf)
17
17
 
18
- [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.14.1 includes [SWT 4.20](https://download.eclipse.org/eclipse/downloads/drops4/R-4.20-202106111600/), which was released on June 11, 2021. 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. Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested in Glimmer DSL for SWT yet, so deem its support experimental for the time being without guarantees for functionality until declared otherwise (please report any issues you may encounter).
18
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.15.2 includes [SWT 4.20](https://download.eclipse.org/eclipse/downloads/drops4/R-4.20-202106111600/), which was released on June 11, 2021. 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. Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested in Glimmer DSL for SWT yet, so deem its support experimental for the time being without guarantees for functionality until declared otherwise (please report any issues you may encounter).
19
19
 
20
20
  **Starting in version 4.20.0.0, [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) comes with the new [***Shine***](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#shine) syntax** for highly intuitive and visually expressive View/Model Attribute Mapping, relying on `<=>` for bidirectional (two-way) data-binding and `<=` for unidirectional (one-way) data-binding, providing an alternative to the `bind` keyword (keep in mind that it is still a beta, so default back to `bind` whenever needed).
21
21
 
@@ -321,7 +321,7 @@ jgem install glimmer-dsl-swt
321
321
 
322
322
  Or this command if you want a specific version:
323
323
  ```
324
- jgem install glimmer-dsl-swt -v 4.20.14.1
324
+ jgem install glimmer-dsl-swt -v 4.20.15.2
325
325
  ```
326
326
 
327
327
  `jgem` is JRuby's version of `gem` command.
@@ -349,7 +349,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
349
349
 
350
350
  Add the following to `Gemfile`:
351
351
  ```
352
- gem 'glimmer-dsl-swt', '~> 4.20.14.1'
352
+ gem 'glimmer-dsl-swt', '~> 4.20.15.2'
353
353
  ```
354
354
 
355
355
  And, then run:
@@ -370,7 +370,7 @@ glimmer
370
370
  ```
371
371
 
372
372
  ```
373
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.14.1
373
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.15.2
374
374
 
375
375
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
376
376
 
@@ -546,7 +546,7 @@ Learn more at: [docs/reference/GLIMMER_PACKAGING_AND_DISTRIBUTION.md](docs/refer
546
546
 
547
547
  ## App Updates
548
548
 
549
- Glimmer already supports automatic (and manual) app updates via the Mac App Store for Mac apps. Simply run the `glimmer package` command with the Mac App Store keys configured as per [Mac Application Distribution](mac-application-distribution) instructions and you get automatic (and manual) app update support courtesy of the Mac App Store.
549
+ Glimmer should have support for automatic (and manual) app updates via the Mac App Store for Mac apps. Simply run the `glimmer package` command with the Mac App Store keys configured as per [Mac Application Distribution](mac-application-distribution) instructions and you get automatic (and manual) app update support courtesy of the Mac App Store.
550
550
 
551
551
  ## Glimmer Supporting Libraries
552
552
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.20.14.1
1
+ 4.20.15.2
@@ -14,6 +14,7 @@
14
14
  - [Hello, List Single Selection!](#hello-list-single-selection)
15
15
  - [Hello, List Multi Selection!](#hello-list-multi-selection)
16
16
  - [Hello, Computed!](#hello-computed)
17
+ - [Hello, Toggle!](#hello-toggle)
17
18
  - [Hello, Message Box!](#hello-message-box)
18
19
  - [Hello, Browser!](#hello-browser)
19
20
  - [Hello, Drag and Drop!](#hello-drag-and-drop)
@@ -32,6 +33,8 @@
32
33
  - [Hello, Checkbox Group!](#hello-checkbox-group)
33
34
  - [Hello, Directory Dialog!](#hello-directory-dialog)
34
35
  - [Hello, File Dialog!](#hello-file-dialog)
36
+ - [Hello, Print Dialog!](#hello-print-dialog)
37
+ - [Hello, Print!](#hello-print)
35
38
  - [Hello, Date Time!](#hello-date-time)
36
39
  - [Hello, Scale!](#hello-scale)
37
40
  - [Hello, Slider!](#hello-slider)
@@ -64,6 +67,7 @@
64
67
  - [Tic Tac Toe](#tic-tac-toe)
65
68
  - [Connect 4](#connect-4)
66
69
  - [Contact Manager](#contact-manager)
70
+ - [Clock](#clock)
67
71
  - [Game of Life](#game-of-life)
68
72
  - [Glimmer Tetris](#glimmer-tetris)
69
73
  - [Klondike Solitaire](#klondike-solitaire)
@@ -315,6 +319,30 @@ Code:
315
319
 
316
320
  ![Hello Browser](/images/glimmer-hello-computed.png)
317
321
 
322
+ #### Hello, Toggle!
323
+
324
+ This sample demonstrates the use of `toggle` button (aka `button(:toggle)`)
325
+
326
+ Code:
327
+
328
+ [samples/hello/hello_toggle.rb](/samples/hello/hello_toggle.rb)
329
+
330
+ ![Hello Toggle](/images/glimmer-hello-toggle.png)
331
+
332
+ ![Hello Toggle Red](/images/glimmer-hello-toggle-red.png)
333
+
334
+ ![Hello Toggle Green](/images/glimmer-hello-toggle-green.png)
335
+
336
+ ![Hello Toggle Blue](/images/glimmer-hello-toggle-blue.png)
337
+
338
+ ![Hello Toggle Red Green](/images/glimmer-hello-toggle-red-green.png)
339
+
340
+ ![Hello Toggle Red Blue](/images/glimmer-hello-toggle-red-blue.png)
341
+
342
+ ![Hello Toggle Green Blue](/images/glimmer-hello-toggle-green-blue.png)
343
+
344
+ ![Hello Toggle Red Green Blue](/images/glimmer-hello-toggle-red-green-blue.png)
345
+
318
346
  #### Hello, Message Box!
319
347
 
320
348
  This sample demonstrates a `message_box` dialog.
@@ -588,7 +616,7 @@ Hello, Directory Dialog! Selected Directory
588
616
 
589
617
  #### Hello, File Dialog!
590
618
 
591
- This sample demonstrates the use of a `file_dialog` in Glimmer.
619
+ This sample demonstrates the use of `file_dialog` in Glimmer.
592
620
 
593
621
  Code:
594
622
 
@@ -606,6 +634,30 @@ Hello, File Dialog! Selected File
606
634
 
607
635
  ![Hello File Dialog](/images/glimmer-hello-file-dialog-selected-file.png)
608
636
 
637
+ #### Hello, Print Dialog!
638
+
639
+ This sample demonstrates the use of `print_dialog` in Glimmer.
640
+
641
+ Code:
642
+
643
+ [samples/hello/hello_print_dialog.rb](/samples/hello/hello_print_dialog.rb)
644
+
645
+ Hello, Print Dialog!
646
+
647
+ ![Hello Print Dialog](/images/glimmer-hello-print-dialog.png)
648
+
649
+ #### Hello, Print!
650
+
651
+ This sample demonstrates the use of `widget#print`, which automates work from Hello, Print Dialog! assuming a single page
652
+
653
+ Code:
654
+
655
+ [samples/hello/hello_print.rb](/samples/hello/hello_print.rb)
656
+
657
+ Hello, Print!
658
+
659
+ ![Hello Print](/images/glimmer-hello-print.png)
660
+
609
661
  #### Hello, Date Time!
610
662
 
611
663
  This sample demonstrates the use of [date_time](#datetime) widget keywords in Glimmer: `date`, `date_drop_down`, `time`, and `calendar`
@@ -1132,6 +1184,16 @@ Contact Manager - Edit Done
1132
1184
 
1133
1185
  ![Contact Manager](/images/glimmer-contact-manager-edit-done.png)
1134
1186
 
1187
+ #### Clock
1188
+
1189
+ This sample demonstrates how to build an animation based application.
1190
+
1191
+ Code:
1192
+
1193
+ [samples/elaborate/clock.rb](/samples/elaborate/clock.rb)
1194
+
1195
+ ![Clock](/images/glimmer-clock.png)
1196
+
1135
1197
  #### Game of Life
1136
1198
 
1137
1199
  This sample demonstrates how to build an interactive canvas-based visualization of Conway's Game of Life ([test-first](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/spec/samples/elaborate/game_of_life/model/grid_spec.rb)), taking advantage of data-binding and multi-threading.
Binary file
@@ -31,6 +31,7 @@ module Glimmer
31
31
  'org.eclipse.swt.browser',
32
32
  'org.eclipse.swt.custom',
33
33
  'org.eclipse.swt.dnd',
34
+ 'org.eclipse.swt.printing',
34
35
  ]
35
36
  DEFAULT_AUTO_SYNC_EXEC = true
36
37
 
@@ -610,6 +610,40 @@ module Glimmer
610
610
  (@swt_widget.style & comparison) == comparison
611
611
  end
612
612
  end
613
+
614
+ def print(gc=nil, job_name: nil)
615
+ if gc.is_a?(org.eclipse.swt.graphics.GC)
616
+ @swt_widget.print(gc)
617
+ else
618
+ image = Image.new(DisplayProxy.instance.swt_display, bounds)
619
+ gc = org.eclipse.swt.graphics.GC.new(image)
620
+ success = print(gc)
621
+ if success
622
+ printer_data = DialogProxy.new('print_dialog', shell.get_data('proxy')).open
623
+ if printer_data
624
+ printer = Printer.new(printer_data)
625
+ job_name ||= 'Glimmer'
626
+ if printer.start_job(job_name)
627
+ printer_gc = org.eclipse.swt.graphics.GC.new(printer)
628
+ if printer.start_page
629
+ printer_gc.drawImage(image, 0, 0)
630
+ printer.end_page
631
+ else
632
+ success = false
633
+ end
634
+ printer_gc.dispose
635
+ printer.end_job
636
+ else
637
+ success = false
638
+ end
639
+ printer.dispose
640
+ gc.dispose
641
+ image.dispose
642
+ end
643
+ end
644
+ success
645
+ end
646
+ end
613
647
 
614
648
  def dispose
615
649
  auto_exec do
@@ -0,0 +1,74 @@
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
+ class Clock
23
+ include Glimmer::UI::CustomShell
24
+
25
+ body {
26
+ shell {
27
+ text 'Glimmer Clock'
28
+ minimum_size 400, 430
29
+
30
+ canvas {
31
+ initial_time = Time.now
32
+ background :black
33
+
34
+ animation {
35
+ every 0.01 # every hundredth of a second to ensure higher accuracy
36
+
37
+ frame { |index|
38
+ time = Time.now
39
+
40
+ oval(0, 0, 400, 400) {
41
+ background :white
42
+ }
43
+ polygon(-5, -5, 180, 0, -5, 5) {
44
+ background :black
45
+
46
+ transform {
47
+ translate 200, 200
48
+ rotate(time.sec*6 - 90)
49
+ }
50
+ }
51
+ polygon(-5, -5, 135, 0, -5, 5) {
52
+ background :dark_gray
53
+
54
+ transform {
55
+ translate 200, 200
56
+ rotate(time.min*6 - 90)
57
+ }
58
+ }
59
+ polygon(-5, -5, 90, 0, -5, 5) {
60
+ background :gray
61
+
62
+ transform {
63
+ translate 200, 200
64
+ rotate((time.hour - 12)*30 - 90)
65
+ }
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ }
72
+ end
73
+
74
+ Clock.launch
@@ -39,8 +39,8 @@ class Timer
39
39
  ## Use after_body block to setup observers for widgets in body
40
40
  #
41
41
  after_body do
42
- Thread.new {
43
- loop {
42
+ Thread.new do
43
+ loop do
44
44
  sleep(1)
45
45
  if @countdown
46
46
  sync_exec {
@@ -54,8 +54,8 @@ class Timer
54
54
  end
55
55
  }
56
56
  end
57
- }
58
- }
57
+ end
58
+ end
59
59
  end
60
60
 
61
61
  ## Add widget content inside custom shell body
@@ -87,7 +87,7 @@ class HelloLabel
87
87
 
88
88
  ['denmark', 'finland', 'norway'].each do |image_name|
89
89
  label {
90
- layout_data :fill, :center, true, false
90
+ layout_data :center, :center, true, false
91
91
  image File.expand_path("images/#{image_name}.png", __dir__)
92
92
  }
93
93
  text {
@@ -0,0 +1,60 @@
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-dsl-swt'
23
+
24
+ class HelloPrint
25
+ include Glimmer::UI::CustomShell
26
+
27
+ body {
28
+ shell {
29
+ text 'Hello, Print!'
30
+ @composite = composite {
31
+ row_layout(:vertical) {
32
+ fill true
33
+ center true
34
+ }
35
+
36
+ label(:center) {
37
+ text "Whatever you see inside the app composite\nwill get printed when clicking the Print button."
38
+ font height: 16
39
+ }
40
+
41
+ button {
42
+ text 'Print'
43
+
44
+ on_widget_selected do
45
+ # The widget#print method automates all the work seen in Hello, Print Dialog!
46
+ # the caveat is it assumes everything fits on one page
47
+ unless @composite.print
48
+ message_box {
49
+ text 'Unable To Print'
50
+ message 'Sorry! Printing is not supported on this platform!'
51
+ }.open
52
+ end
53
+ end
54
+ }
55
+ }
56
+ }
57
+ }
58
+ end
59
+
60
+ HelloPrint.launch
@@ -0,0 +1,89 @@
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-dsl-swt'
23
+
24
+ class HelloPrintDialog
25
+ include Glimmer::UI::CustomShell
26
+
27
+ body {
28
+ shell {
29
+ text 'Hello, Print Dialog!'
30
+ @composite = composite {
31
+ row_layout(:vertical) {
32
+ fill true
33
+ center true
34
+ }
35
+
36
+ label(:center) {
37
+ text "Whatever you see inside the app composite\nwill get printed when clicking the Print button."
38
+ font height: 16
39
+ }
40
+
41
+ button {
42
+ text 'Print'
43
+
44
+ on_widget_selected do
45
+ # note: you may check out Hello, Print! for a simpler version that automates the work below
46
+ image = Image.new(display.swt_display, @composite.bounds)
47
+ gc = org.eclipse.swt.graphics.GC.new(image)
48
+ success = @composite.print(gc)
49
+ if success
50
+ printer_data = print_dialog.open
51
+ if printer_data
52
+ printer = Printer.new(printer_data)
53
+ if printer.start_job('Glimmer')
54
+ printer_gc = org.eclipse.swt.graphics.GC.new(printer)
55
+ if printer.start_page
56
+ printer_gc.drawImage(image, 0, 0)
57
+ printer.end_page
58
+ else
59
+ message_box {
60
+ text 'Unable To Print'
61
+ message 'Sorry! Cannot start printer page!'
62
+ }.open
63
+ end
64
+ printer_gc.dispose
65
+ printer.end_job
66
+ else
67
+ message_box {
68
+ text 'Unable To Print'
69
+ message 'Sorry! Cannot start printer job!'
70
+ }.open
71
+ end
72
+ printer.dispose
73
+ gc.dispose
74
+ image.dispose
75
+ end
76
+ else
77
+ message_box {
78
+ text 'Unable To Print'
79
+ message 'Sorry! Printing is not supported on this platform!'
80
+ }.open
81
+ end
82
+ end
83
+ }
84
+ }
85
+ }
86
+ }
87
+ end
88
+
89
+ HelloPrintDialog.launch
@@ -0,0 +1,91 @@
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-dsl-swt'
23
+
24
+ class HelloToggle
25
+ include Glimmer::UI::CustomShell
26
+
27
+ attr_accessor :red, :green, :blue, :final_color_text, :final_color
28
+
29
+ after_body do
30
+ observe(self, :red) do
31
+ update_final_color!
32
+ end
33
+
34
+ observe(self, :green) do
35
+ update_final_color!
36
+ end
37
+
38
+ observe(self, :blue) do
39
+ update_final_color!
40
+ end
41
+ end
42
+
43
+ body {
44
+ shell {
45
+ grid_layout 3, true
46
+
47
+ text 'Hello, Toggle!'
48
+
49
+ toggle {
50
+ layout_data :fill, :center, true, false
51
+ text 'Red'
52
+
53
+ selection <=> [self, :red]
54
+ }
55
+
56
+ toggle {
57
+ layout_data :fill, :center, true, false
58
+ text 'Green'
59
+
60
+ selection <=> [self, :green]
61
+ }
62
+
63
+ toggle {
64
+ layout_data :fill, :center, true, false
65
+ text 'Blue'
66
+
67
+ selection <=> [self, :blue]
68
+ }
69
+
70
+ label(:center) {
71
+ layout_data {
72
+ horizontal_span 3
73
+ horizontal_alignment :fill
74
+ grab_excess_horizontal_space true
75
+ height_hint 20
76
+ }
77
+
78
+ text <= [self, :final_color_text]
79
+ background <= [self, :final_color]
80
+ }
81
+ }
82
+ }
83
+
84
+ def update_final_color!
85
+ final_color_symbols = [:red, :green, :blue].map {|color| send(color) ? color : nil}.compact
86
+ self.final_color_text = final_color_symbols.map {|color_symbol| color_symbol.to_s.capitalize}.join(' + ')
87
+ self.final_color = final_color_symbols.map {|color_symbol| color(color_symbol)}.reduce {|output_color, color| rgb(output_color.red + color.red, output_color.green + color.green, output_color.blue + color.blue) }
88
+ end
89
+ end
90
+
91
+ HelloToggle.launch
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-swt
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.20.14.1
4
+ version: 4.20.15.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-08 00:00:00.000000000 Z
11
+ date: 2021-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -552,6 +552,7 @@ files:
552
552
  - samples/elaborate/calculator/model/command/operation/subtract.rb
553
553
  - samples/elaborate/calculator/model/command/point.rb
554
554
  - samples/elaborate/calculator/model/presenter.rb
555
+ - samples/elaborate/clock.rb
555
556
  - samples/elaborate/connect4.rb
556
557
  - samples/elaborate/connect4/model/grid.rb
557
558
  - samples/elaborate/connect4/model/slot.rb
@@ -646,6 +647,8 @@ files:
646
647
  - samples/hello/hello_menu_bar.rb
647
648
  - samples/hello/hello_message_box.rb
648
649
  - samples/hello/hello_pop_up_context_menu.rb
650
+ - samples/hello/hello_print.rb
651
+ - samples/hello/hello_print_dialog.rb
649
652
  - samples/hello/hello_progress_bar.rb
650
653
  - samples/hello/hello_radio.rb
651
654
  - samples/hello/hello_radio_group.rb
@@ -660,6 +663,7 @@ files:
660
663
  - samples/hello/hello_table.rb
661
664
  - samples/hello/hello_table/baseball_park.png
662
665
  - samples/hello/hello_text.rb
666
+ - samples/hello/hello_toggle.rb
663
667
  - samples/hello/hello_tool_bar.rb
664
668
  - samples/hello/hello_tray_item.rb
665
669
  - samples/hello/hello_tree.rb