lib/wx/shapes/shape_handle.rb in wxruby3-shapes-0.9.0.pre.beta.3 vs lib/wx/shapes/shape_handle.rb in wxruby3-shapes-0.9.5
- old
+ new
@@ -24,10 +24,20 @@
LINESTART = self.new(9)
LINEEND = self.new(10)
UNDEF = self.new(11)
end
+ class << self
+ def handle_brush
+ if ShapeCanvas.gc_enabled?
+ @gc_brush ||= Wx::Brush.new(Wx::Colour.new(0, 0, 0, 128))
+ else
+ @dc_brush ||= Wx::BLACK_BRUSH.dup
+ end
+ end
+ end
+
# Constructor
# @param [Wx::Shape] parent Parent shape
# @param [TYPE] type Handle type
# @param [Integer] id Handle ID (useful only for line controls handles)
def initialize(parent=nil, type=TYPE::UNDEF, id=-1)
@@ -129,21 +139,18 @@
# Draw handle in the normal way.
# @param [Wx::DC] dc Device context where the handle will be drawn
def draw_normal(dc)
dc.with_pen(Wx::PLATFORM == 'WXGTK' ? Wx::TRANSPARENT_PEN : Wx::BLACK_PEN) do
- if ShapeCanvas::gc_enabled?
- dc.brush = Wx::Brush.new(Wx::Colour.new(0, 0, 0, 128))
- else
- dc.brush = Wx::BLACK_BRUSH
- # dc.logical_function = Wx::RasterOperationMode::INVERT
- end
+ dc.with_brush(Handle.handle_brush) do
+ # unless ShapeCanvas::gc_enabled?
+ # dc.logical_function = Wx::RasterOperationMode::INVERT
+ # end
- dc.draw_rectangle(handle_rect)
- # dc.logical_function = Wx::RasterOperationMode::COPY
-
- dc.brush = Wx::NULL_BRUSH
+ dc.draw_rectangle(handle_rect)
+ # dc.logical_function = Wx::RasterOperationMode::COPY
+ end
end
end
# Draw handle in the "hover" way (the mouse pointer is above the handle area).
# @param [Wx::DC] dc Device context where the handle will be drawn
@@ -159,10 +166,10 @@
end
end
# Set parent shape.
# @param [Wx::Shape] parent parent shape to set
- def parent_shape=(parent)
+ def set_parent_shape(parent)
@parent_shape = parent
end
# Get handle rectangle.
# @return [Wx::Rect] Handle rectangle