Class: Glimmer::SWT::ShellProxy

Inherits:
CompositeProxy show all
Defined in:
lib/glimmer/swt/shell_proxy.rb

Direct Known Subclasses

MakeShiftShellProxy

Constant Summary collapse

WIDTH_MIN =
130
HEIGHT_MIN =
0

Constants inherited from WidgetProxy

WidgetProxy::DEFAULT_INITIALIZERS

Instance Attribute Summary collapse

Attributes inherited from CompositeProxy

#layout

Attributes inherited from WidgetProxy

#args, #background, #children, #enabled, #font, #foreground, #parent, #path

Instance Method Summary collapse

Methods inherited from WidgetProxy

#add_child, #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, #property_type_converters, #remove_css_class, #remove_css_classes, #render, reset_max_id_numbers!, #selector, #set_attribute, #style_element, underscored_widget_name, widget_class, widget_exists?, #widget_property_listener_installers

Methods included from PropertyOwner

#attribute_getter, #attribute_setter, #get_attribute, #set_attribute

Constructor Details

#initialize(args) ⇒ ShellProxy

Returns a new instance of ShellProxy.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/glimmer/swt/shell_proxy.rb', line 14

def initialize(args)
  @args = args
  @children = []
#         Document.ready? do end # TODO consider embedding this jQuery call in so outside consumers don't have to use it
  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)
end

Instance Attribute Details

#minimum_sizeObject

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

#domObject



204
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
# File 'lib/glimmer/swt/shell_proxy.rb', line 204

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: 'tab-item-style') {
#               style_dom_tab_item_css
#             }        
#             style(class: 'modal-style') {
#               style_dom_modal_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
      }
    }
  }.to_s
end

#elementObject



26
27
28
# File 'lib/glimmer/swt/shell_proxy.rb', line 26

def element
  'div'
end

#openObject



241
242
243
244
245
# File 'lib/glimmer/swt/shell_proxy.rb', line 241

def open
  # TODO consider the idea of delaying rendering till the open method
  # TODO make it start as hidden and show shell upon open
  Glimmer::SWT::DisplayProxy.instance.shells << self
end

#parent_pathObject



30
31
32
# File 'lib/glimmer/swt/shell_proxy.rb', line 30

def parent_path
  'body'
end

#style_dom_cssObject



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/glimmer/swt/shell_proxy.rb', line 49

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_cssObject



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/glimmer/swt/shell_proxy.rb', line 83

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_cssObject



139
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
# File 'lib/glimmer/swt/shell_proxy.rb', line 139

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_cssObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/glimmer/swt/shell_proxy.rb', line 61

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_cssObject



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/glimmer/swt/shell_proxy.rb', line 100

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_cssObject



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/glimmer/swt/shell_proxy.rb', line 120

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_cssObject



192
193
194
195
196
197
198
199
200
201
202
# File 'lib/glimmer/swt/shell_proxy.rb', line 192

def style_dom_table_css
  <<~CSS        
    table {
      border-spacing: 0;
    }
      
    table tr th,td {
      cursor: default;
    }   
  CSS
end

#textObject



34
35
36
# File 'lib/glimmer/swt/shell_proxy.rb', line 34

def text
  $document.title
end

#text=(value) ⇒ Object



38
39
40
# File 'lib/glimmer/swt/shell_proxy.rb', line 38

def text=(value)
  Document.title = value
end