[PATCH v3 6/7] comctl32/listbox: Use a helper to set the selected item state
Gabriel Ivăncescu
gabrielopcode at gmail.com
Tue Feb 12 07:07:04 CST 2019
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
is_singlesel_NODATA is needed otherwise it fails the tests for multi-selection
nodata, because it's not implemented yet.
dlls/comctl32/listbox.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/dlls/comctl32/listbox.c b/dlls/comctl32/listbox.c
index d526a2b..374b1df 100644
--- a/dlls/comctl32/listbox.c
+++ b/dlls/comctl32/listbox.c
@@ -127,6 +127,11 @@ static TIMER_DIRECTION LISTBOX_Timer = LB_TIMER_NONE;
static LRESULT LISTBOX_GetItemRect( const LB_DESCR *descr, INT index, RECT *rect );
+static BOOL is_singlesel_NODATA(const LB_DESCR *descr)
+{
+ return (descr->style & (LBS_NODATA | LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == LBS_NODATA;
+}
+
static ULONG_PTR get_item_data( const LB_DESCR *descr, UINT index )
{
return (descr->style & LBS_NODATA) ? 0 : descr->items[index].data;
@@ -170,6 +175,11 @@ static BOOL is_item_selected( const LB_DESCR *descr, UINT index )
return descr->items[index].selected;
}
+static void set_item_selected_state(LB_DESCR *descr, UINT index, BOOL state)
+{
+ if (!is_singlesel_NODATA(descr)) descr->items[index].selected = state;
+}
+
/***********************************************************************
* LISTBOX_GetCurrentPageSize
*
@@ -1433,7 +1443,7 @@ static LRESULT LISTBOX_SelectItemRange( LB_DESCR *descr, INT first,
for (i = first; i <= last; i++)
{
if (descr->items[i].selected) continue;
- descr->items[i].selected = TRUE;
+ set_item_selected_state(descr, i, TRUE);
LISTBOX_InvalidateItemRect(descr, i);
}
}
@@ -1442,7 +1452,7 @@ static LRESULT LISTBOX_SelectItemRange( LB_DESCR *descr, INT first,
for (i = first; i <= last; i++)
{
if (!descr->items[i].selected) continue;
- descr->items[i].selected = FALSE;
+ set_item_selected_state(descr, i, FALSE);
LISTBOX_InvalidateItemRect(descr, i);
}
}
@@ -1475,10 +1485,10 @@ static LRESULT LISTBOX_SetSelection( LB_DESCR *descr, INT index,
{
INT oldsel = descr->selected_item;
if (index == oldsel) return LB_OKAY;
- if (oldsel != -1) descr->items[oldsel].selected = FALSE;
- if (index != -1) descr->items[index].selected = TRUE;
- if (oldsel != -1) LISTBOX_RepaintItem( descr, oldsel, ODA_SELECT );
+ if (oldsel != -1) set_item_selected_state(descr, oldsel, FALSE);
+ if (index != -1) set_item_selected_state(descr, index, TRUE);
descr->selected_item = index;
+ if (oldsel != -1) LISTBOX_RepaintItem( descr, oldsel, ODA_SELECT );
if (index != -1) LISTBOX_RepaintItem( descr, index, ODA_SELECT );
if (send_notify && descr->nb_items) SEND_NOTIFICATION( descr,
(index != -1) ? LBN_SELCHANGE : LBN_SELCANCEL );
--
2.20.1
More information about the wine-devel
mailing list