]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_colour.i
Recent changes in SWIG make this patch no longer necessary
[wxWidgets.git] / wxPython / src / _colour.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _colour.i
3 // Purpose: SWIG interface for wxColour
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 7-July-1997
8 // RCS-ID: $Id$
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17 %newgroup;
18
19 %noautorepr wxColour;
20
21 class wxColour : public wxObject {
22 public:
23 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
24 ~wxColour();
25
26 %name(NamedColour) wxColour( const wxString& colorName);
27 %name(ColourRGB) wxColour( unsigned long colRGB );
28
29 unsigned char Red();
30 unsigned char Green();
31 unsigned char Blue();
32 bool Ok();
33 void Set(unsigned char red, unsigned char green, unsigned char blue);
34 %name(SetRBG) void Set(unsigned long colRGB);
35
36 bool operator==(const wxColour& colour) const;
37 bool operator != (const wxColour& colour) const;
38
39 %extend {
40 PyObject* Get() {
41 PyObject* rv = PyTuple_New(3);
42 int red = -1;
43 int green = -1;
44 int blue = -1;
45 if (self->Ok()) {
46 red = self->Red();
47 green = self->Green();
48 blue = self->Blue();
49 }
50 PyTuple_SetItem(rv, 0, PyInt_FromLong(red));
51 PyTuple_SetItem(rv, 1, PyInt_FromLong(green));
52 PyTuple_SetItem(rv, 2, PyInt_FromLong(blue));
53 return rv;
54 }
55 // bool __eq__(PyObject* obj) {
56 // wxColour tmp;
57 // wxColour* ptr = &tmp;
58 // if (obj == Py_None) return FALSE;
59 // wxPyBLOCK_THREADS(bool success = wxColour_helper(obj, &ptr); PyErr_Clear());
60 // if (! success) return FALSE;
61 // return *self == *ptr;
62 // }
63 // bool __ne__(PyObject* obj) {
64 // wxColour tmp;
65 // wxColour* ptr = &tmp;
66 // if (obj == Py_None) return TRUE;
67 // wxPyBLOCK_THREADS(bool success = wxColour_helper(obj, &ptr); PyErr_Clear());
68 // if (! success) return TRUE;
69 // return *self != *ptr;
70 // }
71 }
72
73
74 %pythoncode {
75 asTuple = Get
76 def __str__(self): return str(self.asTuple())
77 def __repr__(self): return 'wxColour' + str(self.asTuple())
78 def __nonzero__(self): return self.Ok()
79 def __getinitargs__(self): return ()
80 def __getstate__(self): return self.asTuple()
81 def __setstate__(self, state): self.Set(*state)
82 }
83 };
84
85 //---------------------------------------------------------------------------
86