Listview report mode tweaks #2

Duane Clark dclark at akamail.com
Fri Dec 20 12:02:54 CST 2002


This patches replaces my previous listview patch.

As pointed out by Dimitrie, the MS docs do specify that for 
LISTVIEW_GetSubItemRect, LVIR_LABEL and LVIR_BOUNDS should return the 
same values.

Testing on WinNT shows that for non-zero subitems, which are the only 
correct documented values, this is true. For subitem '0', WinNT just 
passes the call on to LISTVIEW_GetItemRect.

So the only fix to LISTVIEW_GetSubItemRect that remains is to change the 
offset that is applied. This is needed because the 
LISTVIEW_GetItemPosition call that is used returns a position that 
already includes the origin. This differs from what is returned by 
LISTVIEW_GetItemOrigin that is used in LISTVIEW_GetItemRect to get the 
item position.

Changelog:
	Report mode padding tweaks.
	Fix to LISTVIEW_GetSubItemRect.

-------------- next part --------------
Index: dlls/comctl32/listview.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/listview.c,v
retrieving revision 1.333
diff -u -r1.333 listview.c
--- dlls/comctl32/listview.c	10 Dec 2002 19:07:27 -0000	1.333
+++ dlls/comctl32/listview.c	20 Dec 2002 17:57:46 -0000
@@ -329,10 +329,10 @@
 #define LISTVIEW_SCROLL_ICON_LINE_SIZE 37
 
 /* Padding betwen image and label */
-#define IMAGE_PADDING  2
+#define IMAGE_PADDING  0
 
 /* Padding behind the label */
-#define TRAILING_PADDING  5
+#define TRAILING_PADDING  10
 
 /* Border for the icon caption */
 #define CAPTION_BORDER  2
@@ -1684,7 +1684,7 @@
     }
     else /* LVS_REPORT */
     {
-	lpptPosition->x = REPORT_MARGINX;
+	lpptPosition->x = 0;
 	lpptPosition->y = nItem * infoPtr->nItemHeight;
     }
 }
@@ -1788,9 +1788,9 @@
 	    State.left = Box.left;
 	    if (uView == LVS_REPORT) 
 	    {
-		State.left += REPORT_MARGINX;
 		if (lpLVItem->iSubItem == 0)
 		{
+		    State.left += REPORT_MARGINX;
 		    assert(lpLVItem->mask & LVIF_INDENT);
 		    State.left += infoPtr->iconSize.cx * lpLVItem->iIndent;
 		}
@@ -1853,7 +1853,6 @@
 	if (uView == LVS_REPORT)
 	{
 	    if (lpLVItem->iSubItem == 0) Label = lpColumnInfo->rcHeader;
-	    Label.right -= REPORT_MARGINX;
 	}
 
 	if (lpLVItem->iSubItem || ((infoPtr->dwStyle & LVS_OWNERDRAWFIXED) && uView == LVS_REPORT))
@@ -3556,7 +3555,12 @@
 	default:            uFormat |= DT_LEFT;
 	}
     }
-    if (!(uFormat & (DT_RIGHT | DT_CENTER))) rcLabel.left += 2;
+    if (!(uFormat & (DT_RIGHT | DT_CENTER)))
+    {
+        if (himl && lvItem.iImage >= 0 && !IsRectEmpty(&rcIcon)) rcLabel.left += 2;
+        else rcLabel.left += 5;
+    }
+    else if (uFormat & DT_RIGHT) rcLabel.right -= 5;
     DrawTextW(hdc, lvItem.pszText, -1, &rcLabel, uFormat);
 
 postpaint:
@@ -5204,14 +5208,16 @@
  */
 static BOOL LISTVIEW_GetSubItemRect(LISTVIEW_INFO *infoPtr, INT nItem, LPRECT lprc)
 {
-    POINT Position, Origin;
+    POINT Position;
     LVITEMW lvItem;
     
     if (!lprc || (infoPtr->dwStyle & LVS_TYPEMASK) != LVS_REPORT) return FALSE;
     
     TRACE("(nItem=%d, nSubItem=%d)\n", nItem, lprc->top);
+    /* On WinNT, a subitem of '0' calls LISTVIEW_GetItemRect */
+    if (lprc->top == 0)
+        return LISTVIEW_GetItemRect(infoPtr, nItem, lprc);
 
-    LISTVIEW_GetOrigin(infoPtr, &Origin);
     if (!LISTVIEW_GetItemPosition(infoPtr, nItem, &Position)) return FALSE;
 
     lvItem.mask = lprc->top == 0 ? LVIF_INDENT : 0;
@@ -5235,7 +5241,7 @@
 	return FALSE;
     }
 
-    OffsetRect(lprc, Position.x + Origin.x, Position.y + Origin.y);
+    OffsetRect(lprc, Position.x, Position.y);
     return TRUE;
 }
 
@@ -6307,7 +6313,7 @@
 		SIZE size;
 
 		if (GetTextExtentPoint32W(hdc, hdi.pszText, lstrlenW(hdi.pszText), &size))
-		    cx = size.cx;
+		    cx = size.cx + 11;
 		/* FIXME: Take into account the header image, if one is present */
 		SelectObject(hdc, old_font);
 		ReleaseDC(infoPtr->hwndSelf, hdc);


More information about the wine-patches mailing list