1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxColour
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 A colour is an object representing a combination of Red, Green, and Blue (RGB)
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.
19 Valid RGB values are in the range 0 to 255.
21 You can retrieve the current system colour settings with wxSystemSettings.
27 ::Objects:, ::wxNullColour, ::Pointers:, ::wxBLACK, ::wxWHITE, ::wxRED,
28 ::wxBLUE, ::wxGREEN, ::wxCYAN, ::wxLIGHT_GREY,
30 @see wxColourDatabase, wxPen, wxBrush, wxColourDialog, wxSystemSettings
32 class wxColour
: public wxObject
46 The alpha value. Alpha values range from 0 (wxALPHA_TRANSPARENT) to 255
56 wxColour(unsigned char red
, unsigned char green
,
58 unsigned char alpha
= wxALPHA_OPAQUE
);
59 wxColour(const wxString
& colourNname
);
60 wxColour(const wxColour
& colour
);
64 Returns the alpha value, on platforms where alpha is not yet supported, this
65 always returns wxALPHA_OPAQUE.
67 unsigned char Alpha() const;
70 Returns the blue intensity.
72 unsigned char Blue() const;
81 wxString
GetAsString(long flags
);
82 const wxC2S_NAME
, to obtain the colour
name (e
.g
.
83 wxColour(255,0,0) - "red"), wxC2S_CSS_SYNTAX
, to obtain
84 the colour in the
"rgb(r,g,b)" or "rgba(r,g,b,a)" syntax
85 (e
.g
. wxColour(255,0,0,85) - "rgba(255,0,0,0.333)"), and
86 wxC2S_HTML_SYNTAX
, to obtain the colour as
"#" followed
87 by
6 hexadecimal
digits (e
.g
. wxColour(255,0,0) - "#FF0000").
88 This function never fails
and always returns a non
-empty string but asserts
if
89 the colour has alpha
channel (i
.e
. is non opaque
) but
94 Returns a pixel value which is platform-dependent. On Windows, a COLORREF is
96 On X, an allocated pixel value is returned.
97 -1 is returned if the pixel is invalid (on X, unallocated).
99 long GetPixel() const;
102 Returns the green intensity.
104 unsigned char Green() const;
107 Returns @true if the colour object is valid (the colour has been initialised
113 Returns the red intensity.
115 unsigned char Red() const;
119 Sets the RGB intensity values using the given values (first overload),
120 extracting them from the packed long (second overload), using the given string (third overloard).
121 When using third form, Set() accepts: colour names (those listed in
122 wxTheColourDatabase()), the CSS-like
123 @c "rgb(r,g,b)" or @c "rgba(r,g,b,a)" syntax (case insensitive)
124 and the HTML-like syntax (i.e. @c "#" followed by 6 hexadecimal digits
125 for red, green, blue components).
126 Returns @true if the conversion was successful, @false otherwise.
130 void Set(unsigned char red
, unsigned char green
,
132 unsigned char alpha
= wxALPHA_OPAQUE
);
133 void Set(unsigned long RGB
);
134 bool Set(const wxString
& str
);
138 Tests the inequality of two colours by comparing individual red, green, blue
139 colours and alpha values.
141 bool operator !=(const wxColour
& colour
);
145 Assignment operator, using a colour name to be found in the colour database.
147 @see wxColourDatabase
149 wxColour
operator =(const wxColour
& colour
);
150 wxColour
operator =(const wxString
& colourName
);
154 Tests the equality of two colours by comparing individual red, green, blue
155 colours and alpha values.
157 bool operator ==(const wxColour
& colour
);
170 wxColour wxNullColour
;
211 wxColour wxLIGHT_GREY
;