Adjust scrolled contents only for wxPaintDC (drawing sample)

Adjust scrolled contents for screen drawing directly in EVT_PAINT
handler instead of doing so conditionally for generic wxDC.
This also helps demonstrating if wxPaintDC transformations
are transferred properly to wxGCDC.
This commit is contained in:
Artur Wieczorek 2022-11-29 18:41:08 +02:00
parent 1baecca49a
commit 48d226bb84

View file

@ -1843,11 +1843,13 @@ void MyCanvas::OnPaint(wxPaintEvent &WXUNUSED(event))
if ( m_useBuffer ) if ( m_useBuffer )
{ {
wxBufferedPaintDC bpdc(this); wxBufferedPaintDC bpdc(this);
PrepareDC(bpdc); // Adjust scrolled contents.
Draw(bpdc); Draw(bpdc);
} }
else else
{ {
wxPaintDC pdc(this); wxPaintDC pdc(this);
PrepareDC(pdc); // Adjust scrolled contents.
Draw(pdc); Draw(pdc);
} }
} }
@ -1891,13 +1893,6 @@ void MyCanvas::Draw(wxDC& pdc)
wxDC &dc = pdc ; wxDC &dc = pdc ;
#endif #endif
// Adjust scrolled contents for screen drawing operations only.
if ( wxDynamicCast(&pdc, wxBufferedPaintDC) ||
wxDynamicCast(&pdc, wxPaintDC) )
{
PrepareDC(dc);
}
m_owner->PrepareDC(dc); m_owner->PrepareDC(dc);
dc.SetBackgroundMode( m_owner->m_backgroundMode ); dc.SetBackgroundMode( m_owner->m_backgroundMode );