glimmer-dsl-opal 0.0.7 → 0.3.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 +56 -0
- data/README.md +815 -76
- data/VERSION +1 -1
- data/lib/glimmer-dsl-opal.rb +45 -8
- data/lib/glimmer-dsl-opal/ext/date.rb +13 -0
- data/lib/glimmer-dsl-opal/ext/exception.rb +5 -0
- data/lib/glimmer-dsl-opal/missing/net/http.rb +17 -0
- data/lib/glimmer-dsl-opal/missing/uri.rb +64 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager.rb +2 -3
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_manager_presenter.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_repository.rb +24 -99
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/login.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe/board.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe/cell.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_browser.rb +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +63 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_computed.rb +19 -19
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_computed/contact.rb +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +155 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +86 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_list_multi_selection.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_list_single_selection.rb +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_tab.rb +50 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_world.rb +29 -0
- data/lib/glimmer-dsl-opal/vendor/jquery.js +2 -0
- data/lib/glimmer/data_binding/element_binding.rb +1 -1
- data/lib/glimmer/data_binding/ext/observable_model.rb +6 -6
- data/lib/glimmer/data_binding/list_selection_binding.rb +1 -1
- data/lib/glimmer/data_binding/table_items_binding.rb +70 -0
- data/lib/glimmer/dsl/opal/async_exec_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/color_expression.rb +38 -0
- data/lib/glimmer/dsl/opal/column_properties_expression.rb +22 -0
- data/lib/glimmer/dsl/opal/combo_selection_data_binding_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/custom_widget_expression.rb +77 -0
- data/lib/glimmer/dsl/opal/dsl.rb +15 -14
- data/lib/glimmer/dsl/opal/font_expression.rb +47 -0
- data/lib/glimmer/dsl/opal/layout_data_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/layout_expression.rb +22 -0
- data/lib/glimmer/dsl/opal/list_selection_data_binding_expression.rb +2 -3
- data/lib/glimmer/dsl/opal/message_box_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/property_expression.rb +5 -2
- data/lib/glimmer/dsl/opal/rgb_expression.rb +32 -0
- data/lib/glimmer/dsl/opal/rgba_expression.rb +32 -0
- data/lib/glimmer/dsl/opal/shell_expression.rb +18 -2
- data/lib/glimmer/dsl/opal/swt_expression.rb +46 -0
- data/lib/glimmer/dsl/opal/{composite_expression.rb → table_column_expression.rb} +3 -3
- data/lib/glimmer/dsl/opal/{list_expression.rb → table_expression.rb} +3 -3
- data/lib/glimmer/dsl/opal/table_items_data_binding_expression.rb +29 -0
- data/lib/glimmer/dsl/opal/widget_expression.rb +24 -0
- data/lib/glimmer/dsl/opal/widget_listener_expression.rb +16 -3
- data/lib/glimmer/swt.rb +499 -0
- data/lib/glimmer/swt/browser_proxy.rb +27 -0
- data/lib/glimmer/swt/button_proxy.rb +40 -0
- data/lib/glimmer/swt/color_proxy.rb +119 -0
- data/lib/glimmer/{opal/select_proxy.rb → swt/combo_proxy.rb} +24 -19
- data/lib/glimmer/swt/composite_proxy.rb +31 -0
- data/lib/glimmer/{opal → swt}/display_proxy.rb +6 -4
- data/lib/glimmer/{opal → swt}/event_listener_proxy.rb +1 -1
- data/lib/glimmer/swt/fill_layout_proxy.rb +84 -0
- data/lib/glimmer/swt/font_proxy.rb +79 -0
- data/lib/glimmer/swt/grid_layout_proxy.rb +71 -0
- data/lib/glimmer/swt/label_proxy.rb +34 -0
- data/lib/glimmer/swt/layout_data_proxy.rb +87 -0
- data/lib/glimmer/swt/layout_proxy.rb +63 -0
- data/lib/glimmer/{opal → swt}/list_proxy.rb +31 -23
- data/lib/glimmer/swt/message_box_proxy.rb +143 -0
- data/lib/glimmer/{opal → swt}/point.rb +1 -1
- data/lib/glimmer/{opal → swt}/property_owner.rb +1 -1
- data/lib/glimmer/swt/row_layout_proxy.rb +105 -0
- data/lib/glimmer/swt/shell_proxy.rb +246 -0
- data/lib/glimmer/swt/style_constantizable.rb +154 -0
- data/lib/glimmer/swt/swt_proxy.rb +53 -0
- data/lib/glimmer/{opal/tab_folder.rb → swt/tab_folder_proxy.rb} +21 -15
- data/lib/glimmer/swt/tab_item_proxy.rb +84 -0
- data/lib/glimmer/swt/table_column_proxy.rb +56 -0
- data/lib/glimmer/swt/table_item_proxy.rb +147 -0
- data/lib/glimmer/swt/table_proxy.rb +159 -0
- data/lib/glimmer/swt/text_proxy.rb +46 -0
- data/lib/glimmer/swt/widget_proxy.rb +490 -0
- data/lib/glimmer/ui/custom_shell.rb +91 -0
- data/lib/glimmer/ui/custom_widget.rb +291 -0
- data/lib/glimmer/util/proc_tracker.rb +39 -0
- metadata +131 -76
- data/lib/glimmer/config.rb +0 -22
- data/lib/glimmer/dsl/engine.rb +0 -193
- data/lib/glimmer/dsl/expression.rb +0 -42
- data/lib/glimmer/dsl/expression_handler.rb +0 -48
- data/lib/glimmer/dsl/opal/browser_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/button_expression.rb +0 -18
- data/lib/glimmer/dsl/opal/combo_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/grid_layout_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/label_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/tab_folder_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/tab_item_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/text_expression.rb +0 -22
- data/lib/glimmer/dsl/parent_expression.rb +0 -12
- data/lib/glimmer/dsl/static_expression.rb +0 -36
- data/lib/glimmer/dsl/top_level_expression.rb +0 -7
- data/lib/glimmer/error.rb +0 -6
- data/lib/glimmer/invalid_keyword_error.rb +0 -6
- data/lib/glimmer/opal/div_proxy.rb +0 -22
- data/lib/glimmer/opal/document_proxy.rb +0 -178
- data/lib/glimmer/opal/element_proxy.rb +0 -287
- data/lib/glimmer/opal/grid_layout_proxy.rb +0 -54
- data/lib/glimmer/opal/iframe_proxy.rb +0 -23
- data/lib/glimmer/opal/input_proxy.rb +0 -45
- data/lib/glimmer/opal/label_proxy.rb +0 -25
- data/lib/glimmer/opal/layout_data_proxy.rb +0 -31
- data/lib/glimmer/opal/modal.rb +0 -94
- data/lib/glimmer/opal/tab_item.rb +0 -98
- data/lib/samples/elaborate/launch +0 -6
- data/lib/samples/hello/hello_combo.rb +0 -34
- data/lib/samples/hello/hello_tab.rb +0 -24
- data/lib/samples/hello/hello_world.rb +0 -8
- data/lib/samples/hello/launch +0 -10
- data/lib/samples/launch +0 -4
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'glimmer/error'
|
2
|
-
require 'glimmer/dsl/engine'
|
3
|
-
require 'glimmer/dsl/expression'
|
4
|
-
|
5
|
-
module Glimmer
|
6
|
-
module DSL
|
7
|
-
# Represents a StaticExpression for expressions where
|
8
|
-
# the keyword does not vary dynamically. These static keywords are then
|
9
|
-
# predefined as methods in Glimmer instead of needing method_missing
|
10
|
-
#
|
11
|
-
# StaticExpression subclasses may optionally implement `#can_interpret?`
|
12
|
-
# (not needed if it only checks for keyword)
|
13
|
-
#
|
14
|
-
# StaticExpression subclasses must define `#interpret`.
|
15
|
-
#
|
16
|
-
# The direct parent namespace of a StaticExpression subclass must match the DSL name (case-insensitive)
|
17
|
-
# (e.g. Glimmer::DSL::SWT::WidgetExpression has a DSL of :swt)
|
18
|
-
class StaticExpression < Expression
|
19
|
-
class << self
|
20
|
-
def inherited(base)
|
21
|
-
Glimmer::DSL::Engine.add_static_expression(base.new)
|
22
|
-
super
|
23
|
-
end
|
24
|
-
|
25
|
-
def keyword
|
26
|
-
@keyword ||= name.split(/::/).last.sub(/Expression$/, '').underscore
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Subclasses may optionally implement
|
31
|
-
def can_interpret?(parent, keyword, *args, &block)
|
32
|
-
true
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/lib/glimmer/error.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'glimmer/opal/element_proxy'
|
2
|
-
|
3
|
-
module Glimmer
|
4
|
-
module Opal
|
5
|
-
class DivProxy < ElementProxy
|
6
|
-
attr_reader :layout
|
7
|
-
|
8
|
-
def initialize(parent, args)
|
9
|
-
super(parent, args)
|
10
|
-
@layout = GridLayoutProxy.new(self, [])
|
11
|
-
end
|
12
|
-
|
13
|
-
def dom
|
14
|
-
div_id = id
|
15
|
-
div_style = css
|
16
|
-
@dom ||= DOM {
|
17
|
-
div(id: div_id, class: 'grid-layout', style: div_style)
|
18
|
-
}
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,178 +0,0 @@
|
|
1
|
-
require 'glimmer/opal/element_proxy'
|
2
|
-
require 'glimmer/opal/point'
|
3
|
-
|
4
|
-
module Glimmer
|
5
|
-
module Opal
|
6
|
-
class DocumentProxy < ElementProxy
|
7
|
-
# TODO consider renaming to ShellProxy to match SWT API
|
8
|
-
attr_reader :minimum_size
|
9
|
-
|
10
|
-
def initialize(args)
|
11
|
-
@args = args
|
12
|
-
@children = []
|
13
|
-
$document.ready do
|
14
|
-
$document.head.replace(head_dom)
|
15
|
-
$document.body.replace(dom)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def text
|
20
|
-
$document.title
|
21
|
-
end
|
22
|
-
|
23
|
-
def text=(value)
|
24
|
-
$document.ready do
|
25
|
-
$document.title = value
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def minimum_size=(width_or_minimum_size, height = nil)
|
30
|
-
@minimum_size = height.nil? ? width_or_minimum_size : Point.new(width_or_minimum_size, height)
|
31
|
-
redraw
|
32
|
-
end
|
33
|
-
|
34
|
-
def head_dom
|
35
|
-
# TODO make grid-layout support grab excess space false
|
36
|
-
@head_dom ||= DOM {
|
37
|
-
head {
|
38
|
-
<<~CSS
|
39
|
-
<style>
|
40
|
-
html {
|
41
|
-
width: 100%;
|
42
|
-
height: 100%;
|
43
|
-
}
|
44
|
-
body {
|
45
|
-
width: 100%;
|
46
|
-
height: 100%;
|
47
|
-
margin: 0;
|
48
|
-
}
|
49
|
-
body > iframe {
|
50
|
-
width: 100%;
|
51
|
-
height: 100%;
|
52
|
-
}
|
53
|
-
ul {
|
54
|
-
list-style: none;
|
55
|
-
padding: 0;
|
56
|
-
}
|
57
|
-
li {
|
58
|
-
cursor: default;
|
59
|
-
padding-left: 10px;
|
60
|
-
padding-right: 10px;
|
61
|
-
}
|
62
|
-
li.selected-list-item {
|
63
|
-
background: rgb(80, 116, 211);
|
64
|
-
color: white;
|
65
|
-
}
|
66
|
-
li.empty-list-item {
|
67
|
-
color: transparent;
|
68
|
-
}
|
69
|
-
.tabs {
|
70
|
-
overflow: hidden;
|
71
|
-
border: 1px solid #ccc;
|
72
|
-
background-color: #f1f1f1;
|
73
|
-
}
|
74
|
-
|
75
|
-
/* Style the buttons inside the tab */
|
76
|
-
.tabs .tab {
|
77
|
-
background-color: inherit;
|
78
|
-
float: left;
|
79
|
-
border: none;
|
80
|
-
outline: none;
|
81
|
-
cursor: pointer;
|
82
|
-
padding: 14px 16px;
|
83
|
-
transition: 0.3s;
|
84
|
-
font-size: 17px;
|
85
|
-
}
|
86
|
-
|
87
|
-
/* Change background color of buttons on hover */
|
88
|
-
.tabs .tab:hover {
|
89
|
-
background-color: #ddd;
|
90
|
-
}
|
91
|
-
|
92
|
-
/* Create an active/current tablink class */
|
93
|
-
.tabs .tab.active {
|
94
|
-
background-color: #ccc;
|
95
|
-
}
|
96
|
-
|
97
|
-
/* Style the tab content */
|
98
|
-
.tab-item {
|
99
|
-
padding: 6px 12px;
|
100
|
-
border: 1px solid #ccc;
|
101
|
-
border-top: none;
|
102
|
-
}
|
103
|
-
|
104
|
-
.hide {
|
105
|
-
display: none !important;
|
106
|
-
}
|
107
|
-
|
108
|
-
/* The Modal (background) */
|
109
|
-
.modal {
|
110
|
-
position: fixed; /* Stay in place */
|
111
|
-
z-index: 1; /* Sit on top */
|
112
|
-
padding-top: 100px; /* Location of the box */
|
113
|
-
left: 0;
|
114
|
-
top: 0;
|
115
|
-
width: 100%; /* Full width */
|
116
|
-
height: 100%; /* Full height */
|
117
|
-
overflow: auto; /* Enable scroll if needed */
|
118
|
-
background-color: rgb(0,0,0); /* Fallback color */
|
119
|
-
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
|
120
|
-
text-align: center;
|
121
|
-
}
|
122
|
-
|
123
|
-
/* Modal Content */
|
124
|
-
.modal-content {
|
125
|
-
background-color: #fefefe;
|
126
|
-
margin: auto;
|
127
|
-
border: 1px solid #888;
|
128
|
-
display: inline-block;
|
129
|
-
min-width: 200px;
|
130
|
-
}
|
131
|
-
|
132
|
-
.modal-content .text {
|
133
|
-
background: rgb(80, 116, 211);
|
134
|
-
color: white;
|
135
|
-
padding: 5px;
|
136
|
-
}
|
137
|
-
|
138
|
-
.modal-content .message {
|
139
|
-
padding: 20px;
|
140
|
-
}
|
141
|
-
|
142
|
-
/* The Close Button */
|
143
|
-
.close {
|
144
|
-
color: #aaaaaa;
|
145
|
-
float: right;
|
146
|
-
# font-size: 18px;
|
147
|
-
font-weight: bold;
|
148
|
-
margin: 5px;
|
149
|
-
}
|
150
|
-
|
151
|
-
.close:hover,
|
152
|
-
.close:focus {
|
153
|
-
color: #000;
|
154
|
-
text-decoration: none;
|
155
|
-
cursor: pointer;
|
156
|
-
}
|
157
|
-
</style>
|
158
|
-
CSS
|
159
|
-
}
|
160
|
-
}
|
161
|
-
end
|
162
|
-
|
163
|
-
def dom
|
164
|
-
i = 0
|
165
|
-
body_style = ''
|
166
|
-
body_style += "min-width: #{@minimum_size.x}px; min-height: #{@minimum_size.y}px;" if @minimum_size
|
167
|
-
@dom ||= DOM {
|
168
|
-
body(style: body_style) {
|
169
|
-
}
|
170
|
-
}
|
171
|
-
end
|
172
|
-
|
173
|
-
def open
|
174
|
-
# No Op (just a placeholder since it is not needed on the web)
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
@@ -1,287 +0,0 @@
|
|
1
|
-
require 'glimmer/opal/property_owner'
|
2
|
-
|
3
|
-
module Glimmer
|
4
|
-
module Opal
|
5
|
-
class ElementProxy
|
6
|
-
include Glimmer
|
7
|
-
include PropertyOwner
|
8
|
-
attr_reader :parent, :args, :css_classes, :css, :children, :enabled
|
9
|
-
|
10
|
-
def initialize(parent, args)
|
11
|
-
@parent = parent
|
12
|
-
@args = args
|
13
|
-
@children = Set.new
|
14
|
-
@css_classes = Set.new
|
15
|
-
@css = ''
|
16
|
-
@enabled = true
|
17
|
-
@parent.add_child(self)
|
18
|
-
end
|
19
|
-
|
20
|
-
def add_child(child)
|
21
|
-
# return if @children.include?(child) # TODO consider adding an option to enable this if needed to prevent dom repetition
|
22
|
-
@children << child
|
23
|
-
dom << child.dom
|
24
|
-
end
|
25
|
-
|
26
|
-
def enabled=(value)
|
27
|
-
@enabled = value
|
28
|
-
redraw
|
29
|
-
end
|
30
|
-
|
31
|
-
def redraw
|
32
|
-
if @dom
|
33
|
-
old_dom = @dom
|
34
|
-
@dom = nil
|
35
|
-
old_dom.replace dom
|
36
|
-
else
|
37
|
-
dom
|
38
|
-
end
|
39
|
-
@children.each do |child|
|
40
|
-
child.redraw
|
41
|
-
add_child(child)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# Subclasses must override with their own mappings
|
46
|
-
def observation_request_to_event_mapping
|
47
|
-
{}
|
48
|
-
end
|
49
|
-
|
50
|
-
def name
|
51
|
-
self.class.name.split('::').last.underscore.sub(/_proxy$/, '')
|
52
|
-
end
|
53
|
-
|
54
|
-
def id
|
55
|
-
# TODO replace hash with autoincrement per name
|
56
|
-
"#{name}-#{hash}"
|
57
|
-
end
|
58
|
-
|
59
|
-
# Subclasses can override with their own selector
|
60
|
-
def selector
|
61
|
-
"#{name}##{id}"
|
62
|
-
end
|
63
|
-
|
64
|
-
def add_css_class(css_class)
|
65
|
-
@css_classes << css_class
|
66
|
-
redraw
|
67
|
-
end
|
68
|
-
|
69
|
-
def add_css_classes(css_classes)
|
70
|
-
@css_classes += css_classes
|
71
|
-
redraw
|
72
|
-
end
|
73
|
-
|
74
|
-
def remove_css_class(css_class)
|
75
|
-
@css_classes.delete(css_class)
|
76
|
-
redraw
|
77
|
-
end
|
78
|
-
|
79
|
-
def remove_css_classes(css_classes)
|
80
|
-
@css_classes -= css_classes
|
81
|
-
redraw
|
82
|
-
end
|
83
|
-
|
84
|
-
def clear_css_classes(css_class)
|
85
|
-
@css_classes.clear
|
86
|
-
redraw
|
87
|
-
end
|
88
|
-
|
89
|
-
def css=(css)
|
90
|
-
@css = css
|
91
|
-
redraw
|
92
|
-
end
|
93
|
-
|
94
|
-
def has_style?(symbol)
|
95
|
-
@args.include?(symbol) # not a very solid implementation. Bring SWT constants eventually
|
96
|
-
end
|
97
|
-
|
98
|
-
def handle_observation_request(keyword, &event_listener)
|
99
|
-
return unless observation_request_to_event_mapping.keys.include?(keyword)
|
100
|
-
event = nil
|
101
|
-
delegate = nil
|
102
|
-
[observation_request_to_event_mapping[keyword]].flatten.each do |mapping|
|
103
|
-
event = mapping[:event]
|
104
|
-
event_handler = mapping[:event_handler]
|
105
|
-
potential_event_listener = event_handler&.call(event_listener)
|
106
|
-
event_listener = event_handler&.call(event_listener) || event_listener
|
107
|
-
delegate = $document.on(event, selector, &event_listener)
|
108
|
-
end
|
109
|
-
EventListenerProxy.new(element_proxy: self, event: event, selector: selector, delegate: delegate)
|
110
|
-
end
|
111
|
-
|
112
|
-
def add_observer(observer, property_name)
|
113
|
-
property_listener_installers = self.class.ancestors.map {|ancestor| widget_property_listener_installers[ancestor]}.compact
|
114
|
-
widget_listener_installers = property_listener_installers.map{|installer| installer[property_name.to_s.to_sym]}.compact if !property_listener_installers.empty?
|
115
|
-
widget_listener_installers.to_a.each do |widget_listener_installer|
|
116
|
-
widget_listener_installer.call(observer)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def set_attribute(attribute_name, *args)
|
121
|
-
apply_property_type_converters(attribute_name, args)
|
122
|
-
super(attribute_name, *args)
|
123
|
-
end
|
124
|
-
|
125
|
-
def apply_property_type_converters(attribute_name, args)
|
126
|
-
if args.count == 1
|
127
|
-
value = args.first
|
128
|
-
converter = property_type_converters[attribute_name.to_sym]
|
129
|
-
args[0] = converter.call(value) if converter
|
130
|
-
end
|
131
|
-
# if args.count == 1 && args.first.is_a?(ColorProxy)
|
132
|
-
# g_color = args.first
|
133
|
-
# args[0] = g_color.swt_color
|
134
|
-
# end
|
135
|
-
end
|
136
|
-
|
137
|
-
def property_type_converters
|
138
|
-
@property_type_converters ||= {
|
139
|
-
# :background => color_converter,
|
140
|
-
# :background_image => lambda do |value|
|
141
|
-
# if value.is_a?(String)
|
142
|
-
# if value.start_with?('uri:classloader')
|
143
|
-
# value = value.sub(/^uri\:classloader\:\//, '')
|
144
|
-
# object = java.lang.Object.new
|
145
|
-
# value = object.java_class.resource_as_stream(value)
|
146
|
-
# value = java.io.BufferedInputStream.new(value)
|
147
|
-
# end
|
148
|
-
# image_data = ImageData.new(value)
|
149
|
-
# on_event_Resize do |resize_event|
|
150
|
-
# new_image_data = image_data.scaledTo(@swt_widget.getSize.x, @swt_widget.getSize.y)
|
151
|
-
# @swt_widget.getBackgroundImage&.dispose
|
152
|
-
# @swt_widget.setBackgroundImage(Image.new(@swt_widget.getDisplay, new_image_data))
|
153
|
-
# end
|
154
|
-
# Image.new(@swt_widget.getDisplay, image_data)
|
155
|
-
# else
|
156
|
-
# value
|
157
|
-
# end
|
158
|
-
# end,
|
159
|
-
# :foreground => color_converter,
|
160
|
-
# :font => lambda do |value|
|
161
|
-
# if value.is_a?(Hash)
|
162
|
-
# font_properties = value
|
163
|
-
# FontProxy.new(self, font_properties).swt_font
|
164
|
-
# else
|
165
|
-
# value
|
166
|
-
# end
|
167
|
-
# end,
|
168
|
-
# :items => lambda do |value|
|
169
|
-
# value.to_java :string
|
170
|
-
# end,
|
171
|
-
:text => lambda do |value|
|
172
|
-
# if swt_widget.is_a?(Browser)
|
173
|
-
# value.to_s
|
174
|
-
# else
|
175
|
-
value.to_s
|
176
|
-
# end
|
177
|
-
end,
|
178
|
-
# :visible => lambda do |value|
|
179
|
-
# !!value
|
180
|
-
# end,
|
181
|
-
}
|
182
|
-
end
|
183
|
-
|
184
|
-
def widget_property_listener_installers
|
185
|
-
@swt_widget_property_listener_installers ||= {
|
186
|
-
# ElementProxy => {
|
187
|
-
# :focus => lambda do |observer|
|
188
|
-
# on_focus_gained { |focus_event|
|
189
|
-
# observer.call(true)
|
190
|
-
# }
|
191
|
-
# on_focus_lost { |focus_event|
|
192
|
-
# observer.call(false)
|
193
|
-
# }
|
194
|
-
# end,
|
195
|
-
# },
|
196
|
-
InputProxy => {
|
197
|
-
:text => lambda do |observer|
|
198
|
-
on_modify_text { |modify_event|
|
199
|
-
observer.call(text)
|
200
|
-
}
|
201
|
-
end,
|
202
|
-
# :caret_position => lambda do |observer|
|
203
|
-
# on_event_keydown { |event|
|
204
|
-
# observer.call(getCaretPosition)
|
205
|
-
# }
|
206
|
-
# on_event_keyup { |event|
|
207
|
-
# observer.call(getCaretPosition)
|
208
|
-
# }
|
209
|
-
# on_event_mousedown { |event|
|
210
|
-
# observer.call(getCaretPosition)
|
211
|
-
# }
|
212
|
-
# on_event_mouseup { |event|
|
213
|
-
# observer.call(getCaretPosition)
|
214
|
-
# }
|
215
|
-
# end,
|
216
|
-
# :selection => lambda do |observer|
|
217
|
-
# on_event_keydown { |event|
|
218
|
-
# observer.call(getSelection)
|
219
|
-
# }
|
220
|
-
# on_event_keyup { |event|
|
221
|
-
# observer.call(getSelection)
|
222
|
-
# }
|
223
|
-
# on_event_mousedown { |event|
|
224
|
-
# observer.call(getSelection)
|
225
|
-
# }
|
226
|
-
# on_event_mouseup { |event|
|
227
|
-
# observer.call(getSelection)
|
228
|
-
# }
|
229
|
-
# end,
|
230
|
-
# :selection_count => lambda do |observer|
|
231
|
-
# on_event_keydown { |event|
|
232
|
-
# observer.call(getSelectionCount)
|
233
|
-
# }
|
234
|
-
# on_event_keyup { |event|
|
235
|
-
# observer.call(getSelectionCount)
|
236
|
-
# }
|
237
|
-
# on_event_mousedown { |event|
|
238
|
-
# observer.call(getSelectionCount)
|
239
|
-
# }
|
240
|
-
# on_event_mouseup { |event|
|
241
|
-
# observer.call(getSelectionCount)
|
242
|
-
# }
|
243
|
-
# end,
|
244
|
-
# :top_index => lambda do |observer|
|
245
|
-
# @last_top_index = getTopIndex
|
246
|
-
# on_paint_control { |event|
|
247
|
-
# if getTopIndex != @last_top_index
|
248
|
-
# @last_top_index = getTopIndex
|
249
|
-
# observer.call(@last_top_index)
|
250
|
-
# end
|
251
|
-
# }
|
252
|
-
# end,
|
253
|
-
},
|
254
|
-
# Java::OrgEclipseSwtCustom::StyledText => {
|
255
|
-
# :text => lambda do |observer|
|
256
|
-
# on_modify_text { |modify_event|
|
257
|
-
# observer.call(getText)
|
258
|
-
# }
|
259
|
-
# end,
|
260
|
-
# },
|
261
|
-
# InputProxy => {
|
262
|
-
# :selection => lambda do |observer|
|
263
|
-
# on_widget_selected { |selection_event|
|
264
|
-
# observer.call(getSelection)
|
265
|
-
# }
|
266
|
-
# end
|
267
|
-
# },
|
268
|
-
# Java::OrgEclipseSwtWidgets::MenuItem => {
|
269
|
-
# :selection => lambda do |observer|
|
270
|
-
# on_widget_selected { |selection_event|
|
271
|
-
# observer.call(getSelection)
|
272
|
-
# }
|
273
|
-
# end
|
274
|
-
# },
|
275
|
-
# Java::OrgEclipseSwtWidgets::Spinner => {
|
276
|
-
# :selection => lambda do |observer|
|
277
|
-
# on_widget_selected { |selection_event|
|
278
|
-
# observer.call(getSelection)
|
279
|
-
# }
|
280
|
-
# end
|
281
|
-
# },
|
282
|
-
}
|
283
|
-
end
|
284
|
-
|
285
|
-
end
|
286
|
-
end
|
287
|
-
end
|