X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/509201463dbd3bce8aff762c664b111a8f2c3412..b70ababc146a97e9f1b2afc0193f92fa6c202dd9:/src/common/gdicmn.cpp diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index 154c2c7008..7755f181e1 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -30,6 +30,8 @@ #include "wx/font.h" #include "wx/palette.h" #include "wx/app.h" +#include "wx/dc.h" +#include "wx/utils.h" #include "wx/log.h" #include @@ -43,29 +45,16 @@ #endif #if !USE_SHARED_LIBRARY -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_DYNAMIC_CLASS(wxRect, wxObject) -IMPLEMENT_DYNAMIC_CLASS(wxPoint, wxObject) -IMPLEMENT_DYNAMIC_CLASS(wxRealPoint, wxObject) -*/ + 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) #endif -wxRect::wxRect() -{ - x = 0; y = 0; width = 0; height = 0; -} - -wxRect::wxRect(long xx, long yy, long w, long h) -{ - x = xx; y = yy; width = w; height = h; -} - wxRect::wxRect(const wxPoint& topLeft, const wxPoint& bottomRight) { x = topLeft.x; @@ -92,38 +81,38 @@ wxRect::wxRect(const wxPoint& point, const wxSize& size) width = size.x; height = size.y; } -wxRect::wxRect(const wxRect& rect) +bool wxRect::operator==(const wxRect& rect) const { - x = rect.x; - y = rect.y; - width = rect.width; - height = rect.height; + return ((x == rect.x) && + (y == rect.y) && + (width == rect.width) && + (height == rect.height)); } -wxRect& wxRect::operator = (const wxRect& rect) +const wxRect& wxRect::operator += (const wxRect& rect) { - x = rect.x; y = rect.y; width = rect.width; height = rect.height; - return *this; + *this = (*this + rect); + return ( *this ) ; } -bool wxRect::operator == (const wxRect& rect) +wxRect wxRect::operator + (const wxRect& rect) const { - return ((x == rect.x) && - (y == rect.y) && - (width == rect.width) && - (height == rect.height)); + int x1 = wxMin(this->x, rect.x); + int y1 = wxMin(this->y, rect.y); + int y2 = wxMax(y+height, rect.height+rect.y); + int x2 = wxMax(x+width, rect.width+rect.x); + return wxRect(x1, y1, x2-x1, y2-y1); } -bool wxRect::operator != (const wxRect& rect) +bool wxRect::Inside(int cx, int cy) const { - return ((x != rect.x) || - (y != rect.y) || - (width != rect.width) || - (height != rect.height)); + return ( (cx >= x) && (cy >= y) + && ((cy - y) < height) + && ((cx - x) < width) + ); } -wxColourDatabase::wxColourDatabase (int type): -wxList (type) +wxColourDatabase::wxColourDatabase (int type) : wxList (type) { } @@ -267,6 +256,9 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour) #ifdef __WXMSW__ else return NULL; #endif +#ifdef __WXPM__ + else return NULL; +#endif // TODO for other implementations. This should really go into // platform-specific directories. @@ -321,23 +313,29 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour) wxString wxColourDatabase::FindName (const wxColour& colour) const { - unsigned char red = colour.Red (); - unsigned char green = colour.Green (); - unsigned char blue = colour.Blue (); + wxString name; - for (wxNode * node = First (); node; node = node->Next ()) - { - wxColour *col = (wxColour *) node->Data (); + unsigned char red = colour.Red (); + unsigned char green = colour.Green (); + unsigned char blue = colour.Blue (); - if (col->Red () == red && col->Green () == green && col->Blue () == blue) + for (wxNode * node = First (); node; node = node->Next ()) + { + wxColour *col = (wxColour *) node->Data (); + + if (col->Red () == red && col->Green () == green && col->Blue () == blue) { - const wxChar *found = node->GetKeyString(); - if (found) - return wxString(found); + const wxChar *found = node->GetKeyString(); + if ( found ) + { + name = found; + + break; + } } - } - return wxString(""); // Not Found + } + return name; } void wxInitializeStockLists () { @@ -600,8 +598,13 @@ wxFont *wxFontList:: //#if defined(__X__) // each_font->GetFontId () == FamilyOrFontId) /* New font system */ //#else - each_font->GetFamily () == FamilyOrFontId && - ((each_font->GetFaceName() == "") || each_font->GetFaceName() == Face)) +#if defined(__WXGTK__) + (each_font->GetFamily() == FamilyOrFontId || + (each_font->GetFamily() == wxSWISS && FamilyOrFontId == wxDEFAULT)) && +#else + each_font->GetFamily() == FamilyOrFontId && +#endif + ((each_font->GetFaceName() == _T("")) || each_font->GetFaceName() == Face)) //#endif return each_font; }