]>
Commit | Line | Data |
---|---|---|
2bda0e17 | 1 | ///////////////////////////////////////////////////////////////////////////// |
f75aecd0 | 2 | // Name: wx/msw/colour.h |
2bda0e17 KB |
3 | // Purpose: wxColour class |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
bbcdf8bc | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
bbcdf8bc JS |
12 | #ifndef _WX_COLOUR_H_ |
13 | #define _WX_COLOUR_H_ | |
2bda0e17 | 14 | |
2d996ed1 | 15 | #include "wx/object.h" |
2bda0e17 | 16 | |
f75aecd0 | 17 | // ---------------------------------------------------------------------------- |
2bda0e17 | 18 | // Colour |
f75aecd0 VZ |
19 | // ---------------------------------------------------------------------------- |
20 | ||
21 | class WXDLLEXPORT wxColour : public wxObject | |
2bda0e17 | 22 | { |
2bda0e17 | 23 | public: |
f75aecd0 VZ |
24 | // constructors |
25 | // ------------ | |
26 | ||
e4a81a2e | 27 | // default |
f75aecd0 VZ |
28 | wxColour() { Init(); } |
29 | ||
30 | // from separate RGB | |
31 | wxColour( unsigned char red, unsigned char green, unsigned char blue ) | |
32 | { Set(red, green, blue); } | |
33 | ||
34 | // from packed RGB | |
35 | wxColour( unsigned long colRGB ) { Set(colRGB); } | |
5f83a454 | 36 | |
e4a81a2e | 37 | // implicit conversion from the colour name |
f75aecd0 VZ |
38 | wxColour(const wxString &colourName) { InitFromName(colourName); } |
39 | wxColour(const wxChar *colourName) { InitFromName(colourName); } | |
e4a81a2e | 40 | |
5f83a454 | 41 | |
e4a81a2e | 42 | // copy ctors and assignment operators |
f75aecd0 VZ |
43 | wxColour(const wxColour& col); |
44 | wxColour& operator=( const wxColour& col); | |
e4a81a2e VZ |
45 | |
46 | // dtor | |
f75aecd0 VZ |
47 | ~wxColour(); |
48 | ||
49 | ||
50 | // other methods | |
51 | // ------------- | |
52 | ||
aad6765c | 53 | // to have the matching Create also for this class |
f75aecd0 | 54 | void Create( unsigned char red, unsigned char green, unsigned char blue ) |
aad6765c | 55 | { Set(red, green, blue); } |
f75aecd0 VZ |
56 | |
57 | // Set() functions | |
58 | void Set(unsigned char red, unsigned char green, unsigned char blue); | |
59 | void Set(unsigned long colRGB) | |
60 | { | |
61 | // we don't need to know sizeof(long) here because we assume that the three | |
62 | // least significant bytes contain the R, G and B values | |
63 | Set((unsigned char)colRGB, | |
aad6765c JS |
64 | (unsigned char)(colRGB >> 8), |
65 | (unsigned char)(colRGB >> 16)); | |
f75aecd0 VZ |
66 | } |
67 | ||
68 | // accessors | |
69 | // --------- | |
70 | ||
aad6765c | 71 | bool Ok() const { return m_isInit; } |
f75aecd0 VZ |
72 | |
73 | unsigned char Red() const { return m_red; } | |
74 | unsigned char Green() const { return m_green; } | |
75 | unsigned char Blue() const { return m_blue; } | |
76 | ||
77 | // comparison | |
78 | bool operator==(const wxColour& colour) const | |
79 | { | |
aad6765c JS |
80 | return m_isInit == colour.m_isInit |
81 | && m_red == colour.m_red | |
82 | && m_green == colour.m_green | |
83 | && m_blue == colour.m_blue; | |
f75aecd0 VZ |
84 | } |
85 | ||
86 | bool operator != (const wxColour& colour) const { return !(*this == colour); } | |
87 | ||
88 | WXCOLORREF GetPixel() const { return m_pixel; }; | |
2bda0e17 | 89 | |
aad6765c JS |
90 | void InitFromName(const wxString& colourName); |
91 | ||
8f177c8e | 92 | public: |
f75aecd0 | 93 | WXCOLORREF m_pixel; |
8f177c8e | 94 | |
aad6765c JS |
95 | protected: |
96 | // Helper function | |
97 | void Init(); | |
98 | ||
68dda785 | 99 | private: |
f75aecd0 VZ |
100 | bool m_isInit; |
101 | unsigned char m_red; | |
102 | unsigned char m_blue; | |
103 | unsigned char m_green; | |
68dda785 | 104 | |
68dda785 | 105 | private: |
f75aecd0 | 106 | DECLARE_DYNAMIC_CLASS(wxColour) |
2bda0e17 KB |
107 | }; |
108 | ||
2bda0e17 | 109 | #endif |
8f177c8e | 110 | // _WX_COLOUR_H_ |