X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c50f92d08cc3633f8127931e7cf5d362ab8ac392..c5fc899bf29ca7d9c4e2a070e28228b430a68dd3:/src/common/gdicmn.cpp diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index bed3f972eb..049d1339dd 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -331,7 +331,6 @@ void wxColourDatabase::Initialize() {wxT("WHEAT"), 216, 216, 191}, {wxT("WHITE"), 255, 255, 255}, {wxT("YELLOW"), 255, 255, 0}, - {wxT("YELLOW GREEN"), 153, 204, 50}, {wxT("YELLOW GREEN"), 153, 204, 50} }; @@ -408,11 +407,9 @@ wxColour wxColourDatabase::Find(const wxString& colour) const if ( it != m_map->end() ) return *(it->second); - // if we didn't find it,query the system, maybe it knows about it - // - // TODO: move this into platform-specific files -#ifdef __WXGTK__ - wxColour col( colour ); + // if we didn't find it, query the system, maybe it knows about it +#if defined(__WXGTK__) || defined(__X__) + wxColour col = wxColour::CreateByName(colour); if ( col.Ok() ) { @@ -422,6 +419,7 @@ wxColour wxColourDatabase::Find(const wxString& colour) const return col; #elif defined(__X__) + // TODO: move this to wxColour::CreateByName() XColor xcolour; #ifdef __WXMOTIF__ @@ -475,18 +473,31 @@ wxString wxColourDatabase::FindName(const wxColour& colour) const wxColour *wxColourDatabase::FindColour(const wxString& name) { - wxColour col = Find(name); - if ( !col.Ok() ) - return NULL; + // This function is deprecated, use Find() instead. + // Formerly this function sometimes would return a deletable pointer and + // sometimes a non-deletable one (when returning a colour from the database). + // Trying to delete the latter anyway results in problems, so probably + // nobody ever freed the pointers. Currently it always returns a new + // instance, which means there will be memory leaks. + wxLogDebug(wxT("wxColourDataBase::FindColour():") + wxT(" Please use wxColourDataBase::Find() instead")); + + // using a static variable here is not the most elegant solution but unless + // we want to make wxStringToColourHashMap public (i.e. move it to the + // header) so that we could have a member function returning + // wxStringToColourHashMap::iterator, there is really no good way to do it + // otherwise + // + // and knowing that this function is going to disappear in the next release + // anyhow I don't want to waste time on this - return new wxColour(col); -} + static wxColour s_col; -void wxColourDatabase::AddColour(const wxString& name, wxColour *colour) -{ - wxCHECK_RET( colour, _T("NULL pointer in wxColourDatabase::AddColour") ); + s_col = Find(name); + if ( !s_col.Ok() ) + return NULL; - AddColour(name, wxColour(*colour)); + return new wxColour(s_col); } // ============================================================================ @@ -520,6 +531,7 @@ void wxInitializeStockObjects () #endif */ #if defined(__WXMAC__) + // retrieve size of system font for all stock fonts int sizeFont = 12; Str255 fontName ; @@ -528,7 +540,12 @@ void wxInitializeStockObjects () GetThemeFont(kThemeSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; sizeFont = fontSize ; +#if __WXMAC_CLASSIC__ wxNORMAL_FONT = new wxFont (fontSize, wxMODERN, wxNORMAL, wxNORMAL , false , wxMacMakeStringFromPascal(fontName) ); +#else + wxNORMAL_FONT = new wxFont () ; + wxNORMAL_FONT->MacCreateThemeFont( kThemeSystemFont ); +#endif #elif defined(__WXPM__) static const int sizeFont = 12; #else @@ -548,8 +565,13 @@ void wxInitializeStockObjects () #elif defined(__WXMAC__) wxSWISS_FONT = new wxFont (sizeFont, wxSWISS, wxNORMAL, wxNORMAL); /* Helv */ wxITALIC_FONT = new wxFont (sizeFont, wxROMAN, wxITALIC, wxNORMAL); +#if __WXMAC_CLASSIC__ GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; wxSMALL_FONT = new wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , wxMacMakeStringFromPascal( fontName ) ); +#else + wxSMALL_FONT = new wxFont () ; + wxSMALL_FONT->MacCreateThemeFont( kThemeSmallSystemFont ); +#endif #else wxSMALL_FONT = new wxFont (sizeFont - 2, wxSWISS, wxNORMAL, wxNORMAL); wxITALIC_FONT = new wxFont (sizeFont, wxROMAN, wxITALIC, wxNORMAL);