]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/colour.cpp
minor reformat
[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
e9576ca5 40wxColour::wxColour (const wxColour& col)
d84afea9 41 : wxObject()
e9576ca5
SC
42{
43 m_red = col.m_red;
44 m_green = col.m_green;
45 m_blue = col.m_blue;
46 m_isInit = col.m_isInit;
519cb848 47
172da31f 48 memcpy( &m_pixel, &col.m_pixel, 6 );
519cb848
SC
49}
50
e9576ca5
SC
51wxColour& wxColour::operator =(const wxColour& col)
52{
e40298d5
JS
53 m_red = col.m_red;
54 m_green = col.m_green;
55 m_blue = col.m_blue;
56 m_isInit = col.m_isInit;
aad6765c 57
172da31f 58 memcpy( &m_pixel, &col.m_pixel, 6 );
aad6765c 59
e40298d5 60 return *this;
e9576ca5
SC
61}
62
564a150b 63void wxColour::InitFromName(const wxString& name)
e9576ca5 64{
aad6765c 65 if ( wxTheColourDatabase )
e9576ca5 66 {
172da31f 67 wxColour col = wxTheColourDatabase->Find( name );
aad6765c
JS
68 if ( col.Ok() )
69 {
70 *this = col;
71 return;
72 }
e9576ca5 73 }
aad6765c
JS
74
75 // leave invalid
76 Init();
e9576ca5
SC
77}
78
79wxColour::~wxColour ()
80{
81}
82
83void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
84{
85 m_red = r;
86 m_green = g;
87 m_blue = b;
aad6765c 88 m_isInit = true;
519cb848 89
172da31f 90 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green );
e9576ca5 91}
76a5e5d2
SC
92
93void wxColour::Set( const WXCOLORREF* color )
aad6765c 94{
172da31f
DS
95 RGBColor* col = (RGBColor*) color;
96 memcpy( &m_pixel, color, 6 );
97 m_red = col->red >> 8;
98 m_blue = col->blue >> 8;
99 m_green = col->green >> 8;
d84afea9 100}