]>
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 #if !USE_SHARED_LIBRARY
22 IMPLEMENT_DYNAMIC_CLASS(wxColour
, wxObject
)
27 #include "wx/mac/private.h"
29 static void wxComposeRGBColor( WXCOLORREF
* color
, int red
, int blue
, int green
) ;
30 static void wxComposeRGBColor( WXCOLORREF
* color
, int red
, int blue
, int green
)
32 RGBColor
* col
= (RGBColor
*) color
;
33 col
->red
= (red
<< 8) + red
;
34 col
->blue
= (blue
<< 8) + blue
;
35 col
->green
= (green
<< 8) + green
;
45 wxComposeRGBColor( &m_pixel
, m_red
, m_blue
, m_green
) ;
48 wxColour::wxColour (const wxColour
& col
)
52 m_green
= col
.m_green
;
54 m_isInit
= col
.m_isInit
;
56 memcpy( &m_pixel
, &col
.m_pixel
, 6 ) ;
59 wxColour
& wxColour::operator =(const wxColour
& col
)
62 m_green
= col
.m_green
;
64 m_isInit
= col
.m_isInit
;
66 memcpy( &m_pixel
, &col
.m_pixel
, 6 ) ;
71 void wxColour::InitFromName(const wxString
& name
)
73 if ( wxTheColourDatabase
)
75 wxColour col
= wxTheColourDatabase
->Find(name
);
87 wxColour::~wxColour ()
91 void wxColour::Set (unsigned char r
, unsigned char g
, unsigned char b
)
98 wxComposeRGBColor( &m_pixel
, m_red
, m_blue
, m_green
) ;
101 void wxColour::Set( const WXCOLORREF
* color
)
103 RGBColor
* col
= (RGBColor
*) color
;
104 memcpy( &m_pixel
, color
, 6 ) ;
105 m_red
= col
->red
>>8 ;
106 m_blue
= col
->blue
>>8 ;
107 m_green
= col
->green
>>8 ;