]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: colour.h | |
3 | // Purpose: wxColour class | |
37f214d5 | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
37f214d5 | 6 | // Created: 10/13/99 |
0e320a79 | 7 | // RCS-ID: $Id$ |
37f214d5 | 8 | // Copyright: (c) David Webster |
0e320a79 DW |
9 | // Licence: wxWindows licence |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_COLOUR_H_ | |
13 | #define _WX_COLOUR_H_ | |
14 | ||
0e320a79 | 15 | #include "wx/object.h" |
0e320a79 DW |
16 | |
17 | // Colour | |
18 | class WXDLLEXPORT wxColour: public wxObject | |
19 | { | |
20 | public: | |
a0606634 DW |
21 | // |
22 | // Ctors | |
23 | // | |
24 | ||
25 | // | |
26 | // Default | |
27 | // | |
28 | wxColour(); | |
29 | ||
30 | // | |
0e320a79 | 31 | // from RGB |
a0606634 DW |
32 | // |
33 | wxColour( unsigned char cRed | |
34 | ,unsigned char cGreen | |
35 | ,unsigned char cBlue | |
36 | ); | |
37 | ||
19193a2c KB |
38 | wxColour( unsigned long colRGB ) { Set(colRGB); } |
39 | ||
a0606634 DW |
40 | // |
41 | // Implicit conversion from the colour name | |
42 | // | |
43 | wxColour(const wxString& rColourName) { InitFromName(rColourName); } | |
aad6765c | 44 | wxColour(const wxChar *zColourName) { InitFromName(zColourName); } |
a0606634 DW |
45 | |
46 | // | |
47 | // Copy ctors and assignment operators | |
48 | // | |
49 | wxColour(const wxColour& rCol); | |
50 | wxColour(const wxColour* pCol); | |
51 | wxColour&operator = (const wxColour& rCol); | |
52 | ||
53 | // | |
54 | // Dtor | |
55 | // | |
56 | ~wxColour(); | |
57 | ||
58 | // | |
59 | // Set functions | |
60 | // | |
61 | void Set( unsigned char cRed | |
62 | ,unsigned char cGreen | |
63 | ,unsigned char cBlue | |
64 | ); | |
65 | void Set(unsigned long lColRGB) | |
66 | { | |
67 | // | |
68 | // We don't need to know sizeof(long) here because we assume that the three | |
69 | // least significant bytes contain the R, G and B values | |
70 | // | |
71 | Set( (unsigned char)lColRGB | |
72 | ,(unsigned char)(lColRGB >> 8) | |
73 | ,(unsigned char)(lColRGB >> 16) | |
74 | ); | |
75 | } | |
5a56a532 DW |
76 | void Set(const wxString& rsColour) |
77 | { | |
78 | InitFromName(rsColour); | |
79 | } | |
a0606634 DW |
80 | |
81 | // | |
82 | // Accessors | |
8c5907ce | 83 | // |
a0606634 DW |
84 | bool Ok(void) const {return m_bIsInit; } |
85 | ||
a0606634 DW |
86 | unsigned char Red(void) const { return m_cRed; } |
87 | unsigned char Green(void) const { return m_cGreen; } | |
88 | unsigned char Blue(void) const { return m_cBlue; } | |
0e320a79 | 89 | |
a0606634 DW |
90 | // |
91 | // Comparison | |
92 | // | |
93 | bool operator == (const wxColour& rColour) const | |
94 | { | |
edb8604f | 95 | return (m_bIsInit == rColour.m_bIsInit |
aad6765c JS |
96 | && m_cRed == rColour.m_cRed |
97 | && m_cGreen == rColour.m_cGreen | |
98 | && m_cBlue == rColour.m_cBlue | |
a0606634 DW |
99 | ); |
100 | } | |
aad6765c | 101 | |
a0606634 | 102 | bool operator != (const wxColour& rColour) const { return !(*this == rColour); } |
0e320a79 | 103 | |
a0606634 | 104 | WXCOLORREF GetPixel(void) const { return m_vPixel; }; |
0e320a79 | 105 | |
aad6765c JS |
106 | void InitFromName(const wxString& rCol); |
107 | ||
0e320a79 | 108 | private: |
aad6765c JS |
109 | |
110 | // Helper function | |
111 | void Init(); | |
112 | ||
a0606634 DW |
113 | bool m_bIsInit; |
114 | unsigned char m_cRed; | |
115 | unsigned char m_cBlue; | |
116 | unsigned char m_cGreen; | |
0e320a79 DW |
117 | |
118 | public: | |
a0606634 | 119 | WXCOLORREF m_vPixel ; |
0e320a79 DW |
120 | private: |
121 | DECLARE_DYNAMIC_CLASS(wxColour) | |
a0606634 | 122 | }; // end of class wxColour |
0e320a79 DW |
123 | |
124 | #endif | |
125 | // _WX_COLOUR_H_ |