]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/cocoa/colour.h
CanAcceptFocus() now returns true if either the window itself or one of its children...
[wxWidgets.git] / include / wx / cocoa / colour.h
... / ...
CommitLineData
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
22class WXDLLEXPORT wxColour : public wxColourBase
23{
24public:
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
40 // initialization using existing NSColor
41 wxColour( WX_NSColor aColor );
42
43
44 // copy ctors and assignment operators
45 wxColour( const wxColour& col );
46 wxColour& operator = ( const wxColour& col );
47
48 virtual ~wxColour();
49
50 // accessors
51 bool Ok() const { return IsOk(); }
52 bool IsOk() const { return m_cocoaNSColor; }
53 WX_NSColor GetNSColor() { return m_cocoaNSColor; }
54
55 unsigned char Red() const { return m_red; }
56 unsigned char Green() const { return m_green; }
57 unsigned char Blue() const { return m_blue; }
58 unsigned char Alpha() const { return m_alpha; }
59
60 // comparison
61 bool operator == (const wxColour& colour) const
62 {
63 return m_cocoaNSColor == colour.m_cocoaNSColor ||
64 (m_red == colour.m_red &&
65 m_green == colour.m_green &&
66 m_blue == colour.m_blue &&
67 m_alpha == colour.m_alpha);
68 }
69 bool operator != (const wxColour& colour) const
70 { return !(*this == colour); }
71
72 // Set() functions
73 void Set( WX_NSColor aColor );
74
75 // reroute the inherited ones
76 void Set(unsigned char red,
77 unsigned char green,
78 unsigned char blue,
79 unsigned char alpha = wxALPHA_OPAQUE)
80 { wxColourBase::Set(red, green, blue, alpha); }
81
82 bool Set(const wxString &str)
83 { return wxColourBase::Set(str); }
84
85 void Set(unsigned long colRGB)
86 { wxColourBase::Set(colRGB); }
87
88protected:
89 // puts the object in an invalid, uninitialized state
90 void Init();
91
92 virtual void
93 InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
94
95private:
96 WX_NSColor m_cocoaNSColor;
97 unsigned char m_red;
98 unsigned char m_green;
99 unsigned char m_blue;
100 unsigned char m_alpha;
101
102 DECLARE_DYNAMIC_CLASS(wxColour)
103};
104
105#endif // __WX_COCOA_COLOUR_H__