Sha256: f56dace9aba16612a0f2f43863a1716dd7f6ff30e87208339b608b485f725e86

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

# Wx::SF::OpenArrow - open arrow class
# Copyright (c) M.J.N. Corino, The Netherlands

require 'wx/shapes/arrow_base'

module Wx::SF

  # Class extends the wxSFArrowBase class and encapsulates
  # arrow shape consisting of single two lines leading from the end of the
  # parent line shape.
  class OpenArrow < ArrowBase

    class << self
      def open_arrow
        @open_arrow ||= [Wx::RealPoint.new(0,0), Wx::RealPoint.new(10,4), Wx::RealPoint.new(10,-4)]
      end
    end

    property :arrow_pen

    # Constructor
    # @param [Wx::SF::Shape] parent parent shape
    def initialize(parent=nil)
      super
      @pen = DEFAULT::BORDER
    end

    # Get arrow border pen
    # @return [Wx::Pen]
    def get_arrow_pen
      @pen
    end
    alias :arrow_pen :get_arrow_pen

    # Set arrow border pen
    # @param [Wx::Pen] pen
    def set_arrow_pen(pen)
      @pen = pen
    end
    alias :arrow_pen= :set_arrow_pen

	  # Draw arrow shape at the end of a virtual line.
	  # @param [Wx::RealPoint] from Start of the virtual line
	  # @param [Wx::RealPoint] to End of the virtual line
	  # @param [Wx::DC] dc Device context for drawing
    def draw(from, to, dc)
      rarrow = translate_arrow(OpenArrow.open_arrow, from, to)
      dc.with_pen(@pen) do |dc|
        dc.draw_line(rarrow[0], rarrow[1])
        dc.draw_line(rarrow[0], rarrow[2])
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wxruby3-shapes-0.9.0.pre.beta.3 lib/wx/shapes/arrows/open_arrow.rb