Class: Shoes::Swt::Shape

Inherits:
Object
  • Object
show all
Includes:
Common::PainterUpdatesPosition, Common::Clickable, Common::Fill, Common::Remove, Common::Stroke, Common::Visibility
Defined in:
shoes-swt/lib/shoes/swt/shape.rb

Instance Attribute Summary collapse

Attributes included from Common::Clickable

#pass_coordinates

Instance Method Summary collapse

Methods included from Common::Stroke

#update_stroke

Methods included from Common::Fill

#update_fill

Methods included from Common::Remove

#remove

Methods included from Common::Visibility

#hidden?, #hidden_from_view?, #hide, #outside_parent_view?, #show, #toggle, #visible?

Methods included from Common::Clickable

#click, #pass_coordinates?, #register_click, #release

Constructor Details

#initialize(dsl, app) ⇒ Shape

Creates a new Shoes::Swt::Shape

Parameters:



17
18
19
20
21
22
23
24
25
# File 'shoes-swt/lib/shoes/swt/shape.rb', line 17

def initialize(dsl, app)
  @dsl = dsl
  @app = app
  @element = ::Swt::Path.new(::Swt.display)
  @painter = ShapePainter.new(self)
  @transform = nil
  @app.add_paint_listener @painter
  @scroll_top_applied = nil
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



32
33
34
# File 'shoes-swt/lib/shoes/swt/shape.rb', line 32

def app
  @app
end

#dslObject (readonly)

Returns the value of attribute dsl.



32
33
34
# File 'shoes-swt/lib/shoes/swt/shape.rb', line 32

def dsl
  @dsl
end

#elementObject (readonly)

Returns the value of attribute element.



32
33
34
# File 'shoes-swt/lib/shoes/swt/shape.rb', line 32

def element
  @element
end

#painterObject (readonly)

Returns the value of attribute painter.



32
33
34
# File 'shoes-swt/lib/shoes/swt/shape.rb', line 32

def painter
  @painter
end

#scroll_top_appliedObject

Returns the value of attribute scroll_top_applied.



33
34
35
# File 'shoes-swt/lib/shoes/swt/shape.rb', line 33

def scroll_top_applied
  @scroll_top_applied
end

Instance Method Details

#arc_to(x, y, width, height, start_angle, arc_angle) ⇒ Object



51
52
53
54
55
# File 'shoes-swt/lib/shoes/swt/shape.rb', line 51

def arc_to(x, y, width, height, start_angle, arc_angle)
  @element.add_arc(x - (width / 2), y - (height / 2), width, height,
                   -start_angle * 180 / ::Shoes::PI,
                   (start_angle - arc_angle) * 180 / ::Shoes::PI)
end

#curve_to(cx1, cy1, cx2, cy2, x, y) ⇒ Object



47
48
49
# File 'shoes-swt/lib/shoes/swt/shape.rb', line 47

def curve_to(cx1, cy1, cx2, cy2, x, y)
  @element.cubic_to(cx1, cy1, cx2, cy2, x, y)
end

#disposeObject



27
28
29
30
# File 'shoes-swt/lib/shoes/swt/shape.rb', line 27

def dispose
  @transform.dispose unless @transform.nil? || @transform.disposed?
  @element.dispose   unless @element.nil? || @element.disposed?
end

#heightObject Also known as: element_height



79
80
81
# File 'shoes-swt/lib/shoes/swt/shape.rb', line 79

def height
  native_height
end

#leftObject Also known as: absolute_left, element_left



62
63
64
# File 'shoes-swt/lib/shoes/swt/shape.rb', line 62

def left
  native_left
end

#line_to(x, y) ⇒ Object



39
40
41
# File 'shoes-swt/lib/shoes/swt/shape.rb', line 39

def line_to(x, y)
  @element.line_to(x, y)
end

#move_to(x, y) ⇒ Object



43
44
45
# File 'shoes-swt/lib/shoes/swt/shape.rb', line 43

def move_to(x, y)
  @element.move_to(x, y)
end

#redraw_targetObject



35
36
37
# File 'shoes-swt/lib/shoes/swt/shape.rb', line 35

def redraw_target
  @dsl
end

#topObject Also known as: absolute_top, element_top



66
67
68
# File 'shoes-swt/lib/shoes/swt/shape.rb', line 66

def top
  native_top
end

#transformObject



86
87
88
# File 'shoes-swt/lib/shoes/swt/shape.rb', line 86

def transform
  @transform ||= ::Swt::Transform.new(::Swt.display)
end

#update_positionObject



57
58
59
60
# File 'shoes-swt/lib/shoes/swt/shape.rb', line 57

def update_position
  transform.translate(dsl.translate_left + (dsl.element_left || 0),
                      dsl.translate_top + (dsl.element_top || 0))
end

#widthObject Also known as: element_width



75
76
77
# File 'shoes-swt/lib/shoes/swt/shape.rb', line 75

def width
  native_width
end