Class: Glimmer::SWT::LayoutProxy
- Inherits:
-
Object
- Object
- Glimmer::SWT::LayoutProxy
- Includes:
- PropertyOwner
- Defined in:
- lib/glimmer/swt/layout_proxy.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Class Method Summary collapse
-
.for(keyword, parent, args) ⇒ Object
Factory Method that translates a Glimmer DSL keyword into a WidgetProxy object.
- .layout_class(keyword) ⇒ Object
- .layout_exists?(keyword) ⇒ Boolean
Instance Method Summary collapse
- #css_class ⇒ Object
-
#dom(widget_dom) ⇒ Object
Decorates widget dom.
-
#initialize(parent, args) ⇒ LayoutProxy
constructor
A new instance of LayoutProxy.
- #reapply ⇒ Object
Methods included from PropertyOwner
#attribute_getter, #attribute_setter, #get_attribute, #set_attribute
Constructor Details
#initialize(parent, args) ⇒ LayoutProxy
Returns a new instance of LayoutProxy.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/glimmer/swt/layout_proxy.rb', line 32 def initialize(parent, args) @parent = parent @parent = parent.body_root if @parent.is_a?(Glimmer::UI::CustomWidget) @parent.css_classes.each do |css_class| @parent.remove_css_class(css_class) if css_class.include?('layout') end @args = args @parent.add_css_class(css_class) @parent.layout = self self.margin_width = 15 if respond_to?(:margin_width=) self.margin_height = 15 if respond_to?(:margin_height=) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
30 31 32 |
# File 'lib/glimmer/swt/layout_proxy.rb', line 30 def args @args end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
30 31 32 |
# File 'lib/glimmer/swt/layout_proxy.rb', line 30 def parent @parent end |
Class Method Details
.for(keyword, parent, args) ⇒ Object
Factory Method that translates a Glimmer DSL keyword into a WidgetProxy object
10 11 12 13 |
# File 'lib/glimmer/swt/layout_proxy.rb', line 10 def for(keyword, parent, args) the_layout_class = layout_class(keyword) || Glimmer::SWT::GridLayoutProxy the_layout_class.new(parent, args) end |
.layout_class(keyword) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/glimmer/swt/layout_proxy.rb', line 15 def layout_class(keyword) class_name_alternative = keyword.camelcase(:upper) class_name_main = "#{class_name_alternative}Proxy" a_layout_class = Glimmer::SWT.const_get(class_name_main.to_sym) rescue Glimmer::SWT.const_get(class_name_alternative.to_sym) a_layout_class if a_layout_class.ancestors.include?(Glimmer::SWT::LayoutProxy) rescue => e puts "Layout #{keyword} was not found!" nil end |
.layout_exists?(keyword) ⇒ Boolean
25 26 27 |
# File 'lib/glimmer/swt/layout_proxy.rb', line 25 def layout_exists?(keyword) !!layout_class(keyword) end |
Instance Method Details
#css_class ⇒ Object
45 46 47 |
# File 'lib/glimmer/swt/layout_proxy.rb', line 45 def css_class self.class.name.split('::').last.underscore.sub(/_proxy$/, '').gsub('_', '-') end |
#dom(widget_dom) ⇒ Object
Decorates widget dom. Subclasses may override. Returns widget dom by default.
54 55 56 |
# File 'lib/glimmer/swt/layout_proxy.rb', line 54 def dom() end |
#reapply ⇒ Object
49 50 51 |
# File 'lib/glimmer/swt/layout_proxy.rb', line 49 def reapply # subclasses can override this end |