1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxColour class
4 // Author: David Elliott
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #import <AppKit/NSColor.h>
14 #include "wx/gdicmn.h"
15 #include "wx/colour.h"
17 #include "wx/cocoa/autorelease.h"
19 IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
22 : m_cocoaNSColor(NULL)
24 m_red = m_blue = m_green = 0;
27 wxColour::wxColour (const wxColour& col)
28 : m_cocoaNSColor(col.m_cocoaNSColor)
30 , m_green(col.m_green)
33 [m_cocoaNSColor retain];
36 wxColour& wxColour::operator =(const wxColour& col)
38 m_cocoaNSColor = col.m_cocoaNSColor;
40 m_green = col.m_green;
42 [m_cocoaNSColor retain];
46 void wxColour::InitFromName(const wxString& col)
48 wxColour *the_colour = wxTheColourDatabase->FindColour (col);
55 [m_cocoaNSColor release];
56 m_cocoaNSColor = NULL;
63 wxColour::~wxColour ()
65 [m_cocoaNSColor release];
68 void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
70 wxAutoNSAutoreleasePool pool;
71 [m_cocoaNSColor release];
72 m_cocoaNSColor = [[NSColor colorWithCalibratedRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0] retain];