glimmer-dsl-opal 0.16.1 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -2
  3. data/README.md +158 -4
  4. data/VERSION +1 -1
  5. data/lib/cgi.rb +14 -0
  6. data/lib/glimmer-dsl-opal.rb +1 -0
  7. data/lib/glimmer-dsl-opal/samples/hello/hello_arrow.rb +65 -0
  8. data/lib/glimmer-dsl-opal/samples/hello/hello_c_combo.rb +67 -0
  9. data/lib/glimmer-dsl-opal/samples/hello/hello_c_tab.rb +172 -0
  10. data/lib/glimmer-dsl-opal/samples/hello/hello_layout.rb +241 -0
  11. data/lib/glimmer-dsl-opal/samples/hello/hello_tab.rb +10 -8
  12. data/lib/glimmer-dsl-opal/samples/hello/images/denmark.png +0 -0
  13. data/lib/glimmer-dsl-opal/samples/hello/images/finland.png +0 -0
  14. data/lib/glimmer-dsl-opal/samples/hello/images/france.png +0 -0
  15. data/lib/glimmer-dsl-opal/samples/hello/images/germany.png +0 -0
  16. data/lib/glimmer-dsl-opal/samples/hello/images/italy.png +0 -0
  17. data/lib/glimmer-dsl-opal/samples/hello/images/mexico.png +0 -0
  18. data/lib/glimmer-dsl-opal/samples/hello/images/netherlands.png +0 -0
  19. data/lib/glimmer-dsl-opal/samples/hello/images/norway.png +0 -0
  20. data/lib/glimmer-dsl-opal/samples/hello/images/usa.png +0 -0
  21. data/lib/glimmer/dsl/opal/menu_expression.rb +3 -0
  22. data/lib/glimmer/swt/arrow_proxy.rb +42 -0
  23. data/lib/glimmer/swt/button_proxy.rb +36 -1
  24. data/lib/glimmer/swt/c_combo_proxy.rb +51 -0
  25. data/lib/glimmer/swt/c_tab_folder_proxy.rb +43 -0
  26. data/lib/glimmer/swt/c_tab_item_proxy.rb +96 -0
  27. data/lib/glimmer/swt/combo_proxy.rb +3 -0
  28. data/lib/glimmer/swt/fill_layout_proxy.rb +9 -3
  29. data/lib/glimmer/swt/grid_layout_proxy.rb +33 -1
  30. data/lib/glimmer/swt/label_proxy.rb +2 -2
  31. data/lib/glimmer/swt/menu_proxy.rb +17 -1
  32. data/lib/glimmer/swt/row_layout_proxy.rb +33 -2
  33. data/lib/glimmer/swt/shell_proxy.rb +4 -0
  34. data/lib/glimmer/swt/tab_folder_proxy.rb +12 -10
  35. data/lib/glimmer/swt/tab_item_proxy.rb +52 -4
  36. data/lib/glimmer/swt/widget_proxy.rb +53 -12
  37. metadata +20 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2ee052273513ff79b9d9ef0f351f30bfa0c4083f589429646b894b132afa4c3
4
- data.tar.gz: f2a9113b2a92168046d19c3068d9b62df1000fdc1dd6c9ea5f168ffb89123fb4
3
+ metadata.gz: 5617b16e9da429aeac72049da8803530ff80be0573a4a97e9f40dc7d543f3869
4
+ data.tar.gz: 90b2d967c42ca61c617d874f070c6a63dc79edeb172566a1c38baffa4f3de51c
5
5
  SHA512:
6
- metadata.gz: 20edcc6d97dbee21a5b8b332bc649fb0f7d77f93e41d02095cdbbed43f0686f8c1dd5bf08972bd21511cb983f77caf247f61136ddde5de859f444ac92f31dbf2
7
- data.tar.gz: ce7347775105f4b2af132cd68b4a805332b4afe910cb3ff91c0da083bd043e93cf067c693c9e4a54b506c2417d684248d23fa78aecccc264c741c38028b35b6e
6
+ metadata.gz: 671f9759f18ac9c60b0ca61c1a2186b2ce04965262848c649cb184037e904bc9a73190a57312e0b233598fcf689f1d19eec0fd69a30f8b03db22d633567bf18a
7
+ data.tar.gz: c5a473ce5ea0e281f53684ebc0eb7cb74517cb30318cd355b42b20e3b70d3cf880e530eadc2b0fb2b577cd1fada551afe774b06930dc2d00853e0237d64bef75
data/CHANGELOG.md CHANGED
@@ -1,13 +1,41 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.19.0
4
+
5
+ - Change `tab_item` default background/foreground color to better match Glimmer DSL for SWT
6
+ - Support `tab_item` `tool_tip_text` attribute
7
+ - Support `tab_item` `image` attribute
8
+ - Implement `c_tab_folder` & `c_tab_item` (without the dropdown for hidden tabs that is in Glimmer DSL for SWT)
9
+ - Hello, C Tab! sample
10
+
11
+ ## 0.18.0
12
+
13
+ - Implement `c_combo`
14
+ - Hello, C Combo! sample
15
+
16
+ ## 0.17.0
17
+
18
+ - Support `menu` `visible` attribute to enable programmatic display of menu
19
+ - Support `arrow` widget
20
+ - Hello, Arrow! sample
21
+
22
+ ## 0.16.2
23
+
24
+ - Support `grid_layout` `margin_top`, `margin_right`, `margin_bottom`, and `margin_left` attributes
25
+ - Support `row_layout` `wrap` and `justify` attributes
26
+ - Hello, Layout! sample
27
+ - Partial CGI implementation to have `escapeHTML` (alias: `escape_html`) method
28
+ - HTML Escape label text content
29
+ - Fix issue with `row_layout` `fill` attribute not working
30
+
3
31
  ## 0.16.1
4
32
 
5
- - Support GridLayout make_columns_equal_width, horizontal_spacing, and vertical_spacing attributes
33
+ - Support `grid_layout` `make_columns_equal_width`, `horizontal_spacing`, and `vertical_spacing` attributes
6
34
  - Hello, Composite! sample
7
35
 
8
36
  ## 0.16.0
9
37
 
10
- - Support label widget background_image attribute
38
+ - Support `label` widget `background_image` attribute
11
39
  - Have File.expand_path support expanding paths even if they did not base off of __dir__ or __FILE__
12
40
  - Custom specification of gems having image paths via server-side configuration in Glimmer::Config.gems_having_image_paths
13
41
 
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 Opal 0.16.0 (Pure Ruby Web GUI)
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 Opal [Alpha] (Pure Ruby Web GUI)
2
2
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-opal.svg)](http://badge.fury.io/rb/glimmer-dsl-opal)
3
3
  [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
4
 
@@ -143,7 +143,7 @@ Hello, Table! Game Booked
143
143
 
144
144
  NOTE: Glimmer DSL for Opal is an alpha project. Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
145
145
 
146
- **Alpha Version** 0.16.0 only supports bare-minimum capabilities for the included [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written for [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt))
146
+ **Alpha Version** 0.19.0 only supports bare-minimum capabilities for the included [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written for [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt))
147
147
 
148
148
  Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
149
149
  - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
@@ -153,7 +153,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
153
153
 
154
154
  ## Table of Contents
155
155
 
156
- - [Glimmer DSL for Opal 0.16.0 (Pure Ruby Web GUI)](#-glimmer-dsl-for-opal-0160-pure-ruby-web-gui)
156
+ - [Glimmer DSL for Opal [Alpha] (Pure Ruby Web GUI)](#-glimmer-dsl-for-opal-alpha-pure-ruby-web-gui)
157
157
  - [Principles](#principles)
158
158
  - [Background](#background)
159
159
  - [Pre-requisites](#pre-requisites)
@@ -165,6 +165,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
165
165
  - [Hello, Combo!](#hello-combo)
166
166
  - [Hello, Composite!](#hello-composite)
167
167
  - [Hello, Computed!](#hello-computed)
168
+ - [Hello, Layout!](#hello-layout)
168
169
  - [Hello, List Single Selection!](#hello-list-single-selection)
169
170
  - [Hello, List Multi Selection!](#hello-list-multi-selection)
170
171
  - [Hello, Browser!](#hello-browser)
@@ -174,11 +175,14 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
174
175
  - [Hello, Radio!](#hello-radio)
175
176
  - [Hello, Radio Group!](#hello-radio-group)
176
177
  - [Hello, Group!](#hello-group)
178
+ - [Hello, C Combo!](#hello-c-combo)
179
+ - [Hello, C Tab!](#hello-c-tab)
177
180
  - [Hello, Checkbox!](#hello-checkbox)
178
181
  - [Hello, Checkbox Group!](#hello-checkbox-group)
179
182
  - [Hello, Date Time!](#hello-date-time)
180
183
  - [Hello, Table!](#hello-table)
181
184
  - [Hello, Button!](#hello-button)
185
+ - [Hello, Arrow!](#hello-arrow)
182
186
  - [Hello, Message Box!](#hello-message-box)
183
187
  - [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu)
184
188
  - [Hello, Menu Bar!](#hello-menu-bar)
@@ -257,7 +261,7 @@ gem 'opal', '1.0.4'
257
261
  gem 'opal-rails', '1.1.2'
258
262
  gem 'opal-async', '~> 1.2.0'
259
263
  gem 'opal-jquery', '~> 0.4.4'
260
- gem 'glimmer-dsl-opal', '~> 0.16.0'
264
+ gem 'glimmer-dsl-opal', '~> 0.19.0'
261
265
  gem 'glimmer-dsl-xml', '~> 1.2.0', require: false
262
266
  gem 'glimmer-dsl-css', '~> 1.2.0', require: false
263
267
 
@@ -321,6 +325,7 @@ shell {
321
325
  The following keywords from [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) have fully functional partial support in Opal:
322
326
 
323
327
  Widgets:
328
+ - `arrow`: featured in [Hello, Arrow!](#hello-arrow)
324
329
  - `button`: featured in [Hello, Checkbox!](#hello-checkbox) / [Hello, Button!](#hello-button) / [Hello, Table!](#hello-table) / [Hello, Radio Group!](#hello-radio-group) / [Hello, Radio!](#hello-radio) / [Hello, Message Box!](#hello-message-box) / [Hello, List Single Selection!](#hello-list-single-selection) / [Hello, List Multi Selection!](#hello-list-multi-selection) / [Hello, Group!](#hello-group) / [Hello, Combo!](#hello-combo) / [Hello, Checkbox Group!](#hello-checkbox-group) / [Contact Manager](#contact-manager) / [Tic Tac Toe](#tic-tac-toe) / [Login](#login)
325
330
  - `browser`: featured in [Hello, Browser!](#hello-browser)
326
331
  - `calendar`: featured in [Hello, Date Time!](#hello-date-time)
@@ -344,6 +349,8 @@ Widgets:
344
349
  - `shell`: featured in [Hello, Checkbox!](#hello-checkbox) / [Hello, Button!](#hello-button) / [Hello, Table!](#hello-table) / [Hello, Tab!](#hello-tab) / [Hello, Radio Group!](#hello-radio-group) / [Hello, Radio!](#hello-radio) / [Hello, List Single Selection!](#hello-list-single-selection) / [Hello, List Multi Selection!](#hello-list-multi-selection) / [Hello, Group!](#hello-group) / [Hello, Date Time!](#hello-date-time) / [Hello, Custom Shell!](#hello-custom-shell) / [Hello, Computed!](#hello-computed) / [Hello, Combo!](#hello-combo) / [Hello, Checkbox Group!](#hello-checkbox-group) / [Contact Manager](#contact-manager) / [Tic Tac Toe](#tic-tac-toe) / [Login](#login)
345
350
  - `tab_folder`: featured in [Hello, Tab!](#hello-tab)
346
351
  - `tab_item`: featured in [Hello, Tab!](#hello-tab)
352
+ - `c_tab_folder`: featured in [Hello, C Tab!](#hello-c-tab)
353
+ - `c_tab_item`: featured in [Hello, C Tab!](#hello-c-tab)
347
354
  - `table`: featured in [Hello, Custom Shell!](#hello-custom-shell) / [Hello, Table!](#hello-table) / [Contact Manager](#contact-manager)
348
355
  - `table_column`: featured in [Hello, Table!](#hello-table) / [Hello, Custom Shell!](#hello-custom-shell) / [Contact Manager](#contact-manager)
349
356
  - `text`: featured in [Hello, Computed!](#hello-computed) / [Login](#login) / [Contact Manager](#contact-manager)
@@ -656,6 +663,58 @@ You should see "Hello, Computed!"
656
663
 
657
664
  ![Glimmer DSL for Opal Hello Computed](images/glimmer-dsl-opal-hello-computed.png)
658
665
 
666
+ #### Hello, Layout!
667
+
668
+ Add the following require statement to `app/assets/javascripts/application.rb`
669
+
670
+
671
+ ```ruby
672
+ require 'glimmer-dsl-opal/samples/hello/hello_layout'
673
+ ```
674
+
675
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
676
+
677
+ ![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab1.png)
678
+
679
+ ![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab2.png)
680
+
681
+ ![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab3.png)
682
+
683
+ ![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab4.png)
684
+
685
+ ![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab5.png)
686
+
687
+ ![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab6.png)
688
+
689
+ ![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab7.png)
690
+
691
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
692
+
693
+ Start the Rails server:
694
+ ```
695
+ rails s
696
+ ```
697
+
698
+ Visit `http://localhost:3000`
699
+
700
+ You should see "Hello, Layout!"
701
+
702
+ ![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab1.png)
703
+
704
+ ![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab2.png)
705
+
706
+ ![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab3.png)
707
+
708
+ ![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab4.png)
709
+
710
+ ![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab4-shrunk.png)
711
+
712
+ ![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab5.png)
713
+
714
+ ![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab6.png)
715
+
716
+ ![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab7.png)
717
+
659
718
  #### Hello, List Single Selection!
660
719
 
661
720
  Add the following require statement to `app/assets/javascripts/application.rb`
@@ -707,6 +766,39 @@ You should see "Hello, List Multi Selection!"
707
766
 
708
767
  ![Glimmer DSL for Opal Hello List Multi Selection](images/glimmer-dsl-opal-hello-list-multi-selection.png)
709
768
 
769
+ #### Hello, Arrow!
770
+
771
+ Add the following require statement to `app/assets/javascripts/application.rb`
772
+
773
+ ```ruby
774
+ require 'glimmer-dsl-opal/samples/hello/hello_arrow'
775
+ ```
776
+
777
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
778
+
779
+ ![Glimmer DSL for SWT Hello Arrow](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-arrow.png)
780
+
781
+ ![Glimmer DSL for SWT Hello Arrow](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-arrow-menu.png)
782
+
783
+ ![Glimmer DSL for SWT Hello Arrow](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-arrow-item-selected.png)
784
+
785
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
786
+
787
+ Start the Rails server:
788
+ ```
789
+ rails s
790
+ ```
791
+
792
+ Visit `http://localhost:3000`
793
+
794
+ You should see "Hello, Arrow!"
795
+
796
+ ![Glimmer DSL for Opal Hello Arrow](images/glimmer-dsl-opal-hello-arrow.png)
797
+
798
+ ![Glimmer DSL for Opal Hello Arrow](images/glimmer-dsl-opal-hello-arrow-menu.png)
799
+
800
+ ![Glimmer DSL for Opal Hello Arrow](images/glimmer-dsl-opal-hello-arrow-item-selected.png)
801
+
710
802
  #### Hello, Browser!
711
803
 
712
804
  Add the following require statement to `app/assets/javascripts/application.rb`
@@ -1204,6 +1296,68 @@ You should see "Hello, Group!"
1204
1296
 
1205
1297
  ![Glimmer DSL for Opal Hello Group](images/glimmer-dsl-opal-hello-group.png)
1206
1298
 
1299
+ #### Hello, C Combo!
1300
+
1301
+ This is the low level way of using `c_combo`
1302
+
1303
+ Add the following require statement to `app/assets/javascripts/application.rb`
1304
+
1305
+ ```ruby
1306
+ require 'glimmer-dsl-opal/samples/hello/hello_c_combo'
1307
+ ```
1308
+
1309
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
1310
+
1311
+ ![Glimmer DSL for SWT Hello C Combo](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-c-combo.png)
1312
+
1313
+ ![Glimmer DSL for SWT Hello C Combo Expanded](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-c-combo-expanded.png)
1314
+
1315
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
1316
+
1317
+ Start the Rails server:
1318
+ ```
1319
+ rails s
1320
+ ```
1321
+
1322
+ Visit `http://localhost:3000`
1323
+
1324
+ You should see "Hello, C Combo!"
1325
+
1326
+ ![Glimmer DSL for Opal Hello C Combo](images/glimmer-dsl-opal-hello-c-combo.png)
1327
+
1328
+ ![Glimmer DSL for Opal Hello C Combo Expanded](images/glimmer-dsl-opal-hello-c-combo-expanded.png)
1329
+
1330
+ #### Hello, C Tab!
1331
+
1332
+ This is the low level way of using `c_tab_folder`/`c_tab_item`
1333
+
1334
+ Add the following require statement to `app/assets/javascripts/application.rb`
1335
+
1336
+ ```ruby
1337
+ require 'glimmer-dsl-opal/samples/hello/hello_c_tab'
1338
+ ```
1339
+
1340
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
1341
+
1342
+ ![Glimmer DSL for SWT Hello C Tab](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-c-tab.png)
1343
+
1344
+ ![Glimmer DSL for SWT Hello C Tab Other Tab](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-c-tab-other-tab.png)
1345
+
1346
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
1347
+
1348
+ Start the Rails server:
1349
+ ```
1350
+ rails s
1351
+ ```
1352
+
1353
+ Visit `http://localhost:3000`
1354
+
1355
+ You should see "Hello, C Tab!"
1356
+
1357
+ ![Glimmer DSL for Opal Hello C Tab](images/glimmer-dsl-opal-hello-c-tab.png)
1358
+
1359
+ ![Glimmer DSL for Opal Hello C Tab Other Tab](images/glimmer-dsl-opal-hello-c-tab-other-tab.png)
1360
+
1207
1361
  #### Hello, Checkbox!
1208
1362
 
1209
1363
  This is the low level way of using `checkbox`
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.16.1
1
+ 0.19.0
data/lib/cgi.rb ADDED
@@ -0,0 +1,14 @@
1
+ class CGI
2
+ class << self
3
+ def escapeHTML(string)
4
+ string.
5
+ gsub('&', '&amp;').
6
+ gsub('<', '&lt;').
7
+ gsub('>', '&gt;').
8
+ gsub("'", '&apos;').
9
+ gsub('"', '&quot;')
10
+ end
11
+ alias escape_html escapeHTML
12
+
13
+ end
14
+ end
@@ -50,6 +50,7 @@ if RUBY_ENGINE == 'opal'
50
50
  require 'to_collection'
51
51
  require 'pure-struct'
52
52
  require 'os'
53
+ require 'cgi'
53
54
  require 'file'
54
55
  require 'display'
55
56
  require 'glimmer-dsl-opal/vendor/jquery'
@@ -0,0 +1,65 @@
1
+ # Copyright (c) 2020-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
+ include Glimmer
23
+
24
+ shell {
25
+ row_layout(:vertical) {
26
+ fill true
27
+ center true
28
+ }
29
+
30
+ text 'Hello, Arrow!'
31
+
32
+ label(:center) {
33
+ text 'Click the arrow to get a menu.'
34
+ }
35
+
36
+ arrow { # can be customized by passing `:arrow` SWT style + `:left`, `:right`, `:up`, or `:down` (default)
37
+ @menu = menu {
38
+ menu_item {
39
+ text 'Item &1'
40
+
41
+ on_widget_selected do
42
+ message_box {
43
+ text 'Item 1'
44
+ message 'Item 1 selected!'
45
+ }.open
46
+ end
47
+ }
48
+ menu_item {
49
+ text 'Item &2'
50
+
51
+ on_widget_selected do
52
+ message_box {
53
+ text 'Item 2'
54
+ message 'Item 2 selected!'
55
+ }.open
56
+ end
57
+ }
58
+ }
59
+
60
+ on_widget_selected do |event|
61
+ event.widget.menu.visible = true
62
+ end
63
+ }
64
+
65
+ }.open
@@ -0,0 +1,67 @@
1
+ # Copyright (c) 2020-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
+ # This is a sample for the c_combo widget, a more customizable version of combo
23
+ class HelloCCombo
24
+ class Person
25
+ attr_accessor :country, :country_options
26
+
27
+ def initialize
28
+ self.country_options = ['', 'Canada', 'US', 'Mexico']
29
+ reset_country!
30
+ end
31
+
32
+ def reset_country!
33
+ self.country = 'Canada'
34
+ end
35
+ end
36
+
37
+ include Glimmer::UI::CustomShell
38
+
39
+ before_body do
40
+ @person = Person.new
41
+ end
42
+
43
+ body {
44
+ shell {
45
+ row_layout(:vertical) {
46
+ fill true
47
+ }
48
+
49
+ text 'Hello, C Combo!'
50
+
51
+ c_combo(:read_only) {
52
+ selection <=> [@person, :country] # also binds to country_options by convention
53
+ font height: 45 # unlike `combo`, `c_combo` changes height when setting the font height
54
+ }
55
+
56
+ button {
57
+ text 'Reset Selection'
58
+
59
+ on_widget_selected do
60
+ @person.reset_country!
61
+ end
62
+ }
63
+ }
64
+ }
65
+ end
66
+
67
+ HelloCCombo.launch