]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/colour.cpp
Mac compile fixes
[wxWidgets.git] / src / mac / carbon / colour.cpp
CommitLineData
e9576ca5 1/////////////////////////////////////////////////////////////////////////////
edc536d3 2// Name: src/mac/carbon/colour.cpp
e9576ca5 3// Purpose: wxColour class
a31a5f85 4// Author: Stefan Csomor
e9576ca5 5// Modified by:
a31a5f85 6// Created: 1998-01-01
e9576ca5 7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) Stefan Csomor
edc536d3 9// Licence: wxWindows licence
e9576ca5
SC
10/////////////////////////////////////////////////////////////////////////////
11
a8e9860d
SC
12#include "wx/wxprec.h"
13
e9576ca5
SC
14#include "wx/gdicmn.h"
15#include "wx/colour.h"
16
76a5e5d2
SC
17#include "wx/mac/private.h"
18
172da31f
DS
19IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
20
21static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green );
aad6765c 22static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green )
519cb848 23{
172da31f 24 RGBColor* col = (RGBColor*) color;
e40298d5
JS
25 col->red = (red << 8) + red;
26 col->blue = (blue << 8) + blue;
27 col->green = (green << 8) + green;
519cb848
SC
28}
29
564a150b 30void wxColour::Init()
e9576ca5 31{
aad6765c 32 m_isInit = false;
564a150b
VZ
33 m_red =
34 m_blue =
35 m_green = 0;
aad6765c 36
172da31f 37 wxComposeRGBColor( &m_pixel, m_red, m_blue, m_green );
e9576ca5
SC
38}
39
564a150b 40void wxColour::InitFromName(const wxString& name)
e9576ca5 41{
aad6765c 42 if ( wxTheColourDatabase )
e9576ca5 43 {
172da31f 44 wxColour col = wxTheColourDatabase->Find( name );
aad6765c
JS
45 if ( col.Ok() )
46 {
47 *this = col;
48 return;
49 }
e9576ca5 50 }
aad6765c
JS
51
52 // leave invalid
53 Init();
e9576ca5
SC
54}
55
56wxColour::~wxColour ()
57{
58}
59
60void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
61{
62 m_red = r;
63 m_green = g;
64 m_blue = b;
aad6765c 65 m_isInit = true;
519cb848 66
172da31f 67 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green );
e9576ca5 68}
76a5e5d2
SC
69
70void wxColour::Set( const WXCOLORREF* color )
aad6765c 71{
172da31f
DS
72 RGBColor* col = (RGBColor*) color;
73 memcpy( &m_pixel, color, 6 );
74 m_red = col->red >> 8;
75 m_blue = col->blue >> 8;
76 m_green = col->green >> 8;
d84afea9 77}