Module: Shoes::Swt::Common::Stroke

Defined in:
shoes-swt/lib/shoes/swt/common/stroke.rb

Overview

Note:

Including classes must provide ‘#dsl`

Methods for retrieving stroke values from a Shoes DSL class

Instance Method Summary collapse

Instance Method Details

#apply_stroke(context) ⇒ Object



39
40
41
42
43
44
45
# File 'shoes-swt/lib/shoes/swt/common/stroke.rb', line 39

def apply_stroke(context)
  return unless stroke

  stroke.apply_as_stroke(context, self)
  context.set_line_width strokewidth
  true
end

#strokeSwt::Graphics::Color

This object’s stroke color

Returns:

  • (Swt::Graphics::Color)

    The Swt representation of this object’s stroke color



13
14
15
16
17
18
# File 'shoes-swt/lib/shoes/swt/common/stroke.rb', line 13

def stroke
  return @cached_swt_stroke if @cached_swt_stroke

  @color_factory ||= ::Shoes::Swt::ColorFactory.new
  @cached_swt_stroke = @color_factory.create(dsl.stroke)
end

#stroke_alphaInteger

This object’s stroke alpha value

Returns:

  • (Integer)

    The alpha value of this object’s stroke color (0-255)



23
24
25
# File 'shoes-swt/lib/shoes/swt/common/stroke.rb', line 23

def stroke_alpha
  dsl&.stroke&.alpha
end

#strokewidthInteger

This object’s strokewidth

Returns:

  • (Integer)

    This object’s strokewidth



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

def strokewidth
  dsl.strokewidth
end

#update_strokeObject

Just clear it out and let next paint recreate and save our SWT color



35
36
37
# File 'shoes-swt/lib/shoes/swt/common/stroke.rb', line 35

def update_stroke
  @cached_swt_stroke = nil
end