]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/msw/colour.cpp
no message
[wxWidgets.git] / src / msw / colour.cpp
... / ...
CommitLineData
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
29IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
30#endif
31
32// Colour
33
34wxColour::wxColour (void)
35{
36 m_isInit = FALSE;
37 m_pixel = 0;
38 m_red = m_blue = m_green = 0;
39}
40
41wxColour::wxColour (const unsigned char r, const unsigned char g, const 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
50wxColour::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
59wxColour& 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
69wxColour::wxColour (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
89wxColour::~wxColour (void)
90{
91}
92
93wxColour& wxColour::operator = (const wxString& col)
94{
95 wxColour *the_colour = wxTheColourDatabase->FindColour (col);
96 if (the_colour)
97 {
98 m_red = the_colour->Red ();
99 m_green = the_colour->Green ();
100 m_blue = the_colour->Blue ();
101 m_isInit = TRUE;
102 }
103 else
104 {
105 m_red = 0;
106 m_green = 0;
107 m_blue = 0;
108 m_isInit = FALSE;
109 }
110 m_pixel = PALETTERGB (m_red, m_green, m_blue);
111 return (*this);
112}
113
114void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
115{
116 m_red = r;
117 m_green = g;
118 m_blue = b;
119 m_isInit = TRUE;
120 m_pixel = PALETTERGB (m_red, m_green, m_blue);
121}
122
123// Obsolete
124#if WXWIN_COMPATIBILITY
125void wxColour::Get (unsigned char *r, unsigned char *g, unsigned char *b) const
126{
127 *r = m_red;
128 *g = m_green;
129 *b = m_blue;
130}
131#endif
132