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 class wxColour : public wxObject {
45 wxColour(byte red=0, byte green=0, byte blue=0),
46 "Constructs a colour from red, green and blue values.
48 :see: Alternate constructors `wx.NamedColour` and `wx.ColourRGB`.
52 wxColour( const wxString& colorName),
53 "Constructs a colour object using a colour name listed in
54 ``wx.TheColourDatabase``.", "",
58 wxColour( unsigned long colRGB ),
59 "Constructs a colour from a packed RGB value.", "",
67 "Returns the red intensity.", "");
71 "Returns the green intensity.", "");
75 "Returns the blue intensity.", "");
79 "Returns True if the colour object is valid (the colour has been
80 initialised with RGB values).", "");
83 void , Set(byte red, byte green, byte blue),
84 "Sets the RGB intensity values.", "");
87 void , Set(unsigned long colRGB),
88 "Sets the RGB intensity values from a packed RGB value.", "",
92 void , InitFromName(const wxString& colourName),
93 "Sets the RGB intensity values using a colour name listed in
94 ``wx.TheColourDatabase``.", "",
99 long , GetPixel() const,
100 "Returns a pixel value which is platform-dependent. On Windows, a
101 COLORREF is returned. On X, an allocated pixel value is returned. -1
102 is returned if the pixel is invalid (on X, unallocated).", "");
106 bool , operator==(const wxColour& colour) const,
107 "Compare colours for equality", "");
110 bool , operator!=(const wxColour& colour) const,
111 "Compare colours for inequality", "");
117 "Get() -> (r, g, b)",
118 "Returns the RGB intensity values as a tuple.", "");
120 PyObject* rv = PyTuple_New(3);
126 green = self->Green();
129 PyTuple_SetItem(rv, 0, PyInt_FromLong(red));
130 PyTuple_SetItem(rv, 1, PyInt_FromLong(green));
131 PyTuple_SetItem(rv, 2, PyInt_FromLong(blue));
136 "Return the colour as a packed RGB value", "");
137 unsigned long GetRGB() {
138 return self->Red() | (self->Green() << 8) | (self->Blue() << 16);
144 asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead")
145 def __str__(self): return str(self.Get())
146 def __repr__(self): return 'wx.Colour' + str(self.Get())
147 def __nonzero__(self): return self.Ok()
148 __safe_for_unpickling__ = True
149 def __reduce__(self): return (Colour, self.Get())
155 NamedColor = NamedColour
159 //---------------------------------------------------------------------------