1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/core/colour.h
3 // Purpose: wxColour class
4 // Author: Stefan Csomor
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
14 #include "wx/object.h"
15 #include "wx/string.h"
17 #include "wx/osx/core/cfref.h"
22 class WXDLLIMPEXP_CORE wxColour
: public wxColourBase
27 DEFINE_STD_WXCOLOUR_CONSTRUCTORS
29 // default copy ctor and dtor are ok
32 virtual bool IsOk() const { return m_cgColour
!= NULL
; }
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
; }
40 bool operator == (const wxColour
& colour
) const;
42 bool operator != (const wxColour
& colour
) const { return !(*this == colour
); }
44 CGColorRef
GetPixel() const { return m_cgColour
; }
46 CGColorRef
GetCGColor() const { return m_cgColour
; }
47 CGColorRef
CreateCGColor() const { return wxCFRetain( (CGColorRef
)m_cgColour
); }
49 #if wxOSX_USE_COCOA_OR_CARBON
50 void GetRGBColor( RGBColor
*col
) const;
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
);
61 wxColour(WX_NSColor color
);
62 WX_NSColor
OSXGetNSColor() const;
64 wxColour
& operator=(CGColorRef col
);
65 wxColour
& operator=(const wxColour
& col
);
69 InitRGBA(ChannelType r
, ChannelType g
, ChannelType b
, ChannelType a
);
70 #if wxOSX_USE_COCOA_OR_CARBON
71 void InitRGBColor( const RGBColor
& col
);
73 void InitCGColorRef( CGColorRef col
);
74 void InitFromComponents(const CGFloat
* components
, size_t numComponents
);
76 wxCFRef
<CGColorRef
> m_cgColour
;
83 DECLARE_DYNAMIC_CLASS(wxColour
)