1 /////////////////////////////////////////////////////////////////////////////
 
   3 // Purpose:     SWIG interface for wxColour
 
   7 // Created:     7-July-1997
 
   9 // Copyright:   (c) 2003 by Total Control Software
 
  10 // Licence:     wxWindows license
 
  11 /////////////////////////////////////////////////////////////////////////////
 
  16 //---------------------------------------------------------------------------
 
  21 "A colour is an object representing a combination of Red, Green, and
 
  22 Blue (RGB) intensity values, and is used to determine drawing colours,
 
  23 window colours, etc.  Valid RGB values are in the range 0 to 255.
 
  25 In wxPython there are typemaps that will automatically convert from a
 
  26 colour name, or from a '#RRGGBB' colour hex value string to a
 
  27 wx.Colour object when calling C++ methods that expect a wxColour.
 
  28 This means that the following are all equivallent::
 
  30     win.SetBackgroundColour(wxColour(0,0,255))
 
  31     win.SetBackgroundColour('BLUE')
 
  32     win.SetBackgroundColour('#0000FF')
 
  34 Additional colour names and their coresponding values can be added
 
  35 using `wx.ColourDatabase`.  Various system colours (as set in the
 
  36 user's system preferences) can be retrieved with
 
  37 `wx.SystemSettings.GetColour`.
 
  41 MustHaveApp( wxColour(const wxString& colorName) );
 
  43 class wxColour : public wxObject {
 
  47         wxColour(byte red=0, byte green=0, byte blue=0),
 
  48         "Constructs a colour from red, green and blue values.
 
  50 :see: Alternate constructors `wx.NamedColour` and `wx.ColourRGB`.
 
  54         wxColour( const wxString& colorName),
 
  55         "Constructs a colour object using a colour name listed in
 
  56 ``wx.TheColourDatabase``.", "",
 
  60         wxColour( unsigned long colRGB ),
 
  61         "Constructs a colour from a packed RGB value.", "",
 
  69         "Returns the red intensity.", "");
 
  73         "Returns the green intensity.", "");
 
  77         "Returns the blue intensity.", "");
 
  81         "Returns True if the colour object is valid (the colour has been
 
  82 initialised with RGB values).", "");
 
  85         void , Set(byte red, byte green, byte blue),
 
  86         "Sets the RGB intensity values.", "");
 
  89         void , Set(unsigned long colRGB),
 
  90         "Sets the RGB intensity values from a packed RGB value.", "",
 
  94         void , InitFromName(const wxString& colourName),
 
  95         "Sets the RGB intensity values using a colour name listed in
 
  96 ``wx.TheColourDatabase``.", "",
 
 101         long , GetPixel() const,
 
 102         "Returns a pixel value which is platform-dependent. On Windows, a
 
 103 COLORREF is returned. On X, an allocated pixel value is returned.  -1
 
 104 is returned if the pixel is invalid (on X, unallocated).", "");
 
 108         bool , operator==(const wxColour& colour) const,
 
 109         "Compare colours for equality", "");
 
 112         bool , operator!=(const wxColour& colour) const,
 
 113         "Compare colours for inequality", "");
 
 119                 "Get() -> (r, g, b)",
 
 120                 "Returns the RGB intensity values as a tuple.", "");
 
 122             PyObject* rv = PyTuple_New(3);
 
 128                 green = self->Green();
 
 131             PyTuple_SetItem(rv, 0, PyInt_FromLong(red));
 
 132             PyTuple_SetItem(rv, 1, PyInt_FromLong(green));
 
 133             PyTuple_SetItem(rv, 2, PyInt_FromLong(blue));
 
 138                "Return the colour as a packed RGB value", "");
 
 139         unsigned long GetRGB() {
 
 140             return self->Red() | (self->Green() << 8) | (self->Blue() << 16);
 
 146         asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead")
 
 147         def __str__(self):                  return str(self.Get())
 
 148         def __repr__(self):                 return 'wx.Colour' + str(self.Get())
 
 149         def __nonzero__(self):              return self.Ok()
 
 150         __safe_for_unpickling__ = True
 
 151         def __reduce__(self):               return (Colour, self.Get())
 
 157     NamedColor = NamedColour
 
 161 //---------------------------------------------------------------------------