]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/colour.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/colour.cpp
3 // Purpose: wxColour class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
14 #include "wx/gdicmn.h"
15 #include "wx/colour.h"
17 IMPLEMENT_DYNAMIC_CLASS(wxColour
, wxObject
)
21 #include "wx/mac/private.h"
23 static void wxComposeRGBColor( WXCOLORREF
* color
, int red
, int blue
, int green
) ;
24 static void wxComposeRGBColor( WXCOLORREF
* color
, int red
, int blue
, int green
)
26 RGBColor
* col
= (RGBColor
*) color
;
27 col
->red
= (red
<< 8) + red
;
28 col
->blue
= (blue
<< 8) + blue
;
29 col
->green
= (green
<< 8) + green
;
39 wxComposeRGBColor( &m_pixel
, m_red
, m_blue
, m_green
) ;
42 wxColour::wxColour (const wxColour
& col
)
46 m_green
= col
.m_green
;
48 m_isInit
= col
.m_isInit
;
50 memcpy( &m_pixel
, &col
.m_pixel
, 6 ) ;
53 wxColour
& wxColour::operator =(const wxColour
& col
)
56 m_green
= col
.m_green
;
58 m_isInit
= col
.m_isInit
;
60 memcpy( &m_pixel
, &col
.m_pixel
, 6 ) ;
65 void wxColour::InitFromName(const wxString
& name
)
67 if ( wxTheColourDatabase
)
69 wxColour col
= wxTheColourDatabase
->Find(name
);
81 wxColour::~wxColour ()
85 void wxColour::Set (unsigned char r
, unsigned char g
, unsigned char b
)
92 wxComposeRGBColor( &m_pixel
, m_red
, m_blue
, m_green
) ;
95 void wxColour::Set( const WXCOLORREF
* color
)
97 RGBColor
* col
= (RGBColor
*) color
;
98 memcpy( &m_pixel
, color
, 6 ) ;
100 m_blue
= col
->blue
>>8 ;
101 m_green
= col
->green
>>8 ;