]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_colour.i
New SWIG runtime and commandline param
[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
20 class wxColour : public wxObject {
21 public:
22 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0);
23 ~wxColour();
24
25 %name(NamedColour) wxColour( const wxString& colorName);
26 %name(ColourRGB) wxColour( unsigned long colRGB );
27
28 unsigned char Red();
29 unsigned char Green();
30 unsigned char Blue();
31 bool Ok();
32 void Set(unsigned char red, unsigned char green, unsigned char blue);
33 %name(SetRBG) void Set(unsigned long colRGB);
34
35 bool operator==(const wxColour& colour) const;
36 bool operator != (const wxColour& colour) const;
37
38 %extend {
39 PyObject* Get() {
40 PyObject* rv = PyTuple_New(3);
41 int red = -1;
42 int green = -1;
43 int blue = -1;
44 if (self->Ok()) {
45 red = self->Red();
46 green = self->Green();
47 blue = self->Blue();
48 }
49 PyTuple_SetItem(rv, 0, PyInt_FromLong(red));
50 PyTuple_SetItem(rv, 1, PyInt_FromLong(green));
51 PyTuple_SetItem(rv, 2, PyInt_FromLong(blue));
52 return rv;
53 }
54 // bool __eq__(PyObject* obj) {
55 // wxColour tmp;
56 // wxColour* ptr = &tmp;
57 // if (obj == Py_None) return False;
58 // wxPyBLOCK_THREADS(bool success = wxColour_helper(obj, &ptr); PyErr_Clear());
59 // if (! success) return False;
60 // return *self == *ptr;
61 // }
62 // bool __ne__(PyObject* obj) {
63 // wxColour tmp;
64 // wxColour* ptr = &tmp;
65 // if (obj == Py_None) return True;
66 // wxPyBLOCK_THREADS(bool success = wxColour_helper(obj, &ptr); PyErr_Clear());
67 // if (! success) return True;
68 // return *self != *ptr;
69 // }
70 }
71
72
73 %pythoncode {
74 asTuple = Get
75 def __str__(self): return str(self.asTuple())
76 def __repr__(self): return 'wxColour' + str(self.asTuple())
77 def __nonzero__(self): return self.Ok()
78 def __getinitargs__(self): return ()
79 def __getstate__(self): return self.asTuple()
80 def __setstate__(self, state): self.Set(*state)
81 }
82 };
83
84 %pythoncode {
85 Color = Colour
86 NamedColor = NamedColour
87 }
88 //---------------------------------------------------------------------------
89