X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3f1c6a14cb362d5a9cf56f1a4bd0f47f417c193e..18d2e17080a0bea4b85e0ad7223cfc6bcdab0e1e:/src/msw/dcmemory.cpp?ds=sidebyside diff --git a/src/msw/dcmemory.cpp b/src/msw/dcmemory.cpp index af483ed3af..f79d33b26e 100644 --- a/src/msw/dcmemory.cpp +++ b/src/msw/dcmemory.cpp @@ -41,9 +41,7 @@ // wxWin macros // ---------------------------------------------------------------------------- -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC) -#endif // ============================================================================ // implementation @@ -141,3 +139,52 @@ void wxMemoryDC::DoGetSize(int *width, int *height) const } } +// For some reason, drawing a rectangle on a memory DC has problems. +// Use this substitute if we can. +static void wxDrawRectangle(wxDC& dc, wxCoord x, wxCoord y, wxCoord width, wxCoord height) +{ + wxBrush brush(dc.GetBrush()); + wxPen pen(dc.GetPen()); + if (brush.Ok() && brush.GetStyle() != wxTRANSPARENT) + { + HBRUSH hBrush = (HBRUSH) brush.GetResourceHandle() ; + if (hBrush) + { + RECT rect; + rect.left = x; rect.top = y; + rect.right = x + width - 1; + rect.bottom = y + height - 1; + ::FillRect((HDC) dc.GetHDC(), &rect, hBrush); + } + } + width --; height --; + if (pen.Ok() && pen.GetStyle() != wxTRANSPARENT) + { + dc.DrawLine(x, y, x + width, y); + dc.DrawLine(x, y, x, y + height); + dc.DrawLine(x, y+height, x+width, y + height); + dc.DrawLine(x+width, y+height, x+width, y); + } +} + +void wxMemoryDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +{ + // Set this to 1 to work around an apparent video driver bug + // (visible with e.g. 70x70 rectangle on a memory DC; see Drawing sample) +#if 0 + if (m_brush.Ok() && m_pen.Ok() && + (m_brush.GetStyle() == wxSOLID || m_brush.GetStyle() == wxTRANSPARENT) && + (m_pen.GetStyle() == wxSOLID || m_pen.GetStyle() == wxTRANSPARENT) && + (GetLogicalFunction() == wxCOPY)) + { + wxDrawRectangle(* this, x, y, width, height); + } + else + { + wxDC::DoDrawRectangle(x, y, width, height); + } +#else + wxDC::DoDrawRectangle(x, y, width, height); +#endif +} +