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,
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;
}
}