]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/colour.h
refactored common parts of DrawItem() in the base class; implemented GetTextTotal...
[wxWidgets.git] / include / wx / cocoa / colour.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/colour.h
3 // Purpose: wxColour class
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2003/06/17
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __WX_COCOA_COLOUR_H__
13 #define __WX_COCOA_COLOUR_H__
14
15 #include "wx/object.h"
16 #include "wx/string.h"
17
18 // ========================================================================
19 // wxColour
20 // ========================================================================
21
22 class WXDLLEXPORT wxColour : public wxColourBase
23 {
24 public:
25 // constructors
26 // ------------
27
28 // default
29 wxColour() { Init(); }
30 DEFINE_STD_WXCOLOUR_CONSTRUCTORS
31
32 // initialization using existing NSColor
33 wxColour( WX_NSColor aColor );
34
35
36 // copy ctors and assignment operators
37 wxColour( const wxColour& col );
38 wxColour& operator = ( const wxColour& col );
39
40 virtual ~wxColour();
41
42 // accessors
43 bool Ok() const { return m_cocoaNSColor; }
44 WX_NSColor GetNSColor() { return m_cocoaNSColor; }
45
46 unsigned char Red() const { return m_red; }
47 unsigned char Green() const { return m_green; }
48 unsigned char Blue() const { return m_blue; }
49 unsigned char Alpha() const { return m_alpha; }
50
51 // comparison
52 bool operator == (const wxColour& colour) const
53 {
54 return m_cocoaNSColor == colour.m_cocoaNSColor ||
55 (m_red == colour.m_red &&
56 m_green == colour.m_green &&
57 m_blue == colour.m_blue &&
58 m_alpha == colour.m_alpha);
59 }
60 bool operator != (const wxColour& colour) const
61 { return !(*this == colour); }
62
63 // Set() functions
64 void Set( WX_NSColor aColor );
65
66 // reroute the inherited ones
67 void Set(unsigned char red,
68 unsigned char green,
69 unsigned char blue,
70 unsigned char alpha = wxALPHA_OPAQUE)
71 { wxColourBase::Set(red, green, blue, alpha); }
72
73 bool Set(const wxChar *str)
74 { return wxColourBase::Set(str); }
75
76 bool Set(const wxString &str)
77 { return wxColourBase::Set(str); }
78
79 void Set(unsigned long colRGB)
80 { wxColourBase::Set(colRGB); }
81
82 protected:
83 // puts the object in an invalid, uninitialized state
84 void Init();
85
86 virtual void
87 InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
88
89 private:
90 WX_NSColor m_cocoaNSColor;
91 unsigned char m_red;
92 unsigned char m_green;
93 unsigned char m_blue;
94 unsigned char m_alpha;
95
96 DECLARE_DYNAMIC_CLASS(wxColour)
97 };
98
99 #endif // __WX_COCOA_COLOUR_H__