]> git.saurik.com Git - wxWidgets.git/blob - src/mac/classic/colour.cpp
Include wx/event.h according to precompiled headers of wx/wx.h (with other minor...
[wxWidgets.git] / src / mac / classic / colour.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/classic/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 #include "wx/gdicmn.h"
17
18 IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
19
20 // Colour
21
22 #include "wx/mac/private.h"
23
24 static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) ;
25 static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green )
26 {
27 RGBColor* col = (RGBColor*) color ;
28 col->red = (red << 8) + red;
29 col->blue = (blue << 8) + blue;
30 col->green = (green << 8) + green;
31 }
32
33 void wxColour::Init()
34 {
35 m_isInit = false;
36 m_red =
37 m_blue =
38 m_green = 0;
39
40 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
41 }
42
43 wxColour::wxColour (const wxColour& col)
44 : wxObject()
45 {
46 m_red = col.m_red;
47 m_green = col.m_green;
48 m_blue = col.m_blue;
49 m_isInit = col.m_isInit;
50
51 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
52 }
53
54 wxColour::wxColour (const wxColour* col)
55 {
56 m_red = col->m_red;
57 m_green = col->m_green;
58 m_blue = col->m_blue;
59 m_isInit = col->m_isInit;
60
61 memcpy( &m_pixel , &col->m_pixel , 6 ) ;
62 }
63
64 wxColour& wxColour::operator =(const wxColour& col)
65 {
66 m_red = col.m_red;
67 m_green = col.m_green;
68 m_blue = col.m_blue;
69 m_isInit = col.m_isInit;
70
71 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
72
73 return *this;
74 }
75
76 wxColour::~wxColour ()
77 {
78 }
79
80 void wxColour::InitWith (unsigned char r, unsigned char g, unsigned char b)
81 {
82 m_red = r;
83 m_green = g;
84 m_blue = b;
85 m_isInit = true;
86
87 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
88 }
89
90 void wxColour::Set( const WXCOLORREF* color )
91 {
92 RGBColor* col = (RGBColor*) color ;
93 memcpy( &m_pixel , color , 6 ) ;
94 m_red = col->red>>8 ;
95 m_blue = col->blue>>8 ;
96 m_green = col->green>>8 ;
97 }