fixed DrawTextFormatted to work in O(n) instead of O(n^2) if the text doesn't fit into the column
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19842 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1808,13 +1808,17 @@ void wxListLineData::DrawTextFormatted(wxDC *dc,
|
|||||||
dc->GetTextExtent(ellipsis, &base_w, &h);
|
dc->GetTextExtent(ellipsis, &base_w, &h);
|
||||||
|
|
||||||
// continue until we have enough space or only one character left
|
// continue until we have enough space or only one character left
|
||||||
drawntext = text.Left(text.Length() - 1);
|
wxCoord w_c, h_c;
|
||||||
while (drawntext.Length() > 1)
|
size_t len = text.Length();
|
||||||
|
drawntext = text.Left(len);
|
||||||
|
while (len > 1)
|
||||||
{
|
{
|
||||||
dc->GetTextExtent(drawntext, &w, &h);
|
dc->GetTextExtent(drawntext.Last(), &w_c, &h_c);
|
||||||
|
drawntext.RemoveLast();
|
||||||
|
len--;
|
||||||
|
w -= w_c;
|
||||||
if (w + base_w <= width)
|
if (w + base_w <= width)
|
||||||
break;
|
break;
|
||||||
drawntext = drawntext.Left(drawntext.Length() - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if still not enough space, remove ellipsis characters
|
// if still not enough space, remove ellipsis characters
|
||||||
|
Reference in New Issue
Block a user