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:
Václav Slavík
2003-03-27 23:21:47 +00:00
parent 427ff66291
commit 5175dbbd9f

View File

@@ -1808,13 +1808,17 @@ void wxListLineData::DrawTextFormatted(wxDC *dc,
dc->GetTextExtent(ellipsis, &base_w, &h);
// continue until we have enough space or only one character left
drawntext = text.Left(text.Length() - 1);
while (drawntext.Length() > 1)
wxCoord w_c, h_c;
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)
break;
drawntext = drawntext.Left(drawntext.Length() - 1);
}
// if still not enough space, remove ellipsis characters