Class: Shoes::Swt::ImagePainter

Inherits:
Object
  • Object
show all
Includes:
Common::Resource
Defined in:
shoes-swt/lib/shoes/swt/image_painter.rb

Constant Summary

Constants included from Common::Resource

Common::Resource::OPAQUE

Instance Method Summary collapse

Methods included from Common::Resource

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

Constructor Details

#initialize(image) ⇒ ImagePainter


8
9
10
11
# File 'shoes-swt/lib/shoes/swt/image_painter.rb', line 8

def initialize(image)
  @image = image
  @dsl = image.dsl
end

Instance Method Details

#paint_control(event) ⇒ Object


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

def paint_control(event)
  return if @dsl.hidden

  graphics_context = event.gc
  clip_context_to(graphics_context, @dsl) do
    graphics_context.drawImage(@image.real, 0, 0,
                               @image.full_width, @image.full_height,
                               @dsl.element_left, @dsl.element_top,
                               @dsl.element_width, @dsl.element_height)
  end
end