]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/colour.h
added SetSelectionToPage/Window() to simplify code and fix more problems with passing...
[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
31 // the other standard ones: notice that we can't use
32 // DEFINE_STD_WXCOLOUR_CONSTRUCTORS here because we need to call Init() to
33 // initialize m_cocoaNSColor and the macro doesn't do it
34 wxColour( ChannelType red, ChannelType green, ChannelType blue,
35 ChannelType alpha = wxALPHA_OPAQUE )
36 { Init(); Set(red, green, blue, alpha); }
37 wxColour(unsigned long colRGB) { Init(); Set(colRGB); }
38 wxColour(const wxString &colourName) { Init(); Set(colourName); }
39 wxColour(const wxChar *colourName) { Init(); Set(colourName); }
40
41 // initialization using existing NSColor
42 wxColour( WX_NSColor aColor );
43
44
45 // copy ctors and assignment operators
46 wxColour( const wxColour& col );
47 wxColour& operator = ( const wxColour& col );
48
49 virtual ~wxColour();
50
51 // accessors
52 bool Ok() const { return IsOk(); }
53 bool IsOk() const { return m_cocoaNSColor; }
54 WX_NSColor GetNSColor() { return m_cocoaNSColor; }
55
56 unsigned char Red() const { return m_red; }
57 unsigned char Green() const { return m_green; }
58 unsigned char Blue() const { return m_blue; }
59 unsigned char Alpha() const { return m_alpha; }
60
61 // comparison
62 bool operator == (const wxColour& colour) const
63 {
64 return m_cocoaNSColor == colour.m_cocoaNSColor ||
65 (m_red == colour.m_red &&
66 m_green == colour.m_green &&
67 m_blue == colour.m_blue &&
68 m_alpha == colour.m_alpha);
69 }
70 bool operator != (const wxColour& colour) const
71 { return !(*this == colour); }
72
73 // Set() functions
74 void Set( WX_NSColor aColor );
75
76 // reroute the inherited ones
77 void Set(unsigned char red,
78 unsigned char green,
79 unsigned char blue,
80 unsigned char alpha = wxALPHA_OPAQUE)
81 { wxColourBase::Set(red, green, blue, alpha); }
82
83 bool Set(const wxChar *str)
84 { return wxColourBase::Set(str); }
85
86 bool Set(const wxString &str)
87 { return wxColourBase::Set(str); }
88
89 void Set(unsigned long colRGB)
90 { wxColourBase::Set(colRGB); }
91
92 protected:
93 // puts the object in an invalid, uninitialized state
94 void Init();
95
96 virtual void
97 InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
98
99 private:
100 WX_NSColor m_cocoaNSColor;
101 unsigned char m_red;
102 unsigned char m_green;
103 unsigned char m_blue;
104 unsigned char m_alpha;
105
106 DECLARE_DYNAMIC_CLASS(wxColour)
107 };
108
109 #endif // __WX_COCOA_COLOUR_H__