]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/carbon/colour.cpp
filedata implementation streamlined
[wxWidgets.git] / src / mac / carbon / colour.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/mac/carbon/colour.cpp
3// Purpose: wxColour class
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
14#include "wx/gdicmn.h"
15#include "wx/colour.h"
16
17#include "wx/mac/private.h"
18
19IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
20
21static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green );
22static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green )
23{
24 RGBColor* col = (RGBColor*) color;
25 col->red = (red << 8) + red;
26 col->blue = (blue << 8) + blue;
27 col->green = (green << 8) + green;
28}
29
30void wxColour::Init()
31{
32 m_isInit = false;
33 m_red =
34 m_blue =
35 m_green = 0;
36
37 wxComposeRGBColor( &m_pixel, m_red, m_blue, m_green );
38}
39
40void wxColour::InitFromName(const wxString& name)
41{
42 if ( wxTheColourDatabase )
43 {
44 wxColour col = wxTheColourDatabase->Find( name );
45 if ( col.Ok() )
46 {
47 *this = col;
48 return;
49 }
50 }
51
52 // leave invalid
53 Init();
54}
55
56wxColour::~wxColour ()
57{
58}
59
60void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
61{
62 m_red = r;
63 m_green = g;
64 m_blue = b;
65 m_isInit = true;
66
67 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green );
68}
69
70void wxColour::Set( const WXCOLORREF* color )
71{
72 RGBColor* col = (RGBColor*) color;
73 memcpy( &m_pixel, color, 6 );
74 m_red = col->red >> 8;
75 m_blue = col->blue >> 8;
76 m_green = col->green >> 8;
77}