]> git.saurik.com Git - wxWidgets.git/blob - src/msw/colour.cpp
1. fixed compilation after wxList::compatibility_iterator changes
[wxWidgets.git] / src / msw / colour.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/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 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #include "wx/gdicmn.h"
20 #include "wx/msw/private.h"
21 #include "wx/colour.h"
22
23 #include <string.h>
24
25 #if wxUSE_EXTENDED_RTTI
26
27 template<> void wxStringReadValue(const wxString &s , wxColour &data )
28 {
29 // copied from VS xrc
30 unsigned long tmp = 0;
31
32 if (s.Length() != 7 || s[0u] != wxT('#')
33 || wxSscanf(s.c_str(), wxT("#%lX"), &tmp) != 1)
34 {
35 wxLogError(_("String To Colour : Incorrect colour specification : %s"),
36 s.c_str() );
37 data = wxNullColour;
38 }
39 else
40 {
41 data = wxColour((unsigned char) ((tmp & 0xFF0000) >> 16) ,
42 (unsigned char) ((tmp & 0x00FF00) >> 8),
43 (unsigned char) ((tmp & 0x0000FF)));
44 }
45 }
46
47 template<> void wxStringWriteValue(wxString &s , const wxColour &data )
48 {
49 s = wxString::Format(wxT("#%02X%02X%02X"),
50 data.Red(), data.Green(), data.Blue() );
51 }
52
53 wxTO_STRING_IMP( wxColour )
54 wxFROM_STRING_IMP( wxColour )
55
56 IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_AND_STREAMERS_XTI( wxColour , wxObject , "wx/colour.h" , &wxTO_STRING( wxColour ) , &wxFROM_STRING( wxColour ))
57
58 wxBEGIN_PROPERTIES_TABLE(wxColour)
59 wxREADONLY_PROPERTY( Red, unsigned char, Red, EMPTY_MACROVALUE , 0 /*flags*/, wxT("Helpstring"), wxT("group"))
60 wxREADONLY_PROPERTY( Green, unsigned char, Green, EMPTY_MACROVALUE , 0 /*flags*/, wxT("Helpstring"), wxT("group"))
61 wxREADONLY_PROPERTY( Blue, unsigned char, Blue, EMPTY_MACROVALUE , 0 /*flags*/, wxT("Helpstring"), wxT("group"))
62 wxEND_PROPERTIES_TABLE()
63
64 wxCONSTRUCTOR_3( wxColour, unsigned char, Red, unsigned char, Green, unsigned char, Blue )
65
66 wxBEGIN_HANDLERS_TABLE(wxColour)
67 wxEND_HANDLERS_TABLE()
68 #else
69 IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
70 #endif
71
72 // Colour
73
74 void wxColour::Init()
75 {
76 m_isInit = false;
77 m_pixel = 0;
78 m_red =
79 m_blue =
80 m_green = 0;
81 }
82
83 void wxColour::InitFromName(const wxString& name)
84 {
85 if ( wxTheColourDatabase )
86 {
87 wxColour col = wxTheColourDatabase->Find(name);
88 if ( col.Ok() )
89 {
90 *this = col;
91 return;
92 }
93 }
94
95 // leave invalid
96 Init();
97 }
98
99 wxColour::~wxColour()
100 {
101 }
102
103 void wxColour::Set(unsigned char r, unsigned char g, unsigned char b)
104 {
105 m_red = r;
106 m_green = g;
107 m_blue = b;
108 m_isInit = true;
109 m_pixel = PALETTERGB(m_red, m_green, m_blue);
110 }