comctl32/listview: Improve hittesting a bit.
This commit is contained in:
parent
c82da7d975
commit
84f14a3716
|
@ -6798,23 +6798,55 @@ static INT LISTVIEW_HitTest(const LISTVIEW_INFO *infoPtr, LPLVHITTESTINFO lpht,
|
||||||
lpht->iItem = -1;
|
lpht->iItem = -1;
|
||||||
if (subitem) lpht->iSubItem = 0;
|
if (subitem) lpht->iSubItem = 0;
|
||||||
|
|
||||||
if (infoPtr->rcList.left > lpht->pt.x)
|
LISTVIEW_GetOrigin(infoPtr, &Origin);
|
||||||
lpht->flags |= LVHT_TOLEFT;
|
|
||||||
else if (infoPtr->rcList.right < lpht->pt.x)
|
/* set whole list relation flags */
|
||||||
lpht->flags |= LVHT_TORIGHT;
|
if (subitem && infoPtr->uView == LV_VIEW_DETAILS)
|
||||||
|
{
|
||||||
|
/* LVM_SUBITEMHITTEST checks left bound of possible client area */
|
||||||
|
if (infoPtr->rcList.left > lpht->pt.x && Origin.x < lpht->pt.x)
|
||||||
|
lpht->flags |= LVHT_TOLEFT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (infoPtr->rcList.left > lpht->pt.x)
|
||||||
|
lpht->flags |= LVHT_TOLEFT;
|
||||||
|
else if (infoPtr->rcList.right < lpht->pt.x)
|
||||||
|
lpht->flags |= LVHT_TORIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
if (infoPtr->rcList.top > lpht->pt.y)
|
if (infoPtr->rcList.top > lpht->pt.y)
|
||||||
lpht->flags |= LVHT_ABOVE;
|
lpht->flags |= LVHT_ABOVE;
|
||||||
else if (infoPtr->rcList.bottom < lpht->pt.y)
|
else if (infoPtr->rcList.bottom < lpht->pt.y)
|
||||||
lpht->flags |= LVHT_BELOW;
|
lpht->flags |= LVHT_BELOW;
|
||||||
|
|
||||||
|
/* even if item is invalid try to find subitem */
|
||||||
|
if (infoPtr->uView == LV_VIEW_DETAILS && subitem)
|
||||||
|
{
|
||||||
|
RECT *pRect;
|
||||||
|
INT j;
|
||||||
|
|
||||||
|
opt.x = lpht->pt.x - Origin.x;
|
||||||
|
|
||||||
|
lpht->iSubItem = -1;
|
||||||
|
for (j = 0; j < DPA_GetPtrCount(infoPtr->hdpaColumns); j++)
|
||||||
|
{
|
||||||
|
pRect = &LISTVIEW_GetColumnInfo(infoPtr, j)->rcHeader;
|
||||||
|
|
||||||
|
if ((opt.x >= pRect->left) && (opt.x < pRect->right))
|
||||||
|
{
|
||||||
|
lpht->iSubItem = j;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TRACE("lpht->iSubItem=%d\n", lpht->iSubItem);
|
||||||
|
}
|
||||||
|
|
||||||
TRACE("lpht->flags=0x%x\n", lpht->flags);
|
TRACE("lpht->flags=0x%x\n", lpht->flags);
|
||||||
if (lpht->flags) return -1;
|
if (lpht->flags) return -1;
|
||||||
|
|
||||||
lpht->flags |= LVHT_NOWHERE;
|
lpht->flags |= LVHT_NOWHERE;
|
||||||
|
|
||||||
LISTVIEW_GetOrigin(infoPtr, &Origin);
|
|
||||||
|
|
||||||
/* first deal with the large items */
|
/* first deal with the large items */
|
||||||
rcSearch.left = lpht->pt.x;
|
rcSearch.left = lpht->pt.x;
|
||||||
rcSearch.top = lpht->pt.y;
|
rcSearch.top = lpht->pt.y;
|
||||||
|
@ -6829,32 +6861,6 @@ static INT LISTVIEW_HitTest(const LISTVIEW_INFO *infoPtr, LPLVHITTESTINFO lpht,
|
||||||
TRACE("lpht->iItem=%d\n", iItem);
|
TRACE("lpht->iItem=%d\n", iItem);
|
||||||
if (iItem == -1) return -1;
|
if (iItem == -1) return -1;
|
||||||
|
|
||||||
if (infoPtr->uView == LV_VIEW_DETAILS && subitem)
|
|
||||||
{
|
|
||||||
RECT bounds, *pRect;
|
|
||||||
INT j;
|
|
||||||
|
|
||||||
/* for top/bottom only */
|
|
||||||
bounds.left = LVIR_BOUNDS;
|
|
||||||
LISTVIEW_GetItemRect(infoPtr, iItem, &bounds);
|
|
||||||
opt.x = lpht->pt.x - Origin.x;
|
|
||||||
opt.y = lpht->pt.y;
|
|
||||||
|
|
||||||
for (j = 0; j < DPA_GetPtrCount(infoPtr->hdpaColumns); j++)
|
|
||||||
{
|
|
||||||
pRect = &LISTVIEW_GetColumnInfo(infoPtr, j)->rcHeader;
|
|
||||||
bounds.left = pRect->left;
|
|
||||||
bounds.right = pRect->right;
|
|
||||||
|
|
||||||
if (PtInRect(&bounds, opt))
|
|
||||||
{
|
|
||||||
lpht->iSubItem = j;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TRACE("lpht->iSubItem=%d\n", lpht->iSubItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
lvItem.mask = LVIF_STATE | LVIF_TEXT;
|
lvItem.mask = LVIF_STATE | LVIF_TEXT;
|
||||||
if (infoPtr->uView == LV_VIEW_DETAILS) lvItem.mask |= LVIF_INDENT;
|
if (infoPtr->uView == LV_VIEW_DETAILS) lvItem.mask |= LVIF_INDENT;
|
||||||
lvItem.stateMask = LVIS_STATEIMAGEMASK;
|
lvItem.stateMask = LVIS_STATEIMAGEMASK;
|
||||||
|
|
|
@ -2684,7 +2684,16 @@ static void test_hittest(void)
|
||||||
x = pos.x + 150; /* outside column */
|
x = pos.x + 150; /* outside column */
|
||||||
y = pos.y + (bounds.bottom - bounds.top) / 2;
|
y = pos.y + (bounds.bottom - bounds.top) / 2;
|
||||||
test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, FALSE, FALSE, __LINE__);
|
test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, FALSE, FALSE, __LINE__);
|
||||||
test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, TRUE, TRUE, TRUE, __LINE__);
|
test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE, __LINE__);
|
||||||
|
/* outside possible client rectangle (to right) */
|
||||||
|
x = pos.x + 500;
|
||||||
|
y = pos.y + (bounds.bottom - bounds.top) / 2;
|
||||||
|
test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, FALSE, FALSE, __LINE__);
|
||||||
|
test_lvm_subitemhittest(hwnd, x, y, -1, -1, LVHT_NOWHERE, FALSE, FALSE, FALSE, __LINE__);
|
||||||
|
/* subitem returned with -1 item too */
|
||||||
|
x = pos.x + 150;
|
||||||
|
y = -10;
|
||||||
|
test_lvm_subitemhittest(hwnd, x, y, -1, 1, LVHT_NOWHERE, FALSE, FALSE, TRUE, __LINE__);
|
||||||
/* parent client area is 100x100 by default */
|
/* parent client area is 100x100 by default */
|
||||||
MoveWindow(hwnd, 0, 0, 300, 100, FALSE);
|
MoveWindow(hwnd, 0, 0, 300, 100, FALSE);
|
||||||
x = pos.x + 150; /* outside column */
|
x = pos.x + 150; /* outside column */
|
||||||
|
@ -2701,7 +2710,12 @@ static void test_hittest(void)
|
||||||
x = pos.x + 150; /* outside column */
|
x = pos.x + 150; /* outside column */
|
||||||
y = pos.y + (bounds.bottom - bounds.top) / 2;
|
y = pos.y + (bounds.bottom - bounds.top) / 2;
|
||||||
test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, FALSE, FALSE, __LINE__);
|
test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, FALSE, FALSE, __LINE__);
|
||||||
test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, TRUE, TRUE, TRUE, __LINE__);
|
test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE, __LINE__);
|
||||||
|
/* outside possible client rectangle (to right) */
|
||||||
|
x = pos.x + 500;
|
||||||
|
y = pos.y + (bounds.bottom - bounds.top) / 2;
|
||||||
|
test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, FALSE, FALSE, __LINE__);
|
||||||
|
test_lvm_subitemhittest(hwnd, x, y, -1, -1, LVHT_NOWHERE, FALSE, FALSE, FALSE, __LINE__);
|
||||||
/* try with icons, state icons index is 1 based so at least 2 bitmaps needed */
|
/* try with icons, state icons index is 1 based so at least 2 bitmaps needed */
|
||||||
himl = ImageList_Create(16, 16, 0, 4, 4);
|
himl = ImageList_Create(16, 16, 0, 4, 4);
|
||||||
ok(himl != NULL, "failed to create imagelist\n");
|
ok(himl != NULL, "failed to create imagelist\n");
|
||||||
|
|
Loading…
Reference in New Issue