]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_colour.i
Force integer values for positions and sizes
[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(SetRGB) void Set(unsigned long colRGB);
34
35 bool operator==(const wxColour& colour) const;
36 bool operator != (const wxColour& colour) const;
37
38 void InitFromName(const wxString& colourName);
39
40 %extend {
41 PyObject* Get() {
42 PyObject* rv = PyTuple_New(3);
43 int red = -1;
44 int green = -1;
45 int blue = -1;
46 if (self->Ok()) {
47 red = self->Red();
48 green = self->Green();
49 blue = self->Blue();
50 }
51 PyTuple_SetItem(rv, 0, PyInt_FromLong(red));
52 PyTuple_SetItem(rv, 1, PyInt_FromLong(green));
53 PyTuple_SetItem(rv, 2, PyInt_FromLong(blue));
54 return rv;
55 }
56 // bool __eq__(PyObject* obj) {
57 // wxColour tmp;
58 // wxColour* ptr = &tmp;
59 // if (obj == Py_None) return False;
60 // wxPyBLOCK_THREADS(bool success = wxColour_helper(obj, &ptr); PyErr_Clear());
61 // if (! success) return False;
62 // return *self == *ptr;
63 // }
64 // bool __ne__(PyObject* obj) {
65 // wxColour tmp;
66 // wxColour* ptr = &tmp;
67 // if (obj == Py_None) return True;
68 // wxPyBLOCK_THREADS(bool success = wxColour_helper(obj, &ptr); PyErr_Clear());
69 // if (! success) return True;
70 // return *self != *ptr;
71 // }
72 }
73
74
75 %pythoncode {
76 asTuple = Get
77 def __str__(self): return str(self.asTuple())
78 def __repr__(self): return 'wx.Colour' + str(self.asTuple())
79 def __nonzero__(self): return self.Ok()
80 __safe_for_unpickling__ = True
81 def __reduce__(self): return (Colour, self.Get())
82 }
83 };
84
85 // %pythoncode {
86 // Color = Colour
87 // NamedColor = NamedColour
88 // }
89
90 //---------------------------------------------------------------------------
91