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