Class: Glimmer::DSL::SWT::WidgetExpression

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

Constant Summary collapse

EXCLUDED_KEYWORDS =
%w[shell display tab_item c_tab_item] + Glimmer::SWT::Custom::Shape.keywords - ['text']

Instance Method Summary collapse

Instance Method Details

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



49
50
51
52
53
54
# File 'lib/glimmer/dsl/swt/widget_expression.rb', line 49

def add_content(parent, keyword, *args, &block)
  return if block&.parameters&.count == 2
  super
  parent.post_add_content
  parent.finish_add_content!
end

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

Returns:

  • (Boolean)


35
36
37
38
39
40
41
# File 'lib/glimmer/dsl/swt/widget_expression.rb', line 35

def can_interpret?(parent, keyword, *args, &block)
  !EXCLUDED_KEYWORDS.include?(keyword) and
    parent.respond_to?(:swt_widget) and
    !parent.is_a?(Glimmer::SWT::Custom::Shape) and
    !((keyword.to_s == 'text') and (args.first.is_a?(String) or parent.swt_widget.class == org.eclipse.swt.widgets.Canvas)) and
    Glimmer::SWT::WidgetProxy.widget_exists?(keyword)
end

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



43
44
45
46
47
# File 'lib/glimmer/dsl/swt/widget_expression.rb', line 43

def interpret(parent, keyword, *args, &block)
  Glimmer::SWT::WidgetProxy.create(keyword, parent, args).tap do |new_widget_proxy|
    new_widget_proxy.paint_pixel_by_pixel(&block) if block&.parameters&.count == 2
  end
end