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