]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/colour.h
Revert last change, which made it impossible to set a custom text color and then...
[wxWidgets.git] / include / wx / mac / carbon / colour.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: colour.h
3 // Purpose: wxColour class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_COLOUR_H_
13 #define _WX_COLOUR_H_
14
15 #include "wx/object.h"
16 #include "wx/string.h"
17
18 // Colour
19 class WXDLLEXPORT wxColour: public wxObject
20 {
21 public:
22 // ctors
23 // default
24 wxColour() { Init(); }
25 // from RGB
26 wxColour( unsigned char red, unsigned char green, unsigned char blue )
27 { Set(red, green, blue); }
28 wxColour( unsigned long colRGB )
29 { Set(colRGB); }
30
31 // implicit conversion from the colour name
32 wxColour( const wxString &colourName )
33 { InitFromName(colourName); }
34 wxColour( const wxChar *colourName )
35 { InitFromName(colourName); }
36
37 // copy ctors and assignment operators
38 wxColour( const wxColour& col );
39 wxColour& operator = ( const wxColour& col );
40
41 // dtor
42 ~wxColour();
43
44 // Set() functions
45 void Set( unsigned char red, unsigned char green, unsigned char blue );
46 void Set( unsigned long colRGB )
47 {
48 // we don't need to know sizeof(long) here because we assume that the three
49 // least significant bytes contain the R, G and B values
50 Set((unsigned char)colRGB,
51 (unsigned char)(colRGB >> 8),
52 (unsigned char)(colRGB >> 16));
53 }
54
55 // accessors
56 bool Ok() const {return m_isInit; }
57
58 unsigned char Red() const { return m_red; }
59 unsigned char Green() const { return m_green; }
60 unsigned char Blue() const { return m_blue; }
61
62 // comparison
63 bool operator == (const wxColour& colour) const
64 {
65 return (m_isInit == colour.m_isInit
66 && m_red == colour.m_red
67 && m_green == colour.m_green
68 && m_blue == colour.m_blue);
69 }
70 bool operator != (const wxColour& colour) const { return !(*this == colour); }
71
72 const WXCOLORREF& GetPixel() const { return m_pixel; };
73
74 void InitFromName(const wxString& col);
75
76 protected :
77
78 // Helper function
79 void Init();
80
81 private:
82 bool m_isInit;
83 unsigned char m_red;
84 unsigned char m_blue;
85 unsigned char m_green;
86
87 public:
88 WXCOLORREF m_pixel ;
89 void Set( const WXCOLORREF* color ) ;
90
91 private:
92 DECLARE_DYNAMIC_CLASS(wxColour)
93 };
94
95 #endif
96 // _WX_COLOUR_H_