]>
Commit | Line | Data |
---|---|---|
17d65207 | 1 | ///////////////////////////////////////////////////////////////////////////// |
233f5738 | 2 | // Name: wx/osx/core/colour.h |
17d65207 SC |
3 | // Purpose: wxColour class |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
17d65207 SC |
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 | |
c4021a79 | 32 | virtual bool IsOk() const { return m_cgColour != NULL; } |
17d65207 | 33 | |
74cc3ec1 SC |
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; } | |
17d65207 SC |
38 | |
39 | // comparison | |
40 | bool operator == (const wxColour& colour) const; | |
41 | ||
42 | bool operator != (const wxColour& colour) const { return !(*this == colour); } | |
43 | ||
6dd0883d | 44 | CGColorRef GetPixel() const { return m_cgColour; } |
17d65207 | 45 | |
6dd0883d SN |
46 | CGColorRef GetCGColor() const { return m_cgColour; } |
47 | CGColorRef CreateCGColor() const { return wxCFRetain( (CGColorRef)m_cgColour ); } | |
17d65207 | 48 | |
e630b0f0 | 49 | #if wxOSX_USE_COCOA_OR_CARBON |
17d65207 SC |
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 ); | |
e630b0f0 | 56 | #if wxOSX_USE_COCOA_OR_CARBON |
17d65207 SC |
57 | wxColour(const RGBColor& col); |
58 | wxColour& operator=(const RGBColor& col); | |
b478f242 KO |
59 | #endif |
60 | #if wxOSX_USE_COCOA | |
61 | wxColour(WX_NSColor color); | |
83586c2a | 62 | WX_NSColor OSXGetNSColor() const; |
17d65207 SC |
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); | |
e630b0f0 | 70 | #if wxOSX_USE_COCOA_OR_CARBON |
17d65207 SC |
71 | void InitRGBColor( const RGBColor& col ); |
72 | #endif | |
73 | void InitCGColorRef( CGColorRef col ); | |
b478f242 | 74 | void InitFromComponents(const CGFloat* components, size_t numComponents ); |
17d65207 SC |
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_ |