glimmer-dsl-swt 4.17.4.2 → 4.17.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +82 -26
- data/VERSION +1 -1
- data/glimmer-dsl-swt.gemspec +7 -3
- data/lib/glimmer/dsl/swt/expand_item_expression.rb +60 -0
- data/lib/glimmer/swt/custom/code_text.rb +2 -2
- data/lib/glimmer/swt/expand_item_proxy.rb +98 -0
- data/lib/glimmer/swt/image_proxy.rb +2 -0
- data/lib/glimmer/swt/tab_item_proxy.rb +1 -1
- data/lib/glimmer/swt/widget_proxy.rb +1 -0
- data/samples/elaborate/meta_sample.rb +24 -24
- data/samples/hello/hello_expand_bar.rb +108 -0
- data/samples/hello/hello_styled_text.rb +138 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2111fbe2df8040f64a319e5e62b15982cdc4749a6cd0c548b97f2b37f01b276
|
4
|
+
data.tar.gz: 283eb8a7a8faedde6ab6224ebe06fda3fca7cdff44ec99b32baca35da9df7d04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cb656a29e5d9da0759b295bc5dba9f1a174e8a83a1ffa2921c4b5efb6fd10542f0a46e475807cbd884c7f14270afa0983b5e49b392f97e9ddd41a6a4ecbbf30
|
7
|
+
data.tar.gz: 9283a302b3aaa99f5ec50f0d0996b951bb72ce0309ae9ca978429621d81f14c4005251286229d3555f31754c0e9a727db2f15f9245fab28f902ef1456e1fa07e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 4.17.5.0
|
4
|
+
|
5
|
+
- Support auto-scaling by aspect ratio of width and height (write specs)
|
6
|
+
- Support SWT ExpandBar via expand_bar keyword
|
7
|
+
- Hello, Expand Bar! Sample
|
8
|
+
- Hello, Styled Text! Sample
|
9
|
+
- Use expand_bar in Glimmer Meta-Sample
|
10
|
+
|
3
11
|
### 4.17.4.2
|
4
12
|
|
5
13
|
- Support StyledText data-binding of caret_offset, selection_count, selection, top_index, and top_pixel, useful for code_text
|
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.
|
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
|
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)
|
@@ -249,7 +249,7 @@ Glimmer App:
|
|
249
249
|
- [Glimmer Command](#glimmer-command)
|
250
250
|
- [Basic Usage](#basic-usage)
|
251
251
|
- [Advanced Usage](#advanced-usage)
|
252
|
-
- [Samples](#samples)
|
252
|
+
- [Glimmer Samples](#glimmer-samples)
|
253
253
|
- [Scaffolding](#scaffolding)
|
254
254
|
- [App](#app)
|
255
255
|
- [Desktopify](#desktopify)
|
@@ -282,6 +282,7 @@ Glimmer App:
|
|
282
282
|
- [Color](#color)
|
283
283
|
- [Font](#font)
|
284
284
|
- [Image](#image)
|
285
|
+
- [Image Options](#image-options)
|
285
286
|
- [Cursor](#cursor)
|
286
287
|
- [Layouts](#layouts)
|
287
288
|
- [Layout Data](#layout-data)
|
@@ -340,6 +341,8 @@ Glimmer App:
|
|
340
341
|
- [Hello, Custom Widget!](#hello-custom-widget)
|
341
342
|
- [Hello, Custom Shell!](#hello-custom-shell)
|
342
343
|
- [Hello, Sash Form!](#hello-sash-form)
|
344
|
+
- [Hello, Styled Text!](#hello-styled-text)
|
345
|
+
- [Hello, Expand Bar!](#hello-expand-bar)
|
343
346
|
- [Elaborate Samples](#elaborate-samples)
|
344
347
|
- [User Profile](#user-profile)
|
345
348
|
- [Login](#login)
|
@@ -433,7 +436,7 @@ jgem install glimmer-dsl-swt
|
|
433
436
|
|
434
437
|
Or this command if you want a specific version:
|
435
438
|
```
|
436
|
-
jgem install glimmer-dsl-swt -v 4.17.
|
439
|
+
jgem install glimmer-dsl-swt -v 4.17.5.0
|
437
440
|
```
|
438
441
|
|
439
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.
|
@@ -511,7 +514,7 @@ bin/glimmer samples
|
|
511
514
|
Below are the full usage instructions that come up when running `glimmer` without args.
|
512
515
|
|
513
516
|
```
|
514
|
-
Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.
|
517
|
+
Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.5.0
|
515
518
|
|
516
519
|
Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
|
517
520
|
|
@@ -622,18 +625,18 @@ You should see output like the following:
|
|
622
625
|
|
623
626
|
```
|
624
627
|
$ glimmer scaffold[greeter]
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
628
|
+
create .gitignore
|
629
|
+
create Rakefile
|
630
|
+
create Gemfile
|
631
|
+
create LICENSE.txt
|
632
|
+
create README.rdoc
|
633
|
+
create .document
|
634
|
+
create lib
|
635
|
+
create lib/greeter.rb
|
636
|
+
create spec
|
637
|
+
create spec/spec_helper.rb
|
638
|
+
create spec/greeter_spec.rb
|
639
|
+
create .rspec
|
637
640
|
Juwelier has prepared your gem in ./greeter
|
638
641
|
Created greeter/.gitignore
|
639
642
|
Created greeter/.ruby-version
|
@@ -731,15 +734,15 @@ Successfully installed github_api-0.19.0
|
|
731
734
|
Successfully installed nokogiri-1.10.10-java
|
732
735
|
Successfully installed juwelier-2.4.9
|
733
736
|
7 gems installed
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
737
|
+
create .gitignore
|
738
|
+
create Rakefile
|
739
|
+
create Gemfile
|
740
|
+
create LICENSE.txt
|
741
|
+
create README.markdown
|
742
|
+
create .document
|
743
|
+
create lib
|
744
|
+
create lib/snowboard_utah.rb
|
745
|
+
create .rspec
|
743
746
|
Juwelier has prepared your gem in ./snowboard_utah
|
744
747
|
Created snowboard_utah/.gitignore
|
745
748
|
Created snowboard_utah/.ruby-version
|
@@ -988,7 +991,7 @@ Output:
|
|
988
991
|
|
989
992
|
Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
|
990
993
|
Opal glimmer-dsl-opal 0.4.0 AndyMaleh Glimmer DSL for Opal
|
991
|
-
Swt glimmer-dsl-swt 4.17.
|
994
|
+
Swt glimmer-dsl-swt 4.17.5.0 AndyMaleh Glimmer DSL for SWT
|
992
995
|
Tk glimmer-dsl-tk 0.0.6 AndyMaleh Glimmer DSL for Tk
|
993
996
|
Xml glimmer-dsl-xml 1.1.0 AndyMaleh Glimmer DSL for XML
|
994
997
|
```
|
@@ -1784,6 +1787,23 @@ Glimmer recently included **EXPERIMENTAL** gif animation support for the `backgr
|
|
1784
1787
|
|
1785
1788
|
Learn more about images in general at this SWT Image guide: https://www.eclipse.org/articles/Article-SWT-images/graphics-resources.html
|
1786
1789
|
|
1790
|
+
#### Image Options
|
1791
|
+
|
1792
|
+
Options may be passed in a hash at the end of `image` arguments:
|
1793
|
+
|
1794
|
+
- `width`: width of image
|
1795
|
+
- `height`: height of image
|
1796
|
+
|
1797
|
+
If only the width or height alone are specified, the other is calculated while maintaining the image aspect ratio.
|
1798
|
+
|
1799
|
+
Example:
|
1800
|
+
|
1801
|
+
```
|
1802
|
+
label {
|
1803
|
+
image 'someimage.png', width: 400, height: 300
|
1804
|
+
}
|
1805
|
+
```
|
1806
|
+
|
1787
1807
|
### Cursor
|
1788
1808
|
|
1789
1809
|
SWT widget `cursor` property represents the mouse cursor you see on the screen when you hover over that widget.
|
@@ -3587,6 +3607,42 @@ Hello, Sash Form! Red Label Maximized
|
|
3587
3607
|
|
3588
3608
|
![Hello Sash Form Red Maximized](images/glimmer-hello-sash-form-red-maximized.png)
|
3589
3609
|
|
3610
|
+
#### Hello, Styled Text!
|
3611
|
+
|
3612
|
+
This sample demonstrates the use of a `styled_text` in Glimmer.
|
3613
|
+
|
3614
|
+
Code:
|
3615
|
+
|
3616
|
+
[samples/hello/hello_styled_text.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_styled_text.rb)
|
3617
|
+
|
3618
|
+
Hello, Styled Text!
|
3619
|
+
|
3620
|
+
![Hello Styled Text](images/glimmer-hello-styled-text.png)
|
3621
|
+
|
3622
|
+
#### Hello, Expand Bar!
|
3623
|
+
|
3624
|
+
This sample demonstrates the use of a `expand_bar` and `expand_item` in Glimmer.
|
3625
|
+
|
3626
|
+
Code:
|
3627
|
+
|
3628
|
+
[samples/hello/hello_expand_bar.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_expand_bar.rb)
|
3629
|
+
|
3630
|
+
Hello, Expand Bar! All Expanded
|
3631
|
+
|
3632
|
+
![Hello Expand Bar All Expanded](images/glimmer-hello-expand-bar-all-expanded.png)
|
3633
|
+
|
3634
|
+
Hello, Expand Bar! Productivity Expanded
|
3635
|
+
|
3636
|
+
![Hello Expand Bar Productivity Expanded](images/glimmer-hello-expand-bar-productivity-expanded.png)
|
3637
|
+
|
3638
|
+
Hello, Expand Bar! Tools Expanded
|
3639
|
+
|
3640
|
+
![Hello Expand Bar Tools Expanded](images/glimmer-hello-expand-bar-tools-expanded.png)
|
3641
|
+
|
3642
|
+
Hello, Expand Bar! Reading Expanded
|
3643
|
+
|
3644
|
+
![Hello Expand Bar Reading Expanded](images/glimmer-hello-expand-bar-reading-expanded.png)
|
3645
|
+
|
3590
3646
|
### Elaborate Samples
|
3591
3647
|
|
3592
3648
|
For more elaborate samples, check the following:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.17.
|
1
|
+
4.17.5.0
|
data/glimmer-dsl-swt.gemspec
CHANGED
@@ -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
|
+
# stub: glimmer-dsl-swt 4.17.5.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.
|
9
|
+
s.version = "4.17.5.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-
|
14
|
+
s.date = "2020-10-24"
|
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]
|
@@ -56,6 +56,7 @@ Gem::Specification.new do |s|
|
|
56
56
|
"lib/glimmer/dsl/swt/dnd_expression.rb",
|
57
57
|
"lib/glimmer/dsl/swt/dsl.rb",
|
58
58
|
"lib/glimmer/dsl/swt/exec_expression.rb",
|
59
|
+
"lib/glimmer/dsl/swt/expand_item_expression.rb",
|
59
60
|
"lib/glimmer/dsl/swt/font_expression.rb",
|
60
61
|
"lib/glimmer/dsl/swt/image_expression.rb",
|
61
62
|
"lib/glimmer/dsl/swt/layout_data_expression.rb",
|
@@ -87,6 +88,7 @@ Gem::Specification.new do |s|
|
|
87
88
|
"lib/glimmer/swt/custom/code_text.rb",
|
88
89
|
"lib/glimmer/swt/display_proxy.rb",
|
89
90
|
"lib/glimmer/swt/dnd_proxy.rb",
|
91
|
+
"lib/glimmer/swt/expand_item_proxy.rb",
|
90
92
|
"lib/glimmer/swt/font_proxy.rb",
|
91
93
|
"lib/glimmer/swt/image_proxy.rb",
|
92
94
|
"lib/glimmer/swt/layout_data_proxy.rb",
|
@@ -126,12 +128,14 @@ Gem::Specification.new do |s|
|
|
126
128
|
"samples/hello/hello_custom_shell.rb",
|
127
129
|
"samples/hello/hello_custom_widget.rb",
|
128
130
|
"samples/hello/hello_drag_and_drop.rb",
|
131
|
+
"samples/hello/hello_expand_bar.rb",
|
129
132
|
"samples/hello/hello_list_multi_selection.rb",
|
130
133
|
"samples/hello/hello_list_single_selection.rb",
|
131
134
|
"samples/hello/hello_menu_bar.rb",
|
132
135
|
"samples/hello/hello_message_box.rb",
|
133
136
|
"samples/hello/hello_pop_up_context_menu.rb",
|
134
137
|
"samples/hello/hello_sash_form.rb",
|
138
|
+
"samples/hello/hello_styled_text.rb",
|
135
139
|
"samples/hello/hello_tab.rb",
|
136
140
|
"samples/hello/hello_world.rb",
|
137
141
|
"vendor/swt/linux/swt.jar",
|
@@ -0,0 +1,60 @@
|
|
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'
|
23
|
+
require 'glimmer/dsl/static_expression'
|
24
|
+
require 'glimmer/dsl/parent_expression'
|
25
|
+
require 'glimmer/swt/widget_proxy'
|
26
|
+
require 'glimmer/swt/expand_item_proxy'
|
27
|
+
|
28
|
+
module Glimmer
|
29
|
+
module DSL
|
30
|
+
module SWT
|
31
|
+
class ExpandItemExpression < StaticExpression
|
32
|
+
include ParentExpression
|
33
|
+
|
34
|
+
include_package 'org.eclipse.swt.widgets'
|
35
|
+
|
36
|
+
def can_interpret?(parent, keyword, *args, &block)
|
37
|
+
initial_condition = (keyword == 'expand_item') and parent.respond_to?(:swt_widget)
|
38
|
+
if initial_condition
|
39
|
+
if parent.swt_widget.is_a?(ExpandBar)
|
40
|
+
return true
|
41
|
+
else
|
42
|
+
Glimmer::Config.logger.error {"expand_item widget may only be used directly under a expand_bar widget!"}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
false
|
46
|
+
end
|
47
|
+
|
48
|
+
def interpret(parent, keyword, *args, &block)
|
49
|
+
Glimmer::SWT::ExpandItemProxy.new(parent, args)
|
50
|
+
end
|
51
|
+
|
52
|
+
def add_content(parent, &block)
|
53
|
+
super
|
54
|
+
parent.post_add_content
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -43,8 +43,8 @@ module Glimmer
|
|
43
43
|
code = text
|
44
44
|
return @syntax_highlighting if @last_code == code
|
45
45
|
@last_code = code
|
46
|
-
lexer
|
47
|
-
lex = lexer.lex(code).to_a
|
46
|
+
@lexer ||= Rouge::Lexer.find_fancy('ruby', code)
|
47
|
+
lex = @lexer.lex(code).to_a
|
48
48
|
code_size = 0
|
49
49
|
lex_hashes = lex.map do |pair|
|
50
50
|
{token_type: pair.first, token_text: pair.last}
|
@@ -0,0 +1,98 @@
|
|
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/swt/widget_proxy'
|
23
|
+
require 'glimmer/swt/swt_proxy'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module SWT
|
27
|
+
# Proxy for org.eclipse.swt.widgets.ExpandItem
|
28
|
+
#
|
29
|
+
# Functions differently from other widget proxies.
|
30
|
+
#
|
31
|
+
# Glimmer instantiates an SWT Composite alongside the SWT ExpandItem
|
32
|
+
# and returns it for `#swt_widget` to allow adding widgets into it.
|
33
|
+
#
|
34
|
+
# In order to get the SWT ExpandItem object, one must call `#swt_expand_item`.
|
35
|
+
#
|
36
|
+
# Behind the scenes, this creates a tab item widget proxy separately from a composite that
|
37
|
+
# is set as the control of the tab item and `#swt_widget`.
|
38
|
+
#
|
39
|
+
# In order to retrieve the tab item widget proxy, one must call `#widget_proxy`
|
40
|
+
#
|
41
|
+
# Follows the Proxy Design Pattern
|
42
|
+
class ExpandItemProxy < WidgetProxy
|
43
|
+
ATTRIBUTES = ['text', 'height', 'expanded']
|
44
|
+
|
45
|
+
include_package 'org.eclipse.swt.widgets'
|
46
|
+
|
47
|
+
attr_reader :widget_proxy, :swt_expand_item
|
48
|
+
|
49
|
+
def initialize(parent, style, &contents)
|
50
|
+
super("composite", parent, style, &contents)
|
51
|
+
layout = FillLayout.new(SWTProxy[:vertical])
|
52
|
+
layout.marginWidth = 0
|
53
|
+
layout.marginHeight = 0
|
54
|
+
layout.spacing = 0
|
55
|
+
swt_widget.layout = layout
|
56
|
+
@widget_proxy = SWT::WidgetProxy.new('expand_item', parent, style)
|
57
|
+
@swt_expand_item = @widget_proxy.swt_widget
|
58
|
+
@swt_expand_item.control = swt_widget
|
59
|
+
@swt_expand_item.expanded = true
|
60
|
+
end
|
61
|
+
|
62
|
+
def post_add_content
|
63
|
+
@swt_expand_item.setHeight(swt_widget.computeSize(SWTProxy[:default], SWTProxy[:default]).y) unless @swt_expand_item.getHeight > 0
|
64
|
+
WidgetProxy.new('composite', self, []) # adding filler since it seems like the last child gets a bad style, so this gets it instead
|
65
|
+
end
|
66
|
+
|
67
|
+
def has_attribute?(attribute_name, *args)
|
68
|
+
if ATTRIBUTES.include?(attribute_name.to_s)
|
69
|
+
true
|
70
|
+
else
|
71
|
+
super(attribute_name, *args)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def set_attribute(attribute_name, *args)
|
76
|
+
if ATTRIBUTES.include?(attribute_name.to_s)
|
77
|
+
@widget_proxy.set_attribute(attribute_name, *args)
|
78
|
+
else
|
79
|
+
super(attribute_name, *args)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def get_attribute(attribute_name)
|
84
|
+
if ATTRIBUTES.include?(attribute_name.to_s)
|
85
|
+
@widget_proxy.get_attribute(attribute_name)
|
86
|
+
else
|
87
|
+
super(attribute_name)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def dispose
|
92
|
+
swt_expand_item.setControl(nil)
|
93
|
+
swt_widget.dispose
|
94
|
+
swt_expand_item.dispose
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -60,6 +60,8 @@ module Glimmer
|
|
60
60
|
@swt_image = Image.new(DisplayProxy.instance.swt_display, @image_data)
|
61
61
|
width = options[:width]
|
62
62
|
height = options[:height]
|
63
|
+
height = (@image_data.height.to_f / @image_data.width.to_f)*width.to_f if !width.nil? && height.nil?
|
64
|
+
width = (@image_data.width.to_f / @image_data.height.to_f)*height.to_f if !height.nil? && width.nil?
|
63
65
|
scale_to(width, height) unless width.nil? || height.nil?
|
64
66
|
else
|
65
67
|
@swt_image = Image.new(*@args)
|
@@ -47,7 +47,7 @@ module Glimmer
|
|
47
47
|
super("composite", parent, style, &contents)
|
48
48
|
@widget_proxy = SWT::WidgetProxy.new('tab_item', parent, style)
|
49
49
|
@swt_tab_item = @widget_proxy.swt_widget
|
50
|
-
@
|
50
|
+
@swt_tab_item.control = swt_widget
|
51
51
|
end
|
52
52
|
|
53
53
|
def has_attribute?(attribute_name, *args)
|
@@ -100,6 +100,7 @@ class MetaSampleApplication
|
|
100
100
|
|
101
101
|
def launch
|
102
102
|
shell {
|
103
|
+
minimum_size 1280, 768
|
103
104
|
text 'Glimmer Meta-Sample (The Sample of Samples)'
|
104
105
|
|
105
106
|
on_swt_show {
|
@@ -109,29 +110,28 @@ class MetaSampleApplication
|
|
109
110
|
sash_form {
|
110
111
|
composite {
|
111
112
|
grid_layout 1, false
|
112
|
-
|
113
|
-
|
113
|
+
|
114
|
+
expand_bar {
|
114
115
|
layout_data(:fill, :fill, true, true)
|
116
|
+
font height: 30
|
115
117
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
sample.selected = true
|
134
|
-
}
|
118
|
+
SampleDirectory.sample_directories.each { |sample_directory|
|
119
|
+
expand_item {
|
120
|
+
layout_data(:fill, :fill, true, true)
|
121
|
+
grid_layout 2, false
|
122
|
+
text "#{sample_directory.name} Samples"
|
123
|
+
|
124
|
+
sample_directory.samples.each { |sample|
|
125
|
+
label_radio = radio {
|
126
|
+
selection bind(sample, :selected)
|
127
|
+
}
|
128
|
+
label {
|
129
|
+
layout_data :fill, :center, true, false
|
130
|
+
text sample.name
|
131
|
+
font height: 24
|
132
|
+
|
133
|
+
on_mouse_up {
|
134
|
+
sample.selected = true
|
135
135
|
}
|
136
136
|
}
|
137
137
|
}
|
@@ -140,11 +140,11 @@ class MetaSampleApplication
|
|
140
140
|
}
|
141
141
|
|
142
142
|
button {
|
143
|
-
layout_data(:
|
144
|
-
height_hint
|
143
|
+
layout_data(:fill, :center, true, false) {
|
144
|
+
height_hint 120
|
145
145
|
}
|
146
146
|
text 'Launch Sample'
|
147
|
-
font height:
|
147
|
+
font height: 30
|
148
148
|
on_widget_selected {
|
149
149
|
SampleDirectory.selected_sample.launch
|
150
150
|
}
|
@@ -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 HelloExpandBar
|
23
|
+
include Glimmer
|
24
|
+
|
25
|
+
def launch
|
26
|
+
shell {
|
27
|
+
grid_layout(1, false) {
|
28
|
+
margin_width 0
|
29
|
+
margin_height 0
|
30
|
+
}
|
31
|
+
minimum_size 320, 240
|
32
|
+
text 'Hello, Expand Bar!'
|
33
|
+
|
34
|
+
@status_label = label(:center) {
|
35
|
+
text ' '
|
36
|
+
layout_data :fill, :center, true, false
|
37
|
+
font height: 24
|
38
|
+
}
|
39
|
+
|
40
|
+
expand_bar {
|
41
|
+
layout_data :fill, :fill, true, true
|
42
|
+
|
43
|
+
expand_item {
|
44
|
+
text 'Productivity'
|
45
|
+
|
46
|
+
button {
|
47
|
+
text 'Word Processing'
|
48
|
+
}
|
49
|
+
button {
|
50
|
+
text 'Spreadsheets'
|
51
|
+
}
|
52
|
+
button {
|
53
|
+
text 'Presentations'
|
54
|
+
}
|
55
|
+
button {
|
56
|
+
text 'Database'
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
expand_item {
|
61
|
+
text 'Tools'
|
62
|
+
|
63
|
+
button {
|
64
|
+
text 'Calculator'
|
65
|
+
}
|
66
|
+
button {
|
67
|
+
text 'Unit Converter'
|
68
|
+
}
|
69
|
+
button {
|
70
|
+
text 'Currency Converter'
|
71
|
+
}
|
72
|
+
button {
|
73
|
+
text 'Scientific Calculator'
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
expand_item {
|
78
|
+
text 'Reading'
|
79
|
+
|
80
|
+
button {
|
81
|
+
text 'eBooks'
|
82
|
+
}
|
83
|
+
button {
|
84
|
+
text 'News'
|
85
|
+
}
|
86
|
+
button {
|
87
|
+
text 'Blogs'
|
88
|
+
}
|
89
|
+
button {
|
90
|
+
text 'Papers'
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
on_item_expanded { |expand_event|
|
95
|
+
@status_label.text = "#{expand_event.item.text} Expanded!"
|
96
|
+
}
|
97
|
+
|
98
|
+
on_item_collapsed { |expand_event|
|
99
|
+
@status_label.text = "#{expand_event.item.text} Collapsed!"
|
100
|
+
}
|
101
|
+
|
102
|
+
|
103
|
+
}
|
104
|
+
}.open
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
HelloExpandBar.new.launch
|
@@ -0,0 +1,138 @@
|
|
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
|
+
verbiage = <<-MULTI_LINE_STRING
|
23
|
+
|
24
|
+
Glimmer DSL for SWT is a native-GUI cross-platform desktop development library written in JRuby,
|
25
|
+
an OS-threaded faster version of Ruby.
|
26
|
+
Glimmer's main innovation is a declarative Ruby DSL that enables productive and efficient authoring
|
27
|
+
of desktop application user-interfaces while relying on the robust Eclipse SWT library.
|
28
|
+
Glimmer additionally innovates by having built-in data-binding support, which greatly facilitates
|
29
|
+
synchronizing the GUI with domain models, thus achieving true decoupling of object oriented components
|
30
|
+
and enabling developers to solve business problems (test-first) without worrying about GUI concerns.
|
31
|
+
To get started quickly, Glimmer offers scaffolding options for Apps, Gems, and Custom Widgets.
|
32
|
+
Glimmer also includes native-executable packaging support, sorely lacking in other libraries,
|
33
|
+
thus enabling the delivery of desktop apps written in Ruby as truly native DMG/PKG/APP files on
|
34
|
+
the Mac + App Store, MSI/EXE files on Windows, and Gem Packaged Shell Scripts on Linux.
|
35
|
+
|
36
|
+
MULTI_LINE_STRING
|
37
|
+
|
38
|
+
class StyledTextPresenter
|
39
|
+
include Glimmer
|
40
|
+
attr_accessor :text, :caret_offset, :selection_count, :selection, :top_pixel
|
41
|
+
|
42
|
+
def line_index_for_offset(line_offset)
|
43
|
+
text[0..line_offset].split("\n").size
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
include Glimmer
|
48
|
+
|
49
|
+
@presenter = StyledTextPresenter.new
|
50
|
+
@presenter.text = verbiage*8
|
51
|
+
@presenter.caret_offset = 0
|
52
|
+
@presenter.selection_count = 0
|
53
|
+
@presenter.selection = Point.new(0, 0)
|
54
|
+
@presenter.top_pixel = 0
|
55
|
+
|
56
|
+
shell {
|
57
|
+
text 'Hello, Styled Text!'
|
58
|
+
|
59
|
+
composite {
|
60
|
+
@styled_text = styled_text {
|
61
|
+
layout_data :fill, :fill, true, true
|
62
|
+
text bind(@presenter, :text)
|
63
|
+
left_margin 5
|
64
|
+
top_margin 5
|
65
|
+
right_margin 5
|
66
|
+
bottom_margin 5
|
67
|
+
# caret offset scrolls text to view when out of page
|
68
|
+
caret_offset bind(@presenter, :caret_offset)
|
69
|
+
# selection_count is not needed if selection is used
|
70
|
+
selection_count bind(@presenter, :selection_count)
|
71
|
+
# selection contains both caret_offset and selection_count, but setting it does not scroll text into view if out of page
|
72
|
+
selection bind(@presenter, :selection)
|
73
|
+
# top_pixel indicates vertically what pixel scrolling is at in a long multi-page text document
|
74
|
+
top_pixel bind(@presenter, :top_pixel)
|
75
|
+
|
76
|
+
# This demonstrates how to set styles via a listener
|
77
|
+
on_line_get_style { |line_style_event|
|
78
|
+
line_offset = line_style_event.lineOffset
|
79
|
+
if @presenter.line_index_for_offset(line_offset) % 52 < 13
|
80
|
+
line_size = line_style_event.lineText.size
|
81
|
+
style_range = StyleRange.new(line_offset, line_size, color(:blue).swt_color, nil, swt(:italic))
|
82
|
+
style_range.font = Font.new(display.swt_display, 'Times New Roman', 18, swt(:normal))
|
83
|
+
line_style_event.styles = [style_range].to_java(StyleRange)
|
84
|
+
elsif @presenter.line_index_for_offset(line_offset) % 52 < 26
|
85
|
+
line_size = line_style_event.lineText.size
|
86
|
+
style_range = StyleRange.new(line_offset, line_size, color(:dark_green).swt_color, color(:yellow).swt_color, swt(:bold))
|
87
|
+
line_style_event.styles = [style_range].to_java(StyleRange)
|
88
|
+
elsif @presenter.line_index_for_offset(line_offset) % 52 < 39
|
89
|
+
line_size = line_style_event.lineText.size
|
90
|
+
style_range = StyleRange.new(line_offset, line_size, color(:red).swt_color, nil, swt(:normal))
|
91
|
+
style_range.underline = true
|
92
|
+
style_range.font = Font.new(display.swt_display, 'Arial', 16, swt(:normal))
|
93
|
+
line_style_event.styles = [style_range].to_java(StyleRange)
|
94
|
+
else
|
95
|
+
line_size = line_style_event.lineText.size
|
96
|
+
style_range = StyleRange.new(line_offset, line_size, color(:dark_magenta).swt_color, color(:cyan).swt_color, swt(:normal))
|
97
|
+
style_range.strikeout = true
|
98
|
+
line_style_event.styles = [style_range].to_java(StyleRange)
|
99
|
+
end
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
composite {
|
104
|
+
row_layout :horizontal
|
105
|
+
|
106
|
+
label {
|
107
|
+
text 'Caret Offset:'
|
108
|
+
}
|
109
|
+
text {
|
110
|
+
text bind(@presenter, :caret_offset, on_read: ->(o) {"%04d" % [o] })
|
111
|
+
}
|
112
|
+
label {
|
113
|
+
text 'Selection Count:'
|
114
|
+
}
|
115
|
+
text {
|
116
|
+
text bind(@presenter, :selection_count, on_read: ->(o) {"%04d" % [o] })
|
117
|
+
}
|
118
|
+
label {
|
119
|
+
text 'Selection Start:'
|
120
|
+
}
|
121
|
+
text {
|
122
|
+
text bind(@presenter, 'selection.x', on_read: ->(o) {"%04d" % [o] })
|
123
|
+
}
|
124
|
+
label {
|
125
|
+
text 'Selection End:'
|
126
|
+
}
|
127
|
+
text {
|
128
|
+
text bind(@presenter, 'selection.y', on_read: ->(o) {"%04d" % [o] })
|
129
|
+
}
|
130
|
+
label {
|
131
|
+
text 'Top Pixel:'
|
132
|
+
}
|
133
|
+
text {
|
134
|
+
text bind(@presenter, :top_pixel, on_read: ->(o) {"%04d" % [o] })
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}
|
138
|
+
}.open
|
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.17.
|
4
|
+
version: 4.17.5.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-
|
11
|
+
date: 2020-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -356,6 +356,7 @@ files:
|
|
356
356
|
- lib/glimmer/dsl/swt/dnd_expression.rb
|
357
357
|
- lib/glimmer/dsl/swt/dsl.rb
|
358
358
|
- lib/glimmer/dsl/swt/exec_expression.rb
|
359
|
+
- lib/glimmer/dsl/swt/expand_item_expression.rb
|
359
360
|
- lib/glimmer/dsl/swt/font_expression.rb
|
360
361
|
- lib/glimmer/dsl/swt/image_expression.rb
|
361
362
|
- lib/glimmer/dsl/swt/layout_data_expression.rb
|
@@ -387,6 +388,7 @@ files:
|
|
387
388
|
- lib/glimmer/swt/custom/code_text.rb
|
388
389
|
- lib/glimmer/swt/display_proxy.rb
|
389
390
|
- lib/glimmer/swt/dnd_proxy.rb
|
391
|
+
- lib/glimmer/swt/expand_item_proxy.rb
|
390
392
|
- lib/glimmer/swt/font_proxy.rb
|
391
393
|
- lib/glimmer/swt/image_proxy.rb
|
392
394
|
- lib/glimmer/swt/layout_data_proxy.rb
|
@@ -426,12 +428,14 @@ files:
|
|
426
428
|
- samples/hello/hello_custom_shell.rb
|
427
429
|
- samples/hello/hello_custom_widget.rb
|
428
430
|
- samples/hello/hello_drag_and_drop.rb
|
431
|
+
- samples/hello/hello_expand_bar.rb
|
429
432
|
- samples/hello/hello_list_multi_selection.rb
|
430
433
|
- samples/hello/hello_list_single_selection.rb
|
431
434
|
- samples/hello/hello_menu_bar.rb
|
432
435
|
- samples/hello/hello_message_box.rb
|
433
436
|
- samples/hello/hello_pop_up_context_menu.rb
|
434
437
|
- samples/hello/hello_sash_form.rb
|
438
|
+
- samples/hello/hello_styled_text.rb
|
435
439
|
- samples/hello/hello_tab.rb
|
436
440
|
- samples/hello/hello_world.rb
|
437
441
|
- vendor/swt/linux/swt.jar
|