]> git.saurik.com Git - wxWidgets.git/blob - src/msw/colour.cpp
Watcom compilation fix
[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
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 #include "wx/msw/private.h"
25
26 #include <string.h>
27
28 IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
29
30 // Colour
31
32 wxColour::wxColour ()
33 {
34 m_isInit = FALSE;
35 m_pixel = 0;
36 m_red = m_blue = m_green = 0;
37 }
38
39 wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b)
40 {
41 m_red = r;
42 m_green = g;
43 m_blue = b;
44 m_isInit = TRUE;
45 m_pixel = PALETTERGB (m_red, m_green, m_blue);
46 }
47
48 wxColour::wxColour (const wxColour& col)
49 {
50 m_red = col.m_red;
51 m_green = col.m_green;
52 m_blue = col.m_blue;
53 m_isInit = col.m_isInit;
54 m_pixel = col.m_pixel;
55 }
56
57 wxColour& wxColour::operator =(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 m_pixel = col.m_pixel;
64 return *this;
65 }
66
67 void wxColour::InitFromName(const wxString& col)
68 {
69 wxColour *the_colour = wxTheColourDatabase->FindColour (col);
70 if (the_colour)
71 {
72 m_red = the_colour->Red ();
73 m_green = the_colour->Green ();
74 m_blue = the_colour->Blue ();
75 m_isInit = TRUE;
76 }
77 else
78 {
79 m_red = 0;
80 m_green = 0;
81 m_blue = 0;
82 m_isInit = FALSE;
83 }
84 m_pixel = PALETTERGB (m_red, m_green, m_blue);
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 m_pixel = PALETTERGB (m_red, m_green, m_blue);
98 }
99
100 // Obsolete
101 #if WXWIN_COMPATIBILITY
102 void wxColour::Get (unsigned char *r, unsigned char *g, unsigned char *b) const
103 {
104 *r = m_red;
105 *g = m_green;
106 *b = m_blue;
107 }
108 #endif
109