comctl32/listview: Fix selection and focus rectangles on reordered list (report mode)

Nikolay Sivov bunglehead at gmail.com
Wed Jul 8 19:49:58 CDT 2009


Next step fixing http://bugs.winehq.org/show_bug.cgi?id=3231.

Changelog:
    - Fix selection and focus rectangles on reordered list (report mode)

>From 789bf724e12895ca359e70c091cbc00702528fe3 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Thu, 9 Jul 2009 02:58:11 +0400
Subject: Fix selection and focus rectangles on reordered list (report mode)

---
 dlls/comctl32/listview.c |   59 ++++++++++++++++++++++++++++++---------------
 1 files changed, 39 insertions(+), 20 deletions(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index cd1d0d5..3e2153a 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -4120,6 +4120,45 @@ static BOOL LISTVIEW_DrawItem(LISTVIEW_INFO *infoPtr, HDC hdc, INT nItem, INT nS
     if (nSubItem && infoPtr->uView == LV_VIEW_DETAILS && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT))
 	nmlvcd.clrTextBk = CLR_NONE;
 
+    /* FIXME: temporary hack */
+    rcSelect.left = rcLabel.left;
+
+    /* draw the selection background, if we're drawing the main item */
+    if (nSubItem == 0)
+    {
+        /* in icon mode, the label rect is really what we want to draw the
+         * background for */
+        if (infoPtr->uView == LV_VIEW_ICON)
+	    rcSelect = rcLabel;
+
+	if (infoPtr->uView == LV_VIEW_DETAILS && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT))
+	{
+	    /* we have to update left focus bound too if item isn't in leftmost column
+	       and reduce right box bound */
+	    if (DPA_GetPtrCount(infoPtr->hdpaColumns) > 0)
+	    {
+		INT leftmost;
+
+	        if ((leftmost = SendMessageW(infoPtr->hwndHeader, HDM_ORDERTOINDEX, 0, 0)))
+	        {
+		    INT Originx = pos.x - LISTVIEW_GetColumnInfo(infoPtr, 0)->rcHeader.left;
+		    INT index = SendMessageW(infoPtr->hwndHeader, HDM_ORDERTOINDEX,
+				DPA_GetPtrCount(infoPtr->hdpaColumns) - 1, 0);
+
+		    rcBox.right   = LISTVIEW_GetColumnInfo(infoPtr, index)->rcHeader.right + Originx;
+		    rcSelect.left = LISTVIEW_GetColumnInfo(infoPtr, leftmost)->rcHeader.left + Originx;
+	        }
+	    }
+
+	    rcSelect.right = rcBox.right;
+	}
+
+	if (nmlvcd.clrTextBk != CLR_NONE) 
+	    ExtTextOutW(hdc, rcSelect.left, rcSelect.top, ETO_OPAQUE, &rcSelect, NULL, 0, NULL);
+	/* store new focus rectangle */
+	if (infoPtr->nFocusedItem == nItem) infoPtr->rcFocus = rcSelect;
+    }
+
     /* state icons */
     if (infoPtr->himlState && STATEIMAGEINDEX(lvItem.state) && (nSubItem == 0))
     {
@@ -4144,26 +4183,6 @@ static BOOL LISTVIEW_DrawItem(LISTVIEW_INFO *infoPtr, HDC hdc, INT nItem, INT nS
 
     /* Don't bother painting item being edited */
     if (infoPtr->hwndEdit && nItem == infoPtr->nEditLabelItem && nSubItem == 0) goto postpaint;
-
-    /* FIXME: temporary hack */
-    rcSelect.left = rcLabel.left;
-
-    /* draw the selection background, if we're drawing the main item */
-    if (nSubItem == 0)
-    {
-        /* in icon mode, the label rect is really what we want to draw the
-         * background for */
-        if (infoPtr->uView == LV_VIEW_ICON)
-	    rcSelect = rcLabel;
-
-	if (infoPtr->uView == LV_VIEW_DETAILS && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT))
-	    rcSelect.right = rcBox.right;
-
-    	if (nmlvcd.clrTextBk != CLR_NONE) 
-            ExtTextOutW(hdc, rcSelect.left, rcSelect.top, ETO_OPAQUE, &rcSelect, 0, 0, 0);
-	/* store new focus rectangle */
-	if (infoPtr->nFocusedItem == nItem) infoPtr->rcFocus = rcSelect;
-    }
    
     /* figure out the text drawing flags */
     uFormat = (infoPtr->uView == LV_VIEW_ICON ? (lprcFocus ? LV_FL_DT_FLAGS : LV_ML_DT_FLAGS) : LV_SL_DT_FLAGS);
-- 
1.5.6.5





More information about the wine-patches mailing list