lib/shoes/swt/shape.rb in shoes-swt-4.0.0.pre6 vs lib/shoes/swt/shape.rb in shoes-swt-4.0.0.pre7

- old
+ new

@@ -16,11 +16,11 @@ # for drawing itself), `opts` should be omitted def initialize(dsl, app) @dsl = dsl @app = app @element = ::Swt::Path.new(::Swt.display) - @painter = Painter.new(self) + @painter = ShapePainter.new(self) @app.add_paint_listener @painter end def dispose @transform.dispose unless @transform.nil? || @transform.disposed? @@ -29,10 +29,14 @@ attr_reader :dsl, :app attr_reader :element, :transform attr_reader :painter + def redraw_target + @dsl + end + def line_to(x, y) @element.line_to(x, y) end def move_to(x, y) @@ -48,36 +52,37 @@ -start_angle * 180 / ::Shoes::PI, (start_angle - arc_angle) * 180 / ::Shoes::PI) end def update_position - transform.translate(dsl.element_left, dsl.element_top) + transform.translate(dsl.translate_left + (dsl.element_left || 0), + dsl.translate_top + (dsl.element_top || 0)) end def left native_left end def top native_top end - alias_method :absolute_left, :left - alias_method :absolute_top, :top - alias_method :element_left, :left - alias_method :element_top, :top + alias absolute_left left + alias absolute_top top + alias element_left left + alias element_top top def width native_width end def height native_height end - alias_method :element_width, :width - alias_method :element_height, :height + alias element_width width + alias element_height height def transform @transform ||= ::Swt::Transform.new(::Swt.display) end @@ -117,19 +122,9 @@ end def native_width bounds_index_for_width = 2 native_bounds_measurement(@element, bounds_index_for_width) - end - - class Painter < Common::Painter - def fill(gc) - gc.fill_path(@obj.element) - end - - def draw(gc) - gc.draw_path(@obj.element) - end end end end end