]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/colour.cpp
adding a peer pointing back to wxWindow
[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
59wxColour::wxColour (const wxColour* col)
60{
61 m_red = col->m_red;
62 m_green = col->m_green;
63 m_blue = col->m_blue;
64 m_isInit = col->m_isInit;
65
76a5e5d2 66 memcpy( &m_pixel , &col->m_pixel , 6 ) ;
e9576ca5
SC
67}
68
69wxColour& wxColour::operator =(const wxColour& col)
70{
e40298d5
JS
71 m_red = col.m_red;
72 m_green = col.m_green;
73 m_blue = col.m_blue;
74 m_isInit = col.m_isInit;
aad6765c 75
e40298d5 76 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
aad6765c 77
e40298d5 78 return *this;
e9576ca5
SC
79}
80
564a150b 81void wxColour::InitFromName(const wxString& name)
e9576ca5 82{
aad6765c 83 if ( wxTheColourDatabase )
e9576ca5 84 {
aad6765c
JS
85 wxColour col = wxTheColourDatabase->Find(name);
86 if ( col.Ok() )
87 {
88 *this = col;
89 return;
90 }
e9576ca5 91 }
aad6765c
JS
92
93 // leave invalid
94 Init();
e9576ca5
SC
95}
96
97wxColour::~wxColour ()
98{
99}
100
101void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
102{
103 m_red = r;
104 m_green = g;
105 m_blue = b;
aad6765c 106 m_isInit = true;
519cb848 107
e40298d5 108 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
e9576ca5 109}
76a5e5d2
SC
110
111void wxColour::Set( const WXCOLORREF* color )
aad6765c 112{
76a5e5d2
SC
113 RGBColor* col = (RGBColor*) color ;
114 memcpy( &m_pixel , color , 6 ) ;
115 m_red = col->red>>8 ;
116 m_blue = col->blue>>8 ;
117 m_green = col->green>>8 ;
d84afea9 118}