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