1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/colour.mm
3 // Purpose: Cocoa additions to wxColour class
4 // Author: Kevin Ollivier
8 // Copyright: (c) Kevin Ollivier
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
14 #include "wx/colour.h"
17 #include "wx/gdicmn.h"
20 #include "wx/osx/private.h"
22 wxColour::wxColour(WX_NSColor col)
24 size_t noComp = [col numberOfComponents];
26 CGFloat components[4];
28 if ( noComp < 1 || noComp > WXSIZEOF(components) )
30 // TODO verify whether we really are on a RGB color space
31 m_alpha = wxALPHA_OPAQUE;
32 [col getComponents: components];
35 else // Unsupported colour format.
40 InitFromComponents(components, noComp);
43 WX_NSColor wxColour::OSXGetNSColor() const
45 return [NSColor colorWithDeviceRed:m_red / 255.0 green:m_green / 255.0 blue:m_blue / 255.0 alpha:m_alpha / 255.0];