]> git.saurik.com Git - wxWidgets.git/blame - src/osx/cocoa/colour.mm
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / src / osx / cocoa / colour.mm
CommitLineData
b478f242
KO
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
b478f242
KO
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
b478f242
KO
21wxColour::wxColour(WX_NSColor col)
22{
23 size_t noComp = [col numberOfComponents];
3721dc6e 24
df7d93f6
VZ
25 CGFloat components[4];
26 CGFloat *p;
27 if ( noComp < 1 || noComp > WXSIZEOF(components) )
b478f242
KO
28 {
29 // TODO verify whether we really are on a RGB color space
30 m_alpha = wxALPHA_OPAQUE;
31 [col getComponents: components];
df7d93f6 32 p = components;
b478f242 33 }
df7d93f6
VZ
34 else // Unsupported colour format.
35 {
36 p = NULL;
37 }
38
39 InitFromComponents(components, noComp);
b478f242 40}
19b40986 41
83586c2a 42WX_NSColor wxColour::OSXGetNSColor() const
19b40986 43{
2331e2ce 44 return [NSColor colorWithCalibratedRed:m_red / 255.0 green:m_green / 255.0 blue:m_blue / 255.0 alpha:m_alpha / 255.0];
19b40986 45}