]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/colour.cpp
Rework wxMotif font/color inheritance so it works
[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/colour.h"
15
dd05139a
WS
16#ifndef WX_PRECOMP
17 #include "wx/gdicmn.h"
18#endif
40989e46 19
76a5e5d2
SC
20#include "wx/mac/private.h"
21
172da31f
DS
22IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
23
055de350
VZ
24wxColour::wxColour(const RGBColor& col)
25{
26 FromRGBColor((WXCOLORREF *)&col);
27}
28
aad6765c 29static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green )
519cb848 30{
172da31f 31 RGBColor* col = (RGBColor*) color;
e40298d5
JS
32 col->red = (red << 8) + red;
33 col->blue = (blue << 8) + blue;
34 col->green = (green << 8) + green;
519cb848
SC
35}
36
564a150b 37void wxColour::Init()
e9576ca5 38{
aad6765c 39 m_isInit = false;
564a150b
VZ
40 m_red =
41 m_blue =
42 m_green = 0;
aad6765c 43
172da31f 44 wxComposeRGBColor( &m_pixel, m_red, m_blue, m_green );
e9576ca5
SC
45}
46
e9576ca5
SC
47wxColour::~wxColour ()
48{
49}
50
aea95b1c 51void wxColour::InitRGBA (unsigned char r, unsigned char g, unsigned char b, unsigned char a)
e9576ca5
SC
52{
53 m_red = r;
54 m_green = g;
55 m_blue = b;
fa8bc37b 56 m_alpha = a ;
aad6765c 57 m_isInit = true;
519cb848 58
172da31f 59 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green );
e9576ca5 60}
76a5e5d2 61
d3c82d0d 62void wxColour::FromRGBColor( WXCOLORREF* color )
aad6765c 63{
172da31f
DS
64 RGBColor* col = (RGBColor*) color;
65 memcpy( &m_pixel, color, 6 );
66 m_red = col->red >> 8;
67 m_blue = col->blue >> 8;
68 m_green = col->green >> 8;
d84afea9 69}
f84a986c 70
055de350
VZ
71wxColour& wxColour::operator=(const RGBColor& col)
72{
73 FromRGBColor((WXCOLORREF *)&col);
5a1c7626 74 return *this;
055de350
VZ
75}
76
f84a986c
SC
77bool wxColour::IsOk() const
78{
79 return m_isInit;
80}
81