Excessive clipping of text in listview
Dimitrie O. Paun
dimi at cs.toronto.edu
Fri Jan 25 12:45:12 CST 2002
On Fri, 25 Jan 2002, Medland, Bill wrote:
> p.s. what is going on in DrawLargeItem with the ellipsification; it looks
> like it ellipsifies it and then throws the result away.
Bill,
Can you try the attached (uncompiled, untested) patch? It simplifies the
code quite a bit IMO. BTW, the previous code did not throw away the
ellipsification since szDispText == lvItem.pszText.
--
Dimi.
-------------- next part --------------
--- listview.c.orig Fri Jan 25 13:19:48 2002
+++ listview.c Fri Jan 25 13:40:13 2002
@@ -3187,22 +3187,16 @@
rcWidth = max(0, rcItem.right - rcItem.left);
if (nLabelWidth > rcWidth)
{
- INT i, len, eos, nCharsFit;
/* give or take a couple, how many average sized chars would fit? */
- nCharsFit = tm.tmAveCharWidth > 0 ? (rcWidth/tm.tmAveCharWidth)+2 : 0;
- /* place the ellipse accordingly, without overrunning the buffer */
- len = strlenW(szDispText);
- eos = min((nCharsFit > 1 && nCharsFit < len) ? nCharsFit+3 : len+2,
- sizeof(szDispText)/sizeof(WCHAR)-1);
-
- nLabelWidth = ListView_GetStringWidthW(hwnd, szDispText);
- while ((nLabelWidth > rcWidth) && (eos > 3))
+ INT nCharsFit = tm.tmAveCharWidth > 0 ? rcWidth/tm.tmAveCharWidth+2 : 0;
+ INT eos = min(strlenW(lvItem.pszText), hCharsFit)
+ if (eos > 0) lvItem.pszText[eos-1] = '.';
+ if (eos > 1) lvItem.pszText[eos-2] = '.';
+ for ( ; eos > 2; eos--)
{
- for (i = 1; i < 4; i++)
- szDispText[eos-i] = '.';
- /* shift the ellipse one char to the left for each iteration */
- szDispText[eos--] = '\0';
- nLabelWidth = ListView_GetStringWidthW(hwnd, szDispText);
+ lvItem.pszText[eos - 3] = '.';
+ lvItem.pszText[eos] = '\0';
+ if (ListView_GetStringWidthW(hwnd, lvItem.pszText) <= rcWidth) break;
}
}
More information about the wine-devel
mailing list