]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/colour.mm
New default configuration is debug/static
[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
12#import <AppKit/NSColor.h>
13
14#include "wx/gdicmn.h"
15#include "wx/colour.h"
16
7fc77f30
DE
17#include "wx/cocoa/autorelease.h"
18
683b185d
DE
19IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
20
21wxColour::wxColour ()
22: m_cocoaNSColor(NULL)
23{
24 m_red = m_blue = m_green = 0;
25}
26
27wxColour::wxColour (const wxColour& col)
28: m_cocoaNSColor(col.m_cocoaNSColor)
29, m_red(col.m_red)
30, m_green(col.m_green)
31, m_blue(col.m_blue)
32{
33 [m_cocoaNSColor retain];
34}
35
36wxColour& wxColour::operator =(const wxColour& col)
37{
38 m_cocoaNSColor = col.m_cocoaNSColor;
39 m_red = col.m_red;
40 m_green = col.m_green;
41 m_blue = col.m_blue;
42 [m_cocoaNSColor retain];
43 return *this;
44}
45
46void wxColour::InitFromName(const wxString& col)
47{
48 wxColour *the_colour = wxTheColourDatabase->FindColour (col);
49 if (the_colour)
50 {
51 *this = *the_colour;
52 }
53 else
54 {
55 [m_cocoaNSColor release];
56 m_cocoaNSColor = NULL;
57 m_red = 0;
58 m_green = 0;
59 m_blue = 0;
60 }
61}
62
63wxColour::~wxColour ()
64{
65 [m_cocoaNSColor release];
66}
67
68void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
69{
7fc77f30 70 wxAutoNSAutoreleasePool pool;
683b185d
DE
71 [m_cocoaNSColor release];
72 m_cocoaNSColor = [[NSColor colorWithCalibratedRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0] retain];
73 m_red = r;
74 m_green = g;
75 m_blue = b;
76}
77