]> git.saurik.com Git - wxWidgets.git/blob - src/msw/colour.cpp
xti additions / changes, trying to reduce dependencies
[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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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 #if wxUSE_EXTENDED_RTTI
29 IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( wxColour , wxObject , "wx/colour.h" )
30
31 WX_BEGIN_PROPERTIES_TABLE(wxColour)
32 WX_READONLY_PROPERTY( Red, unsigned char , Red , 0 )
33 WX_READONLY_PROPERTY( Green, unsigned char , Green , 0 )
34 WX_READONLY_PROPERTY( Blue, unsigned char , Blue , 0 )
35 WX_END_PROPERTIES_TABLE()
36
37 WX_CONSTRUCTOR_3( wxColour , unsigned char , Red , unsigned char , Green , unsigned char , Blue )
38
39 WX_BEGIN_HANDLERS_TABLE(wxColour)
40 WX_END_HANDLERS_TABLE()
41 #else
42 IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
43 #endif
44
45 // Colour
46
47 wxColour::wxColour ()
48 {
49 m_isInit = FALSE;
50 m_pixel = 0;
51 m_red = m_blue = m_green = 0;
52 }
53
54 wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b)
55 {
56 m_red = r;
57 m_green = g;
58 m_blue = b;
59 m_isInit = TRUE;
60 m_pixel = PALETTERGB (m_red, m_green, m_blue);
61 }
62
63 wxColour::wxColour (const wxColour& col)
64 {
65 m_red = col.m_red;
66 m_green = col.m_green;
67 m_blue = col.m_blue;
68 m_isInit = col.m_isInit;
69 m_pixel = col.m_pixel;
70 }
71
72 wxColour& wxColour::operator =(const wxColour& col)
73 {
74 m_red = col.m_red;
75 m_green = col.m_green;
76 m_blue = col.m_blue;
77 m_isInit = col.m_isInit;
78 m_pixel = col.m_pixel;
79 return *this;
80 }
81
82 void wxColour::InitFromName(const wxString& col)
83 {
84 wxColour *the_colour = wxTheColourDatabase->FindColour (col);
85 if (the_colour)
86 {
87 m_red = the_colour->Red ();
88 m_green = the_colour->Green ();
89 m_blue = the_colour->Blue ();
90 m_isInit = TRUE;
91 }
92 else
93 {
94 m_red = 0;
95 m_green = 0;
96 m_blue = 0;
97 m_isInit = FALSE;
98 }
99 m_pixel = PALETTERGB (m_red, m_green, m_blue);
100 }
101
102 wxColour::~wxColour()
103 {
104 }
105
106 void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
107 {
108 m_red = r;
109 m_green = g;
110 m_blue = b;
111 m_isInit = TRUE;
112 m_pixel = PALETTERGB (m_red, m_green, m_blue);
113 }