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

- old
+ new

@@ -6,27 +6,24 @@ module Wx::SF # Class encapsulating the circle shape. class CircleShape < SquareShape - # @overload initialize() - # Default constructor. - # @overload initialize(pos, size, diagram) - # User constructor. - # @param [Wx::RealPoint] pos Initial position - # @param [Float] radius Initial circle radius - # @param [Wx::SF::Diagram] diagram parent diagram - def initialize(*args) - if args.empty? - super - set_rect_size(50,50) - else - pos, rad, diagram = args - super(pos, rad*2, diagram) - end + # Default values + module DEFAULT + # Default circle radius + RADIUS = 25.0 end + # Constructor. + # @param [Wx::RealPoint] pos Initial position + # @param [Float] radius Initial circle radius + # @param [Wx::SF::Diagram] diagram parent diagram + def initialize(pos = Shape::DEFAULT::POSITION, radius = DEFAULT::RADIUS, diagram: nil) + super(pos, radius*2, diagram: diagram) + end + def get_radius @rect_size.x/2 end alias :radius :get_radius @@ -70,12 +67,12 @@ # @param [Wx::DC] dc Reference to device context where the shape will be drawn to def draw_normal(dc) # HINT: overload it for custom actions... pos = get_absolute_position - dc.with_pen(@border) do - dc.with_brush(@fill) do + dc.with_pen(border) do + dc.with_brush(fill) do dc.draw_circle((pos.x + @rect_size.x/2).to_i, (pos.y + @rect_size.y/2).to_i, (@rect_size.x/2).to_i) end end @@ -86,12 +83,12 @@ # @param [Wx::DC] dc Reference to device context where the shape will be drawn to def draw_hover(dc) # HINT: overload it for custom actions... pos = get_absolute_position - 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_circle((pos.x + @rect_size.x/2).to_i, (pos.y + @rect_size.y/2).to_i, (@rect_size.x/2).to_i) end end @@ -103,12 +100,12 @@ # @param [Wx::DC] dc Reference to device context where the shape will be drawn to def draw_highlighted(dc) # HINT: overload it for custom actions... pos = get_absolute_position - 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_circle((pos.x + @rect_size.x/2).to_i, (pos.y + @rect_size.y/2).to_i, (@rect_size.x/2).to_i) end end @@ -118,10 +115,10 @@ # @param [Wx::DC] dc Reference to device context where the shadow will be drawn to def draw_shadow(dc) # HINT: overload it for custom actions... pos = get_absolute_position - 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_circle((pos.x + @rect_size.x/2 + get_parent_canvas.get_shadow_offset.x).to_i, (pos.y + @rect_size.y/2 + get_parent_canvas.get_shadow_offset.y).to_i, (@rect_size.x/2).to_i)