]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/colour.cpp
10.2 additions for non compositing
[wxWidgets.git] / src / mac / carbon / colour.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "colour.h"
14 #endif
15
16 #include "wx/wxprec.h"
17
18 #include "wx/gdicmn.h"
19 #include "wx/colour.h"
20
21 #if !USE_SHARED_LIBRARY
22 IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
23 #endif
24
25 // Colour
26
27 #include "wx/mac/private.h"
28
29 static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) ;
30 static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green )
31 {
32 RGBColor* col = (RGBColor*) color ;
33 col->red = (red << 8) + red;
34 col->blue = (blue << 8) + blue;
35 col->green = (green << 8) + green;
36 }
37
38 void wxColour::Init()
39 {
40 m_isInit = false;
41 m_red =
42 m_blue =
43 m_green = 0;
44
45 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
46 }
47
48 wxColour::wxColour (const wxColour& col)
49 : wxObject()
50 {
51 m_red = col.m_red;
52 m_green = col.m_green;
53 m_blue = col.m_blue;
54 m_isInit = col.m_isInit;
55
56 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
57 }
58
59 wxColour::wxColour (const wxColour* col)
60 {
61 m_red = col->m_red;
62 m_green = col->m_green;
63 m_blue = col->m_blue;
64 m_isInit = col->m_isInit;
65
66 memcpy( &m_pixel , &col->m_pixel , 6 ) ;
67 }
68
69 wxColour& wxColour::operator =(const wxColour& col)
70 {
71 m_red = col.m_red;
72 m_green = col.m_green;
73 m_blue = col.m_blue;
74 m_isInit = col.m_isInit;
75
76 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
77
78 return *this;
79 }
80
81 void wxColour::InitFromName(const wxString& name)
82 {
83 if ( wxTheColourDatabase )
84 {
85 wxColour col = wxTheColourDatabase->Find(name);
86 if ( col.Ok() )
87 {
88 *this = col;
89 return;
90 }
91 }
92
93 // leave invalid
94 Init();
95 }
96
97 wxColour::~wxColour ()
98 {
99 }
100
101 void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
102 {
103 m_red = r;
104 m_green = g;
105 m_blue = b;
106 m_isInit = true;
107
108 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
109 }
110
111 void wxColour::Set( const WXCOLORREF* color )
112 {
113 RGBColor* col = (RGBColor*) color ;
114 memcpy( &m_pixel , color , 6 ) ;
115 m_red = col->red>>8 ;
116 m_blue = col->blue>>8 ;
117 m_green = col->green>>8 ;
118 }