Pls help, vary size item list. | developer.brewmp.com Pls help, vary size item list. | developer.brewmp.com

Developer

Pls help, vary size item list.

:confused: I have create a list widget and item widget. Then set list widget a indexer to calculate the differe item size. it work well, but if the list have a lot of items, eg:200, when we change the focus or get list extent through IWIDGET_GetPreferredExtent, it will be very slowly. I find the ListIndexer will be invoked many many times? Anyone can help me, thks a lot!

static void
ListIndexer(void *piwListWdg, int nIndex, boolean bSelected)
{
WExtent WEx = {0};
IWidget *pIItemWdg = NULL;
uint32 height = 0;

/* calculate the height based on the content*/
IDECORATOR_GetWidget((IDecorator*)piw,&pIItemWdg);
IWIDGET_GetPreferredExtent(pIItemWdg, &WEx);
RELEASEIF(pIItemWdg);
height = WEx.height;
WIDGET_SetVarItemSize(piw, (uint8)height);

IWIDGET_SetFlags(pMe->m_pIListWdg,LWF_VARIABLEITEMSIZE);
IWIDGET_SetIndexer(pMe->m_pIListWdg, ListIndexer, (void *)pMe);

I noticed when change the focus or add the data to the list, the listindexer will be invoked to calculate size of all items again, is there anyway to avoid this, because most of the item size has been calculted. I just wanted the new item size be calculated.
Thanks a lot.

I noticed when change the focus or add the data to the list, the listindexer will be invoked to calculate size of all items again, is there anyway to avoid this, because most of the item size has been calculted. I just wanted the new item size be calculated.
Thanks a lot.

You could store the item sizes somewhere and use those stored values in the indexer instead of recalculating them every time.
-Erik

You could store the item sizes somewhere and use those stored values in the indexer instead of recalculating them every time.
-Erik

Thanks a lot, ebrowne!
It works more effectively than before. But if there are many items, eg: greater than 30, when i used IWIDGET_SetFocusIndex to setfocus, the ListIndexer will be invoked to set every item heigt(which has been stored) through IWIDGET_SetProperty(piw, PROP_VARITEMSIZE, (int)height) function, it still slower.
Could you help me! thks!

Thanks a lot, ebrowne!
It works more effectively than before. But if there are many items, eg: greater than 30, when i used IWIDGET_SetFocusIndex to setfocus, the ListIndexer will be invoked to set every item heigt(which has been stored) through IWIDGET_SetProperty(piw, PROP_VARITEMSIZE, (int)height) function, it still slower.
Could you help me! thks!