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