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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user