]> git.saurik.com Git - wxWidgets.git/blob - src/osx/cocoa/colour.mm
No changes, just use wxRecursionGuard instead of manual boolean flag.
[wxWidgets.git] / src / osx / cocoa / colour.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/colour.mm
3 // Purpose: Cocoa additions to wxColour class
4 // Author: Kevin Ollivier
5 // Modified by:
6 // Created: 2009-10-31
7 // Copyright: (c) Kevin Ollivier
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #include "wx/wxprec.h"
12
13 #include "wx/colour.h"
14
15 #ifndef WX_PRECOMP
16 #include "wx/gdicmn.h"
17 #endif
18
19 #include "wx/osx/private.h"
20
21 wxColour::wxColour(WX_NSColor col)
22 {
23 size_t noComp = [col numberOfComponents];
24
25 CGFloat components[4];
26 CGFloat *p;
27 if ( noComp < 1 || noComp > WXSIZEOF(components) )
28 {
29 // TODO verify whether we really are on a RGB color space
30 m_alpha = wxALPHA_OPAQUE;
31 [col getComponents: components];
32 p = components;
33 }
34 else // Unsupported colour format.
35 {
36 p = NULL;
37 }
38
39 InitFromComponents(components, noComp);
40 }
41
42 WX_NSColor wxColour::OSXGetNSColor() const
43 {
44 return [NSColor colorWithCalibratedRed:m_red / 255.0 green:m_green / 255.0 blue:m_blue / 255.0 alpha:m_alpha / 255.0];
45 }