]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_colour.i
updated Joystick demo, is now wxDesigner-less
[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 79 def __nonzero__(self): return self.Ok()
02376d73
RD
80 __safe_for_unpickling__ = True
81 def __reduce__(self): return (Colour, self.Get())
d14a1e28
RD
82 }
83};
84
cf763f5b
RD
85// %pythoncode {
86// Color = Colour
87// NamedColor = NamedColour
88// }
89
d14a1e28
RD
90//---------------------------------------------------------------------------
91