X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5100cabffa34c38db26884577113d01f21cda446..abb74e976384e2023381f41cc96c80746e664f42:/src/common/gdicmn.cpp diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index e7dc5831e0..2c62bcefda 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -136,6 +136,9 @@ wxColourDatabase::~wxColourDatabase () delete col; node = next; } +#ifdef __WXPM__ + delete [] m_palTable; +#endif } // Colour database stuff @@ -225,11 +228,22 @@ void wxColourDatabase::Initialize () {wxT("MEDIUM GREY"), 100, 100, 100}, }; - for ( size_t n = 0; n < WXSIZEOF(wxColourTable); n++ ) + size_t n; + + for ( n = 0; n < WXSIZEOF(wxColourTable); n++ ) { const wxColourDesc& cc = wxColourTable[n]; Append(cc.name, new wxColour(cc.r,cc.g,cc.b)); } +#ifdef __WXPM__ + m_palTable = new long[n]; + for ( n = 0; n < WXSIZEOF(wxColourTable); n++ ) + { + const wxColourDesc& cc = wxColourTable[n]; + m_palTable[n] = OS2RGB(cc.r,cc.g,cc.b); + } + m_nSize = n; +#endif } /* @@ -365,13 +379,15 @@ void wxInitializeStockObjects () #ifdef __WXMSW__ static const int sizeFont = 10; #else - static const int sizeFont = 12; #endif */ - -// wxNORMAL_FONT = new wxFont (sizeFont, wxMODERN, wxNORMAL, wxNORMAL); +#if defined(__WXPM__) || defined(__WXMAC__) + static const int sizeFont = 12; + wxNORMAL_FONT = new wxFont (sizeFont, wxMODERN, wxNORMAL, wxNORMAL); +#else wxNORMAL_FONT = new wxFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); static const int sizeFont = wxNORMAL_FONT->GetPointSize(); +#endif wxSMALL_FONT = new wxFont (sizeFont - 2, wxSWISS, wxNORMAL, wxNORMAL); wxITALIC_FONT = new wxFont (sizeFont, wxROMAN, wxITALIC, wxNORMAL); @@ -504,27 +520,35 @@ void wxPenList::RemovePen (wxPen * pen) wxPen *wxPenList::FindOrCreatePen (const wxColour& colour, int width, int style) { - for (wxNode * node = First (); node; node = node->Next ()) + for (wxNode * node = First (); node; node = node->Next ()) + { + wxPen *each_pen = (wxPen *) node->Data (); + if (each_pen && + each_pen->GetVisible() && + each_pen->GetWidth () == width && + each_pen->GetStyle () == style && + each_pen->GetColour ().Red () == colour.Red () && + each_pen->GetColour ().Green () == colour.Green () && + each_pen->GetColour ().Blue () == colour.Blue ()) + return each_pen; + } + + wxPen *pen = new wxPen (colour, width, style); + if ( !pen->Ok() ) { - wxPen *each_pen = (wxPen *) node->Data (); - if (each_pen && - each_pen->GetVisible() && - each_pen->GetWidth () == width && - each_pen->GetStyle () == style && - each_pen->GetColour ().Red () == colour.Red () && - each_pen->GetColour ().Green () == colour.Green () && - each_pen->GetColour ().Blue () == colour.Blue ()) - return each_pen; + // don't save the invalid pens in the list + delete pen; + + return NULL; } - wxPen *pen = new wxPen (colour, width, style); - // Yes, we can return a pointer to this in a later FindOrCreatePen call, - // because we created it within FindOrCreatePen. Safeguards against - // returning a pointer to an automatic variable and hanging on to it - // (dangling pointer). - pen->SetVisible(TRUE); + // Yes, we can return a pointer to this in a later FindOrCreatePen call, + // because we created it within FindOrCreatePen. Safeguards against + // returning a pointer to an automatic variable and hanging on to it + // (dangling pointer). + pen->SetVisible(TRUE); - return pen; + return pen; } wxBrushList::~wxBrushList () @@ -547,27 +571,35 @@ void wxBrushList::AddBrush (wxBrush * brush) wxBrush *wxBrushList::FindOrCreateBrush (const wxColour& colour, int style) { - for (wxNode * node = First (); node; node = node->Next ()) + for (wxNode * node = First (); node; node = node->Next ()) { - wxBrush *each_brush = (wxBrush *) node->Data (); - if (each_brush && - each_brush->GetVisible() && - each_brush->GetStyle () == style && - each_brush->GetColour ().Red () == colour.Red () && - each_brush->GetColour ().Green () == colour.Green () && - each_brush->GetColour ().Blue () == colour.Blue ()) - return each_brush; + wxBrush *each_brush = (wxBrush *) node->Data (); + if (each_brush && + each_brush->GetVisible() && + each_brush->GetStyle () == style && + each_brush->GetColour ().Red () == colour.Red () && + each_brush->GetColour ().Green () == colour.Green () && + each_brush->GetColour ().Blue () == colour.Blue ()) + return each_brush; } - // Yes, we can return a pointer to this in a later FindOrCreateBrush call, - // because we created it within FindOrCreateBrush. Safeguards against - // returning a pointer to an automatic variable and hanging on to it - // (dangling pointer). - wxBrush *brush = new wxBrush (colour, style); + wxBrush *brush = new wxBrush (colour, style); - brush->SetVisible(TRUE); + if ( !brush->Ok() ) + { + // don't put the brushes we failed to create into the list + delete brush; - return brush; + return NULL; + } + + brush->SetVisible(TRUE); + + // Yes, we can return a pointer to this in a later FindOrCreateBrush call, + // because we created it within FindOrCreateBrush. Safeguards against + // returning a pointer to an automatic variable and hanging on to it + // (dangling pointer). + return brush; } void wxBrushList::RemoveBrush (wxBrush * brush) @@ -691,6 +723,13 @@ wxSize wxGetDisplaySize() return wxSize(x, y); } +wxSize wxGetDisplaySizeMM() +{ + int x, y; + wxDisplaySizeMM(& x, & y); + return wxSize(x, y); +} + wxResourceCache::~wxResourceCache () { wxNode *node = First ();