From b91dd98ff1b69ad06bc4bdfb98daeb04e5f68044 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Tue, 27 May 2008 14:14:11 +0000 Subject: [PATCH] make sure we add the correct wx-border pixels to native controls when calculating best size git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@53782 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/window.cpp | 67 +++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index f15a77fcad..a64cad9db8 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -2055,41 +2055,46 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) wxSize wxWindowMac::DoGetBestSize() const { if ( m_peer == NULL || m_macIsUserPane || IsTopLevel() ) - return wxWindowBase::DoGetBestSize() ; - - Rect bestsize = { 0 , 0 , 0 , 0 } ; - int bestWidth, bestHeight ; - - m_peer->GetBestRect( &bestsize ) ; - if ( EmptyRect( &bestsize ) ) { - bestsize.left = - bestsize.top = 0 ; - bestsize.right = - bestsize.bottom = 16 ; - - if ( IsKindOf( CLASSINFO( wxScrollBar ) ) ) - { - bestsize.bottom = 16 ; - } -#if wxUSE_SPINBTN - else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) ) - { - bestsize.bottom = 24 ; - } -#endif - else - { - // return wxWindowBase::DoGetBestSize() ; - } + return wxWindowBase::DoGetBestSize() ; } + else + { + Rect bestsize = { 0 , 0 , 0 , 0 } ; + int bestWidth, bestHeight ; - bestWidth = bestsize.right - bestsize.left ; - bestHeight = bestsize.bottom - bestsize.top ; - if ( bestHeight < 10 ) - bestHeight = 13 ; + m_peer->GetBestRect( &bestsize ) ; + if ( EmptyRect( &bestsize ) ) + { + bestsize.left = + bestsize.top = 0 ; + bestsize.right = + bestsize.bottom = 16 ; - return wxSize(bestWidth, bestHeight); + if ( IsKindOf( CLASSINFO( wxScrollBar ) ) ) + { + bestsize.bottom = 16 ; + } + #if wxUSE_SPINBTN + else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) ) + { + bestsize.bottom = 24 ; + } + #endif + else + { + // return wxWindowBase::DoGetBestSize() ; + } + } + // wx-borders are being drawn outside the native control + bestWidth = bestsize.right - bestsize.left + MacGetLeftBorderSize() + + MacGetRightBorderSize(); + bestHeight = bestsize.bottom - bestsize.top + MacGetTopBorderSize() + + MacGetBottomBorderSize(); + if ( bestHeight < 10 ) + bestHeight = 13 ; + return wxSize(bestWidth, bestHeight); + } } // set the size of the window: if the dimensions are positive, just use them,