]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/colour.cpp
wxMac Unicode support
[wxWidgets.git] / src / mac / carbon / colour.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: colour.cpp
3// Purpose: wxColour class
a31a5f85 4// Author: Stefan Csomor
e9576ca5 5// Modified by:
a31a5f85 6// Created: 1998-01-01
e9576ca5 7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) Stefan Csomor
e40298d5 9// Licence: wxWindows licence
e9576ca5
SC
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 ;
e40298d5
JS
31 col->red = (red << 8) + red;
32 col->blue = (blue << 8) + blue;
33 col->green = (green << 8) + green;
519cb848
SC
34}
35
e9576ca5
SC
36wxColour::wxColour ()
37{
e40298d5
JS
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 50
e40298d5 51 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
e9576ca5
SC
52}
53
54wxColour::wxColour (const wxColour& col)
d84afea9 55 : wxObject()
e9576ca5
SC
56{
57 m_red = col.m_red;
58 m_green = col.m_green;
59 m_blue = col.m_blue;
60 m_isInit = col.m_isInit;
519cb848 61
76a5e5d2 62 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
519cb848
SC
63}
64
65wxColour::wxColour (const wxColour* col)
66{
67 m_red = col->m_red;
68 m_green = col->m_green;
69 m_blue = col->m_blue;
70 m_isInit = col->m_isInit;
71
76a5e5d2 72 memcpy( &m_pixel , &col->m_pixel , 6 ) ;
e9576ca5
SC
73}
74
75wxColour& wxColour::operator =(const wxColour& col)
76{
e40298d5
JS
77 m_red = col.m_red;
78 m_green = col.m_green;
79 m_blue = col.m_blue;
80 m_isInit = col.m_isInit;
81
82 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
83
84 return *this;
e9576ca5
SC
85}
86
87void wxColour::InitFromName(const wxString& col)
88{
89 wxColour *the_colour = wxTheColourDatabase->FindColour (col);
90 if (the_colour)
91 {
92 m_red = the_colour->Red ();
93 m_green = the_colour->Green ();
94 m_blue = the_colour->Blue ();
95 m_isInit = TRUE;
96 }
97 else
98 {
99 m_red = 0;
100 m_green = 0;
101 m_blue = 0;
102 m_isInit = FALSE;
103 }
519cb848 104
e40298d5 105 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
e9576ca5
SC
106}
107
108wxColour::~wxColour ()
109{
110}
111
112void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
113{
114 m_red = r;
115 m_green = g;
116 m_blue = b;
117 m_isInit = TRUE;
519cb848 118
e40298d5 119 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
e9576ca5 120}
76a5e5d2
SC
121
122void wxColour::Set( const WXCOLORREF* color )
123{
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 ;
d84afea9 129}