]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/colour.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/colour.cpp
3 // Purpose: wxColour class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
19 #include "wx/gdicmn.h"
20 #include "wx/msw/private.h"
21 #include "wx/colour.h"
25 #if wxUSE_EXTENDED_RTTI
27 template<> void wxStringReadValue(const wxString
&s
, wxColour
&data
)
30 unsigned long tmp
= 0;
32 if (s
.Length() != 7 || s
[0u] != wxT('#')
33 || wxSscanf(s
.c_str(), wxT("#%lX"), &tmp
) != 1)
35 wxLogError(_("String To Colour : Incorrect colour specification : %s"),
41 data
= wxColour((unsigned char) ((tmp
& 0xFF0000) >> 16) ,
42 (unsigned char) ((tmp
& 0x00FF00) >> 8),
43 (unsigned char) ((tmp
& 0x0000FF)));
47 template<> void wxStringWriteValue(wxString
&s
, const wxColour
&data
)
49 s
= wxString::Format(wxT("#%02X%02X%02X"),
50 data
.Red(), data
.Green(), data
.Blue() );
53 wxTO_STRING_IMP( wxColour
)
54 wxFROM_STRING_IMP( wxColour
)
56 IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_AND_STREAMERS_XTI( wxColour
, wxObject
, "wx/colour.h" , &wxTO_STRING( wxColour
) , &wxFROM_STRING( wxColour
))
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()
64 wxCONSTRUCTOR_3( wxColour
, unsigned char, Red
, unsigned char, Green
, unsigned char, Blue
)
66 wxBEGIN_HANDLERS_TABLE(wxColour
)
67 wxEND_HANDLERS_TABLE()
69 IMPLEMENT_DYNAMIC_CLASS(wxColour
, wxObject
)
83 wxColour::wxColour(const wxColour
& col
)
89 wxColour
& wxColour::operator=(const wxColour
& col
)
92 m_green
= col
.m_green
;
94 m_isInit
= col
.m_isInit
;
95 m_pixel
= col
.m_pixel
;
99 void wxColour::InitFromName(const wxString
& name
)
101 if ( wxTheColourDatabase
)
103 wxColour col
= wxTheColourDatabase
->Find(name
);
115 wxColour::~wxColour()
119 void wxColour::Set(unsigned char r
, unsigned char g
, unsigned char b
)
125 m_pixel
= PALETTERGB(m_red
, m_green
, m_blue
);