]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_colour.i
Noted where the documentation was
[wxWidgets.git] / wxPython / src / _colour.i
CommitLineData
d14a1e28
RD
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
d14a1e28
RD
19
20class wxColour : public wxObject {
21public:
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);
3f0ff538 33 %name(SetRGB) void Set(unsigned long colRGB);
d14a1e28
RD
34
35 bool operator==(const wxColour& colour) const;
36 bool operator != (const wxColour& colour) const;
37
3f0ff538
RD
38 void InitFromName(const wxString& colourName);
39
d14a1e28
RD
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;
dd9f7fea 59// if (obj == Py_None) return False;
d14a1e28 60// wxPyBLOCK_THREADS(bool success = wxColour_helper(obj, &ptr); PyErr_Clear());
dd9f7fea 61// if (! success) return False;
d14a1e28
RD
62// return *self == *ptr;
63// }
64// bool __ne__(PyObject* obj) {
65// wxColour tmp;
66// wxColour* ptr = &tmp;
dd9f7fea 67// if (obj == Py_None) return True;
d14a1e28 68// wxPyBLOCK_THREADS(bool success = wxColour_helper(obj, &ptr); PyErr_Clear());
dd9f7fea 69// if (! success) return True;
d14a1e28
RD
70// return *self != *ptr;
71// }
72 }
73
74
75 %pythoncode {
76 asTuple = Get
77 def __str__(self): return str(self.asTuple())
c4f85165 78 def __repr__(self): return 'wx.Colour' + str(self.asTuple())
d14a1e28
RD
79 def __nonzero__(self): return self.Ok()
80 def __getinitargs__(self): return ()
81 def __getstate__(self): return self.asTuple()
82 def __setstate__(self, state): self.Set(*state)
83 }
84};
85
61c5a8ac
RD
86%pythoncode {
87 Color = Colour
88 NamedColor = NamedColour
89}
d14a1e28
RD
90//---------------------------------------------------------------------------
91