Store clipping box coordinates in device units in wxWindowDCImpl, wxGTKDCImpl

Because retrieving clipping box coordinates in DoGetClippingRect() is
delegated to wxDCImpl::DoGetClippingRect() we need to store coordinates
in device units because such units are used internally in wxDCImpl
(2bcc9382a7 ("Store clipping box coordinates in device units for generic
wxDC", 2021-07-26).
Stored device units are converted to the current logical units
in wxDCImpl::DoGetClippingRect().
This commit is contained in:
Artur Wieczorek
2021-07-26 23:19:23 +02:00
parent 2bcc9382a7
commit 95f1b262a4
2 changed files with 6 additions and 7 deletions

View File

@@ -619,7 +619,7 @@ void wxGTKDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCo
wxASSERT_MSG( width >= 0 && height >= 0,
"Clipping box size values cannot be negative" );
wxRect newRegion(x, y, width, height);
wxRect newRegion(LogicalToDevice(x, y), LogicalToDeviceRel(width, height));
wxRect clipRegion;
if ( m_clipping )
@@ -635,8 +635,7 @@ void wxGTKDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCo
// of required clipping box and DC surface.
int dcWidth, dcHeight;
DoGetSize(&dcWidth, &dcHeight);
wxRect dcRect(DeviceToLogicalX(0), DeviceToLogicalY(0),
DeviceToLogicalXRel(dcWidth), DeviceToLogicalYRel(dcHeight));
wxRect dcRect(0, 0, dcWidth, dcHeight);
clipRegion = dcRect.Intersect(newRegion);
m_clipping = true;

View File

@@ -1919,10 +1919,10 @@ void wxWindowDCImpl::UpdateClipBox()
}
else
{
m_clipX1 = DeviceToLogicalX(r.GetLeft());
m_clipY1 = DeviceToLogicalY(r.GetTop());
m_clipX2 = m_clipX1 + DeviceToLogicalXRel(r.GetWidth());
m_clipY2 = m_clipY1 + DeviceToLogicalYRel(r.GetHeight());
m_clipX1 = r.GetLeft();
m_clipY1 = r.GetTop();
m_clipX2 = r.GetRight() + 1;
m_clipY2 = r.GetBottom() + 1;
}
m_isClipBoxValid = true;
}