X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/222ed1d678dff2f5c3c4164321dd05e8f47de487..487f2d58e9d1c28cc54e9800affd91623adadac7:/src/common/gdicmn.cpp diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index 7bf932f207..a525af1b0d 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -9,7 +9,7 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "gdicmn.h" #endif @@ -43,7 +43,7 @@ #include #ifdef __WXMSW__ -#include +#include "wx/msw/wrapwin.h" #endif #ifdef __WXMOTIF__ @@ -64,33 +64,59 @@ #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) + +#if wxUSE_EXTENDED_RTTI + +// wxPoint + +template<> void wxStringReadValue(const wxString &s , wxPoint &data ) +{ + wxSscanf(s, wxT("%d,%d"), &data.x , &data.y ) ; +} + +template<> void wxStringWriteValue(wxString &s , const wxPoint &data ) +{ + s = wxString::Format(wxT("%d,%d"), data.x , data.y ) ; +} + +wxCUSTOM_TYPE_INFO(wxPoint, wxToStringConverter , wxFromStringConverter) + +template<> void wxStringReadValue(const wxString &s , wxSize &data ) +{ + wxSscanf(s, wxT("%d,%d"), &data.x , &data.y ) ; +} + +template<> void wxStringWriteValue(wxString &s , const wxSize &data ) +{ + s = wxString::Format(wxT("%d,%d"), data.x , data.y ) ; +} + +wxCUSTOM_TYPE_INFO(wxSize, wxToStringConverter , wxFromStringConverter) + +#endif IMPLEMENT_ABSTRACT_CLASS(wxDCBase, wxObject) -wxRect::wxRect(const wxPoint& topLeft, const wxPoint& bottomRight) +wxRect::wxRect(const wxPoint& point1, const wxPoint& point2) { - x = topLeft.x; - y = topLeft.y; - width = bottomRight.x - topLeft.x + 1; - height = bottomRight.y - topLeft.y + 1; + x = point1.x; + y = point1.y; + width = point2.x - point1.x; + height = point2.y - point1.y; if (width < 0) { width = -width; - x -= width; + x = point2.x; } + width++; if (height < 0) { height = -height; - y -= height; + y = point2.y; } + height++; } wxRect::wxRect(const wxPoint& point, const wxSize& size) @@ -196,10 +222,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,10 +312,7 @@ void wxColourDatabase::Initialize () {wxT("WHITE"), 255, 255, 255}, {wxT("YELLOW"), 255, 255, 0}, {wxT("YELLOW GREEN"), 153, 204, 50}, - {wxT("MEDIUM GOLDENROD"), 234, 234, 173}, - {wxT("MEDIUM FOREST GREEN"), 107, 142, 35}, - {wxT("LIGHT MAGENTA"), 255, 0, 255}, - {wxT("MEDIUM GREY"), 100, 100, 100}, + {wxT("YELLOW GREEN"), 153, 204, 50} }; size_t n; @@ -300,7 +320,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]; @@ -332,6 +352,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 @@ -381,7 +421,7 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour, bool add) delete col; return (wxColour *) NULL; } - (*m_map)[colour] = col; + AddColour(colour, col); return col; #endif @@ -409,7 +449,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__ @@ -436,10 +476,13 @@ wxString wxColourDatabase::FindName (const wxColour& colour) const void wxInitializeStockLists() { - wxTheBrushList = new wxBrushList; - wxThePenList = new wxPenList; - wxTheFontList = new wxFontList; - wxTheBitmapList = new wxBitmapList; + wxTheColourDatabase = new wxColourDatabase; + wxTheColourDatabase->Initialize(); + + wxTheBrushList = new wxBrushList; + wxThePenList = new wxPenList; + wxTheFontList = new wxFontList; + wxTheBitmapList = new wxBitmapList; } void wxInitializeStockObjects () @@ -467,7 +510,7 @@ void wxInitializeStockObjects () GetThemeFont(kThemeSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; sizeFont = fontSize ; - wxSWISS_FONT = new wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , wxMacMakeStringFromPascal(fontName) ); + wxNORMAL_FONT = new wxFont (fontSize, wxMODERN, wxNORMAL, wxNORMAL , false , wxMacMakeStringFromPascal(fontName) ); #elif defined(__WXPM__) static const int sizeFont = 12; #else @@ -485,7 +528,7 @@ void wxInitializeStockObjects () wxITALIC_FONT = new wxFont (sizeFont, wxROMAN, wxITALIC, wxNORMAL); wxSWISS_FONT = new wxFont (sizeFont, wxSWISS, wxNORMAL, wxNORMAL); /* Helv */ #elif defined(__WXMAC__) - wxNORMAL_FONT = new wxFont (sizeFont, wxMODERN, wxNORMAL, wxNORMAL); + wxSWISS_FONT = new wxFont (sizeFont, wxSWISS, wxNORMAL, wxNORMAL); /* Helv */ wxITALIC_FONT = new wxFont (sizeFont, wxROMAN, wxITALIC, wxNORMAL); GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; wxSMALL_FONT = new wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , wxMacMakeStringFromPascal( fontName ) );