diff --git a/include/wx/osx/textctrl.h b/include/wx/osx/textctrl.h index 96ee937dc1..4afe69def4 100644 --- a/include/wx/osx/textctrl.h +++ b/include/wx/osx/textctrl.h @@ -139,6 +139,7 @@ protected: void Init(); virtual wxSize DoGetBestSize() const wxOVERRIDE; + virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen) const wxOVERRIDE; // flag is set to true when the user edits the controls contents bool m_dirty; diff --git a/src/osx/textctrl_osx.cpp b/src/osx/textctrl_osx.cpp index 8fd8201d26..a6da73bb9c 100644 --- a/src/osx/textctrl_osx.cpp +++ b/src/osx/textctrl_osx.cpp @@ -206,19 +206,19 @@ wxSize wxTextCtrl::DoGetBestSize() const switch ( m_windowVariant ) { case wxWINDOW_VARIANT_NORMAL : - hText = 22 - 6 ; + hText = 22 - 5 ; break ; case wxWINDOW_VARIANT_SMALL : - hText = 19 - 6 ; + hText = 19 - 5 ; break ; case wxWINDOW_VARIANT_MINI : - hText = 15 - 6 ; + hText = 15 - 5 ; break ; default : - hText = 22 - 6; + hText = 22 - 5; break ; } } @@ -229,11 +229,19 @@ wxSize wxTextCtrl::DoGetBestSize() const hText *= 5 ; if ( !HasFlag(wxNO_BORDER) ) - hText += 6 ; + hText += 5 ; return wxSize(wText, hText); } +wxSize wxTextCtrl::DoGetSizeFromTextSize(int xlen, int ylen) const +{ + wxSize size = wxDefaultSize; + if (xlen > 0) size.SetWidth(HasFlag(wxNO_BORDER) ? xlen + 4 : xlen + 9); + if (ylen > 0) size.SetHeight(HasFlag(wxNO_BORDER) ? ylen + 2 : ylen + 7); + return size; +} + bool wxTextCtrl::GetStyle(long position, wxTextAttr& style) { return GetTextPeer()->GetStyle(position, style);