Fixed clearing wxWindowDC, wxMemoryDC for wxMSW.

Current implementation suffers for two issues:
1. Because wxClientDC and wxWindowDC are not distinguished in wxMSWDCImpl::Clear and in both cases DC coordinates are obtained with GetClientRect() Win API what leads to this that for wxWindowDC the entire area is not cleared.
2. Translations like moving logical origin or scaling are not taken into account in wxMemoryDC coordinates calculations (only device origin is included) so for transformed DC calculated coordinates are invalid and finally the entire area is not cleared.

To fix these issues we can use GetClipBox() Win API to obtain actual logical coordinates of the clipping box (with all translations and scaling already included) and this way we can avoid using separate methods of retrieving coordinates for wxClientDC, wxWindowDC and wxMemoryDC.
This commit is contained in:
Artur Wieczorek 2016-07-09 23:32:23 +02:00
parent 2b7aab70ff
commit 13f9789996

View File

@ -709,30 +709,19 @@ int wxMSWDCImpl::GetDepth() const
void wxMSWDCImpl::Clear()
{
RECT rect;
if (m_window)
{
GetClientRect((HWND) m_window->GetHWND(), &rect);
}
else
if ( !m_window )
{
// No, I think we should simply ignore this if printing on e.g.
// a printer DC.
// wxCHECK_RET( m_selectedBitmap.IsOk(), wxT("this DC can't be cleared") );
if (!m_selectedBitmap.IsOk())
return;
rect.left = rect.top = 0;
rect.right = m_selectedBitmap.GetWidth();
rect.bottom = m_selectedBitmap.GetHeight();
}
::OffsetRect(&rect, -m_deviceOriginX, -m_deviceOriginY);
(void) ::SetMapMode(GetHdc(), MM_TEXT);
DWORD colour = ::GetBkColor(GetHdc());
HBRUSH brush = ::CreateSolidBrush(colour);
RECT rect;
::GetClipBox(GetHdc(), &rect);
::FillRect(GetHdc(), &rect, brush);
::DeleteObject(brush);