Fix clipping which resulted in not showing wxGrid editor in wxOSX

Fix clipping for the windows not showing scrollbars.

This commit is best viewed ignoring whitespace-only changes.

Closes #24201.

Closes #24342.
This commit is contained in:
Stefan Csomor 2024-02-21 20:12:13 +01:00 committed by Vadim Zeitlin
parent 5ca49dc56c
commit 6e7bbfd17c
2 changed files with 46 additions and 39 deletions

View file

@ -4079,16 +4079,23 @@ void wxWidgetCocoaImpl::AdjustClippingView(wxScrollBar* horizontal, wxScrollBar*
void wxWidgetCocoaImpl::UseClippingView()
{
wxWindow* peer = m_wxPeer;
if ( peer && m_osxClipView == nil)
// starting from Sonoma child windows are bleeding through under the scrollbar
// use native scrollviews therefore
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_14_0
if ( WX_IS_MACOS_AVAILABLE(14, 0) )
{
m_osxClipView = [[wxNSClipView alloc] initWithFrame: m_osxView.bounds];
[(NSClipView*)m_osxClipView setDrawsBackground: NO];
[m_osxView addSubview:m_osxClipView];
wxWindow* peer = m_wxPeer;
// TODO check for additional subwindows which might have to be moved to the clip view ?
if ( peer && m_osxClipView == nil)
{
m_osxClipView = [[wxNSClipView alloc] initWithFrame: m_osxView.bounds];
[(NSClipView*)m_osxClipView setDrawsBackground: NO];
[m_osxView addSubview:m_osxClipView];
// TODO check for additional subwindows which might have to be moved to the clip view ?
}
}
#endif
}

View file

@ -2112,40 +2112,40 @@ bool wxWindowMac::MacIsChildOfClientArea( const wxWindow* child ) const
void wxWindowMac::MacRepositionScrollBars()
{
#if wxUSE_SCROLLBAR
if ( !m_hScrollBar && !m_vScrollBar )
return ;
int scrlsize = m_hScrollBar ? m_hScrollBar->GetSize().y : ( m_vScrollBar ? m_vScrollBar->GetSize().x : MAC_SCROLLBAR_SIZE ) ;
int adjust = MacHasScrollBarCorner() ? scrlsize - 1 : 0 ;
// get real client area
int width, height ;
GetSize( &width , &height );
width -= MacGetLeftBorderSize() + MacGetRightBorderSize();
height -= MacGetTopBorderSize() + MacGetBottomBorderSize();
wxPoint vPoint( width - scrlsize, 0 ) ;
wxSize vSize( scrlsize, height - adjust ) ;
wxPoint hPoint( 0 , height - scrlsize ) ;
wxSize hSize( width - adjust, scrlsize ) ;
if ( m_vScrollBar )
m_vScrollBar->SetSize( vPoint.x , vPoint.y, vSize.x, vSize.y , wxSIZE_ALLOW_MINUS_ONE );
if ( m_hScrollBar )
m_hScrollBar->SetSize( hPoint.x , hPoint.y, hSize.x, hSize.y, wxSIZE_ALLOW_MINUS_ONE );
if ( m_growBox )
if ( m_hScrollBar || m_vScrollBar )
{
if ( MacHasScrollBarCorner() )
int scrlsize = m_hScrollBar ? m_hScrollBar->GetSize().y : ( m_vScrollBar ? m_vScrollBar->GetSize().x : MAC_SCROLLBAR_SIZE ) ;
int adjust = MacHasScrollBarCorner() ? scrlsize - 1 : 0 ;
// get real client area
int width, height ;
GetSize( &width , &height );
width -= MacGetLeftBorderSize() + MacGetRightBorderSize();
height -= MacGetTopBorderSize() + MacGetBottomBorderSize();
wxPoint vPoint( width - scrlsize, 0 ) ;
wxSize vSize( scrlsize, height - adjust ) ;
wxPoint hPoint( 0 , height - scrlsize ) ;
wxSize hSize( width - adjust, scrlsize ) ;
if ( m_vScrollBar )
m_vScrollBar->SetSize( vPoint.x , vPoint.y, vSize.x, vSize.y , wxSIZE_ALLOW_MINUS_ONE );
if ( m_hScrollBar )
m_hScrollBar->SetSize( hPoint.x , hPoint.y, hSize.x, hSize.y, wxSIZE_ALLOW_MINUS_ONE );
if ( m_growBox )
{
m_growBox->SetSize( width - scrlsize, height - scrlsize, wxDefaultCoord, wxDefaultCoord, wxSIZE_USE_EXISTING );
if ( !m_growBox->IsShown() )
m_growBox->Show();
}
else
{
if ( m_growBox->IsShown() )
m_growBox->Hide();
if ( MacHasScrollBarCorner() )
{
m_growBox->SetSize( width - scrlsize, height - scrlsize, wxDefaultCoord, wxDefaultCoord, wxSIZE_USE_EXISTING );
if ( !m_growBox->IsShown() )
m_growBox->Show();
}
else
{
if ( m_growBox->IsShown() )
m_growBox->Hide();
}
}
}
m_peer->AdjustClippingView(m_hScrollBar, m_vScrollBar);