]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/colour.cpp
Fix STL compilation (note: this is not the correct fix, but since
[wxWidgets.git] / src / mac / carbon / colour.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: colour.cpp
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
65571936 9// Licence: wxWindows licence
e9576ca5
SC
10/////////////////////////////////////////////////////////////////////////////
11
a8e9860d 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
e9576ca5
SC
13#pragma implementation "colour.h"
14#endif
15
a8e9860d
SC
16#include "wx/wxprec.h"
17
e9576ca5
SC
18#include "wx/gdicmn.h"
19#include "wx/colour.h"
20
2f1ae414 21#if !USE_SHARED_LIBRARY
e9576ca5 22IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
2f1ae414 23#endif
e9576ca5
SC
24
25// Colour
26
76a5e5d2
SC
27#include "wx/mac/private.h"
28
29static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) ;
aad6765c 30static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green )
519cb848 31{
76a5e5d2 32 RGBColor* col = (RGBColor*) color ;
e40298d5
JS
33 col->red = (red << 8) + red;
34 col->blue = (blue << 8) + blue;
35 col->green = (green << 8) + green;
519cb848
SC
36}
37
564a150b 38void wxColour::Init()
e9576ca5 39{
aad6765c 40 m_isInit = false;
564a150b
VZ
41 m_red =
42 m_blue =
43 m_green = 0;
aad6765c 44
e40298d5 45 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
e9576ca5
SC
46}
47
e9576ca5 48wxColour::wxColour (const wxColour& col)
d84afea9 49 : wxObject()
e9576ca5
SC
50{
51 m_red = col.m_red;
52 m_green = col.m_green;
53 m_blue = col.m_blue;
54 m_isInit = col.m_isInit;
519cb848 55
76a5e5d2 56 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
519cb848
SC
57}
58
e9576ca5
SC
59wxColour& wxColour::operator =(const wxColour& col)
60{
e40298d5
JS
61 m_red = col.m_red;
62 m_green = col.m_green;
63 m_blue = col.m_blue;
64 m_isInit = col.m_isInit;
aad6765c 65
e40298d5 66 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
aad6765c 67
e40298d5 68 return *this;
e9576ca5
SC
69}
70
564a150b 71void wxColour::InitFromName(const wxString& name)
e9576ca5 72{
aad6765c 73 if ( wxTheColourDatabase )
e9576ca5 74 {
aad6765c
JS
75 wxColour col = wxTheColourDatabase->Find(name);
76 if ( col.Ok() )
77 {
78 *this = col;
79 return;
80 }
e9576ca5 81 }
aad6765c
JS
82
83 // leave invalid
84 Init();
e9576ca5
SC
85}
86
87wxColour::~wxColour ()
88{
89}
90
91void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
92{
93 m_red = r;
94 m_green = g;
95 m_blue = b;
aad6765c 96 m_isInit = true;
519cb848 97
e40298d5 98 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
e9576ca5 99}
76a5e5d2
SC
100
101void wxColour::Set( const WXCOLORREF* color )
aad6765c 102{
76a5e5d2
SC
103 RGBColor* col = (RGBColor*) color ;
104 memcpy( &m_pixel , color , 6 ) ;
105 m_red = col->red>>8 ;
106 m_blue = col->blue>>8 ;
107 m_green = col->green>>8 ;
d84afea9 108}