]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/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
)
57 m_green
= col
.m_green
;
59 m_isInit
= col
.m_isInit
;
61 memcpy( &m_pixel
, &col
.m_pixel
, 6 ) ;
64 wxColour::wxColour (const wxColour
* col
)
67 m_green
= col
->m_green
;
69 m_isInit
= col
->m_isInit
;
71 memcpy( &m_pixel
, &col
->m_pixel
, 6 ) ;
74 wxColour
& wxColour::operator =(const wxColour
& col
)
77 m_green
= col
.m_green
;
79 m_isInit
= col
.m_isInit
;
81 memcpy( &m_pixel
, &col
.m_pixel
, 6 ) ;
86 void wxColour::InitFromName(const wxString
& col
)
88 wxColour
*the_colour
= wxTheColourDatabase
->FindColour (col
);
91 m_red
= the_colour
->Red ();
92 m_green
= the_colour
->Green ();
93 m_blue
= the_colour
->Blue ();
104 wxComposeRGBColor( &m_pixel
, m_red
, m_blue
, m_green
) ;
107 wxColour::~wxColour ()
111 void wxColour::Set (unsigned char r
, unsigned char g
, unsigned char b
)
118 wxComposeRGBColor( &m_pixel
, m_red
, m_blue
, m_green
) ;
121 void wxColour::Set( const WXCOLORREF
* color
)
123 RGBColor
* col
= (RGBColor
*) color
;
124 memcpy( &m_pixel
, color
, 6 ) ;
125 m_red
= col
->red
>>8 ;
126 m_blue
= col
->blue
>>8 ;
127 m_green
= col
->green
>>8 ;