lib/wx/shapes/shapes/round_rect_shape.rb in wxruby3-shapes-0.9.0.pre.beta.3 vs lib/wx/shapes/shapes/round_rect_shape.rb in wxruby3-shapes-0.9.5

- old
+ new

@@ -4,30 +4,26 @@ module Wx::SF # Class encapsulating rounded rectangle. It extends the basic rectangular shape. class RoundRectShape < RectShape - RADIUS = 20 + # Default values + module DEFAULT + # Default corner radius + RADIUS = 20 + end property :radius - # @overload initialize() - # Default constructor. - # @overload initialize(pos, size, diagram) - # User constructor. - # @param [Wx::RealPoint] pos Initial position - # @param [Wx::RealPoint] size Initial size - # @param [Float] radius Corner radius - # @param [Wx::SF::Diagram] diagram parent diagram - def initialize(*args) - if args.empty? - super - @radius = RADIUS - else - pos, size, @radius, diagram = args - super(pos, size, diagram) - end + # Constructor. + # @param [Wx::RealPoint,Wx::Point] pos Initial position + # @param [Wx::RealPoint,Wx::Size,Wx::Point] size Initial size + # @param [Float] radius Corner radius + # @param [Wx::SF::Diagram] diagram parent diagram + def initialize(pos = Shape::DEFAULT::POSITION, size = RectShape::DEFAULT::SIZE, radius: DEFAULT::RADIUS, diagram: nil) + super(pos, size, diagram: diagram) + @radius = radius end # Access (get/set) radius. attr_accessor :radius @@ -71,12 +67,12 @@ def draw_normal(dc) if @radius == 0.0 super return end - dc.with_pen(@border) do - dc.with_brush(@fill) do + dc.with_pen(border) do + dc.with_brush(fill) do dc.draw_rounded_rectangle(get_absolute_position.to_point, @rect_size.to_size, @radius) end end end @@ -86,12 +82,12 @@ def draw_hover(dc) if @radius == 0.0 super return end - dc.with_pen(Wx::Pen.new(@hover_color, 1)) do - dc.with_brush(@fill) do + dc.with_pen(Wx::Pen.new(hover_colour, 1)) do + dc.with_brush(fill) do dc.draw_rounded_rectangle(get_absolute_position.to_point, @rect_size.to_size, @radius) end end end @@ -102,12 +98,12 @@ def draw_highlighted(dc) if @radius == 0.0 super return end - dc.with_pen(Wx::Pen.new(@hover_color, 2)) do - dc.with_brush(@fill) do + dc.with_pen(Wx::Pen.new(hover_colour, 2)) do + dc.with_brush(fill) do dc.draw_rounded_rectangle(get_absolute_position.to_point, @rect_size.to_size, @radius) end end end @@ -116,10 +112,10 @@ def draw_shadow(dc) if @radius == 0.0 super return end - if @fill.style != Wx::BrushStyle::BRUSHSTYLE_TRANSPARENT + if fill.style != Wx::BrushStyle::BRUSHSTYLE_TRANSPARENT dc.with_pen(Wx::TRANSPARENT_PEN) do dc.with_brush(get_parent_canvas.get_shadow_fill) do dc.draw_rounded_rectangle((get_absolute_position + get_parent_canvas.get_shadow_offset).to_point, @rect_size.to_size, @radius) end