]> git.saurik.com Git - wxWidgets.git/blame - interface/colour.h
fixed links to global variables; fixed categories; use @see instead of @seealso
[wxWidgets.git] / interface / colour.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: colour.h
3// Purpose: documentation for wxColour class
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxColour
11 @wxheader{colour.h}
7c913512 12
23324ae1
FM
13 A colour is an object representing a combination of Red, Green, and Blue (RGB)
14 intensity values,
15 and is used to determine drawing colours. See the
16 entry for wxColourDatabase for how a pointer to a predefined,
17 named colour may be returned instead of creating a new colour.
7c913512 18
23324ae1 19 Valid RGB values are in the range 0 to 255.
7c913512 20
23324ae1 21 You can retrieve the current system colour settings with wxSystemSettings.
7c913512 22
23324ae1
FM
23 @library{wxcore}
24 @category{gdi}
7c913512 25
23324ae1
FM
26 @stdobjects
27 Objects:
28 wxNullColour
29 Pointers:
30 wxBLACK
7c913512 31
23324ae1 32 wxWHITE
7c913512 33
23324ae1 34 wxRED
7c913512 35
23324ae1 36 wxBLUE
7c913512 37
23324ae1 38 wxGREEN
7c913512 39
23324ae1 40 wxCYAN
7c913512 41
23324ae1 42 wxLIGHT_GREY
7c913512 43
23324ae1
FM
44 @seealso
45 wxColourDatabase, wxPen, wxBrush, wxColourDialog, wxSystemSettings
46*/
47class wxColour : public wxObject
48{
49public:
50 //@{
51 /**
52 Copy constructor.
53
7c913512 54 @param red
4cc4bfaf 55 The red value.
7c913512 56 @param green
4cc4bfaf 57 The green value.
7c913512 58 @param blue
4cc4bfaf 59 The blue value.
7c913512 60 @param alpha
4cc4bfaf 61 The alpha value. Alpha values range from 0 (wxALPHA_TRANSPARENT) to 255
23324ae1 62 (wxALPHA_OPAQUE).
7c913512 63 @param colourName
4cc4bfaf 64 The colour name.
7c913512 65 @param colour
4cc4bfaf 66 The colour to copy.
23324ae1 67
4cc4bfaf 68 @see wxColourDatabase
23324ae1
FM
69 */
70 wxColour();
7c913512
FM
71 wxColour(unsigned char red, unsigned char green,
72 unsigned char blue,
4cc4bfaf 73 unsigned char alpha = wxALPHA_OPAQUE);
7c913512
FM
74 wxColour(const wxString& colourNname);
75 wxColour(const wxColour& colour);
23324ae1
FM
76 //@}
77
78 /**
79 Returns the alpha value, on platforms where alpha is not yet supported, this
80 always returns wxALPHA_OPAQUE.
81 */
328f5751 82 unsigned char Alpha() const;
23324ae1
FM
83
84 /**
85 Returns the blue intensity.
86 */
328f5751 87 unsigned char Blue() const;
23324ae1
FM
88
89 //@{
90 /**
91 is not
92 specified in flags.
23324ae1
FM
93 This function is new since wxWidgets version 2.7.0
94 */
95 wxString GetAsString(long flags);
328f5751
FM
96 const wxC2S_NAME, to obtain the colour name (e.g.
97 wxColour(255,0,0) - "red"), wxC2S_CSS_SYNTAX, to obtain
7c913512
FM
98 the colour in the "rgb(r,g,b)" or "rgba(r,g,b,a)" syntax
99 (e.g. wxColour(255,0,0,85) - "rgba(255,0,0,0.333)"), and
100 wxC2S_HTML_SYNTAX, to obtain the colour as "#" followed
101 by 6 hexadecimal digits (e.g. wxColour(255,0,0) - "#FF0000").
102 This function never fails and always returns a non-empty string but asserts if
103 the colour has alpha channel (i.e. is non opaque) but
104 wxC2S_CSS_SYNTAX();
23324ae1
FM
105 //@}
106
107 /**
108 Returns a pixel value which is platform-dependent. On Windows, a COLORREF is
109 returned.
110 On X, an allocated pixel value is returned.
23324ae1
FM
111 -1 is returned if the pixel is invalid (on X, unallocated).
112 */
328f5751 113 long GetPixel() const;
23324ae1
FM
114
115 /**
116 Returns the green intensity.
117 */
328f5751 118 unsigned char Green() const;
23324ae1
FM
119
120 /**
121 Returns @true if the colour object is valid (the colour has been initialised
122 with RGB values).
123 */
328f5751 124 bool IsOk() const;
23324ae1
FM
125
126 /**
127 Returns the red intensity.
128 */
328f5751 129 unsigned char Red() const;
23324ae1
FM
130
131 //@{
132 /**
133 Sets the RGB intensity values using the given values (first overload),
134 extracting them from the packed long (second overload), using the given string (third overloard).
7c913512
FM
135 When using third form, Set() accepts: colour names (those listed in
136 wxTheColourDatabase), the CSS-like
137 @c "rgb(r,g,b)" or @c "rgba(r,g,b,a)" syntax (case insensitive)
138 and the HTML-like syntax (i.e. @c "#" followed by 6 hexadecimal digits
23324ae1 139 for red, green, blue components).
23324ae1 140 Returns @true if the conversion was successful, @false otherwise.
23324ae1
FM
141 This function is new since wxWidgets version 2.7.0
142 */
143 void Set(unsigned char red, unsigned char green,
144 unsigned char blue,
4cc4bfaf 145 unsigned char alpha = wxALPHA_OPAQUE);
7c913512 146 void Set(unsigned long RGB);
4cc4bfaf 147 bool Set(const wxString& str);
23324ae1
FM
148 //@}
149
150 /**
151 Tests the inequality of two colours by comparing individual red, green, blue
152 colours and alpha values.
153 */
154 bool operator !=(const wxColour& colour);
155
156 //@{
157 /**
158 Assignment operator, using a colour name to be found in the colour database.
159
4cc4bfaf 160 @see wxColourDatabase
23324ae1
FM
161 */
162 wxColour operator =(const wxColour& colour);
7c913512 163 wxColour operator =(const wxString& colourName);
23324ae1
FM
164 //@}
165
166 /**
167 Tests the equality of two colours by comparing individual red, green, blue
168 colours and alpha values.
169 */
170 bool operator ==(const wxColour& colour);
171};