]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/colour.cpp
Implemented missing pure virt functions (stub functions for now).
[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 #ifdef __GNUG__
13 #pragma implementation "colour.h"
14 #endif
15
16 #include "wx/gdicmn.h"
17 #include "wx/colour.h"
18
19 #if !USE_SHARED_LIBRARY
20 IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
21 #endif
22
23 // Colour
24
25 #include "wx/mac/private.h"
26
27 static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) ;
28 static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green )
29 {
30 RGBColor* col = (RGBColor*) color ;
31 col->red = (red << 8) + red;
32 col->blue = (blue << 8) + blue;
33 col->green = (green << 8) + green;
34 }
35
36 void wxColour::Init()
37 {
38 m_isInit = FALSE;
39 m_red =
40 m_blue =
41 m_green = 0;
42
43 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
44 }
45
46 wxColour::wxColour (const wxColour& col)
47 : wxObject()
48 {
49 m_red = col.m_red;
50 m_green = col.m_green;
51 m_blue = col.m_blue;
52 m_isInit = col.m_isInit;
53
54 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
55 }
56
57 wxColour::wxColour (const wxColour* col)
58 {
59 m_red = col->m_red;
60 m_green = col->m_green;
61 m_blue = col->m_blue;
62 m_isInit = col->m_isInit;
63
64 memcpy( &m_pixel , &col->m_pixel , 6 ) ;
65 }
66
67 wxColour& wxColour::operator =(const wxColour& col)
68 {
69 m_red = col.m_red;
70 m_green = col.m_green;
71 m_blue = col.m_blue;
72 m_isInit = col.m_isInit;
73
74 memcpy( &m_pixel , &col.m_pixel , 6 ) ;
75
76 return *this;
77 }
78
79 void wxColour::InitFromName(const wxString& name)
80 {
81 wxColour col = wxTheColourDatabase->Find(name);
82 if ( col.Ok() )
83 {
84 *this = col;
85 }
86 else
87 {
88 Init();
89 }
90 }
91
92 wxColour::~wxColour ()
93 {
94 }
95
96 void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
97 {
98 m_red = r;
99 m_green = g;
100 m_blue = b;
101 m_isInit = TRUE;
102
103 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
104 }
105
106 void wxColour::Set( const WXCOLORREF* color )
107 {
108 RGBColor* col = (RGBColor*) color ;
109 memcpy( &m_pixel , color , 6 ) ;
110 m_red = col->red>>8 ;
111 m_blue = col->blue>>8 ;
112 m_green = col->green>>8 ;
113 }