]> git.saurik.com Git - wxWidgets.git/blame - src/mac/colour.cpp
added common regex
[wxWidgets.git] / src / mac / 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
519cb848
SC
25static void wxComposeRGBColor( RGBColor * col , int red, int blue, int green ) ;
26static void wxComposeRGBColor( RGBColor * col , int red, int blue, int green )
27{
28 col->red = (red << 8) + red;
29 col->blue = (blue << 8) + blue;
30 col->green = (green << 8) + green;
31}
32
e9576ca5
SC
33wxColour::wxColour ()
34{
519cb848
SC
35 m_isInit = FALSE;
36 m_red = m_blue = m_green = 0;
37
38 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
e9576ca5
SC
39}
40
41wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b)
42{
43 m_red = r;
44 m_green = g;
45 m_blue = b;
46 m_isInit = TRUE;
519cb848
SC
47
48 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
e9576ca5
SC
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;
519cb848 57
e9576ca5 58 m_pixel = col.m_pixel;
519cb848
SC
59}
60
61wxColour::wxColour (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 m_pixel = col->m_pixel;
e9576ca5
SC
69}
70
71wxColour& wxColour::operator =(const wxColour& col)
72{
73 m_red = col.m_red;
74 m_green = col.m_green;
75 m_blue = col.m_blue;
76 m_isInit = col.m_isInit;
519cb848 77
e9576ca5 78 m_pixel = col.m_pixel;
519cb848 79
e9576ca5
SC
80 return *this;
81}
82
83void wxColour::InitFromName(const wxString& col)
84{
85 wxColour *the_colour = wxTheColourDatabase->FindColour (col);
86 if (the_colour)
87 {
88 m_red = the_colour->Red ();
89 m_green = the_colour->Green ();
90 m_blue = the_colour->Blue ();
91 m_isInit = TRUE;
92 }
93 else
94 {
95 m_red = 0;
96 m_green = 0;
97 m_blue = 0;
98 m_isInit = FALSE;
99 }
519cb848
SC
100
101 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
e9576ca5
SC
102}
103
104wxColour::~wxColour ()
105{
106}
107
108void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
109{
110 m_red = r;
111 m_green = g;
112 m_blue = b;
113 m_isInit = TRUE;
519cb848
SC
114
115 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
e9576ca5 116}