]> git.saurik.com Git - wxWidgets.git/blame - interface/colour.h
addind nonowned window implementation
[wxWidgets.git] / interface / colour.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: colour.h
e54c96f1 3// Purpose: interface of wxColour
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxColour
11 @wxheader{colour.h}
7c913512 12
7fa7088e
BP
13 A colour is an object representing a combination of Red, Green, and Blue
14 (RGB) intensity values, and is used to determine drawing colours. See the
15 entry for wxColourDatabase for how a pointer to a predefined, named colour
16 may be returned instead of creating a new colour.
7c913512 17
23324ae1 18 Valid RGB values are in the range 0 to 255.
7c913512 19
23324ae1 20 You can retrieve the current system colour settings with wxSystemSettings.
7c913512 21
23324ae1
FM
22 @library{wxcore}
23 @category{gdi}
7c913512 24
23324ae1 25 @stdobjects
7fa7088e
BP
26 ::wxNullColour, ::wxBLACK, ::wxWHITE, ::wxRED, ::wxBLUE, ::wxGREEN,
27 ::wxCYAN, ::wxLIGHT_GREY
7c913512 28
e54c96f1 29 @see wxColourDatabase, wxPen, wxBrush, wxColourDialog, wxSystemSettings
23324ae1
FM
30*/
31class wxColour : public wxObject
32{
33public:
7fa7088e 34
23324ae1 35 /**
7fa7088e
BP
36 Default constructor.
37 */
38 wxColour();
3c4f71cc 39
7fa7088e 40 /**
7c913512 41 @param red
4cc4bfaf 42 The red value.
7c913512 43 @param green
4cc4bfaf 44 The green value.
7c913512 45 @param blue
4cc4bfaf 46 The blue value.
7c913512 47 @param alpha
7fa7088e
BP
48 The alpha value. Alpha values range from 0 (wxALPHA_TRANSPARENT) to
49 255 (wxALPHA_OPAQUE).
50 */
51 wxColour(unsigned char red, unsigned char green, unsigned char blue,
52 unsigned char alpha = wxALPHA_OPAQUE);
53
54 /**
7c913512 55 @param colourName
4cc4bfaf 56 The colour name.
7fa7088e
BP
57 */
58 wxColour(const wxString& colourName);
3c4f71cc 59
7fa7088e
BP
60 /**
61 Copy constructor.
23324ae1 62 */
7c913512 63 wxColour(const wxColour& colour);
23324ae1
FM
64
65 /**
66 Returns the alpha value, on platforms where alpha is not yet supported, this
67 always returns wxALPHA_OPAQUE.
68 */
328f5751 69 unsigned char Alpha() const;
23324ae1
FM
70
71 /**
72 Returns the blue intensity.
73 */
328f5751 74 unsigned char Blue() const;
23324ae1 75
23324ae1 76 /**
7fa7088e
BP
77 Converts this colour to a wxString using the given flags.
78
79 The supported flags are wxC2S_NAME, to obtain the colour name (e.g.
80 wxColour(255,0,0) == "red"), wxC2S_CSS_SYNTAX, to obtain the colour in
81 the "rgb(r,g,b)" or "rgba(r,g,b,a)" syntax (e.g.
82 wxColour(255,0,0,85) == "rgba(255,0,0,0.333)"), and wxC2S_HTML_SYNTAX,
83 to obtain the colour as "#" followed by 6 hexadecimal digits (e.g.
84 wxColour(255,0,0) == "#FF0000").
85
86 This function never fails and always returns a non-empty string but
87 asserts if the colour has alpha channel (i.e. is non opaque) but
88 wxC2S_CSS_SYNTAX (which is the only one supporting alpha) is not
23324ae1 89 specified in flags.
3c4f71cc 90
e54c96f1 91 @wxsince{2.7.0}
23324ae1
FM
92 */
93 wxString GetAsString(long flags);
23324ae1
FM
94
95 /**
96 Returns a pixel value which is platform-dependent. On Windows, a COLORREF is
97 returned.
98 On X, an allocated pixel value is returned.
23324ae1
FM
99 -1 is returned if the pixel is invalid (on X, unallocated).
100 */
328f5751 101 long GetPixel() const;
23324ae1
FM
102
103 /**
104 Returns the green intensity.
105 */
328f5751 106 unsigned char Green() const;
23324ae1
FM
107
108 /**
109 Returns @true if the colour object is valid (the colour has been initialised
110 with RGB values).
111 */
328f5751 112 bool IsOk() const;
23324ae1
FM
113
114 /**
115 Returns the red intensity.
116 */
328f5751 117 unsigned char Red() const;
23324ae1
FM
118
119 //@{
120 /**
121 Sets the RGB intensity values using the given values (first overload),
7fa7088e
BP
122 extracting them from the packed long (second overload), using the given
123 string (third overloard).
124
7c913512 125 When using third form, Set() accepts: colour names (those listed in
7fa7088e
BP
126 wxTheColourDatabase()), the CSS-like @c "rgb(r,g,b)" or
127 @c "rgba(r,g,b,a)" syntax (case insensitive) and the HTML-like syntax
128 (i.e. @c "#" followed by 6 hexadecimal digits for red, green, blue
129 components).
130
23324ae1 131 Returns @true if the conversion was successful, @false otherwise.
3c4f71cc 132
e54c96f1 133 @wxsince{2.7.0}
23324ae1
FM
134 */
135 void Set(unsigned char red, unsigned char green,
136 unsigned char blue,
4cc4bfaf 137 unsigned char alpha = wxALPHA_OPAQUE);
7c913512 138 void Set(unsigned long RGB);
4cc4bfaf 139 bool Set(const wxString& str);
23324ae1
FM
140 //@}
141
142 /**
143 Tests the inequality of two colours by comparing individual red, green, blue
144 colours and alpha values.
145 */
146 bool operator !=(const wxColour& colour);
147
148 //@{
149 /**
150 Assignment operator, using a colour name to be found in the colour database.
3c4f71cc 151
4cc4bfaf 152 @see wxColourDatabase
23324ae1
FM
153 */
154 wxColour operator =(const wxColour& colour);
7c913512 155 wxColour operator =(const wxString& colourName);
23324ae1
FM
156 //@}
157
158 /**
159 Tests the equality of two colours by comparing individual red, green, blue
160 colours and alpha values.
161 */
162 bool operator ==(const wxColour& colour);
163};
e54c96f1
FM
164
165
e54c96f1
FM
166/**
167 FIXME
168*/
169wxColour wxNullColour;
170
e54c96f1
FM
171/**
172 FIXME
173*/
174wxColour wxBLACK;
175
176/**
177 FIXME
178*/
179wxColour wxWHITE;
180
181/**
182 FIXME
183*/
184wxColour wxRED;
185
186/**
187 FIXME
188*/
189wxColour wxBLUE;
190
191/**
192 FIXME
193*/
194wxColour wxGREEN;
195
196/**
197 FIXME
198*/
199wxColour wxCYAN;
200
201/**
202 FIXME
203*/
204wxColour wxLIGHT_GREY;
205
206
7fa7088e
BP
207
208// ============================================================================
209// Global functions/macros
210// ============================================================================
211
212/** @ingroup group_funcmacro_misc */
213//@{
214
215/**
216 Converts string to a wxColour best represented by the given string. Returns
217 @true on success.
218
219 @see wxToString(const wxColour&)
220
221 @header{wx/colour.h}
222*/
223bool wxFromString(const wxString& string, wxColour* colour);
224
225/**
226 Converts the given wxColour into a string.
227
228 @see wxFromString(const wxString&, wxColour*)
229
230 @header{wx/colour.h}
231*/
232wxString wxToString(const wxColour& colour);
233
234//@}
235