]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/classic/colour.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/classic/colour.cpp
3 // Purpose: wxColour class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/gdicmn.h"
13 #include "wx/colour.h"
15 IMPLEMENT_DYNAMIC_CLASS(wxColour
, wxObject
)
19 #include "wx/mac/private.h"
21 static void wxComposeRGBColor( WXCOLORREF
* color
, int red
, int blue
, int green
) ;
22 static void wxComposeRGBColor( WXCOLORREF
* color
, int red
, int blue
, int green
)
24 RGBColor
* col
= (RGBColor
*) color
;
25 col
->red
= (red
<< 8) + red
;
26 col
->blue
= (blue
<< 8) + blue
;
27 col
->green
= (green
<< 8) + green
;
37 wxComposeRGBColor( &m_pixel
, m_red
, m_blue
, m_green
) ;
40 wxColour::wxColour (const wxColour
& col
)
44 m_green
= col
.m_green
;
46 m_isInit
= col
.m_isInit
;
48 memcpy( &m_pixel
, &col
.m_pixel
, 6 ) ;
51 wxColour::wxColour (const wxColour
* col
)
54 m_green
= col
->m_green
;
56 m_isInit
= col
->m_isInit
;
58 memcpy( &m_pixel
, &col
->m_pixel
, 6 ) ;
61 wxColour
& wxColour::operator =(const wxColour
& col
)
64 m_green
= col
.m_green
;
66 m_isInit
= col
.m_isInit
;
68 memcpy( &m_pixel
, &col
.m_pixel
, 6 ) ;
73 void wxColour::InitFromName(const wxString
& name
)
75 if ( wxTheColourDatabase
)
77 wxColour col
= wxTheColourDatabase
->Find(name
);
89 wxColour::~wxColour ()
93 void wxColour::Set (unsigned char r
, unsigned char g
, unsigned char b
)
100 wxComposeRGBColor( &m_pixel
, m_red
, m_blue
, m_green
) ;
103 void wxColour::Set( const WXCOLORREF
* color
)
105 RGBColor
* col
= (RGBColor
*) color
;
106 memcpy( &m_pixel
, color
, 6 ) ;
107 m_red
= col
->red
>>8 ;
108 m_blue
= col
->blue
>>8 ;
109 m_green
= col
->green
>>8 ;