Commit fe966335 authored by Lei Zhang's avatar Lei Zhang Committed by Alexandre Julliard

comctl32: Implement listview checkbox toggle.

parent 778c04db
...@@ -1353,6 +1353,19 @@ static inline BOOL is_autoarrange(const LISTVIEW_INFO *infoPtr) ...@@ -1353,6 +1353,19 @@ static inline BOOL is_autoarrange(const LISTVIEW_INFO *infoPtr)
(uView == LVS_ICON || uView == LVS_SMALLICON); (uView == LVS_ICON || uView == LVS_SMALLICON);
} }
static void toggle_checkbox_state(LISTVIEW_INFO *infoPtr, INT nItem)
{
DWORD state = STATEIMAGEINDEX(LISTVIEW_GetItemState(infoPtr, nItem, LVIS_STATEIMAGEMASK));
if(state == 1 || state == 2)
{
LVITEMW lvitem;
state ^= 3;
lvitem.state = INDEXTOSTATEIMAGEMASK(state);
lvitem.stateMask = LVIS_STATEIMAGEMASK;
LISTVIEW_SetItemState(infoPtr, nItem, &lvitem);
}
}
/******** Internal API functions ************************************/ /******** Internal API functions ************************************/
static inline COLUMN_INFO * LISTVIEW_GetColumnInfo(const LISTVIEW_INFO *infoPtr, INT nSubItem) static inline COLUMN_INFO * LISTVIEW_GetColumnInfo(const LISTVIEW_INFO *infoPtr, INT nSubItem)
...@@ -8283,6 +8296,8 @@ static LRESULT LISTVIEW_KeyDown(LISTVIEW_INFO *infoPtr, INT nVirtualKey, LONG lK ...@@ -8283,6 +8296,8 @@ static LRESULT LISTVIEW_KeyDown(LISTVIEW_INFO *infoPtr, INT nVirtualKey, LONG lK
{ {
case VK_SPACE: case VK_SPACE:
nItem = infoPtr->nFocusedItem; nItem = infoPtr->nFocusedItem;
if (infoPtr->dwLvExStyle & LVS_EX_CHECKBOXES)
toggle_checkbox_state(infoPtr, infoPtr->nFocusedItem);
break; break;
case VK_RETURN: case VK_RETURN:
...@@ -8475,15 +8490,7 @@ static LRESULT LISTVIEW_LButtonDown(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, IN ...@@ -8475,15 +8490,7 @@ static LRESULT LISTVIEW_LButtonDown(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, IN
{ {
if ((infoPtr->dwLvExStyle & LVS_EX_CHECKBOXES) && (lvHitTestInfo.flags & LVHT_ONITEMSTATEICON)) if ((infoPtr->dwLvExStyle & LVS_EX_CHECKBOXES) && (lvHitTestInfo.flags & LVHT_ONITEMSTATEICON))
{ {
DWORD state = STATEIMAGEINDEX(LISTVIEW_GetItemState(infoPtr, nItem, LVIS_STATEIMAGEMASK)); toggle_checkbox_state(infoPtr, nItem);
if(state == 1 || state == 2)
{
LVITEMW lvitem;
state ^= 3;
lvitem.state = INDEXTOSTATEIMAGEMASK(state);
lvitem.stateMask = LVIS_STATEIMAGEMASK;
LISTVIEW_SetItemState(infoPtr, nItem, &lvitem);
}
return 0; return 0;
} }
......
...@@ -564,7 +564,7 @@ static void test_checkboxes(void) ...@@ -564,7 +564,7 @@ static void test_checkboxes(void)
item.mask = LVIF_STATE; item.mask = LVIF_STATE;
item.stateMask = 0xffff; item.stateMask = 0xffff;
r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item); r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
todo_wine ok(item.state == 0x2aab, "state %x\n", item.state); ok(item.state == 0x2aab, "state %x\n", item.state);
r = SendMessage(hwnd, WM_KEYDOWN, VK_SPACE, 0); r = SendMessage(hwnd, WM_KEYDOWN, VK_SPACE, 0);
expect(0, r); expect(0, r);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment