]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/colour.mm
set descent in GetTextExtend; use PANGO_PIXELS instead of dividing by PANGO_SCALE
[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
065e208e 9// Licence: wxWidgets licence
683b185d
DE
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
211436b6 25void wxColour::Init()
683b185d 26{
211436b6
VZ
27 m_cocoaNSColor = NULL;
28 m_red =
29 m_blue =
30 m_green = 0;
683b185d
DE
31}
32
33wxColour::wxColour (const wxColour& col)
34: m_cocoaNSColor(col.m_cocoaNSColor)
35, m_red(col.m_red)
36, m_green(col.m_green)
37, m_blue(col.m_blue)
38{
39 [m_cocoaNSColor retain];
40}
41
42wxColour& wxColour::operator =(const wxColour& col)
43{
44 m_cocoaNSColor = col.m_cocoaNSColor;
45 m_red = col.m_red;
46 m_green = col.m_green;
47 m_blue = col.m_blue;
48 [m_cocoaNSColor retain];
49 return *this;
50}
51
211436b6 52void wxColour::InitFromName(const wxString& name)
683b185d 53{
211436b6 54 if ( wxTheColourDatabase )
683b185d 55 {
211436b6
VZ
56 wxColour col = wxTheColourDatabase->Find(name);
57 if ( col.Ok() )
58 {
59 *this = col;
60 return;
61 }
683b185d 62 }
211436b6
VZ
63
64 // leave invalid
65 Init();
683b185d
DE
66}
67
68wxColour::~wxColour ()
69{
70 [m_cocoaNSColor release];
71}
72
73void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
74{
7fc77f30 75 wxAutoNSAutoreleasePool pool;
683b185d
DE
76 [m_cocoaNSColor release];
77 m_cocoaNSColor = [[NSColor colorWithCalibratedRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0] retain];
78 m_red = r;
79 m_green = g;
80 m_blue = b;
81}
82