]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/colour.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxColour class
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "colour.h"
16 #include "wx/gdicmn.h"
17 #include "wx/colour.h"
19 #if !USE_SHARED_LIBRARY
20 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
;
39 m_red
= m_blue
= m_green
= 0;
41 wxComposeRGBColor( &m_pixel
, m_red
, m_blue
, m_green
) ;
44 wxColour::wxColour (unsigned char r
, unsigned char g
, unsigned char b
)
51 wxComposeRGBColor( &m_pixel
, m_red
, m_blue
, m_green
) ;
54 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 (const wxColour
* col
)
68 m_green
= col
->m_green
;
70 m_isInit
= col
->m_isInit
;
72 memcpy( &m_pixel
, &col
->m_pixel
, 6 ) ;
75 wxColour
& wxColour::operator =(const wxColour
& col
)
78 m_green
= col
.m_green
;
80 m_isInit
= col
.m_isInit
;
82 memcpy( &m_pixel
, &col
.m_pixel
, 6 ) ;
87 void wxColour::InitFromName(const wxString
& col
)
89 wxColour
*the_colour
= wxTheColourDatabase
->FindColour (col
);
92 m_red
= the_colour
->Red ();
93 m_green
= the_colour
->Green ();
94 m_blue
= the_colour
->Blue ();
105 wxComposeRGBColor( &m_pixel
, m_red
, m_blue
, m_green
) ;
108 wxColour::~wxColour ()
112 void wxColour::Set (unsigned char r
, unsigned char g
, unsigned char b
)
119 wxComposeRGBColor( &m_pixel
, m_red
, m_blue
, m_green
) ;
122 void wxColour::Set( const WXCOLORREF
* color
)
124 RGBColor
* col
= (RGBColor
*) color
;
125 memcpy( &m_pixel
, color
, 6 ) ;
126 m_red
= col
->red
>>8 ;
127 m_blue
= col
->blue
>>8 ;
128 m_green
= col
->green
>>8 ;