]> git.saurik.com Git - wxWidgets.git/blob - src/mac/colour.cpp
Added wxYieldIfNeeded
[wxWidgets.git] / src / mac / colour.cpp
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
19 #if !USE_SHARED_LIBRARY
20 IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
21 #endif
22
23 // Colour
24
25 static void wxComposeRGBColor( RGBColor * col , int red, int blue, int green ) ;
26 static 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
33 wxColour::wxColour ()
34 {
35 m_isInit = FALSE;
36 m_red = m_blue = m_green = 0;
37
38 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
39 }
40
41 wxColour::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;
47
48 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
49 }
50
51 wxColour::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 m_pixel = col.m_pixel;
59 }
60
61 wxColour::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;
69 }
70
71 wxColour& 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;
77
78 m_pixel = col.m_pixel;
79
80 return *this;
81 }
82
83 void 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 }
100
101 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
102 }
103
104 wxColour::~wxColour ()
105 {
106 }
107
108 void 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;
114
115 wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
116 }