]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_colour.i
silence a bogus error message
[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 19
6ad421ae
RD
20DocStr(wxColour,
21"A colour is an object representing a combination of Red, Green, and Blue (RGB)
22intensity values, and is used to determine drawing colours, window colours,
23etc. Valid RGB values are in the range 0 to 255.
24
25In wxPython there are typemaps that will automatically convert from a colour
2b619822 26name, or from a '#RRGGBB' colour hex value string to a wx.Colour object when
6ad421ae
RD
27calling C++ methods that expect a wxColour. This means that the following are
28all equivallent:
29
30 win.SetBackgroundColour(wxColour(0,0,255))
2b619822
RD
31 win.SetBackgroundColour('BLUE')
32 win.SetBackgroundColour('#0000FF')
6ad421ae
RD
33
34You can retrieve the various current system colour settings with
35wx.SystemSettings.GetColour.");
36
37
d14a1e28
RD
38class wxColour : public wxObject {
39public:
6ad421ae
RD
40
41 DocCtorStr(
42 wxColour(unsigned char red=0, unsigned char green=0, unsigned char blue=0),
43 "Constructs a colour from red, green and blue values.");
44
45 DocCtorStrName(
46 wxColour( const wxString& colorName),
47 "Constructs a colour object using a colour name listed in wx.TheColourDatabase.",
48 NamedColour);
49
50 DocCtorStrName(
51 wxColour( unsigned long colRGB ),
52 "Constructs a colour from a packed RGB value.",
53 ColourRGB);
54
d14a1e28
RD
55 ~wxColour();
56
6ad421ae
RD
57
58 DocDeclStr(
59 unsigned char , Red(),
60 "Returns the red intensity.");
61
62 DocDeclStr(
63 unsigned char , Green(),
64 "Returns the green intensity.");
65
66 DocDeclStr(
67 unsigned char , Blue(),
68 "Returns the blue intensity.");
69
70 DocDeclStr(
71 bool , Ok(),
72 "Returns True if the colour object is valid (the colour has been\n"
73 "initialised with RGB values).");
74
75 DocDeclStr(
76 void , Set(unsigned char red, unsigned char green, unsigned char blue),
77 "Sets the RGB intensity values.");
d14a1e28 78
6ad421ae
RD
79 DocDeclStrName(
80 void , Set(unsigned long colRGB),
81 "Sets the RGB intensity values from a packed RGB value.",
82 SetRGB);
d14a1e28 83
6ad421ae
RD
84 DocDeclStrName(
85 void , InitFromName(const wxString& colourName),
86 "Sets the RGB intensity values using a colour name listed in wx.TheColourDatabase.",
87 SetFromName);
88
89
90 DocDeclStr(
91 long , GetPixel() const,
92 "Returns a pixel value which is platform-dependent. On Windows, a\n"
93 "COLORREF is returned. On X, an allocated pixel value is returned.\n"
94 "-1 is returned if the pixel is invalid (on X, unallocated).");
95
96
97 DocDeclStr(
98 bool , operator==(const wxColour& colour) const,
99 "Compare colours for equality");
100
101 DocDeclStr(
102 bool , operator!=(const wxColour& colour) const,
103 "Compare colours for inequality");
104
d14a1e28 105
3f0ff538 106
d14a1e28 107 %extend {
6ad421ae
RD
108 DocAStr(Get,
109 "Get() -> (r, g, b)",
110 "Returns the RGB intensity values as a tuple.");
d14a1e28
RD
111 PyObject* Get() {
112 PyObject* rv = PyTuple_New(3);
113 int red = -1;
114 int green = -1;
115 int blue = -1;
116 if (self->Ok()) {
117 red = self->Red();
118 green = self->Green();
119 blue = self->Blue();
120 }
121 PyTuple_SetItem(rv, 0, PyInt_FromLong(red));
122 PyTuple_SetItem(rv, 1, PyInt_FromLong(green));
123 PyTuple_SetItem(rv, 2, PyInt_FromLong(blue));
124 return rv;
125 }
6ad421ae
RD
126
127 DocStr(GetRGB,
128 "Return the colour as a packed RGB value");
129 unsigned long GetRGB() {
130 return self->Red() | (self->Green() << 8) | (self->Blue() << 16);
131 }
d14a1e28
RD
132 }
133
134
135 %pythoncode {
136 asTuple = Get
137 def __str__(self): return str(self.asTuple())
c4f85165 138 def __repr__(self): return 'wx.Colour' + str(self.asTuple())
d14a1e28 139 def __nonzero__(self): return self.Ok()
02376d73
RD
140 __safe_for_unpickling__ = True
141 def __reduce__(self): return (Colour, self.Get())
d14a1e28
RD
142 }
143};
144
2b9048c5
RD
145%pythoncode {
146 Color = Colour
147 NamedColor = NamedColour
148 ColorRGB = ColourRGB
149}
cf763f5b 150
d14a1e28
RD
151//---------------------------------------------------------------------------
152