use wxColourDatabase::Find() instead of deprecated FindColour(); some minor code cleanup

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24228 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-10-18 23:20:13 +00:00
parent f9ebac93e7
commit f75aecd00f
2 changed files with 97 additions and 94 deletions

View File

@@ -70,59 +70,44 @@ IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
// Colour
wxColour::wxColour ()
void wxColour::Init()
{
m_isInit = FALSE;
m_pixel = 0;
m_red = m_blue = m_green = 0;
}
wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b)
{
m_red = r;
m_green = g;
m_blue = b;
m_isInit = TRUE;
m_pixel = PALETTERGB (m_red, m_green, m_blue);
m_isInit = FALSE;
m_pixel = 0;
m_red =
m_blue =
m_green = 0;
}
wxColour::wxColour (const wxColour& col)
{
m_red = col.m_red;
m_green = col.m_green;
m_blue = col.m_blue;
m_isInit = col.m_isInit;
m_pixel = col.m_pixel;
*this = col;
}
wxColour& wxColour::operator =(const wxColour& col)
wxColour& wxColour::operator=(const wxColour& col)
{
m_red = col.m_red;
m_green = col.m_green;
m_blue = col.m_blue;
m_isInit = col.m_isInit;
m_pixel = col.m_pixel;
return *this;
m_red = col.m_red;
m_green = col.m_green;
m_blue = col.m_blue;
m_isInit = col.m_isInit;
m_pixel = col.m_pixel;
return *this;
}
void wxColour::InitFromName(const wxString& col)
void wxColour::InitFromName(const wxString& name)
{
wxColour *the_colour = wxTheColourDatabase->FindColour (col);
if (the_colour)
if ( wxTheColourDatabase )
{
m_red = the_colour->Red ();
m_green = the_colour->Green ();
m_blue = the_colour->Blue ();
m_isInit = TRUE;
wxColour col = wxTheColourDatabase->Find(name);
if ( col.Ok() )
{
*this = col;
return;
}
}
else
{
m_red = 0;
m_green = 0;
m_blue = 0;
m_isInit = FALSE;
}
m_pixel = PALETTERGB (m_red, m_green, m_blue);
// leave invalid
Init();
}
wxColour::~wxColour()
@@ -131,9 +116,10 @@ wxColour::~wxColour()
void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
{
m_red = r;
m_green = g;
m_blue = b;
m_isInit = TRUE;
m_pixel = PALETTERGB (m_red, m_green, m_blue);
m_red = r;
m_green = g;
m_blue = b;
m_isInit = TRUE;
m_pixel = PALETTERGB (m_red, m_green, m_blue);
}