]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/colour.cpp
corrected DoDrawPoint
[wxWidgets.git] / src / mac / carbon / colour.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: colour.cpp
3 // Purpose: wxColour class
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "colour.h"
14 #endif
15
16 #include "wx/gdicmn.h"
17 #include "wx/colour.h"
18
19 #if !USE_SHARED_LIBRARY
20 IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
21 #endif
22
23 // Colour
24
25 #include "wx/mac/private.h"
26
27 static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) ;
28 static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green )
29 {
30 RGBColor* col = (RGBColor*) color ;
31 col->red = (red << 8) + red;
32 col->blue = (blue << 8) + blue;
33 col->green = (green << 8) + green;
34 }
35
36 wxColour::wxColour ()
37 {
38 m_isInit = FALSE;
39 m_red = m_blue = m_green = 0;
40
41 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
42 }
43
44 wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b)
45 {
46 m_red = r;
47 m_green = g;
48 m_blue = b;
49 m_isInit = TRUE;
50
51 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
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 (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
74 wxColour& wxColour::operator =(const wxColour& col)
75 {
76 m_red = col.m_red;
77 m_green = col.m_green;
78 m_blue = col.m_blue;
79 m_isInit = col.m_isInit;
80
81 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
82
83 return *this;
84 }
85
86 void wxColour::InitFromName(const wxString& col)
87 {
88 wxColour *the_colour = wxTheColourDatabase->FindColour (col);
89 if (the_colour)
90 {
91 m_red = the_colour->Red ();
92 m_green = the_colour->Green ();
93 m_blue = the_colour->Blue ();
94 m_isInit = TRUE;
95 }
96 else
97 {
98 m_red = 0;
99 m_green = 0;
100 m_blue = 0;
101 m_isInit = FALSE;
102 }
103
104 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
105 }
106
107 wxColour::~wxColour ()
108 {
109 }
110
111 void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
112 {
113 m_red = r;
114 m_green = g;
115 m_blue = b;
116 m_isInit = TRUE;
117
118 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
119 }
120
121 void wxColour::Set( const WXCOLORREF* color )
122 {
123 RGBColor* col = (RGBColor*) color ;
124 memcpy( &m_pixel , color , 6 ) ;
125 m_red = col->red>>8 ;
126 m_blue = col->blue>>8 ;
127 m_green = col->green>>8 ;
128 }