1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxColour class
4 // Author: David Elliott
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
16 #include "wx/gdicmn.h"
17 #include "wx/colour.h"
19 #include "wx/cocoa/autorelease.h"
21 #import <AppKit/NSColor.h>
23 IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
26 : m_cocoaNSColor(NULL)
28 m_red = m_blue = m_green = 0;
31 wxColour::wxColour (const wxColour& col)
32 : m_cocoaNSColor(col.m_cocoaNSColor)
34 , m_green(col.m_green)
37 [m_cocoaNSColor retain];
40 wxColour& wxColour::operator =(const wxColour& col)
42 m_cocoaNSColor = col.m_cocoaNSColor;
44 m_green = col.m_green;
46 [m_cocoaNSColor retain];
50 void wxColour::InitFromName(const wxString& col)
52 wxColour *the_colour = wxTheColourDatabase->FindColour (col);
59 [m_cocoaNSColor release];
60 m_cocoaNSColor = NULL;
67 wxColour::~wxColour ()
69 [m_cocoaNSColor release];
72 void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
74 wxAutoNSAutoreleasePool pool;
75 [m_cocoaNSColor release];
76 m_cocoaNSColor = [[NSColor colorWithCalibratedRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0] retain];