glimmer-dsl-swt 0.5.6 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/RUBY_VERSION +1 -1
- data/VERSION +1 -1
- data/bin/girb +1 -1
- data/bin/glimmer +1 -1
- data/icons/scaffold_app.ico +0 -0
- data/icons/scaffold_app.png +0 -0
- data/lib/ext/glimmer/config.rb +5 -1
- data/lib/glimmer/Rakefile +5 -0
- data/lib/glimmer/dsl/swt/cursor_expression.rb +23 -0
- data/lib/glimmer/dsl/swt/dsl.rb +3 -0
- data/lib/glimmer/dsl/swt/font_expression.rb +26 -0
- data/lib/glimmer/dsl/swt/image_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/message_box_expression.rb +9 -1
- data/lib/glimmer/dsl/swt/widget_expression.rb +7 -7
- data/lib/glimmer/launcher.rb +36 -8
- data/lib/glimmer/package.rb +31 -7
- data/lib/glimmer/rake_task.rb +111 -6
- data/lib/glimmer/scaffold.rb +98 -62
- data/lib/glimmer/swt/cursor_proxy.rb +45 -0
- data/lib/glimmer/swt/display_proxy.rb +13 -2
- data/lib/glimmer/swt/font_proxy.rb +7 -7
- data/lib/glimmer/swt/image_proxy.rb +16 -23
- data/lib/glimmer/swt/layout_proxy.rb +2 -0
- data/lib/glimmer/swt/message_box_proxy.rb +23 -5
- data/lib/glimmer/swt/scrolled_composite_proxy.rb +6 -11
- data/lib/glimmer/swt/style_constantizable.rb +11 -1
- data/lib/glimmer/swt/table_proxy.rb +50 -2
- data/lib/glimmer/swt/widget_proxy.rb +79 -18
- data/samples/elaborate/contact_manager.rb +121 -0
- data/samples/elaborate/contact_manager/contact.rb +11 -0
- data/samples/elaborate/contact_manager/contact_manager_presenter.rb +26 -0
- data/samples/elaborate/contact_manager/contact_repository.rb +244 -0
- data/samples/elaborate/login.rb +108 -0
- data/samples/elaborate/tic_tac_toe.rb +55 -0
- data/samples/elaborate/tic_tac_toe/board.rb +124 -0
- data/samples/elaborate/tic_tac_toe/cell.rb +27 -0
- data/samples/hello/hello_browser.rb +8 -0
- data/samples/hello/hello_combo.rb +38 -0
- data/samples/hello/hello_computed.rb +69 -0
- data/samples/hello/hello_computed/contact.rb +21 -0
- data/samples/hello/hello_drag_and_drop.rb +29 -0
- data/samples/hello/hello_list_multi_selection.rb +48 -0
- data/samples/hello/hello_list_single_selection.rb +37 -0
- data/samples/hello/hello_menu_bar.rb +64 -0
- data/samples/hello/hello_message_box.rb +15 -0
- data/samples/hello/hello_pop_up_context_menu.rb +36 -0
- data/samples/hello/hello_tab.rb +24 -0
- data/samples/hello/hello_world.rb +8 -0
- data/vendor/swt/linux/swt.jar +0 -0
- data/vendor/swt/mac/swt.jar +0 -0
- data/vendor/swt/windows/swt.jar +0 -0
- metadata +48 -7
@@ -0,0 +1,27 @@
|
|
1
|
+
class TicTacToe
|
2
|
+
class Cell
|
3
|
+
EMPTY = ""
|
4
|
+
attr_accessor :sign, :empty
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
reset
|
8
|
+
end
|
9
|
+
|
10
|
+
def mark(sign)
|
11
|
+
self.sign = sign
|
12
|
+
end
|
13
|
+
|
14
|
+
def reset
|
15
|
+
self.sign = EMPTY
|
16
|
+
end
|
17
|
+
|
18
|
+
def sign=(sign_symbol)
|
19
|
+
@sign = sign_symbol
|
20
|
+
self.empty = sign == EMPTY
|
21
|
+
end
|
22
|
+
|
23
|
+
def marked
|
24
|
+
!empty
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class Person
|
2
|
+
attr_accessor :country, :country_options
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
self.country_options=["", "Canada", "US", "Mexico"]
|
6
|
+
self.country = "Canada"
|
7
|
+
end
|
8
|
+
|
9
|
+
def reset_country
|
10
|
+
self.country = "Canada"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class HelloCombo
|
15
|
+
include Glimmer
|
16
|
+
def launch
|
17
|
+
person = Person.new
|
18
|
+
|
19
|
+
shell {
|
20
|
+
fill_layout :vertical
|
21
|
+
text 'Hello, Combo!'
|
22
|
+
|
23
|
+
combo(:read_only) {
|
24
|
+
selection bind(person, :country)
|
25
|
+
}
|
26
|
+
|
27
|
+
button {
|
28
|
+
text "Reset Selection"
|
29
|
+
|
30
|
+
on_widget_selected do
|
31
|
+
person.reset_country
|
32
|
+
end
|
33
|
+
}
|
34
|
+
}.open
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
HelloCombo.new.launch
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require_relative 'hello_computed/contact'
|
2
|
+
|
3
|
+
class HelloComputed
|
4
|
+
include Glimmer
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@contact = Contact.new(
|
8
|
+
first_name: 'Barry',
|
9
|
+
last_name: 'McKibbin',
|
10
|
+
year_of_birth: 1985
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
def launch
|
15
|
+
shell {
|
16
|
+
text 'Hello, Computed!'
|
17
|
+
composite {
|
18
|
+
grid_layout {
|
19
|
+
num_columns 2
|
20
|
+
make_columns_equal_width true
|
21
|
+
horizontal_spacing 20
|
22
|
+
vertical_spacing 10
|
23
|
+
}
|
24
|
+
label {text 'First &Name: '}
|
25
|
+
text {
|
26
|
+
text bind(@contact, :first_name)
|
27
|
+
layout_data {
|
28
|
+
horizontal_alignment :fill
|
29
|
+
grab_excess_horizontal_space true
|
30
|
+
}
|
31
|
+
}
|
32
|
+
label {text '&Last Name: '}
|
33
|
+
text {
|
34
|
+
text bind(@contact, :last_name)
|
35
|
+
layout_data {
|
36
|
+
horizontal_alignment :fill
|
37
|
+
grab_excess_horizontal_space true
|
38
|
+
}
|
39
|
+
}
|
40
|
+
label {text '&Year of Birth: '}
|
41
|
+
text {
|
42
|
+
text bind(@contact, :year_of_birth)
|
43
|
+
layout_data {
|
44
|
+
horizontal_alignment :fill
|
45
|
+
grab_excess_horizontal_space true
|
46
|
+
}
|
47
|
+
}
|
48
|
+
label {text 'Name: '}
|
49
|
+
label {
|
50
|
+
text bind(@contact, :name, computed_by: [:first_name, :last_name])
|
51
|
+
layout_data {
|
52
|
+
horizontal_alignment :fill
|
53
|
+
grab_excess_horizontal_space true
|
54
|
+
}
|
55
|
+
}
|
56
|
+
label {text 'Age: '}
|
57
|
+
label {
|
58
|
+
text bind(@contact, :age, on_write: :to_i, computed_by: [:year_of_birth])
|
59
|
+
layout_data {
|
60
|
+
horizontal_alignment :fill
|
61
|
+
grab_excess_horizontal_space true
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}.open
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
HelloComputed.new.launch
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class HelloComputed
|
2
|
+
class Contact
|
3
|
+
attr_accessor :first_name, :last_name, :year_of_birth
|
4
|
+
|
5
|
+
def initialize(attribute_map)
|
6
|
+
@first_name = attribute_map[:first_name]
|
7
|
+
@last_name = attribute_map[:last_name]
|
8
|
+
@year_of_birth = attribute_map[:year_of_birth]
|
9
|
+
end
|
10
|
+
|
11
|
+
def name
|
12
|
+
"#{last_name}, #{first_name}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def age
|
16
|
+
Time.now.year - year_of_birth.to_i
|
17
|
+
rescue
|
18
|
+
0
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Location
|
2
|
+
attr_accessor :country
|
3
|
+
|
4
|
+
def country_options
|
5
|
+
%w[USA Canada Mexico Columbia UK Australia Germany Italy Spain]
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
@location = Location.new
|
10
|
+
|
11
|
+
include Glimmer
|
12
|
+
|
13
|
+
shell {
|
14
|
+
text 'Hello, Drag and Drop!'
|
15
|
+
list {
|
16
|
+
selection bind(@location, :country)
|
17
|
+
on_drag_set_data { |event|
|
18
|
+
list = event.widget.getControl
|
19
|
+
event.data = list.getSelection.first
|
20
|
+
}
|
21
|
+
}
|
22
|
+
label(:center) {
|
23
|
+
text 'Drag a country here!'
|
24
|
+
font height: 20
|
25
|
+
on_drop { |event|
|
26
|
+
event.widget.getControl.setText(event.data)
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}.open
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class Person
|
2
|
+
attr_accessor :provinces, :provinces_options
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
self.provinces_options=[
|
6
|
+
"",
|
7
|
+
"Quebec",
|
8
|
+
"Ontario",
|
9
|
+
"Manitoba",
|
10
|
+
"Saskatchewan",
|
11
|
+
"Alberta",
|
12
|
+
"British Columbia",
|
13
|
+
"Nova Skotia",
|
14
|
+
"Newfoundland"
|
15
|
+
]
|
16
|
+
self.provinces = ["Quebec", "Manitoba", "Alberta"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def reset_provinces
|
20
|
+
self.provinces = ["Quebec", "Manitoba", "Alberta"]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class HelloListMultiSelection
|
25
|
+
include Glimmer
|
26
|
+
|
27
|
+
def launch
|
28
|
+
person = Person.new
|
29
|
+
|
30
|
+
shell {
|
31
|
+
grid_layout
|
32
|
+
|
33
|
+
text 'Hello, List Multi Selection!'
|
34
|
+
|
35
|
+
list(:multi) {
|
36
|
+
selection bind(person, :provinces)
|
37
|
+
}
|
38
|
+
|
39
|
+
button {
|
40
|
+
text "Reset Selection To Defaults"
|
41
|
+
|
42
|
+
on_widget_selected { person.reset_provinces }
|
43
|
+
}
|
44
|
+
}.open
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
HelloListMultiSelection.new.launch
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class Person
|
2
|
+
attr_accessor :country, :country_options
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
self.country_options=["", "Canada", "US", "Mexico"]
|
6
|
+
self.country = "Canada"
|
7
|
+
end
|
8
|
+
|
9
|
+
def reset_country
|
10
|
+
self.country = "Canada"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class HelloListSingleSelection
|
15
|
+
include Glimmer
|
16
|
+
def launch
|
17
|
+
person = Person.new
|
18
|
+
|
19
|
+
shell {
|
20
|
+
grid_layout
|
21
|
+
|
22
|
+
text 'Hello, List Single Selection!'
|
23
|
+
|
24
|
+
list {
|
25
|
+
selection bind(person, :country)
|
26
|
+
}
|
27
|
+
|
28
|
+
button {
|
29
|
+
text "Reset Selection To Default Value"
|
30
|
+
|
31
|
+
on_widget_selected { person.reset_country }
|
32
|
+
}
|
33
|
+
}.open
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
HelloListSingleSelection.new.launch
|
@@ -0,0 +1,64 @@
|
|
1
|
+
include Glimmer
|
2
|
+
|
3
|
+
shell { |shell_proxy|
|
4
|
+
text 'Hello, Menu Bar!'
|
5
|
+
grid_layout
|
6
|
+
label(:center) {
|
7
|
+
font height: 16
|
8
|
+
text 'Check Out The File Menu and History Menu in The Menu Bar Above!'
|
9
|
+
}
|
10
|
+
menu_bar {
|
11
|
+
menu {
|
12
|
+
text '&File'
|
13
|
+
menu_item {
|
14
|
+
text 'E&xit'
|
15
|
+
on_widget_selected {
|
16
|
+
exit(0)
|
17
|
+
}
|
18
|
+
}
|
19
|
+
menu_item(0) {
|
20
|
+
text '&New'
|
21
|
+
on_widget_selected {
|
22
|
+
message_box(shell_proxy) {
|
23
|
+
text 'New File'
|
24
|
+
message 'New File Contents'
|
25
|
+
}.open
|
26
|
+
}
|
27
|
+
}
|
28
|
+
menu(1) {
|
29
|
+
text '&Options'
|
30
|
+
menu_item(:radio) {
|
31
|
+
text 'Option 1'
|
32
|
+
}
|
33
|
+
menu_item(:separator)
|
34
|
+
menu_item(:check) {
|
35
|
+
text 'Option 3'
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
menu {
|
40
|
+
text '&History'
|
41
|
+
menu {
|
42
|
+
text '&Recent'
|
43
|
+
menu_item {
|
44
|
+
text 'File 1'
|
45
|
+
on_widget_selected {
|
46
|
+
message_box(shell_proxy) {
|
47
|
+
text 'File 1'
|
48
|
+
message 'File 1 Contents'
|
49
|
+
}.open
|
50
|
+
}
|
51
|
+
}
|
52
|
+
menu_item {
|
53
|
+
text 'File 2'
|
54
|
+
on_widget_selected {
|
55
|
+
message_box(shell_proxy) {
|
56
|
+
text 'File 2'
|
57
|
+
message 'File 2 Contents'
|
58
|
+
}.open
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}.open
|
@@ -0,0 +1,15 @@
|
|
1
|
+
include Glimmer
|
2
|
+
|
3
|
+
@shell = shell {
|
4
|
+
text 'Hello, Message Box!'
|
5
|
+
button {
|
6
|
+
text 'Please Click To Win a Surprise'
|
7
|
+
on_widget_selected {
|
8
|
+
message_box(@shell) {
|
9
|
+
text 'Surprise'
|
10
|
+
message "Congratulations!\n\nYou have won $1,000,000!"
|
11
|
+
}.open
|
12
|
+
}
|
13
|
+
}
|
14
|
+
}
|
15
|
+
@shell.open
|
@@ -0,0 +1,36 @@
|
|
1
|
+
include Glimmer
|
2
|
+
|
3
|
+
shell { |shell_proxy|
|
4
|
+
text 'Hello, Pop Up Context Menu!'
|
5
|
+
grid_layout
|
6
|
+
label {
|
7
|
+
font height: 16
|
8
|
+
text 'Right-Click To Pop Up a Context Menu'
|
9
|
+
menu {
|
10
|
+
menu {
|
11
|
+
text '&History'
|
12
|
+
menu {
|
13
|
+
text '&Recent'
|
14
|
+
menu_item {
|
15
|
+
text 'File 1'
|
16
|
+
on_widget_selected {
|
17
|
+
message_box(shell_proxy) {
|
18
|
+
text 'File 1'
|
19
|
+
message 'File 1 Contents'
|
20
|
+
}.open
|
21
|
+
}
|
22
|
+
}
|
23
|
+
menu_item {
|
24
|
+
text 'File 2'
|
25
|
+
on_widget_selected {
|
26
|
+
message_box(shell_proxy) {
|
27
|
+
text 'File 2'
|
28
|
+
message 'File 2 Contents'
|
29
|
+
}.open
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}.open
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class HelloTab
|
2
|
+
include Glimmer
|
3
|
+
def launch
|
4
|
+
shell {
|
5
|
+
text "Hello, Tab!"
|
6
|
+
tab_folder {
|
7
|
+
tab_item {
|
8
|
+
text "English"
|
9
|
+
label {
|
10
|
+
text "Hello, World!"
|
11
|
+
}
|
12
|
+
}
|
13
|
+
tab_item {
|
14
|
+
text "French"
|
15
|
+
label {
|
16
|
+
text "Bonjour, Univers!"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}.open
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
HelloTab.new.launch
|
data/vendor/swt/linux/swt.jar
CHANGED
Binary file
|
data/vendor/swt/mac/swt.jar
CHANGED
Binary file
|