Class: Shoes::Swt::RectPainter

Inherits:
Common::Painter show all
Defined in:
shoes-swt/lib/shoes/swt/rect_painter.rb

Direct Known Subclasses

Background::Painter, Border::Painter

Constant Summary

Constants inherited from Common::Painter

Common::Painter::LINECAP

Constants included from Common::Resource

Common::Resource::OPAQUE

Instance Method Summary collapse

Methods inherited from Common::Painter

#after_painted, #before_painted, #draw_setup, #drawing_bottom, #drawing_top, #fill_and_draw, #fill_setup, #initialize, #paint_control, #paint_object, #reset_rotate, #set_rotate

Methods included from Common::Resource

#clip_context_to, #dispose_previous_contexts, #reset_graphics_context, #set_defaults_on_context, #track_graphics_context

Constructor Details

This class inherits a constructor from Shoes::Swt::Common::Painter

Instance Method Details

#draw(gc) ⇒ Object



15
16
17
18
19
20
21
22
# File 'shoes-swt/lib/shoes/swt/rect_painter.rb', line 15

def draw(gc)
  stroke_width = gc.get_line_width
  gc.draw_round_rectangle(@obj.translate_left + @obj.element_left + stroke_width / 2,
                          @obj.translate_top + drawing_top + stroke_width / 2,
                          @obj.element_width - stroke_width,
                          @obj.element_height - stroke_width,
                          @obj.corners * 2, @obj.corners * 2)
end

#fill(gc) ⇒ Object



6
7
8
9
10
11
12
13
# File 'shoes-swt/lib/shoes/swt/rect_painter.rb', line 6

def fill(gc)
  gc.fill_round_rectangle(@obj.translate_left + @obj.element_left + inset,
                          @obj.translate_top + drawing_top + inset,
                          @obj.element_width - inset * 2,
                          @obj.element_height - inset * 2,
                          @obj.corners * 2,
                          @obj.corners * 2)
end

#insetObject



24
25
26
27
28
# File 'shoes-swt/lib/shoes/swt/rect_painter.rb', line 24

def inset
  # If drawing a stroke around the shape, inset the fill so the draw
  # isn't inside bounds of fill because of integer division remainders.
  inset_fill? ? 1 : 0
end

#inset_fill?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'shoes-swt/lib/shoes/swt/rect_painter.rb', line 30

def inset_fill?
  rounded? && strokewidth?
end

#rounded?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'shoes-swt/lib/shoes/swt/rect_painter.rb', line 34

def rounded?
  (@obj.corners || 0).positive?
end

#strokewidth?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'shoes-swt/lib/shoes/swt/rect_painter.rb', line 38

def strokewidth?
  (@obj.dsl.style[:strokewidth] || 0).positive?
end