added ctor wxColour(unsigned long colRGB) and the corresponding Set()
[wxWidgets.git] / include / wx / msw / colour.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __COLOURH__
13 #define __COLOURH__
14
15 #ifdef __GNUG__
16 #pragma interface "colour.h"
17 #endif
18
19 // Colour
20 class WXDLLEXPORT wxColour: public wxObject
21 {
22 DECLARE_DYNAMIC_CLASS(wxColour)
23 public:
24 wxColour(void);
25 wxColour(const unsigned char r, const unsigned char g, const unsigned char b);
26 wxColour(unsigned long colRGB) { Set(colRGB); }
27 wxColour(const wxColour& col);
28 wxColour(const wxString& col);
29 ~wxColour(void) ;
30 wxColour& operator =(const wxColour& src) ;
31 wxColour& operator =(const wxString& src) ;
32 inline int Ok(void) const { return (m_isInit) ; }
33
34 void Set(unsigned char r, unsigned char g, unsigned char b);
35 void Set(unsigned long colRGB)
36 {
37 // we don't need to know sizeof(long) here because we assume that the three
38 // least significant bytes contain the R, G and B values
39 Set((unsigned char)colRGB,
40 (unsigned char)(colRGB >> 8),
41 (unsigned char)(colRGB >> 16));
42 }
43
44 // Let's remove this inelegant function
45 #if WXWIN_COMPATIBILITY
46 void Get(unsigned char *r, unsigned char *g, unsigned char *b) const;
47 #endif
48
49 inline unsigned char Red(void) const { return m_red; }
50 inline unsigned char Green(void) const { return m_green; }
51 inline unsigned char Blue(void) const { return m_blue; }
52
53 inline bool operator == (const wxColour& colour) { return (m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue); }
54
55 inline bool operator != (const wxColour& colour) { return (!(m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue)); }
56
57 WXCOLORREF GetPixel(void) const { return m_pixel; };
58
59 private:
60 bool m_isInit;
61 unsigned char m_red;
62 unsigned char m_blue;
63 unsigned char m_green;
64 public:
65 WXCOLORREF m_pixel ;
66 };
67
68 #define wxColor wxColour
69
70 #endif
71 // __COLOURH__