]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/colour.cpp
db8be109744cd10f4d3b13b6b67db895d7ff3264
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxColour class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "colour.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
23 #include "wx/gdicmn.h"
24 #include "wx/msw/private.h"
28 #if wxUSE_EXTENDED_RTTI
30 template<> void wxStringReadValue(const wxString
&s
, wxColour
&data
)
33 unsigned long tmp
= 0;
35 if (s
.Length() != 7 || s
[0u] != wxT('#')
36 || wxSscanf(s
.c_str(), wxT("#%lX"), &tmp
) != 1)
38 wxLogError(_("String To Colour : Incorrect colour specification : %s"),
44 data
= wxColour((unsigned char) ((tmp
& 0xFF0000) >> 16) ,
45 (unsigned char) ((tmp
& 0x00FF00) >> 8),
46 (unsigned char) ((tmp
& 0x0000FF)));
50 template<> void wxStringWriteValue(wxString
&s
, const wxColour
&data
)
52 s
= wxString::Format(wxT("#%02X%02X%02X"),
53 data
.Red(), data
.Green(), data
.Blue() );
56 wxTO_STRING_IMP( wxColour
)
57 wxFROM_STRING_IMP( wxColour
)
59 IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_AND_STREAMERS_XTI( wxColour
, wxObject
, "wx/colour.h" , &wxTO_STRING( wxColour
) , &wxFROM_STRING( wxColour
))
61 wxBEGIN_PROPERTIES_TABLE(wxColour
)
62 wxREADONLY_PROPERTY( Red
, unsigned char, Red
, EMPTY_MACROVALUE
, 0 /*flags*/, wxT("Helpstring"), wxT("group"))
63 wxREADONLY_PROPERTY( Green
, unsigned char, Green
, EMPTY_MACROVALUE
, 0 /*flags*/, wxT("Helpstring"), wxT("group"))
64 wxREADONLY_PROPERTY( Blue
, unsigned char, Blue
, EMPTY_MACROVALUE
, 0 /*flags*/, wxT("Helpstring"), wxT("group"))
65 wxEND_PROPERTIES_TABLE()
67 wxCONSTRUCTOR_3( wxColour
, unsigned char, Red
, unsigned char, Green
, unsigned char, Blue
)
69 wxBEGIN_HANDLERS_TABLE(wxColour
)
70 wxEND_HANDLERS_TABLE()
72 IMPLEMENT_DYNAMIC_CLASS(wxColour
, wxObject
)
86 wxColour::wxColour(const wxColour
& col
)
92 wxColour
& wxColour::operator=(const wxColour
& col
)
95 m_green
= col
.m_green
;
97 m_isInit
= col
.m_isInit
;
98 m_pixel
= col
.m_pixel
;
102 void wxColour::InitFromName(const wxString
& name
)
104 if ( wxTheColourDatabase
)
106 wxColour col
= wxTheColourDatabase
->Find(name
);
118 wxColour::~wxColour()
122 void wxColour::Set(unsigned char r
, unsigned char g
, unsigned char b
)
128 m_pixel
= PALETTERGB(m_red
, m_green
, m_blue
);