%newgroup;
+enum {
+ wxC2S_NAME, // return colour name, when possible
+ wxC2S_CSS_SYNTAX, // return colour in rgb(r,g,b) syntax
+ wxC2S_HTML_SYNTAX, // return colour in #rrggbb syntax
+};
+
+
DocStr(wxColour,
"A colour is an object representing a combination of Red, Green, and
Blue (RGB) intensity values, and is used to determine drawing colours,
window colours, etc. Valid RGB values are in the range 0 to 255.
In wxPython there are typemaps that will automatically convert from a
-colour name, or from a '#RRGGBB' colour hex value string to a
-wx.Colour object when calling C++ methods that expect a wxColour.
-This means that the following are all equivallent::
+colour name, from a '#RRGGBB' colour hex value string, or from a 3
+integer tuple to a wx.Colour object when calling C++ methods that
+expect a wxColour. This means that the following are all
+equivallent::
win.SetBackgroundColour(wxColour(0,0,255))
win.SetBackgroundColour('BLUE')
win.SetBackgroundColour('#0000FF')
+ win.SetBackgroundColour((0,0,255))
Additional colour names and their coresponding values can be added
using `wx.ColourDatabase`. Various system colours (as set in the
", "");
+MustHaveApp( wxColour(const wxString& colorName) );
+
class wxColour : public wxObject {
public:
``wx.TheColourDatabase``.", "",
SetFromName);
+ DocDeclStr(
+ wxString , GetAsString(long flags = wxC2S_NAME | wxC2S_CSS_SYNTAX) const,
+ "Return the colour as a string. Acceptable flags are:
+
+ =================== ==================================
+ wx.C2S_NAME return colour name, when possible
+ wx.C2S_CSS_SYNTAX return colour in rgb(r,g,b) syntax
+ wx.C2S_HTML_SYNTAX return colour in #rrggbb syntax
+ =================== ==================================", "");
+
DocDeclStr(
long , GetPixel() const,
is returned if the pixel is invalid (on X, unallocated).", "");
- DocDeclStr(
- bool , operator==(const wxColour& colour) const,
- "Compare colours for equality", "");
-
- DocDeclStr(
- bool , operator!=(const wxColour& colour) const,
- "Compare colours for inequality", "");
-
+ %extend {
+ KeepGIL(__eq__);
+ DocStr(__eq__, "Compare colours for equality.", "");
+ bool __eq__(PyObject* other) {
+ wxColour temp, *obj = &temp;
+ if ( other == Py_None ) return false;
+ if ( ! wxColour_helper(other, &obj) ) {
+ PyErr_Clear();
+ return false;
+ }
+ return self->operator==(*obj);
+ }
+
+
+ KeepGIL(__ne__);
+ DocStr(__ne__, "Compare colours for inequality.", "");
+ bool __ne__(PyObject* other) {
+ wxColour temp, *obj = &temp;
+ if ( other == Py_None ) return true;
+ if ( ! wxColour_helper(other, &obj)) {
+ PyErr_Clear();
+ return true;
+ }
+ return self->operator!=(*obj);
+ }
+ }
%extend {