]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/colour.h
Tweaks for demos on MacOSX
[wxWidgets.git] / include / wx / os2 / colour.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/os2/colour.h
3 // Purpose: wxColour class
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/13/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_COLOUR_H_
13 #define _WX_COLOUR_H_
14
15 #include "wx/object.h"
16
17 // Colour
18 class WXDLLEXPORT wxColour: public wxObject
19 {
20 public:
21 // constructors
22 // ------------
23
24 // default
25 wxColour();
26
27 // from separate RGB
28 wxColour( unsigned char cRed, unsigned char cGreen, unsigned char cBlue );
29
30 // from packed RGB
31 wxColour( unsigned long colRGB ) { Set(colRGB); }
32
33 // Implicit conversion from the colour name
34 wxColour(const wxString& rColourName) { InitFromName(rColourName); }
35 wxColour(const wxChar *zColourName) { InitFromName(zColourName); }
36
37 // Copy ctors and assignment operators
38 wxColour(const wxColour& rCol);
39 wxColour(const wxColour* pCol);
40 wxColour&operator = (const wxColour& rCol);
41
42 // Dtor
43 ~wxColour();
44
45 // Set functions
46 void Set( unsigned char cRed, unsigned char cGreen, unsigned char cBlue);
47 void Set( unsigned long lColRGB)
48 {
49 // We don't need to know sizeof(long) here because we assume that the three
50 // least significant bytes contain the R, G and B values
51 Set( (unsigned char)lColRGB
52 ,(unsigned char)(lColRGB >> 8)
53 ,(unsigned char)(lColRGB >> 16)
54 );
55 }
56 void Set(const wxString& rsColour)
57 {
58 InitFromName(rsColour);
59 }
60
61 // Accessors
62 bool Ok(void) const {return m_bIsInit; }
63
64 unsigned char Red(void) const { return m_cRed; }
65 unsigned char Green(void) const { return m_cGreen; }
66 unsigned char Blue(void) const { return m_cBlue; }
67
68 // Comparison
69 bool operator == (const wxColour& rColour) const
70 {
71 return (m_bIsInit == rColour.m_bIsInit
72 && m_cRed == rColour.m_cRed
73 && m_cGreen == rColour.m_cGreen
74 && m_cBlue == rColour.m_cBlue
75 );
76 }
77
78 bool operator != (const wxColour& rColour) const { return !(*this == rColour); }
79
80 WXCOLORREF GetPixel(void) const { return m_vPixel; };
81
82 void InitFromName(const wxString& rCol);
83
84 private:
85
86 // Helper function
87 void Init();
88
89 bool m_bIsInit;
90 unsigned char m_cRed;
91 unsigned char m_cBlue;
92 unsigned char m_cGreen;
93
94 public:
95 WXCOLORREF m_vPixel ;
96 private:
97 DECLARE_DYNAMIC_CLASS(wxColour)
98 }; // end of class wxColour
99
100 #endif
101 // _WX_COLOUR_H_