fix for the previous commit

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18739 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-01-15 00:54:46 +00:00
parent 747798efb8
commit b826684e26

View File

@@ -76,10 +76,15 @@ wxSize wxStaticText::DoGetBestSize() const
int widthTextMax = 0, widthLine, int widthTextMax = 0, widthLine,
heightTextTotal = 0, heightLineDefault = 0, heightLine = 0; heightTextTotal = 0, heightLineDefault = 0, heightLine = 0;
bool lastWasAmpersand = FALSE;
wxString curLine; wxString curLine;
for ( const wxChar *pc = text; ; pc++ ) { for ( const wxChar *pc = text; ; pc++ )
if ( *pc == wxT('\n') || *pc == wxT('\0') ) { {
if ( !curLine ) { if ( *pc == wxT('\n') || *pc == wxT('\0') )
{
if ( !curLine )
{
// we can't use GetTextExtent - it will return 0 for both width // we can't use GetTextExtent - it will return 0 for both width
// and height and an empty line should count in height // and height and an empty line should count in height
// calculation // calculation
@@ -90,25 +95,44 @@ wxSize wxStaticText::DoGetBestSize() const
heightTextTotal += heightLineDefault; heightTextTotal += heightLineDefault;
} }
else { else
{
GetTextExtent(curLine, &widthLine, &heightLine); GetTextExtent(curLine, &widthLine, &heightLine);
if ( widthLine > widthTextMax ) if ( widthLine > widthTextMax )
widthTextMax = widthLine; widthTextMax = widthLine;
heightTextTotal += heightLine; heightTextTotal += heightLine;
} }
if ( *pc == wxT('\n') ) { if ( *pc == wxT('\n') )
{
curLine.Empty(); curLine.Empty();
} }
else { else
{
// the end of string // the end of string
break; break;
} }
} }
else { else
// we shouldn't take into account the '&' which just introduce the {
// mnemonic characters and so are not shown on the screen // we shouldn't take into account the '&' which just introduces the
if ( pc != _T('&') ) // 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; curLine += *pc;
} }
} }