]> git.saurik.com Git - wxWidgets.git/blame - src/msw/colour.cpp
unicode and linkage corrections
[wxWidgets.git] / src / msw / colour.cpp
CommitLineData
2bda0e17
KB
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$
6c9a19aa 8// Copyright: (c) Julian Smart
2bda0e17
KB
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
14f355c2 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
2bda0e17
KB
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"
8cb172b4 24#include "wx/msw/private.h"
2bda0e17
KB
25
26#include <string.h>
2bda0e17 27
066f1b7a 28#if wxUSE_EXTENDED_RTTI
067e9be6
SC
29
30/*
31
32template<> void wxStringReadValue(const wxString &s , wxColour &data )
33{
34 // copied from VS xrc
35 unsigned long tmp = 0;
36
37 if (s.Length() != 7 || s[0u] != wxT('#') ||
38 wxSscanf(s.c_str(), wxT("#%lX"), &tmp) != 1)
39 {
40 wxLogError(_("String To Colour : Incorrect colour specification : %s"),
41 s.c_str() );
42 data = wxNullColour;
43 }
44 else
45 {
46 data = wxColour((unsigned char) ((tmp & 0xFF0000) >> 16) ,
47 (unsigned char) ((tmp & 0x00FF00) >> 8),
48 (unsigned char) ((tmp & 0x0000FF)));
49 }
50}
51
52template<> void wxStringWriteValue(wxString &s , const wxColour &data )
53{
54 s = wxString::Format("#%2X%2X%2X", data.Red() , data.Green() , data.Blue() ) ;
55}
56
57WX_CUSTOM_TYPE_INFO(wxColour)
58
59*/
60
066f1b7a
SC
61IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( wxColour , wxObject , "wx/colour.h" )
62
63WX_BEGIN_PROPERTIES_TABLE(wxColour)
067e9be6
SC
64 WX_READONLY_PROPERTY( Red, unsigned char , Red , 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
65 WX_READONLY_PROPERTY( Green, unsigned char , Green , 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
66 WX_READONLY_PROPERTY( Blue, unsigned char , Blue , 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
066f1b7a
SC
67WX_END_PROPERTIES_TABLE()
68
69WX_CONSTRUCTOR_3( wxColour , unsigned char , Red , unsigned char , Green , unsigned char , Blue )
70
71WX_BEGIN_HANDLERS_TABLE(wxColour)
72WX_END_HANDLERS_TABLE()
73#else
2bda0e17 74IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
066f1b7a 75#endif
2bda0e17
KB
76
77// Colour
78
68dda785 79wxColour::wxColour ()
2bda0e17
KB
80{
81 m_isInit = FALSE;
82 m_pixel = 0;
83 m_red = m_blue = m_green = 0;
84}
85
e4a81a2e 86wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b)
2bda0e17
KB
87{
88 m_red = r;
89 m_green = g;
90 m_blue = b;
91 m_isInit = TRUE;
92 m_pixel = PALETTERGB (m_red, m_green, m_blue);
93}
94
95wxColour::wxColour (const wxColour& col)
96{
97 m_red = col.m_red;
98 m_green = col.m_green;
99 m_blue = col.m_blue;
100 m_isInit = col.m_isInit;
101 m_pixel = col.m_pixel;
102}
103
104wxColour& wxColour::operator =(const wxColour& col)
105{
106 m_red = col.m_red;
107 m_green = col.m_green;
108 m_blue = col.m_blue;
109 m_isInit = col.m_isInit;
110 m_pixel = col.m_pixel;
111 return *this;
112}
113
68dda785 114void wxColour::InitFromName(const wxString& col)
2bda0e17
KB
115{
116 wxColour *the_colour = wxTheColourDatabase->FindColour (col);
117 if (the_colour)
118 {
119 m_red = the_colour->Red ();
120 m_green = the_colour->Green ();
121 m_blue = the_colour->Blue ();
122 m_isInit = TRUE;
123 }
124 else
125 {
126 m_red = 0;
127 m_green = 0;
128 m_blue = 0;
129 m_isInit = FALSE;
130 }
131 m_pixel = PALETTERGB (m_red, m_green, m_blue);
132}
133
68dda785 134wxColour::~wxColour()
2bda0e17
KB
135{
136}
137
2bda0e17
KB
138void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
139{
140 m_red = r;
141 m_green = g;
142 m_blue = b;
143 m_isInit = TRUE;
144 m_pixel = PALETTERGB (m_red, m_green, m_blue);
145}