]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/colour.cpp
fix wxExecute() return code checks and removed not working code to open URLs in new...
[wxWidgets.git] / src / mac / carbon / colour.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
18
19 // Colour
20
21 #include "wx/mac/private.h"
22
23 static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) ;
24 static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green )
25 {
26 RGBColor* col = (RGBColor*) color ;
27 col->red = (red << 8) + red;
28 col->blue = (blue << 8) + blue;
29 col->green = (green << 8) + green;
30 }
31
32 void wxColour::Init()
33 {
34 m_isInit = false;
35 m_red =
36 m_blue =
37 m_green = 0;
38
39 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
40 }
41
42 wxColour::wxColour (const wxColour& col)
43 : wxObject()
44 {
45 m_red = col.m_red;
46 m_green = col.m_green;
47 m_blue = col.m_blue;
48 m_isInit = col.m_isInit;
49
50 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
51 }
52
53 wxColour& wxColour::operator =(const wxColour& col)
54 {
55 m_red = col.m_red;
56 m_green = col.m_green;
57 m_blue = col.m_blue;
58 m_isInit = col.m_isInit;
59
60 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
61
62 return *this;
63 }
64
65 void wxColour::InitFromName(const wxString& name)
66 {
67 if ( wxTheColourDatabase )
68 {
69 wxColour col = wxTheColourDatabase->Find(name);
70 if ( col.Ok() )
71 {
72 *this = col;
73 return;
74 }
75 }
76
77 // leave invalid
78 Init();
79 }
80
81 wxColour::~wxColour ()
82 {
83 }
84
85 void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
86 {
87 m_red = r;
88 m_green = g;
89 m_blue = b;
90 m_isInit = true;
91
92 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
93 }
94
95 void wxColour::Set( const WXCOLORREF* color )
96 {
97 RGBColor* col = (RGBColor*) color ;
98 memcpy( &m_pixel , color , 6 ) ;
99 m_red = col->red>>8 ;
100 m_blue = col->blue>>8 ;
101 m_green = col->green>>8 ;
102 }