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)
27 m_cocoaNSColor = NULL;
33 wxColour::wxColour (const wxColour& col)
34 : m_cocoaNSColor(col.m_cocoaNSColor)
36 , m_green(col.m_green)
39 [m_cocoaNSColor retain];
42 wxColour& wxColour::operator =(const wxColour& col)
44 m_cocoaNSColor = col.m_cocoaNSColor;
46 m_green = col.m_green;
48 [m_cocoaNSColor retain];
52 void wxColour::InitFromName(const wxString& name)
54 if ( wxTheColourDatabase )
56 wxColour col = wxTheColourDatabase->Find(name);
68 wxColour::~wxColour ()
70 [m_cocoaNSColor release];
73 void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
75 wxAutoNSAutoreleasePool pool;
76 [m_cocoaNSColor release];
77 m_cocoaNSColor = [[NSColor colorWithCalibratedRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0] retain];