]>
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 (const wxColour
* col
)
62 m_green
= col
->m_green
;
64 m_isInit
= col
->m_isInit
;
66 memcpy( &m_pixel
, &col
->m_pixel
, 6 ) ;
69 wxColour
& wxColour::operator =(const wxColour
& col
)
72 m_green
= col
.m_green
;
74 m_isInit
= col
.m_isInit
;
76 memcpy( &m_pixel
, &col
.m_pixel
, 6 ) ;
81 void wxColour::InitFromName(const wxString
& name
)
83 if ( wxTheColourDatabase
)
85 wxColour col
= wxTheColourDatabase
->Find(name
);
97 wxColour::~wxColour ()
101 void wxColour::Set (unsigned char r
, unsigned char g
, unsigned char b
)
108 wxComposeRGBColor( &m_pixel
, m_red
, m_blue
, m_green
) ;
111 void wxColour::Set( const WXCOLORREF
* color
)
113 RGBColor
* col
= (RGBColor
*) color
;
114 memcpy( &m_pixel
, color
, 6 ) ;
115 m_red
= col
->red
>>8 ;
116 m_blue
= col
->blue
>>8 ;
117 m_green
= col
->green
>>8 ;