]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/colour.cpp
Tidied space and tabs in wxMac files
[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 #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 : wxObject()
56 {
57 m_red = col.m_red;
58 m_green = col.m_green;
59 m_blue = col.m_blue;
60 m_isInit = col.m_isInit;
61
62 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
63 }
64
65 wxColour::wxColour (const wxColour* col)
66 {
67 m_red = col->m_red;
68 m_green = col->m_green;
69 m_blue = col->m_blue;
70 m_isInit = col->m_isInit;
71
72 memcpy( &m_pixel , &col->m_pixel , 6 ) ;
73 }
74
75 wxColour& wxColour::operator =(const wxColour& col)
76 {
77 m_red = col.m_red;
78 m_green = col.m_green;
79 m_blue = col.m_blue;
80 m_isInit = col.m_isInit;
81
82 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
83
84 return *this;
85 }
86
87 void wxColour::InitFromName(const wxString& col)
88 {
89 wxColour *the_colour = wxTheColourDatabase->FindColour (col);
90 if (the_colour)
91 {
92 m_red = the_colour->Red ();
93 m_green = the_colour->Green ();
94 m_blue = the_colour->Blue ();
95 m_isInit = TRUE;
96 }
97 else
98 {
99 m_red = 0;
100 m_green = 0;
101 m_blue = 0;
102 m_isInit = FALSE;
103 }
104
105 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
106 }
107
108 wxColour::~wxColour ()
109 {
110 }
111
112 void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
113 {
114 m_red = r;
115 m_green = g;
116 m_blue = b;
117 m_isInit = TRUE;
118
119 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
120 }
121
122 void wxColour::Set( const WXCOLORREF* color )
123 {
124 RGBColor* col = (RGBColor*) color ;
125 memcpy( &m_pixel , color , 6 ) ;
126 m_red = col->red>>8 ;
127 m_blue = col->blue>>8 ;
128 m_green = col->green>>8 ;
129 }