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