Class: Glimmer::SWT::ShellProxy
Constant Summary
collapse
- WIDTH_MIN =
130
- HEIGHT_MIN =
0
Constants inherited
from WidgetProxy
WidgetProxy::DEFAULT_INITIALIZERS
Instance Attribute Summary collapse
#layout
Attributes inherited from WidgetProxy
#args, #background, #children, #enabled, #focus, #font, #foreground, #parent, #path
Instance Method Summary
collapse
Methods inherited from WidgetProxy
#add_css_class, #add_css_classes, #add_observer, #apply_property_type_converters, #build_dom, #can_handle_observation_request?, #clear_css_classes, #content, #css_classes, #dispose, #dom_element, for, #handle_observation_request, #has_style?, #id, #id=, #listener_dom_element, #listener_path, max_id_number_for, max_id_numbers, #name, next_id_number_for, #observation_request_to_event_mapping, #parent_dom_element, #post_add_content, #post_initialize_child, #property_type_converters, #remove_css_class, #remove_css_classes, #render, reset_max_id_numbers!, #selector, #set_attribute, #set_focus, #style_element, underscored_widget_name, widget_class, widget_exists?, #widget_property_listener_installers
#attribute_getter, #attribute_setter, #get_attribute, #set_attribute
Constructor Details
Returns a new instance of ShellProxy.
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/glimmer/swt/shell_proxy.rb', line 14
def initialize(args)
@args = args
@children = []
Document.find('body').empty unless ENV['RUBY_ENV'] == 'test'
render
@layout = FillLayoutProxy.new(self, [])
@layout.margin_width = 0
@layout.margin_height = 0
self.minimum_size = Point.new(WIDTH_MIN, HEIGHT_MIN)
DisplayProxy.instance.shells << self
end
|
Instance Attribute Details
#minimum_size ⇒ Object
TODO consider renaming to ShellProxy to match SWT API
9
10
11
|
# File 'lib/glimmer/swt/shell_proxy.rb', line 9
def minimum_size
@minimum_size
end
|
Instance Method Details
#dom ⇒ Object
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
# File 'lib/glimmer/swt/shell_proxy.rb', line 205
def dom
i = 0
body_id = id
body_class = ([name] + css_classes.to_a).join(' ')
@dom ||= html {
div(id: body_id, class: body_class) {
style(class: 'common-style') {
style_dom_css
}
style(class: 'shell-style') {
style_dom_shell_css
}
style(class: 'list-style') {
style_dom_list_css
}
style(class: 'tab-style') {
style_dom_tab_css
}
style(class: 'table-style') {
style_dom_table_css
}
style(class: 'fill-layout-style') {
Glimmer::SWT::FillLayoutProxy::STYLE
}
style(class: 'row-layout-style') {
Glimmer::SWT::RowLayoutProxy::STYLE
}
style(class: 'grid-layout-style') {
Glimmer::SWT::GridLayoutProxy::STYLE
}
style(class: 'checkbox-style') {
Glimmer::SWT::CheckboxProxy::STYLE
}
style(class: 'radio-style') {
Glimmer::SWT::RadioProxy::STYLE
}
style(class: 'scrolled-composite-style') {
Glimmer::SWT::ScrolledCompositeProxy::STYLE
}
style(class: 'table-item-style') {
Glimmer::SWT::TableItemProxy::STYLE
}
style(class: 'table-column-style') {
Glimmer::SWT::TableColumnProxy::STYLE
}
}
}.to_s
end
|
#element ⇒ Object
27
28
29
|
# File 'lib/glimmer/swt/shell_proxy.rb', line 27
def element
'div'
end
|
#parent_path ⇒ Object
31
32
33
|
# File 'lib/glimmer/swt/shell_proxy.rb', line 31
def parent_path
'body'
end
|
#style_dom_css ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/glimmer/swt/shell_proxy.rb', line 50
def style_dom_css
<<~CSS
.hide {
display: none !important;
}
.selected, .tabs .tab.selected {
background: rgb(80, 116, 211);
color: white;
}
CSS
end
|
#style_dom_list_css ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/glimmer/swt/shell_proxy.rb', line 84
def style_dom_list_css
<<~CSS
ul {
list-style: none;
padding: 0;
}
li {
cursor: default;
padding-left: 10px;
padding-right: 10px;
}
li.empty-list-item {
color: transparent;
}
CSS
end
|
#style_dom_modal_css ⇒ Object
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
# File 'lib/glimmer/swt/shell_proxy.rb', line 140
def style_dom_modal_css
<<~CSS
/* The Modal (background) */
.modal {
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
padding-top: 100px; /* Location of the box */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
text-align: center;
}
/* Modal Content */
.modal-content {
background-color: #fefefe;
margin: auto;
border: 1px solid #888;
display: inline-block;
min-width: 200px;
}
.modal-content .text {
background: rgb(80, 116, 211);
color: white;
padding: 5px;
}
.modal-content .message {
padding: 20px;
}
/* The Close Button */
.close {
color: #aaaaaa;
float: right;
font-weight: bold;
margin: 5px;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
CSS
end
|
#style_dom_shell_css ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/glimmer/swt/shell_proxy.rb', line 62
def style_dom_shell_css
<<~CSS
html {
width: 100%;
height: 100%;
}
body {
width: 100%;
height: 100%;
margin: 0;
}
.shell {
height: 100%;
margin: 0;
}
.shell iframe {
width: 100%;
height: 100%;
}
CSS
end
|
#style_dom_tab_css ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/glimmer/swt/shell_proxy.rb', line 101
def style_dom_tab_css
<<~CSS
.tabs .tab {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
font-size: 17px;
}
.tabs {
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
}
CSS
end
|
#style_dom_tab_item_css ⇒ Object
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
# File 'lib/glimmer/swt/shell_proxy.rb', line 121
def style_dom_tab_item_css
<<~CSS
/* Create an selected/current tablink class */
.tabs .tab.selected {
background-color: #ccc;
}
/* Change background color of buttons on hover */
.tabs .tab:hover {
background-color: #ddd;
}
/* Style the tab content */
.tab-item {
padding: 6px 12px;
border: 1px solid #ccc;
border-top: none;
}
CSS
end
|
#style_dom_table_css ⇒ Object
193
194
195
196
197
198
199
200
201
202
203
|
# File 'lib/glimmer/swt/shell_proxy.rb', line 193
def style_dom_table_css
<<~CSS
table {
border-spacing: 0;
}
table tr th,td {
cursor: default;
}
CSS
end
|
#text ⇒ Object
35
36
37
|
# File 'lib/glimmer/swt/shell_proxy.rb', line 35
def text
$document.title
end
|
#text=(value) ⇒ Object
39
40
41
|
# File 'lib/glimmer/swt/shell_proxy.rb', line 39
def text=(value)
Document.title = value
end
|