1 /***
2 * DESCRIPTION:
3 * Processes mouse down messages (left mouse button).
4 *
5 * PARAMETERS:
6 * infoPtr [I ] valid pointer to the listview structure
7 * wKey [I ] key flag
8 * x,y [I ] mouse coordinate
9 *
10 * RETURN:
11 * Zero
12 */
13 static LRESULT LISTVIEW_LButtonDown(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, INT y)
14 {
15 LVHITTESTINFO lvHitTestInfo;
16 static BOOL bGroupSelect = TRUE;
17 POINT pt = { x, y };
18 INT nItem;
19
20 TRACE("(key=%hu, X=%u, Y=%u)\n", wKey, x, y);
21
22 /* send NM_RELEASEDCAPTURE notification */
23 if (!notify(infoPtr, NM_RELEASEDCAPTURE)) return 0;
24
25 /* set left button down flag and record the click position */
26 infoPtr->bLButtonDown = TRUE;
27 infoPtr->ptClickPos = pt;
28 infoPtr->bDragging = FALSE;
29 infoPtr->bMarqueeSelect = FALSE;
30 infoPtr->bScrolling = FALSE;
31
32 lvHitTestInfo.pt.x = x;
33 lvHitTestInfo.pt.y = y;
34
35 nItem = LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, TRUE);
36 TRACE("at %s, nItem=%d\n", wine_dbgstr_point(&pt), nItem);
37 if ((nItem >= 0) && (nItem < infoPtr->nItemCount))
38 {
39 if ((infoPtr->dwLvExStyle & LVS_EX_CHECKBOXES) && (lvHitTestInfo.flags & LVHT_ONITEMSTATEICON))
40 {
41 toggle_checkbox_state(infoPtr, nItem);
42 return 0;
43 }
44
45 if (infoPtr->dwStyle & LVS_SINGLESEL)
46 {
47 if (LISTVIEW_GetItemState(infoPtr, nItem, LVIS_SELECTED))
48 infoPtr->nEditLabelItem = nItem;
49 else
50 LISTVIEW_SetSelection(infoPtr, nItem);
51 }
52 else
53 {
54 if ((wKey & MK_CONTROL) && (wKey & MK_SHIFT))
55 {
56 if (bGroupSelect)
57 {
58 if (!LISTVIEW_AddGroupSelection(infoPtr, nItem)) return 0;
59 LISTVIEW_SetItemFocus(infoPtr, nItem);
60 infoPtr->nSelectionMark = nItem;
61 }
62 else
63 {
64 LVITEMW item;
65
66 item.state = LVIS_SELECTED | LVIS_FOCUSED;
67 item.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
68
69 LISTVIEW_SetItemState(infoPtr,nItem,&item);
70 infoPtr->nSelectionMark = nItem;
71 }
72 }
73 else if (wKey & MK_CONTROL)
74 {
75 LVITEMW item;
76
77 bGroupSelect = (LISTVIEW_GetItemState(infoPtr, nItem, LVIS_SELECTED) == 0);
78
79 item.state = (bGroupSelect ? LVIS_SELECTED : 0) | LVIS_FOCUSED;
80 item.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
81 LISTVIEW_SetItemState(infoPtr, nItem, &item);
82 infoPtr->nSelectionMark = nItem;
83 }
84 else if (wKey & MK_SHIFT)
85 {
86 LISTVIEW_SetGroupSelection(infoPtr, nItem);
87 }
88 else
89 {
90 if (LISTVIEW_GetItemState(infoPtr, nItem, LVIS_SELECTED))
91 {
92 infoPtr->nEditLabelItem = nItem;
93 infoPtr->nLButtonDownItem = nItem;
94
95 LISTVIEW_SetItemFocus(infoPtr, nItem);
96 }
97 else
98 /* set selection (clears other pre-existing selections) */
99 LISTVIEW_SetSelection(infoPtr, nItem);
100 }
101 }
102
103 if (infoPtr->dwLvExStyle & LVS_EX_ONECLICKACTIVATE)
104 if(lvHitTestInfo.iItem != -1) notify_itemactivate(infoPtr,&lvHitTestInfo);
105 }
106 else
107 {
108 if (!infoPtr->bFocus)
109 SetFocus(infoPtr->hwndSelf);
110
111 /* remove all selections */
112 if (!(wKey & MK_CONTROL) && !(wKey & MK_SHIFT))
113 LISTVIEW_DeselectAll(infoPtr);
114 ReleaseCapture();
115 }
116
117 return 0;
118 }
posted on 2011-09-15 21:45
shaker(太子) 阅读(672)
评论(0) 编辑 收藏 引用 所属分类:
Windows Kernel