Class: Wx::SF::CrossBarArrow

Inherits:
LineArrow show all
Defined in:
lib/wx/shapes/arrows/cross_bar_arrow.rb

Overview

Class extends the Wx::LineArrow class and encapsulates arrow shape consisting of single crossbar before the end of the parent line shape.

Direct Known Subclasses

DoubleCrossBarArrow

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LineArrow

#get_pen, #get_pen_width, #set_parent_shape, #set_pen

Methods inherited from ArrowBase

#get_parent_shape, #set_parent_shape, #translate_arrow

Constructor Details

#initialize(parent = nil) ⇒ CrossBarArrow

Constructor

Parameters:



22
23
24
25
# File 'lib/wx/shapes/arrows/cross_bar_arrow.rb', line 22

def initialize(parent=nil)
  super(parent)
  scale
end

Class Method Details

.arrow(ratio) ⇒ Object



14
15
16
17
# File 'lib/wx/shapes/arrows/cross_bar_arrow.rb', line 14

def arrow(ratio)
  x = ratio*6; y = ratio*6
  [[Wx::RealPoint.new(x,y), Wx::RealPoint.new(x, -y), Wx::RealPoint.new(x, 0)]]
end

Instance Method Details

#draw(from, to, dc) ⇒ Wx::Point

Draw arrow shape at the end of a virtual line.

Parameters:

  • from (Wx::RealPoint)

    Start of the virtual line

  • to (Wx::RealPoint)

    End of the virtual line

  • dc (Wx::DC)

    Device context for drawing

Returns:

  • (Wx::Point)

    translated connection point for arrow



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/wx/shapes/arrows/cross_bar_arrow.rb', line 43

def draw(from, to, dc)
  bar_cp = nil
  dc.with_pen(pen) do |dc|
    lines.each do |line|
      bar_from, bar_to, bar_cp = translate_arrow(line, from, to)
      dc.draw_line(bar_from, bar_to)
    end
    dc.draw_line(bar_cp, to.to_point)
  end
  bar_cp
end

#scaleObject (protected)



32
33
34
35
# File 'lib/wx/shapes/arrows/cross_bar_arrow.rb', line 32

def scale
  @lines = nil
  @ratio = 1 + (pen_width / 2) * 0.5
end