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

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

Constant Summary

Constants inherited from Glimmer::SWT::Custom::Shape

String

Instance Attribute Summary

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

#args, #disposed, #drawable, #extent, #name, #options, #parent, #properties, #shapes, #widget_listener_proxies

Instance Method Summary collapse

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

#absolute_x, #absolute_y, #add_shape, #all_parent_properties, #amend_method_name_options_based_on_properties!, #any_potential_drop_targets?, #apply_property_arg_conversions, #apply_shape_arg_conversions!, #apply_shape_arg_defaults!, arg_options, #background_pattern_args, #bounds, #bounds_contain?, #calculate_args!, #calculate_paint_args!, #calculated_args?, #calculated_args_changed!, #calculated_args_changed_for_defaults!, #calculated_height, #calculated_paint_args_changed!, #calculated_width, #calculated_x, #calculated_y, #can_handle_observation_request?, #cancel_dragging!, #center_x, #center_y, #clear_shapes, #composite?, #contain?, #container?, #content, #convert_properties!, #converted_properties, create, #current_parameter_name?, #default_height, #default_height?, #default_width, #default_width?, #default_x, #default_y, #deregister_drag_listeners, #dispose, #drag_and_move, #drag_and_move=, #drag_source, #drag_source=, #draw?, #ensure_extent, #expanded_shapes, #fill?, flyweight_method_names, flyweight_patterns, #foreground_pattern_args, gc_instance_methods, #get_attribute, #get_data, #get_parameter_attribute, #gradient?, #handle_observation_request, #has_attribute?, #has_some_background?, #has_some_foreground?, #height_delta, #height_delta=, #include?, #include_shape?, #include_with_children?, #initialize, #inspect, #inverse_transform_point, #irregular?, keywords, #location, #location_parameter_names, #max_height, #max_height?, #max_width, #max_width?, #method_missing, method_name, #paint, #paint_children, #paint_self, #parameter_index, #parameter_name?, #parent_shape_composites, #parent_shape_containers, #parent_shapes, #pattern, pattern, #pattern_args, #post_add_content, #remove_shape_disposed_listener, #respond_to?, #rotate, #rotation_angle, #round?, #set_attribute, #set_data, #shell_proxy, #size, #tolerate_shape_extra_args!, #transform_point, valid?, #width_delta, #width_delta=, #x_delta, #x_delta=, #x_end, #y_delta, #y_delta=, #y_end

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

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

#default_x?Boolean

Returns:

  • (Boolean)


84
85
86
87
# File 'lib/glimmer/swt/custom/shape/image.rb', line 84

def default_x?
  super ||
    current_parameter_name?(:dest_x) && (dest_x.nil? || dest_x.to_s == 'default')
end

#default_y?Boolean

Returns:

  • (Boolean)


89
90
91
92
# File 'lib/glimmer/swt/custom/shape/image.rb', line 89

def default_y?
  super ||
    current_parameter_name?(:dest_y) && (dest_y.nil? || dest_y.to_s == 'default')
end

#heightObject



76
77
78
# File 'lib/glimmer/swt/custom/shape/image.rb', line 76

def height
  dest_height || image_proxy.bounds.height
end

#image_part_parameter_namesObject



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

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

#image_proxyObject



80
81
82
# File 'lib/glimmer/swt/custom/shape/image.rb', line 80

def image_proxy
  ImageProxy.create(image)
end

#image_whole_parameter_namesObject



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

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

#move_by(x_delta, y_delta) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/glimmer/swt/custom/shape/image.rb', line 94

def move_by(x_delta, y_delta)
  if default_x?
    self.default_x_delta += x_delta
  elsif dest_x
    self.dest_x += x_delta
  else
    self.x += x_delta
  end
  
  if default_y?
    self.default_y_delta += y_delta
  elsif dest_y
    self.dest_y += y_delta
  else
    self.y += y_delta
  end
end

#parameter_namesObject



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

def parameter_names
  @parameter_names || image_whole_parameter_names
end

#possible_parameter_namesObject



41
42
43
# File 'lib/glimmer/swt/custom/shape/image.rb', line 41

def possible_parameter_names
  (image_part_parameter_names + image_whole_parameter_names).uniq
end

#set_parameter_attribute(attribute_name, *args) ⇒ Object



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

def set_parameter_attribute(attribute_name, *args)
  return super if @parameter_names.to_a.map(&:to_s).include?(attribute_name.to_s)
  ####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)
    @parameter_names = image_part_parameter_names
  elsif image_whole_parameter_names.map(&:to_s).include?(attribute_name.to_s)
    @parameter_names = image_whole_parameter_names
  end
  super
end

#widthObject



72
73
74
# File 'lib/glimmer/swt/custom/shape/image.rb', line 72

def width
  dest_width || image_proxy.bounds.width
end

#xObject



64
65
66
# File 'lib/glimmer/swt/custom/shape/image.rb', line 64

def x
  dest_x || get_attribute('x')
end

#yObject



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

def y
  dest_y || get_attribute('y')
end