Class: Glimmer::SWT::ShellProxy
- Inherits:
-
CompositeProxy
- Object
- WidgetProxy
- CompositeProxy
- Glimmer::SWT::ShellProxy
- Defined in:
- lib/glimmer/swt/shell_proxy.rb
Direct Known Subclasses
Constant Summary collapse
- STYLE =
<<~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
- WIDTH_MIN =
130- HEIGHT_MIN =
0
Constants inherited from WidgetProxy
WidgetProxy::DEFAULT_INITIALIZERS
Instance Attribute Summary collapse
-
#menu_bar ⇒ Object
Returns the value of attribute menu_bar.
-
#minimum_size ⇒ Object
TODO consider renaming to ShellProxy to match SWT API.
Attributes inherited from CompositeProxy
Attributes inherited from WidgetProxy
#args, #background, #children, #disposed?, #enabled, #focus, #font, #foreground, #menu, #menu_requested, #parent, #path, #rendered
Instance Method Summary collapse
- #dom ⇒ Object
- #element ⇒ Object
-
#initialize(args) ⇒ ShellProxy
constructor
A new instance of ShellProxy.
- #open ⇒ Object
- #parent_path ⇒ Object
- #style_dom_css ⇒ Object
- #text ⇒ Object
- #text=(value) ⇒ Object
Methods inherited from CompositeProxy
Methods inherited from WidgetProxy
#add_content_on_render, #add_css_class, #add_css_classes, #add_observer, #apply_property_type_converters, #build_dom, #can_handle_observation_request?, #clear_css_classes, #content, #content_on_render_blocks, #css_classes, #default_observation_request_to_event_mapping, #dispose, #dom_element, #effective_observation_request_to_event_mapping, #event_listener_proxies, for, #get_data, #handle_observation_request, #has_style?, #id, #id=, #layout, #listener_dom_element, #listener_path, max_id_number_for, max_id_numbers, #method_missing, #name, next_id_number_for, #observation_request_to_event_mapping, #observation_requests, #pack, #parent_dom_element, #post_add_content, #post_dispose_child, #post_initialize_child, #property_type_converters, #remove_all_listeners, #remove_css_class, #remove_css_classes, #remove_event_listener_proxies, #render, reset_max_id_numbers!, #selector, #set_attribute, #set_data, #set_focus, #skip_content_on_render_blocks?, #style_element, #swt_widget, 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.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/glimmer/swt/shell_proxy.rb', line 36 def initialize(args) @args = args @children = [] # TODO consider the implication of emptying the body 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Glimmer::SWT::WidgetProxy
Instance Attribute Details
#menu_bar ⇒ Object
Returns the value of attribute menu_bar.
31 32 33 |
# File 'lib/glimmer/swt/shell_proxy.rb', line 31 def @menu_bar end |
#minimum_size ⇒ Object
TODO consider renaming to ShellProxy to match SWT API
30 31 32 |
# File 'lib/glimmer/swt/shell_proxy.rb', line 30 def minimum_size @minimum_size end |
Instance Method Details
#dom ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/glimmer/swt/shell_proxy.rb', line 84 def dom i = 0 body_id = id body_class = ([name] + css_classes.to_a).join(' ') @dom ||= html { div(id: body_id, class: body_class) { # TODO consider supporting the idea of dynamic CSS building on close of shell that adds only as much CSS as needed for widgets that were mentioned style(class: 'common-style') { style_dom_css } [LayoutProxy, WidgetProxy].map(&:descendants).reduce(:+).each do |style_class| if style_class.constants.include?('STYLE') style(class: "#{style_class.name.split(':').last.underscore.gsub('_', '-').sub(/-proxy$/, '')}-style") { style_class::STYLE } end end '' } }.to_s end |
#element ⇒ Object
49 50 51 |
# File 'lib/glimmer/swt/shell_proxy.rb', line 49 def element 'div' end |
#open ⇒ Object
106 107 108 109 110 |
# File 'lib/glimmer/swt/shell_proxy.rb', line 106 def open # TODO consider the idea of delaying rendering till the open method # TODO make it start as hidden and show shell upon open # DisplayProxy.instance.shells << self end |
#parent_path ⇒ Object
53 54 55 |
# File 'lib/glimmer/swt/shell_proxy.rb', line 53 def parent_path 'body' end |
#style_dom_css ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/glimmer/swt/shell_proxy.rb', line 72 def style_dom_css <<~CSS .hide { display: none !important; } .selected { background: rgb(80, 116, 211); color: white; } CSS end |
#text ⇒ Object
57 58 59 |
# File 'lib/glimmer/swt/shell_proxy.rb', line 57 def text $document.title end |
#text=(value) ⇒ Object
61 62 63 |
# File 'lib/glimmer/swt/shell_proxy.rb', line 61 def text=(value) Document.title = value end |