X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d0bdc3ca5f3e1d2adf70c8630b4b524bc53a798e..5701b057fb4b5bf672da2fb19230d179f7f3e251:/src/common/gdicmn.cpp diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index fa54d946b1..b2554b00fd 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) { } @@ -321,23 +310,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,7 +595,12 @@ wxFont *wxFontList:: //#if defined(__X__) // each_font->GetFontId () == FamilyOrFontId) /* New font system */ //#else - each_font->GetFamily () == FamilyOrFontId && +#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;