Sha256: eb03c6654accfef140d4f89b36cb9964ba2b8ac6bef300b2cbee3b78347efe6d

Contents?: true

Size: 1.52 KB

Versions: 4

Compression:

Stored size: 1.52 KB

Contents

class Shoes
  module Swt
    class Oval
      include Common::Fill
      include Common::Stroke
      include Common::Clickable
      include Common::PainterUpdatesPosition
      include Common::Visibility
      include Common::Remove
      include ::Shoes::BackendDimensionsDelegations

      attr_reader :dsl, :app, :transform, :painter, :container

      # @param [Shoes::Oval] dsl the dsl object to provide gui for
      # @param [Shoes::Swt::App] app the app
      # @param [Hash] opts options
      def initialize(dsl, app)
        @dsl = dsl
        @app = app
        @container = @app.real

        @painter = Painter.new(self)
        @app.add_paint_listener @painter
      end

      def update_position
        # No-op, since it has its own painter
      end

      class Painter < Common::Painter
        def clipping
          clipping = ::Swt::Path.new(Shoes.display)
          clipping.add_arc(@obj.element_left, @obj.element_top,
                           @obj.element_width, @obj.element_height, 0, 360)
          clipping
        end

        def fill(graphics_context)
          graphics_context.fill_oval(@obj.element_left, @obj.element_top,
                                     @obj.element_width, @obj.element_height)
        end

        def draw(graphics_context)
          sw = graphics_context.get_line_width
          graphics_context.draw_oval(@obj.element_left + sw / 2, @obj.element_top + sw / 2,
                                     @obj.element_width - sw, @obj.element_height - sw)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shoes-swt-4.0.0.pre6 lib/shoes/swt/oval.rb
shoes-swt-4.0.0.pre5 lib/shoes/swt/oval.rb
shoes-swt-4.0.0.pre4 lib/shoes/swt/oval.rb
shoes-swt-4.0.0.pre3 lib/shoes/swt/oval.rb