]> git.saurik.com Git - wxWidgets.git/blob - src/msw/colour.cpp
Changes to allow Cygwin to compile in non-PCH mode
[wxWidgets.git] / src / msw / colour.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: colour.cpp
3 // Purpose: wxColour class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "colour.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #include "wx/gdicmn.h"
24
25 #include <string.h>
26 #include <windows.h>
27
28 #if !USE_SHARED_LIBRARY
29 IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
30 #endif
31
32 // Colour
33
34 wxColour::wxColour ()
35 {
36 m_isInit = FALSE;
37 m_pixel = 0;
38 m_red = m_blue = m_green = 0;
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 m_pixel = PALETTERGB (m_red, m_green, m_blue);
48 }
49
50 wxColour::wxColour (const wxColour& col)
51 {
52 m_red = col.m_red;
53 m_green = col.m_green;
54 m_blue = col.m_blue;
55 m_isInit = col.m_isInit;
56 m_pixel = col.m_pixel;
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 m_pixel = col.m_pixel;
66 return *this;
67 }
68
69 void wxColour::InitFromName(const wxString& col)
70 {
71 wxColour *the_colour = wxTheColourDatabase->FindColour (col);
72 if (the_colour)
73 {
74 m_red = the_colour->Red ();
75 m_green = the_colour->Green ();
76 m_blue = the_colour->Blue ();
77 m_isInit = TRUE;
78 }
79 else
80 {
81 m_red = 0;
82 m_green = 0;
83 m_blue = 0;
84 m_isInit = FALSE;
85 }
86 m_pixel = PALETTERGB (m_red, m_green, m_blue);
87 }
88
89 wxColour::~wxColour()
90 {
91 }
92
93 void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
94 {
95 m_red = r;
96 m_green = g;
97 m_blue = b;
98 m_isInit = TRUE;
99 m_pixel = PALETTERGB (m_red, m_green, m_blue);
100 }
101
102 // Obsolete
103 #if WXWIN_COMPATIBILITY
104 void wxColour::Get (unsigned char *r, unsigned char *g, unsigned char *b) const
105 {
106 *r = m_red;
107 *g = m_green;
108 *b = m_blue;
109 }
110 #endif
111