]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/colour.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxColour class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "colour.h"
16 #include "wx/wxprec.h"
18 #include "wx/gdicmn.h"
19 #include "wx/colour.h"
21 IMPLEMENT_DYNAMIC_CLASS(wxColour
, wxObject
)
25 #include "wx/mac/private.h"
27 static void wxComposeRGBColor( WXCOLORREF
* color
, int red
, int blue
, int green
) ;
28 static void wxComposeRGBColor( WXCOLORREF
* color
, int red
, int blue
, int green
)
30 RGBColor
* col
= (RGBColor
*) color
;
31 col
->red
= (red
<< 8) + red
;
32 col
->blue
= (blue
<< 8) + blue
;
33 col
->green
= (green
<< 8) + green
;
43 wxComposeRGBColor( &m_pixel
, m_red
, m_blue
, m_green
) ;
46 wxColour::wxColour (const wxColour
& col
)
50 m_green
= col
.m_green
;
52 m_isInit
= col
.m_isInit
;
54 memcpy( &m_pixel
, &col
.m_pixel
, 6 ) ;
57 wxColour
& wxColour::operator =(const wxColour
& col
)
60 m_green
= col
.m_green
;
62 m_isInit
= col
.m_isInit
;
64 memcpy( &m_pixel
, &col
.m_pixel
, 6 ) ;
69 void wxColour::InitFromName(const wxString
& name
)
71 if ( wxTheColourDatabase
)
73 wxColour col
= wxTheColourDatabase
->Find(name
);
85 wxColour::~wxColour ()
89 void wxColour::Set (unsigned char r
, unsigned char g
, unsigned char b
)
96 wxComposeRGBColor( &m_pixel
, m_red
, m_blue
, m_green
) ;
99 void wxColour::Set( const WXCOLORREF
* color
)
101 RGBColor
* col
= (RGBColor
*) color
;
102 memcpy( &m_pixel
, color
, 6 ) ;
103 m_red
= col
->red
>>8 ;
104 m_blue
= col
->blue
>>8 ;
105 m_green
= col
->green
>>8 ;