Sha256: 8852d2dd5f8c7d5a5b278223b3e28ea87dcb782611d15dd5118c6993e12db128

Contents?: true

Size: 762 Bytes

Versions: 9

Compression:

Stored size: 762 Bytes

Contents

class Wx::Bitmap
  # Redefine the initialize method so it raises an exception if a
  # non-existent file is given to the constructor; otherwise, wx Widgets
  # just carries on with an empty bitmap, which may cause faults later
  wx_init = self.instance_method(:initialize)
  define_method(:initialize) do | *args |
    if args[0].kind_of? String
      if not File.exist?( File.expand_path(args[0]) )
        Kernel.raise(ArgumentError, "Bitmap file does not exist: #{args[0]}")
      end
    end
    wx_init.bind(self).call(*args)
  end

  # Accepts a block, which will be passed a device context which can be
  # used to draw upon the Bitmap
  def draw
    dc = MemoryDC.new
    dc.select_object(self)
    yield dc
    dc.select_object( NULL_BITMAP )
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
wxruby-1.9.1-powerpc-darwin8.3.0 lib/wx/classes/bitmap.rb
wxruby-1.9.1-i686-linux lib/wx/classes/bitmap.rb
wxruby-1.9.1-i686-darwin8.4.1 lib/wx/classes/bitmap.rb
wxruby-1.9.1-i386-mswin32 lib/wx/classes/bitmap.rb
wxruby-1.9.0-powerpc-darwin8.10.0 lib/wx/classes/bitmap.rb
wxruby-1.9.0-i686-linux lib/wx/classes/bitmap.rb
wxruby-1.9.0-i686-darwin8.4.1 lib/wx/classes/bitmap.rb
wxruby-1.9.0-i386-mswin32 lib/wx/classes/bitmap.rb
wxruby-1.9.1-x86_64-linux lib/wx/classes/bitmap.rb