Remove all lines containing cvs/svn "$Id$" keyword.
[wxWidgets.git] / include / wx / osx / core / colour.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/core/colour.h
3 // Purpose: wxColour class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_COLOUR_H_
12 #define _WX_COLOUR_H_
13
14 #include "wx/object.h"
15 #include "wx/string.h"
16
17 #include "wx/osx/core/cfref.h"
18
19 struct RGBColor;
20
21 // Colour
22 class WXDLLIMPEXP_CORE wxColour: public wxColourBase
23 {
24 public:
25 // constructors
26 // ------------
27 DEFINE_STD_WXCOLOUR_CONSTRUCTORS
28
29 // default copy ctor and dtor are ok
30
31 // accessors
32 virtual bool IsOk() const { return m_cgColour != NULL; }
33
34 virtual WXDLLIMPEXP_INLINE_CORE ChannelType Red() const { return m_red; }
35 virtual WXDLLIMPEXP_INLINE_CORE ChannelType Green() const { return m_green; }
36 virtual WXDLLIMPEXP_INLINE_CORE ChannelType Blue() const { return m_blue; }
37 virtual WXDLLIMPEXP_INLINE_CORE ChannelType Alpha() const { return m_alpha; }
38
39 // comparison
40 bool operator == (const wxColour& colour) const;
41
42 bool operator != (const wxColour& colour) const { return !(*this == colour); }
43
44 CGColorRef GetPixel() const { return m_cgColour; }
45
46 CGColorRef GetCGColor() const { return m_cgColour; }
47 CGColorRef CreateCGColor() const { return wxCFRetain( (CGColorRef)m_cgColour ); }
48
49 #if wxOSX_USE_COCOA_OR_CARBON
50 void GetRGBColor( RGBColor *col ) const;
51 #endif
52
53 // Mac-specific ctor and assignment operator from the native colour
54 // assumes ownership of CGColorRef
55 wxColour( CGColorRef col );
56 #if wxOSX_USE_COCOA_OR_CARBON
57 wxColour(const RGBColor& col);
58 wxColour& operator=(const RGBColor& col);
59 #endif
60 #if wxOSX_USE_COCOA
61 wxColour(WX_NSColor color);
62 WX_NSColor OSXGetNSColor() const;
63 #endif
64 wxColour& operator=(CGColorRef col);
65 wxColour& operator=(const wxColour& col);
66
67 protected :
68 virtual void
69 InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a);
70 #if wxOSX_USE_COCOA_OR_CARBON
71 void InitRGBColor( const RGBColor& col );
72 #endif
73 void InitCGColorRef( CGColorRef col );
74 void InitFromComponents(const CGFloat* components, size_t numComponents );
75 private:
76 wxCFRef<CGColorRef> m_cgColour;
77
78 ChannelType m_red;
79 ChannelType m_blue;
80 ChannelType m_green;
81 ChannelType m_alpha;
82
83 DECLARE_DYNAMIC_CLASS(wxColour)
84 };
85
86 #endif
87 // _WX_COLOUR_H_