Make GetClippingBox() work for wxPrinterDC in wxGTK.
GetClippingBox() implementation relies on wxDCImpl::m_clip[XY][12] being updated in DoSetClippingRegion() but this wasn't done here. Fix this by adding the code to do this to the base class version of this method and calling it from wxGtkPrinterDCImpl. Also, refactor wxGCDCImpl to reuse the same code instead of duplicating it. Closes #14697. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72674 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
4d604ad397
commit
332afcdb2f
@ -433,8 +433,12 @@ public:
|
||||
|
||||
// clipping
|
||||
|
||||
// Note that this pure virtual method has an implementation that updates
|
||||
// the values returned by DoGetClippingBox() and so can be called from the
|
||||
// derived class overridden version if it makes sense (i.e. if the clipping
|
||||
// box coordinates are not already updated in some other way).
|
||||
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
|
||||
wxCoord width, wxCoord height) = 0;
|
||||
wxCoord w, wxCoord h) = 0;
|
||||
|
||||
// NB: this function works with device coordinates, not the logical ones!
|
||||
virtual void DoSetDeviceClippingRegion(const wxRegion& region) = 0;
|
||||
|
@ -367,6 +367,30 @@ wxDCImpl::~wxDCImpl()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// clipping
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
|
||||
{
|
||||
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) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_clipping = true;
|
||||
|
||||
m_clipX1 = x;
|
||||
m_clipY1 = y;
|
||||
m_clipX2 = x + w;
|
||||
m_clipY2 = y + h;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// coordinate conversions and transforms
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -289,22 +289,8 @@ void wxGCDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord w, wxCoord h
|
||||
wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoSetClippingRegion - invalid DC") );
|
||||
|
||||
m_graphicContext->Clip( x, y, w, h );
|
||||
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) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_clipping = true;
|
||||
|
||||
m_clipX1 = x;
|
||||
m_clipY1 = y;
|
||||
m_clipX2 = x + w;
|
||||
m_clipY2 = y + h;
|
||||
}
|
||||
wxDCImpl::DoSetClippingRegion(x, y, w, h);
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoSetDeviceClippingRegion( const wxRegion ®ion )
|
||||
|
@ -2072,6 +2072,8 @@ void wxGtkPrinterDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width
|
||||
{
|
||||
cairo_rectangle ( m_cairo, XLOG2DEV(x), YLOG2DEV(y), XLOG2DEVREL(width), YLOG2DEVREL(height));
|
||||
cairo_clip(m_cairo);
|
||||
|
||||
wxDCImpl::DoSetClippingRegion(x, y, width, height);
|
||||
}
|
||||
|
||||
void wxGtkPrinterDCImpl::DestroyClippingRegion()
|
||||
|
Loading…
Reference in New Issue
Block a user