Commit a0ebe244 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

comctl32: Close previously selected treeview item at common ancestor.

Also, send WM_NOTIFY mesages when collapsing the previous selection and expanding the new one.
parent 9f930807
...@@ -1767,9 +1767,9 @@ static void test_TVS_SINGLEEXPAND(void) ...@@ -1767,9 +1767,9 @@ static void test_TVS_SINGLEEXPAND(void)
{ {
{ &alpha, parent_singleexpand_seq0, FALSE }, { &alpha, parent_singleexpand_seq0, FALSE },
{ &bravo, parent_singleexpand_seq1, FALSE }, { &bravo, parent_singleexpand_seq1, FALSE },
{ &delta, parent_singleexpand_seq2, TRUE }, { &delta, parent_singleexpand_seq2, FALSE },
{ &foxtrot, parent_singleexpand_seq3, TRUE }, { &foxtrot, parent_singleexpand_seq3, FALSE },
{ &alpha, parent_singleexpand_seq4, TRUE }, { &alpha, parent_singleexpand_seq4, FALSE },
{ &golf, parent_singleexpand_seq5, TRUE }, { &golf, parent_singleexpand_seq5, TRUE },
{ &hotel, parent_singleexpand_seq6, FALSE }, { &hotel, parent_singleexpand_seq6, FALSE },
{ &india, parent_singleexpand_seq7, FALSE }, { &india, parent_singleexpand_seq7, FALSE },
...@@ -1801,10 +1801,6 @@ static void test_TVS_SINGLEEXPAND(void) ...@@ -1801,10 +1801,6 @@ static void test_TVS_SINGLEEXPAND(void)
for (i = 0; i < sizeof(items)/sizeof(items[0]); i++) for (i = 0; i < sizeof(items)/sizeof(items[0]); i++)
{ {
ret = SendMessageA(hTree, TVM_GETITEMSTATE, (WPARAM)(*items[i].handle), 0xFFFF); ret = SendMessageA(hTree, TVM_GETITEMSTATE, (WPARAM)(*items[i].handle), 0xFFFF);
if (i == 0)
todo_wine ok(ret == items[i].final_state, "singleexpand items[%d]: expected state 0x%x got 0x%x\n",
i, items[i].final_state, ret);
else
ok(ret == items[i].final_state, "singleexpand items[%d]: expected state 0x%x got 0x%x\n", ok(ret == items[i].final_state, "singleexpand items[%d]: expected state 0x%x got 0x%x\n",
i, items[i].final_state, ret); i, items[i].final_state, ret);
} }
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
* *
* TODO: * TODO:
* missing notifications: TVN_GETINFOTIP, TVN_KEYDOWN, * missing notifications: TVN_GETINFOTIP, TVN_KEYDOWN,
* TVN_SETDISPINFO, TVN_SINGLEEXPAND * TVN_SETDISPINFO
* *
* missing styles: TVS_FULLROWSELECT, TVS_INFOTIP, TVS_RTLREADING, * missing styles: TVS_FULLROWSELECT, TVS_INFOTIP, TVS_RTLREADING,
* *
...@@ -3508,47 +3508,31 @@ TREEVIEW_Expand(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, ...@@ -3508,47 +3508,31 @@ TREEVIEW_Expand(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
static void TREEVIEW_SingleExpand(TREEVIEW_INFO *infoPtr, static void TREEVIEW_SingleExpand(TREEVIEW_INFO *infoPtr,
HTREEITEM selection, HTREEITEM item) HTREEITEM selection, HTREEITEM item)
{ {
TREEVIEW_ITEM *SelItem; TREEVIEW_ITEM *prev, *curr;
if ((infoPtr->dwStyle & TVS_SINGLEEXPAND) == 0 || infoPtr->hwndEdit || !item) return; if ((infoPtr->dwStyle & TVS_SINGLEEXPAND) == 0 || infoPtr->hwndEdit || !item) return;
TREEVIEW_SendTreeviewNotify(infoPtr, TVN_SINGLEEXPAND, TVC_UNKNOWN, TVIF_HANDLE | TVIF_PARAM, item, 0); TREEVIEW_SendTreeviewNotify(infoPtr, TVN_SINGLEEXPAND, TVC_UNKNOWN, TVIF_HANDLE | TVIF_PARAM, item, 0);
/* /*
* Close the previous selection all the way to the root * Close the previous item and its ancestors as long as they are not
* as long as the new selection is not a child * ancestors of the current item
*/ */
if(selection && (selection != item)) for (prev = selection; prev && TREEVIEW_ValidItem(infoPtr, prev); prev = prev->parent)
{ {
BOOL closeit = TRUE; for (curr = item; curr && TREEVIEW_ValidItem(infoPtr, curr); curr = curr->parent)
SelItem = item;
/* determine if the hitItem is a child of the currently selected item */
while(closeit && SelItem && TREEVIEW_ValidItem(infoPtr, SelItem) &&
(SelItem->parent != infoPtr->root))
{
closeit = (SelItem != selection);
SelItem = SelItem->parent;
}
if(closeit)
{ {
if(TREEVIEW_ValidItem(infoPtr, selection)) if (curr == prev)
SelItem = selection; goto finish;
while(SelItem && (SelItem != item) && TREEVIEW_ValidItem(infoPtr, SelItem) &&
SelItem->parent != infoPtr->root)
{
TREEVIEW_Collapse(infoPtr, SelItem, FALSE, FALSE);
SelItem = SelItem->parent;
}
} }
TREEVIEW_Collapse(infoPtr, prev, FALSE, TRUE);
} }
finish:
/* /*
* Expand the current item * Expand the current item
*/ */
TREEVIEW_Expand(infoPtr, item, FALSE, FALSE); TREEVIEW_Expand(infoPtr, item, FALSE, TRUE);
} }
static BOOL static BOOL
......
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