From: Vadim Zeitlin Date: Wed, 15 Jan 2003 00:54:46 +0000 (+0000) Subject: fix for the previous commit X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/b826684e26da261f9da490a28c48658938b5fdd2?ds=inline fix for the previous commit git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18739 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index 14c62eca20..e34b055958 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -76,10 +76,15 @@ wxSize wxStaticText::DoGetBestSize() const int widthTextMax = 0, widthLine, heightTextTotal = 0, heightLineDefault = 0, heightLine = 0; + bool lastWasAmpersand = FALSE; + wxString curLine; - for ( const wxChar *pc = text; ; pc++ ) { - if ( *pc == wxT('\n') || *pc == wxT('\0') ) { - if ( !curLine ) { + for ( const wxChar *pc = text; ; pc++ ) + { + if ( *pc == wxT('\n') || *pc == wxT('\0') ) + { + if ( !curLine ) + { // we can't use GetTextExtent - it will return 0 for both width // and height and an empty line should count in height // calculation @@ -90,26 +95,45 @@ wxSize wxStaticText::DoGetBestSize() const heightTextTotal += heightLineDefault; } - else { + else + { GetTextExtent(curLine, &widthLine, &heightLine); if ( widthLine > widthTextMax ) widthTextMax = widthLine; heightTextTotal += heightLine; } - if ( *pc == wxT('\n') ) { + if ( *pc == wxT('\n') ) + { curLine.Empty(); } - else { + else + { // the end of string break; } } - else { - // we shouldn't take into account the '&' which just introduce the - // mnemonic characters and so are not shown on the screen - if ( pc != _T('&') ) - curLine += *pc; + else + { + // we shouldn't take into account the '&' which just introduces the + // mnemonic characters and so are not shown on the screen -- except + // when it is preceded by another '&' in which case it stands for a + // literal ampersand + if ( *pc == _T('&') ) + { + if ( !lastWasAmpersand ) + { + lastWasAmpersand = TRUE; + + // skip the statement adding pc to curLine below + continue; + } + + // it is a literal ampersand + lastWasAmpersand = FALSE; + } + + curLine += *pc; } }