Class: Glimmer::DSL::SWT::CustomWidgetExpression

Inherits:
Expression
  • Object
show all
Includes:
ParentExpression
Defined in:
lib/glimmer/dsl/swt/custom_widget_expression.rb

Instance Method Summary collapse

Methods inherited from Expression

dsl, #textual?, #widget?

Instance Method Details

#add_content(parent, &block) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/glimmer/dsl/swt/custom_widget_expression.rb', line 25

def add_content(parent, &block)
  # TODO consider avoiding source_location
  if block.source_location == parent.content&.__getobj__.source_location
    parent.content.call(parent) unless parent.content.called?
  else
    super
  end
end

#can_interpret?(parent, keyword, *args, &block) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
# File 'lib/glimmer/dsl/swt/custom_widget_expression.rb', line 13

def can_interpret?(parent, keyword, *args, &block)
  custom_widget_class = UI::CustomWidget.for(keyword)
  custom_widget_class and
    (widget?(parent) or
    custom_widget_class.ancestors.include?(UI::CustomShell))
end

#interpret(parent, keyword, *args, &block) ⇒ Object



20
21
22
23
# File 'lib/glimmer/dsl/swt/custom_widget_expression.rb', line 20

def interpret(parent, keyword, *args, &block)
  options = args.last.is_a?(Hash) ? args.pop : {}
  UI::CustomWidget.for(keyword).new(parent, *args, options, &block)
end