X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e59a80556ed4011ddf85c1abf52cb19f838c536a..350fffae72c078442d6d177d2071e62f2687df9f:/src/common/gdicmn.cpp diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index 3aacfbf638..280d4d94c3 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -43,7 +43,7 @@ #include #ifdef __WXMSW__ -#include +#include "wx/msw/wrapwin.h" #endif #ifdef __WXMOTIF__ @@ -64,12 +64,6 @@ #include "wx/mac/private.h" #include "wx/mac/uma.h" #endif -//IMPLEMENT_CLASS(wxColourDatabase, wxList) -//IMPLEMENT_DYNAMIC_CLASS(wxFontList, wxList) -//IMPLEMENT_DYNAMIC_CLASS(wxPenList, wxList) -//IMPLEMENT_DYNAMIC_CLASS(wxBrushList, wxList) -//IMPLEMENT_DYNAMIC_CLASS(wxBitmapList, wxList) -//IMPLEMENT_DYNAMIC_CLASS(wxResourceCache, wxList) IMPLEMENT_ABSTRACT_CLASS(wxDCBase, wxObject) @@ -196,10 +190,7 @@ wxColourDatabase::wxColourDatabase () wxColourDatabase::~wxColourDatabase () { - typedef wxStringToColourHashMap::iterator iterator; - - for( iterator it = m_map->begin(), en = m_map->end(); it != en; ++it ) - delete it->second; + WX_CLEAR_HASH_MAP(wxStringToColourHashMap, *m_map); delete m_map; m_map = NULL; @@ -289,6 +280,7 @@ void wxColourDatabase::Initialize () {wxT("WHITE"), 255, 255, 255}, {wxT("YELLOW"), 255, 255, 0}, {wxT("YELLOW GREEN"), 153, 204, 50}, + {wxT("YELLOW GREEN"), 153, 204, 50} }; size_t n; @@ -296,7 +288,7 @@ void wxColourDatabase::Initialize () for ( n = 0; n < WXSIZEOF(wxColourTable); n++ ) { const wxColourDesc& cc = wxColourTable[n]; - (*m_map)[cc.name] = new wxColour(cc.r,cc.g,cc.b); + AddColour(cc.name, new wxColour(cc.r,cc.g,cc.b)); } #ifdef __WXPM__ m_palTable = new long[n]; @@ -328,6 +320,26 @@ wxColour *wxColourDatabase::FindColourNoAdd(const wxString& colour) const return ((wxColourDatabase*)this)->FindColour(colour, false); } +void wxColourDatabase::AddColour (const wxString& name, wxColour* colour) +{ + wxString colName = name; + colName.MakeUpper(); + wxString colName2 = colName; + if ( !colName2.Replace(_T("GRAY"), _T("GREY")) ) + colName2.clear(); + + wxStringToColourHashMap::iterator it = m_map->find(colName); + if ( it == m_map->end() ) + it = m_map->find(colName2); + if ( it != m_map->end() ) + { + delete it->second; + it->second = colour; + } + + (*m_map)[name] = colour; +} + wxColour *wxColourDatabase::FindColour(const wxString& colour, bool add) { // VZ: make the comparaison case insensitive and also match both grey and @@ -377,7 +389,7 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour, bool add) delete col; return (wxColour *) NULL; } - (*m_map)[colour] = col; + AddColour(colour, col); return col; #endif @@ -405,7 +417,7 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour, bool add) #endif wxColour *col = new wxColour(r, g, b); - (*m_map)[colour] = col; + AddColour(colour, col); return col; #endif // __X__