]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/colour.mm
remove us from the parents children list in Destroy()
[wxWidgets.git] / src / cocoa / colour.mm
CommitLineData
683b185d
DE
1/////////////////////////////////////////////////////////////////////////////
2// Name: colour.mm
3// Purpose: wxColour class
4// Author: David Elliott
5// Modified by:
6// Created: 2003/06/17
7// RCS-ID: $Id$
8// Copyright: (c) 2003 David Elliott
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
449c5673
DE
12#include "wx/wxprec.h"
13#ifndef WX_PRECOMP
14#endif //WX_PRECOMP
683b185d
DE
15
16#include "wx/gdicmn.h"
17#include "wx/colour.h"
18
7fc77f30
DE
19#include "wx/cocoa/autorelease.h"
20
449c5673
DE
21#import <AppKit/NSColor.h>
22
683b185d
DE
23IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
24
25wxColour::wxColour ()
26: m_cocoaNSColor(NULL)
27{
28 m_red = m_blue = m_green = 0;
29}
30
31wxColour::wxColour (const wxColour& col)
32: m_cocoaNSColor(col.m_cocoaNSColor)
33, m_red(col.m_red)
34, m_green(col.m_green)
35, m_blue(col.m_blue)
36{
37 [m_cocoaNSColor retain];
38}
39
40wxColour& wxColour::operator =(const wxColour& col)
41{
42 m_cocoaNSColor = col.m_cocoaNSColor;
43 m_red = col.m_red;
44 m_green = col.m_green;
45 m_blue = col.m_blue;
46 [m_cocoaNSColor retain];
47 return *this;
48}
49
50void wxColour::InitFromName(const wxString& col)
51{
52 wxColour *the_colour = wxTheColourDatabase->FindColour (col);
53 if (the_colour)
54 {
55 *this = *the_colour;
56 }
57 else
58 {
59 [m_cocoaNSColor release];
60 m_cocoaNSColor = NULL;
61 m_red = 0;
62 m_green = 0;
63 m_blue = 0;
64 }
65}
66
67wxColour::~wxColour ()
68{
69 [m_cocoaNSColor release];
70}
71
72void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
73{
7fc77f30 74 wxAutoNSAutoreleasePool pool;
683b185d
DE
75 [m_cocoaNSColor release];
76 m_cocoaNSColor = [[NSColor colorWithCalibratedRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0] retain];
77 m_red = r;
78 m_green = g;
79 m_blue = b;
80}
81