comctl32/listbox.c Use helper functions for item initialization.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
stable
Huw Davies 2019-02-28 10:50:48 +00:00 committed by Alexandre Julliard
parent 3f508e6edb
commit b60108e022
1 changed files with 11 additions and 7 deletions

View File

@ -171,6 +171,11 @@ static WCHAR *get_item_string( const LB_DESCR *descr, UINT index )
return HAS_STRINGS(descr) ? descr->items[index].str : NULL; return HAS_STRINGS(descr) ? descr->items[index].str : NULL;
} }
static void set_item_string( const LB_DESCR *descr, UINT index, WCHAR *string )
{
if (!(descr->style & LBS_NODATA)) descr->items[index].str = string;
}
static UINT get_item_height( const LB_DESCR *descr, UINT index ) static UINT get_item_height( const LB_DESCR *descr, UINT index )
{ {
return (descr->style & LBS_NODATA) ? 0 : descr->items[index].height; return (descr->style & LBS_NODATA) ? 0 : descr->items[index].height;
@ -194,7 +199,7 @@ static void set_item_selected_state(LB_DESCR *descr, UINT index, BOOL state)
descr->items[index].selected = state; descr->items[index].selected = state;
} }
static void insert_item_data(LB_DESCR *descr, UINT index, WCHAR *str, ULONG_PTR data) static void insert_item_data(LB_DESCR *descr, UINT index)
{ {
LB_ITEMDATA *item; LB_ITEMDATA *item;
@ -203,11 +208,6 @@ static void insert_item_data(LB_DESCR *descr, UINT index, WCHAR *str, ULONG_PTR
item = descr->items + index; item = descr->items + index;
if (index < descr->nb_items) if (index < descr->nb_items)
memmove(item + 1, item, (descr->nb_items - index) * sizeof(LB_ITEMDATA)); memmove(item + 1, item, (descr->nb_items - index) * sizeof(LB_ITEMDATA));
item->str = str;
item->data = HAS_STRINGS(descr) ? 0 : data;
item->height = 0;
item->selected = FALSE;
} }
static void remove_item_data(LB_DESCR *descr, UINT index) static void remove_item_data(LB_DESCR *descr, UINT index)
@ -1599,8 +1599,12 @@ static LRESULT LISTBOX_InsertItem( LB_DESCR *descr, INT index,
else if ((index < 0) || (index > descr->nb_items)) return LB_ERR; else if ((index < 0) || (index > descr->nb_items)) return LB_ERR;
if (!resize_storage(descr, descr->nb_items + 1)) return LB_ERR; if (!resize_storage(descr, descr->nb_items + 1)) return LB_ERR;
insert_item_data(descr, index, str, data); insert_item_data(descr, index);
descr->nb_items++; descr->nb_items++;
set_item_string(descr, index, str);
set_item_data(descr, index, HAS_STRINGS(descr) ? 0 : data);
set_item_height(descr, index, 0);
set_item_selected_state(descr, index, FALSE);
/* Get item height */ /* Get item height */