1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/colour.mm
3 // Purpose: Cocoa additions to wxColour class
4 // Author: Kevin Ollivier
7 // Copyright: (c) Kevin Ollivier
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #include "wx/wxprec.h"
13 #include "wx/colour.h"
16 #include "wx/gdicmn.h"
19 #include "wx/osx/private.h"
21 wxColour::wxColour(WX_NSColor col)
23 size_t noComp = [col numberOfComponents];
25 CGFloat components[4];
27 if ( noComp < 1 || noComp > WXSIZEOF(components) )
29 // TODO verify whether we really are on a RGB color space
30 m_alpha = wxALPHA_OPAQUE;
31 [col getComponents: components];
34 else // Unsupported colour format.
39 InitFromComponents(components, noComp);
42 WX_NSColor wxColour::OSXGetNSColor() const
44 return [NSColor colorWithCalibratedRed:m_red / 255.0 green:m_green / 255.0 blue:m_blue / 255.0 alpha:m_alpha / 255.0];