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