]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/classic/colour.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxColour class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "colour.h"
16 #include "wx/gdicmn.h"
17 #include "wx/colour.h"
19 IMPLEMENT_DYNAMIC_CLASS(wxColour
, wxObject
)
23 #include "wx/mac/private.h"
25 static void wxComposeRGBColor( WXCOLORREF
* color
, int red
, int blue
, int green
) ;
26 static void wxComposeRGBColor( WXCOLORREF
* color
, int red
, int blue
, int green
)
28 RGBColor
* col
= (RGBColor
*) color
;
29 col
->red
= (red
<< 8) + red
;
30 col
->blue
= (blue
<< 8) + blue
;
31 col
->green
= (green
<< 8) + green
;
41 wxComposeRGBColor( &m_pixel
, m_red
, m_blue
, m_green
) ;
44 wxColour::wxColour (const wxColour
& col
)
48 m_green
= col
.m_green
;
50 m_isInit
= col
.m_isInit
;
52 memcpy( &m_pixel
, &col
.m_pixel
, 6 ) ;
55 wxColour::wxColour (const wxColour
* col
)
58 m_green
= col
->m_green
;
60 m_isInit
= col
->m_isInit
;
62 memcpy( &m_pixel
, &col
->m_pixel
, 6 ) ;
65 wxColour
& wxColour::operator =(const wxColour
& col
)
68 m_green
= col
.m_green
;
70 m_isInit
= col
.m_isInit
;
72 memcpy( &m_pixel
, &col
.m_pixel
, 6 ) ;
77 void wxColour::InitFromName(const wxString
& name
)
79 if ( wxTheColourDatabase
)
81 wxColour col
= wxTheColourDatabase
->Find(name
);
93 wxColour::~wxColour ()
97 void wxColour::Set (unsigned char r
, unsigned char g
, unsigned char b
)
104 wxComposeRGBColor( &m_pixel
, m_red
, m_blue
, m_green
) ;
107 void wxColour::Set( const WXCOLORREF
* color
)
109 RGBColor
* col
= (RGBColor
*) color
;
110 memcpy( &m_pixel
, color
, 6 ) ;
111 m_red
= col
->red
>>8 ;
112 m_blue
= col
->blue
>>8 ;
113 m_green
= col
->green
>>8 ;