]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/colour.cpp
rebaked after timer/socket changes
[wxWidgets.git] / src / mac / carbon / colour.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/colour.cpp
3 // Purpose: wxColour class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #include "wx/colour.h"
15
16 #ifndef WX_PRECOMP
17 #include "wx/gdicmn.h"
18 #endif
19
20 #include "wx/mac/private.h"
21
22 IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
23
24 wxColour::wxColour(const RGBColor& col)
25 {
26 FromRGBColor((WXCOLORREF *)&col);
27 }
28
29 static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green )
30 {
31 RGBColor* col = (RGBColor*) color;
32 col->red = (red << 8) + red;
33 col->blue = (blue << 8) + blue;
34 col->green = (green << 8) + green;
35 }
36
37 void wxColour::Init()
38 {
39 m_isInit = false;
40 m_red =
41 m_blue =
42 m_green = 0;
43
44 wxComposeRGBColor( &m_pixel, m_red, m_blue, m_green );
45 }
46
47 wxColour::~wxColour ()
48 {
49 }
50
51 void wxColour::InitRGBA (unsigned char r, unsigned char g, unsigned char b, unsigned char a)
52 {
53 m_red = r;
54 m_green = g;
55 m_blue = b;
56 m_alpha = a ;
57 m_isInit = true;
58
59 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green );
60 }
61
62 void wxColour::FromRGBColor( WXCOLORREF* color )
63 {
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;
69 m_alpha = 255;
70 }
71
72 wxColour& wxColour::operator=(const RGBColor& col)
73 {
74 FromRGBColor((WXCOLORREF *)&col);
75 return *this;
76 }
77
78 bool wxColour::IsOk() const
79 {
80 return m_isInit;
81 }
82