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