]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/colour.h
Fixes for WinCE build caused by my last commit.
[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 #include "wx/object.h"
16
17 // ----------------------------------------------------------------------------
18 // Colour
19 // ----------------------------------------------------------------------------
20
21 class WXDLLEXPORT wxColour : public wxObject
22 {
23 public:
24 // constructors
25 // ------------
26
27 // default
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); }
36
37 // implicit conversion from the colour name
38 wxColour(const wxString &colourName) { InitFromName(colourName); }
39 wxColour(const wxChar *colourName) { InitFromName(colourName); }
40
41 // dtor
42 ~wxColour();
43
44
45 // other methods
46 // -------------
47
48 // to have the matching Create also for this class
49 void Create( unsigned char red, unsigned char green, unsigned char blue )
50 { Set(red, green, blue); }
51
52 // Set() functions
53 void Set(unsigned char red, unsigned char green, unsigned char blue);
54 void Set(unsigned long colRGB)
55 {
56 // we don't need to know sizeof(long) here because we assume that the three
57 // least significant bytes contain the R, G and B values
58 Set((unsigned char)colRGB,
59 (unsigned char)(colRGB >> 8),
60 (unsigned char)(colRGB >> 16));
61 }
62
63 // accessors
64 // ---------
65
66 bool Ok() const { return m_isInit; }
67
68 unsigned char Red() const { return m_red; }
69 unsigned char Green() const { return m_green; }
70 unsigned char Blue() const { return m_blue; }
71
72 // comparison
73 bool operator==(const wxColour& colour) const
74 {
75 return m_isInit == colour.m_isInit
76 && m_red == colour.m_red
77 && m_green == colour.m_green
78 && m_blue == colour.m_blue;
79 }
80
81 bool operator != (const wxColour& colour) const { return !(*this == colour); }
82
83 WXCOLORREF GetPixel() const { return m_pixel; };
84
85 void InitFromName(const wxString& colourName);
86
87 public:
88 WXCOLORREF m_pixel;
89
90 protected:
91 // Helper function
92 void Init();
93
94 private:
95 bool m_isInit;
96 unsigned char m_red;
97 unsigned char m_blue;
98 unsigned char m_green;
99
100 private:
101 DECLARE_DYNAMIC_CLASS(wxColour)
102 };
103
104 #endif
105 // _WX_COLOUR_H_