class Glimmer::SWT::Custom::Shape::String

Public Instance Methods

background=(value) click to toggle source
Calls superclass method Glimmer::SWT::Custom::Shape#background=
# File lib/glimmer/swt/custom/shape/text.rb, line 84
def background=(value)
  # TODO override background= to fill a rectangle containing text, matching its size
  # For now, disable background when foreground is not set
  super(value) unless foreground.nil?
end
dom() click to toggle source
# File lib/glimmer/swt/custom/shape/text.rb, line 99
def dom
  shape_id = id
  shape_class = name
  @dom ||= xml {
    tag(:_name => 'text', id: shape_id, class: shape_class, x: @args[1], y: @args[2]) {
      @args[0]
    }
  }.to_s
end
element() click to toggle source
# File lib/glimmer/swt/custom/shape/text.rb, line 95
def element
  'text'
end
foreground=(value) click to toggle source
Calls superclass method Glimmer::SWT::Custom::Shape#foreground=
# File lib/glimmer/swt/custom/shape/text.rb, line 90
def foreground=(value)
  super(value)
  self.background = value
end
parameter_names() click to toggle source
# File lib/glimmer/swt/custom/shape/text.rb, line 33
def parameter_names
  if text_parameter_names.size == @args.size
    @parameter_names = text_parameter_names
  elsif text_transparent_parameter_names.size == @args.size
    @parameter_names = text_transparent_parameter_names
  elsif text_flags_parameter_names.size == @args.size
    @parameter_names = text_flags_parameter_names
  end
  @parameter_names || text_parameter_names
end
possible_parameter_names() click to toggle source
# File lib/glimmer/swt/custom/shape/text.rb, line 44
def possible_parameter_names
  # TODO refactor and improve this method through meta-programming (and share across other shapes)
  (text_parameter_names + text_transparent_parameter_names + text_flags_parameter_names).uniq
end
reattach(old_element) click to toggle source
# File lib/glimmer/swt/custom/shape/text.rb, line 78
def reattach(old_element)
  old_element.attr('x', Element[@dom].attr('x'))
  old_element.attr('y', Element[@dom].attr('y'))
  old_element.text(Element[@dom].html)
end
set_parameter_attribute(attribute_name, *args) click to toggle source
# File lib/glimmer/swt/custom/shape/text.rb, line 61
def set_parameter_attribute(attribute_name, *args)
  if @parameter_names.to_a.map(&:to_s).include?(attribute_name.to_s)
    super(attribute_name, *args)
    build_dom
    reattach(dom_element)
    return
  end
  if text_parameter_names.map(&:to_s).include?(attribute_name.to_s)
    @parameter_names = text_parameter_names
  elsif text_transparent_parameter_names.map(&:to_s).include?(attribute_name.to_s)
    @parameter_names = text_transparent_parameter_names
  elsif text_flags_parameter_names.map(&:to_s).include?(attribute_name.to_s)
    @parameter_names = text_flags_parameter_names
  end
  super(attribute_name, *args)
end
text_flags_parameter_names() click to toggle source
# File lib/glimmer/swt/custom/shape/text.rb, line 57
def text_flags_parameter_names
  [:string, :x, :y, :flags]
end
text_parameter_names() click to toggle source
# File lib/glimmer/swt/custom/shape/text.rb, line 49
def text_parameter_names
  [:string, :x, :y]
end
text_transparent_parameter_names() click to toggle source
# File lib/glimmer/swt/custom/shape/text.rb, line 53
def text_transparent_parameter_names
  [:string, :x, :y, :is_transparent]
end