Fixed retrieving clipping box for transformed wxDC

Because wxDC can be the subject of geometric transformations (like translation, scaling) so we cannot assume in the calculations of the clipping box that DC origin is always at (0,0) and its logical size is the same as physical size. To get correct result we have to use logical coordinates of wxDC area in all clipping box calculations.
This commit is contained in:
Artur Wieczorek 2016-07-09 22:50:27 +02:00
parent fc0108ce71
commit 53230aaf4d
2 changed files with 6 additions and 5 deletions

View File

@ -449,13 +449,13 @@ public:
DoGetSize(&dcWidth, &dcHeight);
if ( x )
*x = m_clipping ? m_clipX1 : 0;
*x = m_clipping ? m_clipX1 : DeviceToLogicalX(0);
if ( y )
*y = m_clipping ? m_clipY1 : 0;
*y = m_clipping ? m_clipY1 : DeviceToLogicalY(0);
if ( w )
*w = m_clipping ? m_clipX2 - m_clipX1 : dcWidth;
*w = m_clipping ? m_clipX2 - m_clipX1 : DeviceToLogicalXRel(dcWidth);
if ( h )
*h = m_clipping ? m_clipY2 - m_clipY1 : dcHeight;
*h = m_clipping ? m_clipY2 - m_clipY1 : DeviceToLogicalYRel(dcHeight);
}
virtual void DestroyClippingRegion() { ResetClipping(); }

View File

@ -387,7 +387,8 @@ void wxDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
// of required clipping box and DC surface.
int dcWidth, dcHeight;
DoGetSize(&dcWidth, &dcHeight);
wxRect dcRect(wxSize(dcWidth, dcHeight));
wxRect dcRect(DeviceToLogicalX(0), DeviceToLogicalY(0),
DeviceToLogicalXRel(dcWidth), DeviceToLogicalYRel(dcHeight));
clipRegion = dcRect.Intersect(newRegion);
m_clipping = true;