From 51e7994cff68d98ed1f027b441f90d16db05caa0 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 6 Sep 2017 09:54:35 +0200 Subject: [PATCH] Adding Borders and Multi-Line calculations also when native best size is available Otherwise wxTE_MULTILINE are getting a tiny one-line minimal size, and the border as to be added as well. --- src/osx/textctrl_osx.cpp | 47 +++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/src/osx/textctrl_osx.cpp b/src/osx/textctrl_osx.cpp index d9fa0f4c4c..8b60ba0fa0 100644 --- a/src/osx/textctrl_osx.cpp +++ b/src/osx/textctrl_osx.cpp @@ -194,36 +194,43 @@ bool wxTextCtrl::AcceptsFocus() const wxSize wxTextCtrl::DoGetBestSize() const { + int wText = -1; + int hText = -1; + if (GetTextPeer()) { wxSize size = GetTextPeer()->GetBestSize(); if (size.x > 0 && size.y > 0) - return size; + { + hText = size.y; + wText = size.x; + } } - int wText, hText; - - // these are the numbers from the HIG: - // we reduce them by the borders first - wText = 100 ; - - switch ( m_windowVariant ) + if ( hText == - 1) { - case wxWINDOW_VARIANT_NORMAL : - hText = 22 - 6 ; - break ; + // these are the numbers from the HIG: + // we reduce them by the borders first + wText = 100 ; - case wxWINDOW_VARIANT_SMALL : - hText = 19 - 6 ; - break ; + switch ( m_windowVariant ) + { + case wxWINDOW_VARIANT_NORMAL : + hText = 22 - 6 ; + break ; - case wxWINDOW_VARIANT_MINI : - hText = 15 - 6 ; - break ; + case wxWINDOW_VARIANT_SMALL : + hText = 19 - 6 ; + break ; - default : - hText = 22 - 6; - break ; + case wxWINDOW_VARIANT_MINI : + hText = 15 - 6 ; + break ; + + default : + hText = 22 - 6; + break ; + } } // as the above numbers have some free space around the text