Class: Glimmer::SWT::LayoutProxy

Inherits:
Object
  • Object
show all
Includes:
PropertyOwner
Defined in:
lib/glimmer/swt/layout_proxy.rb

Direct Known Subclasses

FillLayoutProxy, GridLayoutProxy, RowLayoutProxy

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PropertyOwner

#attribute_getter, #attribute_setter, #get_attribute, #set_attribute

Constructor Details

#initialize(parent, args) ⇒ LayoutProxy

Returns a new instance of LayoutProxy.



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/glimmer/swt/layout_proxy.rb', line 52

def initialize(parent, args)
  @parent = parent
  @args = args
  @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
  @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

#argsObject (readonly)

Returns the value of attribute args.



50
51
52
# File 'lib/glimmer/swt/layout_proxy.rb', line 50

def args
  @args
end

#parentObject (readonly)

Returns the value of attribute parent.



50
51
52
# File 'lib/glimmer/swt/layout_proxy.rb', line 50

def parent
  @parent
end

Class Method Details

.for(keyword, parent, args) ⇒ Object

Factory Method that translates a Glimmer DSL keyword into a WidgetProxy object



31
32
33
34
# File 'lib/glimmer/swt/layout_proxy.rb', line 31

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



36
37
38
39
40
41
42
43
# File 'lib/glimmer/swt/layout_proxy.rb', line 36

def layout_class(keyword)
  class_name_main = "#{keyword.camelcase(:upper)}Proxy"
  a_layout_class = Glimmer::SWT.const_get(class_name_main.to_sym)
  a_layout_class if a_layout_class.ancestors.include?(Glimmer::SWT::LayoutProxy)
rescue => e
  Glimmer::Config.logger.debug "Layout #{keyword} was not found!"
  nil
end

.layout_exists?(keyword) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/glimmer/swt/layout_proxy.rb', line 45

def layout_exists?(keyword)
  !!layout_class(keyword)
end

Instance Method Details

#css_classObject



71
72
73
# File 'lib/glimmer/swt/layout_proxy.rb', line 71

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.



76
77
78
# File 'lib/glimmer/swt/layout_proxy.rb', line 76

def dom(widget_dom)
  widget_dom
end

#layout​(composite = nil, flush_cache = false) ⇒ Object



65
66
67
68
69
# File 'lib/glimmer/swt/layout_proxy.rb', line 65

def layout​(composite = nil, flush_cache = false)
  # TODO implement def layout​(composite = nil, flush_cache = false) as per SWT API
  composite ||= @parent
  initialize(composite, @args)
end