]> git.saurik.com Git - wxWidgets.git/commitdiff
fix for the previous commit
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 15 Jan 2003 00:54:46 +0000 (00:54 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 15 Jan 2003 00:54:46 +0000 (00:54 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18739 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/stattext.cpp

index 14c62eca20a3ace748db6d4b6b2287294e3f1f64..e34b05595891e3ba478ddabe94932ce309f03f39 100644 (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;
         }
     }