Sha256: 1c55905f2fdc55b76c4998855bc6525314550093db258f5c179ba91b56691c68

Contents?: true

Size: 1.4 KB

Versions: 25

Compression:

Stored size: 1.4 KB

Contents

class Wx::Colour
  # Redefine the initialize method so it raises an exception if an
  # invalid colour value is given. This might be an unknown colour
  # string (eg 'dark blue') or out-of-bounds integer values (<0 or >255)
  wx_init = self.instance_method(:initialize)
  define_method(:initialize) do | *args |
    begin
      wx_init.bind(self).call(*args)
    # Invalid integer values raise SWIG 'no matching func'
    rescue ArgumentError 
      Kernel.raise ArgumentError, "Invalid colour values #{args.inspect}"
    end

    if not is_ok
      Kernel.raise ArgumentError, "Invalid colour values #{args.inspect}"
    end
  end

  # Standard colours, corresponding to WxWidgets stock colours.
  Wx::WHITE = new(255, 255, 255)
  Wx::BLACK = new(0, 0, 0)

  Wx::RED   = new(255, 0, 0)
  Wx::GREEN = new(0, 255, 0)
  Wx::BLUE  = new(0, 0, 255)

  Wx::YELLOW  = new(255, 255, 0)
  Wx::MAGENTA = new(255, 0, 255)
  Wx::CYAN    = new(0, 255, 255)

  Wx::LIGHT_GREY = new(192, 192, 192)

  # Colours are equal to one another if they have the same red, green
  # and blue intensity, and the same alpha
  def ==(other)
    case other
    when Wx::Colour
      [  self.red,  self.green,  self.blue,  self.alpha ] == 
      [ other.red, other.green, other.blue, other.alpha ]
    else
      false
    end
  end

  # More informative output for inspect etc
  def to_s
    "#<Wx::Colour: (#{red}, #{green}, #{blue} *#{alpha})>"
  end
end

Version data entries

25 entries across 25 versions & 3 rubygems

Version Path
wxruby64-2.0.1-x64-mingw32 lib/wx/classes/colour.rb
wxruby-ruby19-2.0.1-x86-mingw32 lib/wx/classes/colour.rb
wxruby-ruby19-2.0.1-x86-linux lib/wx/classes/colour.rb
wxruby-ruby19-2.0.1-x86-darwin-9 lib/wx/classes/colour.rb
wxruby-2.0.1-x86-mswin32-60 lib/wx/classes/colour.rb
wxruby-2.0.1-x86-mingw32 lib/wx/classes/colour.rb
wxruby-2.0.1-x86-linux lib/wx/classes/colour.rb
wxruby-2.0.1-universal-darwin-9 lib/wx/classes/colour.rb
wxruby-1.9.10-universal-darwin-9 lib/wx/classes/colour.rb
wxruby-1.9.10-x86-linux lib/wx/classes/colour.rb
wxruby-1.9.10-x86_64-linux lib/wx/classes/colour.rb
wxruby-1.9.10-x86-mingw32 lib/wx/classes/colour.rb
wxruby-1.9.10-x86-mswin32-60 lib/wx/classes/colour.rb
wxruby-2.0.0-universal-darwin-9 lib/wx/classes/colour.rb
wxruby-2.0.0-x86-linux lib/wx/classes/colour.rb
wxruby-2.0.0-x86-mingw32 lib/wx/classes/colour.rb
wxruby-2.0.0-x86-mswin32-60 lib/wx/classes/colour.rb
wxruby-2.0.0-x86_64-linux lib/wx/classes/colour.rb
wxruby-ruby19-1.9.10-x86-darwin-9 lib/wx/classes/colour.rb
wxruby-ruby19-1.9.10-x86-linux lib/wx/classes/colour.rb