Don't shorten text too much in wxControl::Ellipsize().

If the allowed width is so small that nothing reasonable can fit it,
overlap it. Ellipsized text must always contain "..." to indicate that
it was shortened, it isn't acceptable to omit it.

See #11360.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66872 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2011-02-09 19:52:10 +00:00
parent d6ebae9a94
commit 508fc76d0c
2 changed files with 6 additions and 19 deletions

View File

@@ -397,20 +397,7 @@ wxString wxControlBase::DoEllipsizeSingleLine(const wxString& curLine, const wxD
wxString ret(curLine);
ret.erase(initialCharToRemove, nCharsToRemove);
int removedPx;
if (initialCharToRemove >= 1)
removedPx = charOffsetsPx[initialCharToRemove+nCharsToRemove-1] - charOffsetsPx[initialCharToRemove-1];
else
removedPx = charOffsetsPx[initialCharToRemove+nCharsToRemove-1];
wxASSERT(removedPx >= excessPx);
// if there is space for the replacement dots, add them
if ((int)totalWidthPx-removedPx+replacementWidthPx <= maxFinalWidthPx)
ret.insert(initialCharToRemove, wxELLIPSE_REPLACEMENT);
// if everything was ok, we should have shortened this line
// enough to make it fit in maxFinalWidthPx:
wxASSERT(dc.GetTextExtent(ret).GetWidth() <= maxFinalWidthPx);
ret.insert(initialCharToRemove, wxELLIPSE_REPLACEMENT);
return ret;
}