]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/colour.cpp
export statement added
[wxWidgets.git] / src / mac / carbon / colour.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: colour.cpp
3// Purpose: wxColour class
4// Author: AUTHOR
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) AUTHOR
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "colour.h"
14#endif
15
16#include "wx/gdicmn.h"
17#include "wx/colour.h"
18
2f1ae414 19#if !USE_SHARED_LIBRARY
e9576ca5 20IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
2f1ae414 21#endif
e9576ca5
SC
22
23// Colour
24
76a5e5d2
SC
25#include "wx/mac/private.h"
26
27static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) ;
28static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green )
519cb848 29{
76a5e5d2 30 RGBColor* col = (RGBColor*) color ;
519cb848
SC
31 col->red = (red << 8) + red;
32 col->blue = (blue << 8) + blue;
33 col->green = (green << 8) + green;
34}
35
e9576ca5
SC
36wxColour::wxColour ()
37{
519cb848
SC
38 m_isInit = FALSE;
39 m_red = m_blue = m_green = 0;
40
41 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
e9576ca5
SC
42}
43
44wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b)
45{
46 m_red = r;
47 m_green = g;
48 m_blue = b;
49 m_isInit = TRUE;
519cb848
SC
50
51 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
e9576ca5
SC
52}
53
54wxColour::wxColour (const wxColour& col)
55{
56 m_red = col.m_red;
57 m_green = col.m_green;
58 m_blue = col.m_blue;
59 m_isInit = col.m_isInit;
519cb848 60
76a5e5d2 61 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
519cb848
SC
62}
63
64wxColour::wxColour (const wxColour* col)
65{
66 m_red = col->m_red;
67 m_green = col->m_green;
68 m_blue = col->m_blue;
69 m_isInit = col->m_isInit;
70
76a5e5d2 71 memcpy( &m_pixel , &col->m_pixel , 6 ) ;
e9576ca5
SC
72}
73
74wxColour& wxColour::operator =(const wxColour& col)
75{
76 m_red = col.m_red;
77 m_green = col.m_green;
78 m_blue = col.m_blue;
79 m_isInit = col.m_isInit;
519cb848 80
76a5e5d2 81 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
519cb848 82
e9576ca5
SC
83 return *this;
84}
85
86void wxColour::InitFromName(const wxString& col)
87{
88 wxColour *the_colour = wxTheColourDatabase->FindColour (col);
89 if (the_colour)
90 {
91 m_red = the_colour->Red ();
92 m_green = the_colour->Green ();
93 m_blue = the_colour->Blue ();
94 m_isInit = TRUE;
95 }
96 else
97 {
98 m_red = 0;
99 m_green = 0;
100 m_blue = 0;
101 m_isInit = FALSE;
102 }
519cb848
SC
103
104 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
e9576ca5
SC
105}
106
107wxColour::~wxColour ()
108{
109}
110
111void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
112{
113 m_red = r;
114 m_green = g;
115 m_blue = b;
116 m_isInit = TRUE;
519cb848
SC
117
118 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
e9576ca5 119}
76a5e5d2
SC
120
121void wxColour::Set( const WXCOLORREF* color )
122{
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 ;
128}