Class: Glimmer::SWT::Custom::Shape::Image

Inherits:
Glimmer::SWT::Custom::Shape show all
Defined in:
lib/glimmer/swt/custom/shape/image.rb

Instance Attribute Summary

Attributes inherited from Glimmer::SWT::Custom::Shape

#args, #name, #options, #parent

Instance Method Summary collapse

Methods inherited from Glimmer::SWT::Custom::Shape

#amend_method_name_options_based_on_properties!, #apply_property_arg_conversions, #apply_shape_arg_conversions!, #apply_shape_arg_defaults!, arg_options, #background_pattern_args, #calculate_paint_args!, create, #dispose, #draw?, #fill?, flyweight_method_names, flyweight_patterns, #foreground_pattern_args, gc_instance_methods, #get_attribute, #gradient?, #has_attribute?, #has_some_background?, #has_some_foreground?, #initialize, keywords, #method_missing, method_name, #paint, #parameter_name?, pattern, #pattern, #pattern_args, #post_add_content, #respond_to?, #round?, #set_attribute, #set_parameter_attribute, #tolerate_shape_extra_args!, valid?

Methods included from Properties

attribute_getter, #attribute_getter, attribute_setter, #attribute_setter, normalized_attribute, #normalized_attribute, ruby_attribute_getter, #ruby_attribute_setter, ruby_attribute_setter

Methods included from Packages

included

Constructor Details

This class inherits a constructor from Glimmer::SWT::Custom::Shape

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Glimmer::SWT::Custom::Shape

Instance Method Details

#image_part_parameter_namesObject



48
49
50
# File 'lib/glimmer/swt/custom/shape/image.rb', line 48

def image_part_parameter_names
  [:image, :src_x, :src_y, :src_width, :src_height, :dest_x, :dest_y, :dest_width, :dest_height]
end

#image_whole_parameter_namesObject



52
53
54
# File 'lib/glimmer/swt/custom/shape/image.rb', line 52

def image_whole_parameter_names
  [:image, :x, :y]
end

#include?(x, y) ⇒ Boolean

Returns:

  • (Boolean)


65
66
67
68
69
70
71
# File 'lib/glimmer/swt/custom/shape/image.rb', line 65

def include?(x, y)
  self_x = dest_x || self.x
  self_y = dest_y || self.y
  width = dest_width || image.bounds.width
  height = dest_height || image.bounds.height
  x.between?(self_x, self_x + width) && y.between?(self_y, self_y + height)
end

#move_by(x_delta, y_delta) ⇒ Object



73
74
75
76
77
78
79
80
81
# File 'lib/glimmer/swt/custom/shape/image.rb', line 73

def move_by(x_delta, y_delta)
  if dest_x
    self.dest_x += x_delta
    self.dest_y += y_delta
  else
    self.x += x_delta
    self.y += y_delta
  end
end

#parameter_index(attribute_name) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/glimmer/swt/custom/shape/image.rb', line 56

def parameter_index(attribute_name)
  ####TODO refactor and improve this method through meta-programming (and share across other shapes)
  if image_part_parameter_names.map(&:to_s).include?(attribute_name.to_s)
    image_part_parameter_names.map(&:to_s).index(attribute_name.to_s)
  elsif image_whole_parameter_names.map(&:to_s).include?(attribute_name.to_s)
    image_whole_parameter_names.map(&:to_s).index(attribute_name.to_s)
  end
end

#parameter_namesObject



36
37
38
39
40
41
42
# File 'lib/glimmer/swt/custom/shape/image.rb', line 36

def parameter_names
  if @args.to_a.size > 3
    image_part_parameter_names
  else
    image_whole_parameter_names
  end
end

#possible_parameter_namesObject



44
45
46
# File 'lib/glimmer/swt/custom/shape/image.rb', line 44

def possible_parameter_names
  (image_part_parameter_names + image_whole_parameter_names).uniq
end