1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxColour
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
11 @ingroup group_class_gdi
14 A colour is an object representing a combination of Red, Green, and Blue (RGB)
16 and is used to determine drawing colours. See the
17 entry for wxColourDatabase for how a pointer to a predefined,
18 named colour may be returned instead of creating a new colour.
20 Valid RGB values are in the range 0 to 255.
22 You can retrieve the current system colour settings with wxSystemSettings.
28 ::Objects:, ::wxNullColour, ::Pointers:, ::wxBLACK, ::wxWHITE, ::wxRED,
29 ::wxBLUE, ::wxGREEN, ::wxCYAN, ::wxLIGHT_GREY,
31 @see wxColourDatabase, wxPen, wxBrush, wxColourDialog, wxSystemSettings
33 class wxColour
: public wxObject
47 The alpha value. Alpha values range from 0 (wxALPHA_TRANSPARENT) to 255
57 wxColour(unsigned char red
, unsigned char green
,
59 unsigned char alpha
= wxALPHA_OPAQUE
);
60 wxColour(const wxString
& colourNname
);
61 wxColour(const wxColour
& colour
);
65 Returns the alpha value, on platforms where alpha is not yet supported, this
66 always returns wxALPHA_OPAQUE.
68 unsigned char Alpha() const;
71 Returns the blue intensity.
73 unsigned char Blue() const;
82 wxString
GetAsString(long flags
);
83 const wxC2S_NAME
, to obtain the colour
name (e
.g
.
84 wxColour(255,0,0) - "red"), wxC2S_CSS_SYNTAX
, to obtain
85 the colour in the
"rgb(r,g,b)" or "rgba(r,g,b,a)" syntax
86 (e
.g
. wxColour(255,0,0,85) - "rgba(255,0,0,0.333)"), and
87 wxC2S_HTML_SYNTAX
, to obtain the colour as
"#" followed
88 by
6 hexadecimal
digits (e
.g
. wxColour(255,0,0) - "#FF0000").
89 This function never fails
and always returns a non
-empty string but asserts
if
90 the colour has alpha
channel (i
.e
. is non opaque
) but
95 Returns a pixel value which is platform-dependent. On Windows, a COLORREF is
97 On X, an allocated pixel value is returned.
98 -1 is returned if the pixel is invalid (on X, unallocated).
100 long GetPixel() const;
103 Returns the green intensity.
105 unsigned char Green() const;
108 Returns @true if the colour object is valid (the colour has been initialised
114 Returns the red intensity.
116 unsigned char Red() const;
120 Sets the RGB intensity values using the given values (first overload),
121 extracting them from the packed long (second overload), using the given string (third overloard).
122 When using third form, Set() accepts: colour names (those listed in
123 wxTheColourDatabase()), the CSS-like
124 @c "rgb(r,g,b)" or @c "rgba(r,g,b,a)" syntax (case insensitive)
125 and the HTML-like syntax (i.e. @c "#" followed by 6 hexadecimal digits
126 for red, green, blue components).
127 Returns @true if the conversion was successful, @false otherwise.
131 void Set(unsigned char red
, unsigned char green
,
133 unsigned char alpha
= wxALPHA_OPAQUE
);
134 void Set(unsigned long RGB
);
135 bool Set(const wxString
& str
);
139 Tests the inequality of two colours by comparing individual red, green, blue
140 colours and alpha values.
142 bool operator !=(const wxColour
& colour
);
146 Assignment operator, using a colour name to be found in the colour database.
148 @see wxColourDatabase
150 wxColour
operator =(const wxColour
& colour
);
151 wxColour
operator =(const wxString
& colourName
);
155 Tests the equality of two colours by comparing individual red, green, blue
156 colours and alpha values.
158 bool operator ==(const wxColour
& colour
);
171 wxColour wxNullColour
;
212 wxColour wxLIGHT_GREY
;