Fixed setting clipping box.
While setting a clipping box there is necessary to intersect it either with current clipping region location if such region exists or with wxDC surface extents if no clipping region is set. This way effective clipping box will be always inside the wxDC surface. Note: Effective clipping box can be an empty region. See #17013
This commit is contained in:
@@ -368,21 +368,41 @@ wxDCImpl::~wxDCImpl()
|
||||
|
||||
void wxDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
|
||||
{
|
||||
wxASSERT_MSG( w >= 0 && h >= 0,
|
||||
wxS("Clipping box size values cannot be negative") );
|
||||
|
||||
wxRect newRegion(x, y, w, h);
|
||||
|
||||
wxRect clipRegion;
|
||||
if ( m_clipping )
|
||||
{
|
||||
m_clipX1 = wxMax( m_clipX1, x );
|
||||
m_clipY1 = wxMax( m_clipY1, y );
|
||||
m_clipX2 = wxMin( m_clipX2, (x + w) );
|
||||
m_clipY2 = wxMin( m_clipY2, (y + h) );
|
||||
// New clipping box is an intersection
|
||||
// of required clipping box and the current one.
|
||||
wxRect curRegion(m_clipX1, m_clipY1, m_clipX2 - m_clipX1, m_clipY2 - m_clipY1);
|
||||
clipRegion = curRegion.Intersect(newRegion);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_clipping = true;
|
||||
// Effective clipping box is an intersection
|
||||
// of required clipping box and DC surface.
|
||||
int dcWidth, dcHeight;
|
||||
DoGetSize(&dcWidth, &dcHeight);
|
||||
wxRect dcRect(wxSize(dcWidth, dcHeight));
|
||||
clipRegion = dcRect.Intersect(newRegion);
|
||||
|
||||
m_clipX1 = x;
|
||||
m_clipY1 = y;
|
||||
m_clipX2 = x + w;
|
||||
m_clipY2 = y + h;
|
||||
m_clipping = true;
|
||||
}
|
||||
|
||||
if ( clipRegion.IsEmpty() )
|
||||
{
|
||||
m_clipX1 = m_clipY1 = m_clipX2 = m_clipY2 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_clipX1 = clipRegion.GetLeftTop().x;
|
||||
m_clipY1 = clipRegion.GetLeftTop().y;
|
||||
m_clipX2 = clipRegion.GetBottomRight().x + 1;
|
||||
m_clipY2 = clipRegion.GetBottomRight().y + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user