// Ellipsize() helper:
static wxString DoEllipsizeSingleLine(const wxString& label, const wxDC& dc,
wxEllipsizeMode mode, int maxWidth,
- int replacementWidth, int marginWidth);
+ int replacementWidth);
// this field contains the label in wx format, i.e. with '&' mnemonics,
// as it was passed to the last SetLabel() call
/* static and protected */
wxString wxControlBase::DoEllipsizeSingleLine(const wxString& curLine, const wxDC& dc,
wxEllipsizeMode mode, int maxFinalWidthPx,
- int replacementWidthPx, int marginWidthPx)
+ int replacementWidthPx)
{
- wxASSERT_MSG(replacementWidthPx > 0 && marginWidthPx > 0,
- "Invalid parameters");
+ wxASSERT_MSG(replacementWidthPx > 0, "Invalid parameters");
wxASSERT_LEVEL_2_MSG(!curLine.Contains('\n'),
"Use Ellipsize() instead!");
return curLine; // we don't need to do any ellipsization!
int excessPx = wxMin(totalWidthPx - maxFinalWidthPx +
- replacementWidthPx +
- marginWidthPx, // security margin
+ replacementWidthPx,
totalWidthPx);
wxASSERT(excessPx>0); // excessPx should be in the [1;totalWidthPx] range
wxASSERT(removedPx >= excessPx);
// if there is space for the replacement dots, add them
- if ((int)totalWidthPx-removedPx+replacementWidthPx < maxFinalWidthPx)
+ 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_LEVEL_2(dc.GetTextExtent(ret).GetWidth() <= maxFinalWidthPx);
+ wxASSERT(dc.GetTextExtent(ret).GetWidth() <= maxFinalWidthPx);
return ret;
}
// change because of e.g. a font change; however we calculate them only once
// when ellipsizing multiline labels:
int replacementWidth = dc.GetTextExtent(wxELLIPSE_REPLACEMENT).GetWidth();
- int marginWidth = dc.GetCharWidth();
// NB: we must handle correctly labels with newlines:
wxString curLine;
if ( pc == label.end() || *pc == wxS('\n') )
{
curLine = DoEllipsizeSingleLine(curLine, dc, mode, maxFinalWidth,
- replacementWidth, marginWidth);
+ replacementWidth);
// add this (ellipsized) row to the rest of the label
ret << curLine;