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] + Glimmer::SWT::Custom::Shape.keywords - ['text']

Instance Method Summary collapse

Instance Method Details

#add_content(parent, &block) ⇒ Object



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

def add_content(parent, &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
# File 'lib/glimmer/dsl/swt/widget_expression.rb', line 35

def can_interpret?(parent, keyword, *args, &block)
  result = !EXCLUDED_KEYWORDS.include?(keyword) &&
    parent.respond_to?(:swt_widget) && #TODO change to composite?(parent)
    Glimmer::SWT::WidgetProxy.widget_exists?(keyword)
  (keyword.to_s == 'text' && args.first.is_a?(String)) ? false : result
end

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



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

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