X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ec5d77998a16fbdf328ec689a48449c84f0d4336..abfcca57dd0d805ceec9e19c4be207614d79252a:/src/common/gdicmn.cpp?ds=sidebyside diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index c6b57f5f99..0145deabfc 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -113,6 +113,29 @@ wxRect wxRect::operator + (const wxRect& rect) const return wxRect(x1, y1, x2-x1, y2-y1); } +wxRect& wxRect::Inflate(wxCoord dx, wxCoord dy) +{ + x -= dx; + y -= dy; + width += 2*dx; + height += 2*dy; + + // check that we didn't make the rectangle invalid by accident (you almost + // never want to have negative coords and never want negative size) + if ( x < 0 ) + x = 0; + if ( y < 0 ) + y = 0; + + // what else can we do? + if ( width < 0 ) + width = 0; + if ( height < 0 ) + height = 0; + + return *this; +} + bool wxRect::Inside(int cx, int cy) const { return ( (cx >= x) && (cy >= y) @@ -121,6 +144,40 @@ bool wxRect::Inside(int cx, int cy) const ); } +wxRect& wxRect::Intersect(const wxRect& rect) +{ + int x2 = GetRight(), + y2 = GetBottom(); + + if ( x < rect.x ) + x = rect.x; + if ( y < rect.y ) + y = rect.y; + if ( x2 > rect.GetRight() ) + x2 = rect.GetRight(); + if ( y2 > rect.GetBottom() ) + y2 = rect.GetBottom(); + + width = x2 - x + 1; + height = y2 - y + 1; + + if ( width <= 0 || height <= 0 ) + { + width = + height = 0; + } + + return *this; +} + +bool wxRect::Intersects(const wxRect& rect) const +{ + wxRect r = Intersect(rect); + + // if there is no intersection, both width and height are 0 + return r.width != 0; +} + wxColourDatabase::wxColourDatabase (int type) : wxList (type) { } @@ -283,6 +340,9 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour) #ifdef __WXPM__ return NULL; #endif +#ifdef __WXMGL__ + return NULL; +#endif // TODO for other implementations. This should really go into // platform-specific directories. @@ -393,35 +453,35 @@ void wxInitializeStockObjects () wxITALIC_FONT = new wxFont (sizeFont, wxROMAN, wxITALIC, wxNORMAL); wxSWISS_FONT = new wxFont (sizeFont, wxSWISS, wxNORMAL, wxNORMAL); - wxRED_PEN = new wxPen ("RED", 1, wxSOLID); - wxCYAN_PEN = new wxPen ("CYAN", 1, wxSOLID); - wxGREEN_PEN = new wxPen ("GREEN", 1, wxSOLID); - wxBLACK_PEN = new wxPen ("BLACK", 1, wxSOLID); - wxWHITE_PEN = new wxPen ("WHITE", 1, wxSOLID); - wxTRANSPARENT_PEN = new wxPen ("BLACK", 1, wxTRANSPARENT); - wxBLACK_DASHED_PEN = new wxPen ("BLACK", 1, wxSHORT_DASH); - wxGREY_PEN = new wxPen ("GREY", 1, wxSOLID); - wxMEDIUM_GREY_PEN = new wxPen ("MEDIUM GREY", 1, wxSOLID); - wxLIGHT_GREY_PEN = new wxPen ("LIGHT GREY", 1, wxSOLID); - - wxBLUE_BRUSH = new wxBrush ("BLUE", wxSOLID); - wxGREEN_BRUSH = new wxBrush ("GREEN", wxSOLID); - wxWHITE_BRUSH = new wxBrush ("WHITE", wxSOLID); - wxBLACK_BRUSH = new wxBrush ("BLACK", wxSOLID); - wxTRANSPARENT_BRUSH = new wxBrush ("BLACK", wxTRANSPARENT); - wxCYAN_BRUSH = new wxBrush ("CYAN", wxSOLID); - wxRED_BRUSH = new wxBrush ("RED", wxSOLID); - wxGREY_BRUSH = new wxBrush ("GREY", wxSOLID); - wxMEDIUM_GREY_BRUSH = new wxBrush ("MEDIUM GREY", wxSOLID); - wxLIGHT_GREY_BRUSH = new wxBrush ("LIGHT GREY", wxSOLID); - - wxBLACK = new wxColour ("BLACK"); - wxWHITE = new wxColour ("WHITE"); - wxRED = new wxColour ("RED"); - wxBLUE = new wxColour ("BLUE"); - wxGREEN = new wxColour ("GREEN"); - wxCYAN = new wxColour ("CYAN"); - wxLIGHT_GREY = new wxColour ("LIGHT GREY"); + wxRED_PEN = new wxPen (wxT("RED"), 1, wxSOLID); + wxCYAN_PEN = new wxPen (wxT("CYAN"), 1, wxSOLID); + wxGREEN_PEN = new wxPen (wxT("GREEN"), 1, wxSOLID); + wxBLACK_PEN = new wxPen (wxT("BLACK"), 1, wxSOLID); + wxWHITE_PEN = new wxPen (wxT("WHITE"), 1, wxSOLID); + wxTRANSPARENT_PEN = new wxPen (wxT("BLACK"), 1, wxTRANSPARENT); + wxBLACK_DASHED_PEN = new wxPen (wxT("BLACK"), 1, wxSHORT_DASH); + wxGREY_PEN = new wxPen (wxT("GREY"), 1, wxSOLID); + wxMEDIUM_GREY_PEN = new wxPen (wxT("MEDIUM GREY"), 1, wxSOLID); + wxLIGHT_GREY_PEN = new wxPen (wxT("LIGHT GREY"), 1, wxSOLID); + + wxBLUE_BRUSH = new wxBrush (wxT("BLUE"), wxSOLID); + wxGREEN_BRUSH = new wxBrush (wxT("GREEN"), wxSOLID); + wxWHITE_BRUSH = new wxBrush (wxT("WHITE"), wxSOLID); + wxBLACK_BRUSH = new wxBrush (wxT("BLACK"), wxSOLID); + wxTRANSPARENT_BRUSH = new wxBrush (wxT("BLACK"), wxTRANSPARENT); + wxCYAN_BRUSH = new wxBrush (wxT("CYAN"), wxSOLID); + wxRED_BRUSH = new wxBrush (wxT("RED"), wxSOLID); + wxGREY_BRUSH = new wxBrush (wxT("GREY"), wxSOLID); + wxMEDIUM_GREY_BRUSH = new wxBrush (wxT("MEDIUM GREY"), wxSOLID); + wxLIGHT_GREY_BRUSH = new wxBrush (wxT("LIGHT GREY"), wxSOLID); + + wxBLACK = new wxColour (wxT("BLACK")); + wxWHITE = new wxColour (wxT("WHITE")); + wxRED = new wxColour (wxT("RED")); + wxBLUE = new wxColour (wxT("BLUE")); + wxGREEN = new wxColour (wxT("GREEN")); + wxCYAN = new wxColour (wxT("CYAN")); + wxLIGHT_GREY = new wxColour (wxT("LIGHT GREY")); wxSTANDARD_CURSOR = new wxCursor (wxCURSOR_ARROW); wxHOURGLASS_CURSOR = new wxCursor (wxCURSOR_WAIT);