]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/ctrlcmn.cpp
fixing infinite recursion for rotated text, introduced in cleanup r57915
[wxWidgets.git] / src / common / ctrlcmn.cpp
index 9928f77c2911d664a0d91c0133fdd0edee2c00cd..8cb01a3adb253be0c0b5fdc94ad2a85257e01f6d 100644 (file)
@@ -29,6 +29,7 @@
 #include "wx/control.h"
 
 #ifndef WX_PRECOMP
 #include "wx/control.h"
 
 #ifndef WX_PRECOMP
+    #include "wx/dc.h"
     #include "wx/log.h"
     #include "wx/radiobut.h"
     #include "wx/statbmp.h"
     #include "wx/log.h"
     #include "wx/radiobut.h"
     #include "wx/statbmp.h"
@@ -158,6 +159,14 @@ wxString wxControlBase::RemoveMnemonics(const wxString& str)
     return wxStripMenuCodes(str, wxStrip_Mnemonics);
 }
 
     return wxStripMenuCodes(str, wxStrip_Mnemonics);
 }
 
+/* static */
+wxString wxControlBase::EscapeMnemonics(const wxString& text)
+{
+    wxString label(text);
+    label.Replace("&", "&&");
+    return label;
+}
+
 /* static */
 int wxControlBase::FindAccelIndex(const wxString& label, wxString *labelOnly)
 {
 /* static */
 int wxControlBase::FindAccelIndex(const wxString& label, wxString *labelOnly)
 {
@@ -241,7 +250,7 @@ wxString wxControlBase::Ellipsize(const wxString& label, const wxDC& dc,
                     // remove characters in excess
                     size_t initialChar,     // index of first char to erase
                            nChars;          // how many chars do we need to erase?
                     // remove characters in excess
                     size_t initialChar,     // index of first char to erase
                            nChars;          // how many chars do we need to erase?
-                    if (mode == wxST_ELLIPSIZE_START)
+                    if (mode == wxELLIPSIZE_START)
                     {
                         initialChar = 0;
                         for (nChars=0;
                     {
                         initialChar = 0;
                         for (nChars=0;
@@ -249,7 +258,7 @@ wxString wxControlBase::Ellipsize(const wxString& label, const wxDC& dc,
                              nChars++)
                             ;
                     }
                              nChars++)
                             ;
                     }
-                    else if (mode == wxST_ELLIPSIZE_MIDDLE)
+                    else if (mode == wxELLIPSIZE_MIDDLE)
                     {
                         // the start & end of the removed span of chars
                         initialChar = len/2;
                     {
                         // the start & end of the removed span of chars
                         initialChar = len/2;
@@ -293,7 +302,7 @@ wxString wxControlBase::Ellipsize(const wxString& label, const wxDC& dc,
                     }
                     else
                     {
                     }
                     else
                     {
-                        wxASSERT(mode == wxST_ELLIPSIZE_END);
+                        wxASSERT(mode == wxELLIPSIZE_END);
                         wxASSERT(len > 0);
 
                         int maxWidth = totalWidth - excessPixels;
                         wxASSERT(len > 0);
 
                         int maxWidth = totalWidth - excessPixels;
@@ -330,7 +339,7 @@ wxString wxControlBase::Ellipsize(const wxString& label, const wxDC& dc,
                     }
 
                     // if everything was ok, we should have shortened this line
                     }
 
                     // if everything was ok, we should have shortened this line
-                    // enough to make it fit in sz.maxFinalWidth:
+                    // enough to make it fit in maxFinalWidth:
                     wxASSERT(dc.GetTextExtent(curLine).GetWidth() < maxFinalWidth);
                 }
             }
                     wxASSERT(dc.GetTextExtent(curLine).GetWidth() < maxFinalWidth);
                 }
             }
@@ -339,6 +348,7 @@ wxString wxControlBase::Ellipsize(const wxString& label, const wxDC& dc,
             ret << curLine;
             if ( pc == label.end() )
             {
             ret << curLine;
             if ( pc == label.end() )
             {
+                // NOTE: this is the return which always exits the function
                 return ret;
             }
             else
                 return ret;
             }
             else
@@ -368,7 +378,10 @@ wxString wxControlBase::Ellipsize(const wxString& label, const wxDC& dc,
         }
     }
 
         }
     }
 
-    return ret;
+    // this return would generate a
+    //  warning C4702: unreachable code
+    // with MSVC since the function always exits from inside the loop
+    //return ret;
 }
 
 wxBorder wxControlBase::GetDefaultBorder() const
 }
 
 wxBorder wxControlBase::GetDefaultBorder() const