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 Blue (RGB)
22 intensity values, and is used to determine drawing colours, window colours,
23 etc. Valid RGB values are in the range 0 to 255.
25 In wxPython there are typemaps that will automatically convert from a colour
26 name, or from a '#RRGGBB' colour hex value string to a wx.Colour object when
27 calling C++ methods that expect a wxColour. This means that the following are
30 win.SetBackgroundColour(wxColour(0,0,255))
31 win.SetBackgroundColour('BLUE')
32 win.SetBackgroundColour('#0000FF')
34 You can retrieve the various current system colour settings with
35 wx.SystemSettings.GetColour.");
38 class wxColour : public wxObject {
42 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0),
43 "Constructs a colour from red, green and blue values.");
46 wxColour( const wxString& colorName),
47 "Constructs a colour object using a colour name listed in wx.TheColourDatabase.",
51 wxColour( unsigned long colRGB ),
52 "Constructs a colour from a packed RGB value.",
59 unsigned char , Red(),
60 "Returns the red intensity.");
63 unsigned char , Green(),
64 "Returns the green intensity.");
67 unsigned char , Blue(),
68 "Returns the blue intensity.");
72 "Returns True if the colour object is valid (the colour has been\n"
73 "initialised with RGB values).");
76 void , Set(unsigned char red, unsigned char green, unsigned char blue),
77 "Sets the RGB intensity values.");
80 void , Set(unsigned long colRGB),
81 "Sets the RGB intensity values from a packed RGB value.",
85 void , InitFromName(const wxString& colourName),
86 "Sets the RGB intensity values using a colour name listed in wx.TheColourDatabase.",
91 long , GetPixel() const,
92 "Returns a pixel value which is platform-dependent. On Windows, a\n"
93 "COLORREF is returned. On X, an allocated pixel value is returned.\n"
94 "-1 is returned if the pixel is invalid (on X, unallocated).");
98 bool , operator==(const wxColour& colour) const,
99 "Compare colours for equality");
102 bool , operator!=(const wxColour& colour) const,
103 "Compare colours for inequality");
109 "Get() -> (r, g, b)",
110 "Returns the RGB intensity values as a tuple.");
112 PyObject* rv = PyTuple_New(3);
118 green = self->Green();
121 PyTuple_SetItem(rv, 0, PyInt_FromLong(red));
122 PyTuple_SetItem(rv, 1, PyInt_FromLong(green));
123 PyTuple_SetItem(rv, 2, PyInt_FromLong(blue));
128 "Return the colour as a packed RGB value");
129 unsigned long GetRGB() {
130 return self->Red() | (self->Green() << 8) | (self->Blue() << 16);
137 def __str__(self): return str(self.asTuple())
138 def __repr__(self): return 'wx.Colour' + str(self.asTuple())
139 def __nonzero__(self): return self.Ok()
140 __safe_for_unpickling__ = True
141 def __reduce__(self): return (Colour, self.Get())
147 NamedColor = NamedColour
151 //---------------------------------------------------------------------------