Account for first removal char with wxELLIPSIZE_MIDDLE.
authorVáclav Slavík <vslavik@fastmail.fm>
Mon, 31 Jan 2011 18:23:32 +0000 (18:23 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Mon, 31 Jan 2011 18:23:32 +0000 (18:23 +0000)
wxControl::Ellipsize() in wxELLIPSIZE_MIDDLE mode starts the
string-shortening loop with the removal interval initially set to remove
only the len/2-th character. But it didn't add its size to the running
total of removal characters' length, thus always removing one more
character. Fixed by making the initial interval 0-sized rather than
1-sized.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66823 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/ctrlcmn.cpp

index 398de36712118864ab9fa7525f3a52988f5f3b71..c1b4fa67a7e915c439adff0f1569738d53122ac5 100644 (file)
@@ -303,8 +303,8 @@ wxString wxControlBase::DoEllipsizeSingleLine(const wxString& curLine, const wxD
                 // - the second one to remove, valid range [initialCharToRemove;endCharToRemove]
                 // - the third one to preserve, valid range [endCharToRemove+1;len-1] or the empty range if endCharToRemove==len-1
                 // NOTE: empty range != range [0;0] since the range [0;0] contains 1 character (the zero-th one)!
-                initialCharToRemove = len/2;
-                size_t endCharToRemove = len/2;     // index of the last character to remove; valid range is [0;len-1]
+                initialCharToRemove = len/2; // index of the last character to remove; valid range is [0;len-1]
+                size_t endCharToRemove = initialCharToRemove - 1; // initial removal range is empty
 
                 int removedPx = 0;
                 bool removeFromStart = true;