add IsOk() to all classes having Ok() method (patch 1570985)
[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 IsOk(); }
44 bool IsOk() const { return m_cocoaNSColor; }
45 WX_NSColor GetNSColor() { return m_cocoaNSColor; }
46
47 unsigned char Red() const { return m_red; }
48 unsigned char Green() const { return m_green; }
49 unsigned char Blue() const { return m_blue; }
50 unsigned char Alpha() const { return m_alpha; }
51
52 // comparison
53 bool operator == (const wxColour& colour) const
54 {
55 return m_cocoaNSColor == colour.m_cocoaNSColor ||
56 (m_red == colour.m_red &&
57 m_green == colour.m_green &&
58 m_blue == colour.m_blue &&
59 m_alpha == colour.m_alpha);
60 }
61 bool operator != (const wxColour& colour) const
62 { return !(*this == colour); }
63
64 // Set() functions
65 void Set( WX_NSColor aColor );
66
67 // reroute the inherited ones
68 void Set(unsigned char red,
69 unsigned char green,
70 unsigned char blue,
71 unsigned char alpha = wxALPHA_OPAQUE)
72 { wxColourBase::Set(red, green, blue, alpha); }
73
74 bool Set(const wxChar *str)
75 { return wxColourBase::Set(str); }
76
77 bool Set(const wxString &str)
78 { return wxColourBase::Set(str); }
79
80 void Set(unsigned long colRGB)
81 { wxColourBase::Set(colRGB); }
82
83 protected:
84 // puts the object in an invalid, uninitialized state
85 void Init();
86
87 virtual void
88 InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
89
90 private:
91 WX_NSColor m_cocoaNSColor;
92 unsigned char m_red;
93 unsigned char m_green;
94 unsigned char m_blue;
95 unsigned char m_alpha;
96
97 DECLARE_DYNAMIC_CLASS(wxColour)
98 };
99
100 #endif // __WX_COCOA_COLOUR_H__