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 ChannelType Red() const wxOVERRIDE;
33     virtual ChannelType Green() const wxOVERRIDE;
34     virtual ChannelType Blue() const wxOVERRIDE;
35     virtual ChannelType Alpha() const wxOVERRIDE;
36 
37     virtual bool IsSolid() const wxOVERRIDE;
38 
39     // comparison
40     bool operator == (const wxColour& colour) const;
41     bool operator != (const wxColour& colour) const { return !(*this == colour); }
42 
43     // CoreGraphics CGColor
44     // --------------------
45 
46     // This ctor does take ownership of the color.
47     wxColour( CGColorRef col );
48 
49     // don't take ownership of the returned value
50     CGColorRef GetCGColor() const;
51 
52     // do take ownership of the returned value
CreateCGColor()53     CGColorRef CreateCGColor() const { return wxCFRetain(GetCGColor()); }
54 
55 #if wxOSX_USE_COCOA_OR_CARBON
56     // Quickdraw RGBColor
57     // ------------------
58     wxColour(const RGBColor& col);
59     void GetRGBColor( RGBColor *col ) const;
60 #endif
61 
62 #if wxOSX_USE_COCOA
63     // NSColor Cocoa
64     // -------------
65 
66     // This ctor does not take ownership of the color.
67     explicit wxColour(WX_NSColor color);
68     WX_NSColor OSXGetNSColor() const;
69     WX_NSImage OSXGetNSPatternImage() const;
70 #endif
71 
72 protected :
73     virtual void
74     InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) wxOVERRIDE;
75 
76     virtual wxGDIRefData *CreateGDIRefData() const wxOVERRIDE;
77     virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const wxOVERRIDE;
78 
79 private:
80 
81     wxDECLARE_DYNAMIC_CLASS(wxColour);
82 };
83 
84 class wxColourRefData : public wxGDIRefData
85 {
86 public:
wxColourRefData()87     wxColourRefData() {}
~wxColourRefData()88     virtual ~wxColourRefData() {}
89 
90     virtual CGFloat Red() const = 0;
91     virtual CGFloat Green() const = 0;
92     virtual CGFloat Blue() const = 0;
93     virtual CGFloat Alpha() const = 0;
94 
IsSolid()95     virtual bool IsSolid() const
96         { return true; }
97 
98     virtual CGColorRef GetCGColor() const = 0;
99 
100     virtual wxColourRefData* Clone() const = 0;
101 
102 #if wxOSX_USE_COCOA
103     virtual WX_NSColor GetNSColor() const;
104     virtual WX_NSImage GetNSPatternImage() const;
105 #endif
106 };
107 
108 #endif
109   // _WX_COLOUR_H_
110