]> git.saurik.com Git - wxWidgets.git/blame - src/mac/classic/colour.cpp
Include order is wxprec.h=>defs.h=>platform.h=>setup.h so remove explicit setup.h...
[wxWidgets.git] / src / mac / classic / colour.cpp
CommitLineData
2646f485 1/////////////////////////////////////////////////////////////////////////////
edc536d3 2// Name: src/mac/classic/colour.cpp
2646f485
SC
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
edc536d3 9// Licence: wxWindows licence
2646f485
SC
10/////////////////////////////////////////////////////////////////////////////
11
2646f485
SC
12#include "wx/gdicmn.h"
13#include "wx/colour.h"
14
2646f485 15IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
2646f485
SC
16
17// Colour
18
19#include "wx/mac/private.h"
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
40wxColour::wxColour (const wxColour& col)
41 : wxObject()
42{
43 m_red = col.m_red;
44 m_green = col.m_green;
45 m_blue = col.m_blue;
46 m_isInit = col.m_isInit;
47
48 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
49}
50
51wxColour::wxColour (const wxColour* col)
52{
53 m_red = col->m_red;
54 m_green = col->m_green;
55 m_blue = col->m_blue;
56 m_isInit = col->m_isInit;
57
58 memcpy( &m_pixel , &col->m_pixel , 6 ) ;
59}
60
61wxColour& wxColour::operator =(const wxColour& col)
62{
63 m_red = col.m_red;
64 m_green = col.m_green;
65 m_blue = col.m_blue;
66 m_isInit = col.m_isInit;
67
68 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
69
70 return *this;
71}
72
73void wxColour::InitFromName(const wxString& name)
74{
75 if ( wxTheColourDatabase )
76 {
77 wxColour col = wxTheColourDatabase->Find(name);
78 if ( col.Ok() )
79 {
80 *this = col;
81 return;
82 }
83 }
84
85 // leave invalid
86 Init();
87}
88
89wxColour::~wxColour ()
90{
91}
92
93void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
94{
95 m_red = r;
96 m_green = g;
97 m_blue = b;
98 m_isInit = true;
99
100 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
101}
102
103void wxColour::Set( const WXCOLORREF* color )
104{
105 RGBColor* col = (RGBColor*) color ;
106 memcpy( &m_pixel , color , 6 ) ;
107 m_red = col->red>>8 ;
108 m_blue = col->blue>>8 ;
109 m_green = col->green>>8 ;
110}