X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d553992a3c1aa98ae615b9e009ea23fcbcab0242..6164d85e896743b16a0cf8b0610f5d17ceb47f36:/src/common/gdicmn.cpp diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index 1045d4c0ab..57c72604d3 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -20,6 +20,7 @@ #pragma hdrstop #endif + #include "wx/gdicmn.h" #include "wx/brush.h" #include "wx/pen.h" @@ -28,13 +29,19 @@ #include "wx/cursor.h" #include "wx/font.h" #include "wx/palette.h" +#include "wx/app.h" +#include "wx/log.h" #include #ifdef __WXMSW__ #include #endif +#ifdef __WXMOTIF__ +#include +#endif + #if !USE_SHARED_LIBRARY IMPLEMENT_CLASS(wxColourDatabase, wxList) IMPLEMENT_DYNAMIC_CLASS(wxFontList, wxList) @@ -249,7 +256,11 @@ void wxColourDatabase::Initialize () wxColour *wxColourDatabase::FindColour(const wxString& colour) { - wxNode *node = Find((char *) (const char *)colour); + // VZ: make the comparaison case insensitive + wxString str = colour; + str.MakeUpper(); + + wxNode *node = Find(str); if (node) return (wxColour *)node->Data(); @@ -269,7 +280,7 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour) if (!(col->Ok())) { delete col; - return NULL; + return (wxColour *) NULL; } Append( colour, col ); return col; @@ -281,7 +292,7 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour) XColor xcolour; #ifdef __WXMOTIF__ - Display *display = XtDisplay(wxTheApp->topLevel) ; + Display *display = XtDisplay((Widget) wxTheApp->GetTopLevelWidget()) ; #endif #ifdef __XVIEW__ Xv_Screen screen = xv_get(xview_server, SERVER_NTH_SCREEN, 0); @@ -290,7 +301,7 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour) #endif /* MATTHEW: [4] Use wxGetMainColormap */ - if (!XParseColor(display, wxGetMainColormap(display), colour,&xcolour)) + if (!XParseColor(display, (Colormap) wxTheApp->GetMainColormap((WXDisplay*) display), colour,&xcolour)) return NULL; unsigned char r = (unsigned char)(xcolour.red >> 8); @@ -317,7 +328,7 @@ wxString wxColourDatabase::FindName (const wxColour& colour) const if (col->Red () == red && col->Green () == green && col->Blue () == blue) { - char *found = node->key.string; + const char *found = node->GetKeyString(); if (found) return wxString(found); } @@ -338,7 +349,8 @@ void wxInitializeStockObjects () #ifdef __WXMOTIF__ #endif #ifdef __X__ - wxFontPool = new XFontPool; + // TODO + // wxFontPool = new XFontPool; #endif wxNORMAL_FONT = new wxFont (12, wxMODERN, wxNORMAL, wxNORMAL); @@ -437,29 +449,34 @@ wxBitmapList::wxBitmapList () wxBitmapList::~wxBitmapList () { +#ifdef __WXMSW__ + wxNode *node = First (); while (node) { wxBitmap *bitmap = (wxBitmap *) node->Data (); wxNode *next = node->Next (); - delete bitmap; -// bitmap->FreeResource(TRUE); + if (bitmap->GetVisible()) + delete bitmap; node = next; } +#endif } // Pen and Brush lists wxPenList::~wxPenList () { +#ifdef __WXMSW__ wxNode *node = First (); while (node) { wxPen *pen = (wxPen *) node->Data (); wxNode *next = node->Next (); - delete pen; -// pen->FreeResource(TRUE); + if (pen->GetVisible()) + delete pen; node = next; } +#endif } void wxPenList::AddPen (wxPen * pen) @@ -495,25 +512,19 @@ wxPen *wxPenList::FindOrCreatePen (const wxColour& colour, int width, int style) return pen; } -wxPen *wxPenList::FindOrCreatePen (const wxString& colour, int width, int style) -{ - wxColour *the_colour = wxTheColourDatabase->FindColour (colour); - if (the_colour) - return FindOrCreatePen (*the_colour, width, style); - else - return NULL; -} - wxBrushList::~wxBrushList () { +#ifdef __WXMSW__ wxNode *node = First (); while (node) { wxBrush *brush = (wxBrush *) node->Data (); wxNode *next = node->Next (); - delete brush; + if (brush->GetVisible()) + delete brush; node = next; } +#endif } void wxBrushList::AddBrush (wxBrush * brush) @@ -542,15 +553,6 @@ wxBrush *wxBrushList::FindOrCreateBrush (const wxColour& colour, int style) return brush; } -wxBrush *wxBrushList::FindOrCreateBrush (const wxString& colour, int style) -{ - wxColour *the_colour = wxTheColourDatabase->FindColour (colour); - if (the_colour) - return FindOrCreateBrush (*the_colour, style); - else - return NULL; -} - void wxBrushList::RemoveBrush (wxBrush * brush) { DeleteObject (brush); @@ -558,26 +560,19 @@ void wxBrushList::RemoveBrush (wxBrush * brush) wxFontList::~wxFontList () { -#ifdef __WXMSW__ wxNode *node = First (); while (node) { -/* - wxFont *font = (wxFont *) node->Data (); - wxNode *next = node->Next (); - delete font; - node = next; -*/ - // New for 2.0: don't delete the font (it may be a member - // of a wxDC, for example) + // Only delete objects that are 'visible', i.e. + // that have been created using FindOrCreate..., + // where the pointers are expected to be shared + // (and therefore not deleted by any one part of an app). wxFont *font = (wxFont *) node->Data (); wxNode *next = node->Next (); - - // Force the font to be deleted - font->FreeResource(TRUE); + if (font->GetVisible()) + delete font; node = next; - } -#endif +} } void wxFontList::AddFont (wxFont * font) @@ -601,12 +596,12 @@ wxFont *wxFontList:: each_font->GetStyle () == Style && each_font->GetWeight () == Weight && each_font->GetUnderlined () == underline && -#if defined(__X__) || (defined(__WXMSW__) && USE_PORTABLE_FONTS_IN_MSW) - each_font->GetFontId () == FamilyOrFontId) /* New font system */ -#else + //#if defined(__X__) + // each_font->GetFontId () == FamilyOrFontId) /* New font system */ + //#else each_font->GetFamily () == FamilyOrFontId && (!each_font->GetFaceName() || each_font->GetFaceName() == Face)) -#endif + //#endif return each_font; } wxFont *font = new wxFont (PointSize, FamilyOrFontId, Style, Weight, underline, Face); @@ -626,12 +621,6 @@ wxSize wxGetDisplaySize() return wxSize(x, y); } -wxResourceCache::wxResourceCache () : wxList() { -} - -wxResourceCache::wxResourceCache (const unsigned int the_key_type) : wxList(the_key_type) { -} - wxResourceCache::~wxResourceCache () { wxNode *node = First (); while (node) {