Handle wxOSX-specific clipping in wxOSX wxWindowDC implementation

Instead of setting clipping for client area for wxOSX windows
with non-native borders in the common wxGCDC::DestroyClippingRegion()
we can encapsulate this operation in dedicated DestroyClippingRegion()
implementation in wxWindowDC.

See #19108.
See #22914.
This commit is contained in:
Artur Wieczorek 2022-10-25 10:50:40 +02:00
parent 7d3f776ec3
commit ee70221a0d
4 changed files with 21 additions and 5 deletions

View file

@ -228,7 +228,10 @@ protected:
wxGCDCImpl(wxDC* owner, int);
#ifdef __WXOSX__
#if WXWIN_COMPATIBILITY_3_2
wxDEPRECATED_MSG("Don't use OSXGetOrigin()")
virtual wxPoint OSXGetOrigin() const { return wxPoint(); }
#endif // WXWIN_COMPATIBILITY_3_2
#endif
// scaling variables

View file

@ -30,9 +30,13 @@ public:
virtual void DoGetSize( int *width, int *height ) const override;
virtual wxBitmap DoGetAsBitmap(const wxRect *subrect) const override;
virtual void DestroyClippingRegion() override;
protected:
#if WXWIN_COMPATIBILITY_3_2
wxDEPRECATED_MSG("Don't use OSXGetOrigin()")
virtual wxPoint OSXGetOrigin() const override;
#endif // WXWIN_COMPATIBILITY_3_2
bool m_release;
int m_width;

View file

@ -431,17 +431,15 @@ void wxGCDCImpl::DoSetDeviceClippingRegion( const wxRegion &region )
void wxGCDCImpl::DestroyClippingRegion()
{
m_graphicContext->ResetClip();
#ifndef __WXOSX__
// currently the clip eg of a window extends to the area between the scrollbars
// so we must explicitly make sure it only covers the area we want it to draw
int width, height ;
GetOwner()->GetSize( &width , &height ) ;
wxPoint origin;
#ifdef __WXOSX__
origin = OSXGetOrigin();
#endif
wxPoint clipOrig = DeviceToLogical(origin.x, origin.y);
wxPoint clipOrig = DeviceToLogical(0, 0);
wxSize clipDim = DeviceToLogicalRel(width, height);
m_graphicContext->Clip(clipOrig.x, clipOrig.y, clipDim.x, clipDim.y);
#endif // !__WXOSX__
m_graphicContext->SetPen( m_pen );
m_graphicContext->SetBrush( m_brush );

View file

@ -105,10 +105,21 @@ void wxWindowDCImpl::DoGetSize( int* width, int* height ) const
*height = m_height;
}
void wxWindowDCImpl::DestroyClippingRegion()
{
wxGCDCImpl::DestroyClippingRegion();
wxPoint clipPos = DeviceToLogical(m_origin.x, m_origin.y);
wxSize clipDim = DeviceToLogicalRel(m_width, m_height);
DoSetClippingRegion(clipPos.x, clipPos.y, clipDim.x, clipDim.y);
}
#if WXWIN_COMPATIBILITY_3_2
wxPoint wxWindowDCImpl::OSXGetOrigin() const
{
return m_origin;
}
#endif // WXWIN_COMPATIBILITY_3_2
/*
* wxClientDCImpl