how to add Multiple Images and Text to List Widget | developer.brewmp.com how to add Multiple Images and Text to List Widget | developer.brewmp.com

Developer

how to add Multiple Images and Text to List Widget

Forums:

Hi,

I'm Trying to develop an application with two images and text as one menu item.

I tried with Image Static Widget but it is not displaying,

can anyone give me some idea on this.

 

Regards 

Srinag

Use propcontainer or XYContainer as list item - add images and text widgets to container.
Install indexer on list or value model listener on container. Load and set the data (images/text) to corresponding widgets in indexer or value model listener. Here is a sample code snippet:
static int listwidgetapp_GetResString(IResFile *piResFile, int nResId, AECHAR **ppDest)
{
AEEResult nErr;
AECHAR *pwsz = NULL;
uint32 nLen = 0;

nErr = IResFile_Get(piResFile, (uint32)nResId, RESTYPE_STRING, (AECHAR*)-1, &nLen);

if (nLen > 2) {
pwsz = MALLOC(nLen);
if (NULL == pwsz) {
return (AEE_ENOMEMORY);
}
}

nErr = IResFile_Get(piResFile, (uint32)nResId, RESTYPE_STRING, pwsz, &nLen);
*ppDest = pwsz;

if (AEE_SUCCESS != nErr) {
*ppDest = NULL;
FREEIF(pwsz);
}
return nErr;

static int listwidgetapp_GetResImage(IResFile *piResFile, int nResId, IImage** ppDest)
{
AEEResult nErr;
void *pObj = NULL;
nErr = IResFile_GetObject(piResFile, (uint32)nResId, AEECLSID_VIEW, &pObj);
*ppDest = pObj;
return nErr;

void ListIndexer(void *pCtx, int nIndex, boolean bSelected)
{
IWidget *piwStatic1;
IWidget *piwStatic2;
IWidget *piwStatic3;
WidgetExtent pWExtent;

IWidget *piwImage1;
IWidget *piwImage2;
IWidget *piwImage3;
IImage *pii1 = NULL;
IImage *pii2 = NULL;
IImage *pii3 = NULL;
IWidget *piXYCntwgt = NULL;
IXYContainer *piXYCnt = NULL;
IWidget *piXYCntwgt1 = NULL;
IXYContainer *piXYCnt1 = NULL;
AECHAR *pszTxt;
listwidgetapp *pMe = (listwidgetapp *)pCtx;

if(nIndex >= 0 && nIndex < 10)
{
piwImage1 = IPropContainer_GetWidget(pMe->picPropCnt, WIDGET_ZNORMAL, TRUE, FALSE);
listwidgetapp_GetResImage(pMe->piResFile, IDI_PHOTO_1, &pii1) ;
IWidget_SetImage(piwImage1, pii1) ;

piwImage2 = IPropContainer_GetWidget(pMe->picPropCnt, piwImage1, TRUE, FALSE);
listwidgetapp_GetResImage(pMe->piResFile, IDI_PHOTO_2, &pii2) ;
IWidget_SetImage(piwImage2, pii2) ;

piwImage3 = IPropContainer_GetWidget(pMe->picPropCnt, piwImage2, TRUE, FALSE);
listwidgetapp_GetResImage(pMe->piResFile, IDI_PHOTO_3, &pii3) ;
IWidget_SetImage(piwImage3, pii3) ;

piXYCntwgt = IPropContainer_GetWidget(pMe->picPropCnt, piwImage3, TRUE, FALSE);
{
IWidget_QueryInterface(piXYCntwgt,AEEIID_IXYContainer,(void **)&piXYCnt);

piwStatic1 = IXYContainer_GetWidget(piXYCnt, WIDGET_ZNORMAL, TRUE, FALSE);
//load the text and set the data to widget
listwidgetapp_GetResString(pMe->piResFile,IDS_STR_NAME_1 + nIndex, &pszTxt);
if(piwStatic1)
{
if(nIndex == 0)
IWIDGET_SetText(piwStatic1, pszTxt, FALSE);
else
IWIDGET_SetText(piwStatic1, L"Hi", FALSE);
}

piwStatic2 = IXYContainer_GetWidget(piXYCnt, piwStatic1, TRUE, FALSE);
//load the text and set the data to widget
listwidgetapp_GetResString(pMe->piResFile,IDS_STR_NAME_1 + nIndex, &pszTxt);
if(piwStatic2)
IWIDGET_SetText(piwStatic2, pszTxt, FALSE);
IWidget_Animate(piwStatic2, TRUE);
}

piXYCntwgt1 = IPropContainer_GetWidget(pMe->picPropCnt, piXYCntwgt, TRUE, FALSE);
{
IWidget_QueryInterface(piXYCntwgt1,AEEIID_IXYContainer,(void **)&piXYCnt1);
IWidget_GetPreferredExtent(piXYCntwgt1,&pWExtent);
pWExtent.width = pMe->deviceInfo.cxScreen/2;
pWExtent.height = pMe->deviceInfo.cyScreen/8;
IWidget_SetExtent(piXYCntwgt1,&pWExtent);

piwStatic3 = IXYContainer_GetWidget(piXYCnt1, WIDGET_ZNORMAL, TRUE, FALSE);
//load the text and set the data to widget
listwidgetapp_GetResString(pMe->piResFile,IDS_STR_NAME_1 + nIndex, &pszTxt);
if(piwStatic3)
IWIDGET_SetText(piwStatic3, pszTxt, FALSE);
}

}

void listwidgetapp_DrawMainMenu(listwidgetapp * pMe)
{
int ret = 0;
IDisplayCanvas *pDisplayCanvas;
AEERect rectRoot;

WidgetExtent pWExtent;
WidgetPos ppos;
IWidget *piwPropCnt = NULL;
IWidget *piwStatic1 = NULL;
IWidget *piwStatic2 = NULL;
IWidget *piwStatic3 = NULL;
IDecorator *pidList = NULL;
IVectorModel *piVectorModel = NULL;
IModel *piViewModel = NULL;
WidgetProp WidProp;
IDecorator *pidRotate = NULL;
IWidget *piwImage1 = NULL;
IWidget *piwImage2 = NULL;
IWidget *piwImage3 = NULL;
IWidget *piXYCntwgt = NULL;
IXYContainer *piXYCnt = NULL;
IWidget *piXYCntwgt1 = NULL;
IXYContainer *piXYCnt1 = NULL;
int i = 0;

//Create display canvas and assign the display
ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_DisplayCanvas, (void**)&pDisplayCanvas);
IDisplayCanvas_SetDisplay(pDisplayCanvas, pMe->piDisplay);

//Create root container and assign the display canvas
ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_RootContainer, (void**)&pMe->picRootMenu);
ret = IRootContainer_QueryInterface(pMe->picRootMenu, AEEIID_IWidget, (void**)&pMe->piwRootMenu);

SETAEERECT(&rectRoot, 0, 0, pMe->deviceInfo.cxScreen, pMe->deviceInfo.cyScreen);
IRootContainer_SetCanvas(pMe->picRootMenu, (ICanvas*)pDisplayCanvas, &rectRoot);

// Set BG color
IWidget_SetBGColor(pMe->piwRootMenu, MAKE_RGBA(224, 224, 224, 255));
// Enable touch
IWidget_EnableTouch(pMe->piwRootMenu);

IShell_CreateInstance(pMe->piShell, AEECLSID_MenuModel, (void **)&pMe->m_pIMenuModel);
Add_Items_VectorModel(pMe->m_pIMenuModel, 4);

ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_ListWidget, (void**) &pidList);
IDecorator_QueryInterface(pidList, AEEIID_IWidget, (void**) &pMe->piwlist);

IWidget_SetIndexer(pMe->piwlist, ListIndexer, pMe);

// Create a prop container as list item.
ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_PropContainer, (void**) &pMe->picPropCnt);
WidProp.bVisible = TRUE;
WidProp.prop = WIDGET_SIZE_TO_FIT;
ret = IPropContainer_QueryInterface(pMe->picPropCnt, AEEIID_IWidget, (void**) &piwPropCnt);
IWidget_SetLayoutStyle(piwPropCnt, LAYOUT_HORZ);

ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_ImageWidget,(void **)&piwImage1);

IPropContainer_Insert(pMe->picPropCnt, piwImage1, WIDGET_ZNORMAL, &WidProp);

ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_ImageWidget,(void **)&piwImage2);
IPropContainer_Insert(pMe->picPropCnt, piwImage2, WIDGET_ZNORMAL, &WidProp);

ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_ImageWidget,(void **)&piwImage3);
IPropContainer_Insert(pMe->picPropCnt, piwImage3, WIDGET_ZNORMAL, &WidProp);

ISHELL_CreateInstance(pMe->piShell,AEECLSID_XYContainer,(void **)&piXYCnt);
IXYContainer_QueryInterface(piXYCnt,AEEIID_IWidget,(void **)&piXYCntwgt);

// Create a static widget to display the strings we created.
ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_StaticWidget, (void**) &piwStatic1);

pWExtent.width = 100;
pWExtent.height = 20;
IWidget_SetExtent(piwStatic1,&pWExtent);
ppos.bVisible = TRUE;
ppos.x = 0;
ppos.y = 0;
IXYContainer_Insert(piXYCnt, piwStatic1, WIDGET_ZNORMAL, &ppos);

ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_StaticWidget, (void**) &piwStatic2);
IWidget_SetExtent(piwStatic2,&pWExtent);

ppos.bVisible = TRUE;
ppos.x = 0;
ppos.y = 15;
IXYContainer_Insert(piXYCnt, piwStatic2, WIDGET_ZNORMAL, &ppos);

IPropContainer_Insert(pMe->picPropCnt, piXYCntwgt, WIDGET_ZNORMAL, &WidProp);

ISHELL_CreateInstance(pMe->piShell,AEECLSID_XYContainer,(void **)&piXYCnt1);
IXYContainer_QueryInterface(piXYCnt1,AEEIID_IWidget,(void **)&piXYCntwgt1);

// Create a static widget to display the strings we created.
ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_StaticWidget, (void**) &piwStatic3);
IWidget_SetExtent(piwStatic3,&pWExtent);

ppos.bVisible = TRUE;
ppos.x = 0;
ppos.y = 0;
IXYContainer_Insert(piXYCnt1, piwStatic3, WIDGET_ZNORMAL, &ppos);

IPropContainer_Insert(pMe->picPropCnt, piXYCntwgt1, WIDGET_ZNORMAL, &WidProp);
// Set the background colors
IWidget_SetActiveBGColor(piwPropCnt, LIST_UA_RGBA_BACKGROUND);
IWidget_SetSelectedActiveBGColor(piwPropCnt, LIST_SA_RGBA_BACKGROUND);

// Set the widget's gradient colors and style (if applicable)
IWidget_SetGradientStyle(piwPropCnt, LIST_GRADIENT_STYLE);
if (LIST_GRADIENT_STYLE != GRADIENT_STYLE_NONE)
{
IWidget_SetActiveGradientColor(piwPropCnt, LIST_UA_RGBA_GRADIENT);
IWidget_SetSelectedActiveGradientColor(piwPropCnt, LIST_SA_RGBA_GRADIENT);
}

// Set the border widths and colors
// IWidget_SetActiveBorderWidth(piwPropCnt, LIST_ACTIVE_BORDERWIDTH);
IWidget_SetActiveBorderWidth(piwPropCnt, LIST_ACTIVE_BORDERWIDTH);
IWidget_SetActiveBorderColor(piwPropCnt, LIST_UA_RGBA_BORDER);
IWidget_SetSelectedActiveBorderColor(piwPropCnt, LIST_SA_RGBA_BORDER);

// Set the foreground (text) color (if applicable)
IWidget_SetActiveFGColor(piwPropCnt, LIST_UA_RGBA_FOREGROUND);
IWidget_SetSelectedActiveFGColor(piwPropCnt, LIST_SA_RGBA_FOREGROUND);

IWidget_SetActiveBorderWidth(pMe->piwlist, LIST_ACTIVE_BORDERWIDTH);

// Attach our static widget to the list widget so that the user can see all those strings
// we are trying to display.
IDecorator_SetWidget(pidList, piwPropCnt);

pWExtent.width = pMe->deviceInfo.cxScreen ;
pWExtent.height = pMe->deviceInfo.cyScreen ;
IWidget_SetItemHeight(pMe->piwlist, pWExtent.height / 8);

IWidget_SetFlags(pMe->piwlist, LWF_LIVESCROLL | LWF_PIXELSCROLL);
IWidget_SetExtent(pMe->piwlist, &pWExtent);

(void)IWidget_AddRef(pMe->piwlist);
ppos.bVisible = TRUE;
ppos.x = 0;
ppos.y = 0;
IRootContainer_Insert(pMe->picRootMenu, pMe->piwlist, WIDGET_ZNORMAL, &ppos);
IWidget_SetModel(pMe->piwlist, IMenuModel_to_IModel(pMe->m_pIMenuModel));

// Apply our list item listener to the list widget so we know when important
// events, such as a change in the selected item, occurs
IWidget_GetViewModel(pMe->piwlist, &piViewModel);
LISTENER_Init(&pMe->mlList, listwidgetapp_listviewlistener, (void*)pMe);
(void)IModel_AddListener(piViewModel, &pMe->mlList);
//Move focus to list widget
IWidget_MoveFocus(pMe->piwRootMenu, (IWidget *)WIDGET_FOCUS_FIRST);

// Clean up. Release local references.
RELEASEIF(piXYCnt);
RELEASEIF(piXYCntwgt);
RELEASEIF(piXYCnt1);
RELEASEIF(piXYCntwgt1);
RELEASEIF(piwImage1);
RELEASEIF(piwImage2);
RELEASEIF(piwImage3);
RELEASEIF(pidList);
RELEASEIF(piwStatic1);
RELEASEIF(piwStatic2);
RELEASEIF(piwPropCnt);
RELEASEIF(piViewModel);
RELEASEIF(pDisplayCanvas);

boolean Add_Items_VectorModel(IMenuModel *m_pIMenuModel, int nSize)
{
int i = 0, itemID = 1000;
for(i = 0; i < nSize; i++)
IMenuModel_Add(m_pIMenuModel, &i, itemID++, MMF_ENABLED);

void listwidgetapp_listviewlistener(listwidgetapp* pme, ModelEvent *pEvt)
{
WidgetElemStateEvent *wese = (WidgetElemStateEvent *)pEvt;
if (pEvt->evCode == EVT_MDL_FOCUS_SELECT) {
switch(pEvt->dwParam)
{
case 0:
break;
case 1:
case 2:
case 3:
break;
default:
break;
}
}

For optimized performance, you can use list container instead of list widget. Refer https://developer.brewmp.com/forum/custom-items-list-container
 

Use propcontainer or XYContainer as list item - add images and text widgets to container.
Install indexer on list or value model listener on container. Load and set the data (images/text) to corresponding widgets in indexer or value model listener. Here is a sample code snippet:
static int listwidgetapp_GetResString(IResFile *piResFile, int nResId, AECHAR **ppDest)
{
AEEResult nErr;
AECHAR *pwsz = NULL;
uint32 nLen = 0;

nErr = IResFile_Get(piResFile, (uint32)nResId, RESTYPE_STRING, (AECHAR*)-1, &nLen);

if (nLen > 2) {
pwsz = MALLOC(nLen);
if (NULL == pwsz) {
return (AEE_ENOMEMORY);
}
}

nErr = IResFile_Get(piResFile, (uint32)nResId, RESTYPE_STRING, pwsz, &nLen);
*ppDest = pwsz;

if (AEE_SUCCESS != nErr) {
*ppDest = NULL;
FREEIF(pwsz);
}
return nErr;

static int listwidgetapp_GetResImage(IResFile *piResFile, int nResId, IImage** ppDest)
{
AEEResult nErr;
void *pObj = NULL;
nErr = IResFile_GetObject(piResFile, (uint32)nResId, AEECLSID_VIEW, &pObj);
*ppDest = pObj;
return nErr;

void ListIndexer(void *pCtx, int nIndex, boolean bSelected)
{
IWidget *piwStatic1;
IWidget *piwStatic2;
IWidget *piwStatic3;
WidgetExtent pWExtent;

IWidget *piwImage1;
IWidget *piwImage2;
IWidget *piwImage3;
IImage *pii1 = NULL;
IImage *pii2 = NULL;
IImage *pii3 = NULL;
IWidget *piXYCntwgt = NULL;
IXYContainer *piXYCnt = NULL;
IWidget *piXYCntwgt1 = NULL;
IXYContainer *piXYCnt1 = NULL;
AECHAR *pszTxt;
listwidgetapp *pMe = (listwidgetapp *)pCtx;

if(nIndex >= 0 && nIndex < 10)
{
piwImage1 = IPropContainer_GetWidget(pMe->picPropCnt, WIDGET_ZNORMAL, TRUE, FALSE);
listwidgetapp_GetResImage(pMe->piResFile, IDI_PHOTO_1, &pii1) ;
IWidget_SetImage(piwImage1, pii1) ;

piwImage2 = IPropContainer_GetWidget(pMe->picPropCnt, piwImage1, TRUE, FALSE);
listwidgetapp_GetResImage(pMe->piResFile, IDI_PHOTO_2, &pii2) ;
IWidget_SetImage(piwImage2, pii2) ;

piwImage3 = IPropContainer_GetWidget(pMe->picPropCnt, piwImage2, TRUE, FALSE);
listwidgetapp_GetResImage(pMe->piResFile, IDI_PHOTO_3, &pii3) ;
IWidget_SetImage(piwImage3, pii3) ;

piXYCntwgt = IPropContainer_GetWidget(pMe->picPropCnt, piwImage3, TRUE, FALSE);
{
IWidget_QueryInterface(piXYCntwgt,AEEIID_IXYContainer,(void **)&piXYCnt);

piwStatic1 = IXYContainer_GetWidget(piXYCnt, WIDGET_ZNORMAL, TRUE, FALSE);
//load the text and set the data to widget
listwidgetapp_GetResString(pMe->piResFile,IDS_STR_NAME_1 + nIndex, &pszTxt);
if(piwStatic1)
{
if(nIndex == 0)
IWIDGET_SetText(piwStatic1, pszTxt, FALSE);
else
IWIDGET_SetText(piwStatic1, L"Hi", FALSE);
}

piwStatic2 = IXYContainer_GetWidget(piXYCnt, piwStatic1, TRUE, FALSE);
//load the text and set the data to widget
listwidgetapp_GetResString(pMe->piResFile,IDS_STR_NAME_1 + nIndex, &pszTxt);
if(piwStatic2)
IWIDGET_SetText(piwStatic2, pszTxt, FALSE);
IWidget_Animate(piwStatic2, TRUE);
}

piXYCntwgt1 = IPropContainer_GetWidget(pMe->picPropCnt, piXYCntwgt, TRUE, FALSE);
{
IWidget_QueryInterface(piXYCntwgt1,AEEIID_IXYContainer,(void **)&piXYCnt1);
IWidget_GetPreferredExtent(piXYCntwgt1,&pWExtent);
pWExtent.width = pMe->deviceInfo.cxScreen/2;
pWExtent.height = pMe->deviceInfo.cyScreen/8;
IWidget_SetExtent(piXYCntwgt1,&pWExtent);

piwStatic3 = IXYContainer_GetWidget(piXYCnt1, WIDGET_ZNORMAL, TRUE, FALSE);
//load the text and set the data to widget
listwidgetapp_GetResString(pMe->piResFile,IDS_STR_NAME_1 + nIndex, &pszTxt);
if(piwStatic3)
IWIDGET_SetText(piwStatic3, pszTxt, FALSE);
}

}

void listwidgetapp_DrawMainMenu(listwidgetapp * pMe)
{
int ret = 0;
IDisplayCanvas *pDisplayCanvas;
AEERect rectRoot;

WidgetExtent pWExtent;
WidgetPos ppos;
IWidget *piwPropCnt = NULL;
IWidget *piwStatic1 = NULL;
IWidget *piwStatic2 = NULL;
IWidget *piwStatic3 = NULL;
IDecorator *pidList = NULL;
IVectorModel *piVectorModel = NULL;
IModel *piViewModel = NULL;
WidgetProp WidProp;
IDecorator *pidRotate = NULL;
IWidget *piwImage1 = NULL;
IWidget *piwImage2 = NULL;
IWidget *piwImage3 = NULL;
IWidget *piXYCntwgt = NULL;
IXYContainer *piXYCnt = NULL;
IWidget *piXYCntwgt1 = NULL;
IXYContainer *piXYCnt1 = NULL;
int i = 0;

//Create display canvas and assign the display
ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_DisplayCanvas, (void**)&pDisplayCanvas);
IDisplayCanvas_SetDisplay(pDisplayCanvas, pMe->piDisplay);

//Create root container and assign the display canvas
ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_RootContainer, (void**)&pMe->picRootMenu);
ret = IRootContainer_QueryInterface(pMe->picRootMenu, AEEIID_IWidget, (void**)&pMe->piwRootMenu);

SETAEERECT(&rectRoot, 0, 0, pMe->deviceInfo.cxScreen, pMe->deviceInfo.cyScreen);
IRootContainer_SetCanvas(pMe->picRootMenu, (ICanvas*)pDisplayCanvas, &rectRoot);

// Set BG color
IWidget_SetBGColor(pMe->piwRootMenu, MAKE_RGBA(224, 224, 224, 255));
// Enable touch
IWidget_EnableTouch(pMe->piwRootMenu);

IShell_CreateInstance(pMe->piShell, AEECLSID_MenuModel, (void **)&pMe->m_pIMenuModel);
Add_Items_VectorModel(pMe->m_pIMenuModel, 4);

ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_ListWidget, (void**) &pidList);
IDecorator_QueryInterface(pidList, AEEIID_IWidget, (void**) &pMe->piwlist);

IWidget_SetIndexer(pMe->piwlist, ListIndexer, pMe);

// Create a prop container as list item.
ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_PropContainer, (void**) &pMe->picPropCnt);
WidProp.bVisible = TRUE;
WidProp.prop = WIDGET_SIZE_TO_FIT;
ret = IPropContainer_QueryInterface(pMe->picPropCnt, AEEIID_IWidget, (void**) &piwPropCnt);
IWidget_SetLayoutStyle(piwPropCnt, LAYOUT_HORZ);

ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_ImageWidget,(void **)&piwImage1);

IPropContainer_Insert(pMe->picPropCnt, piwImage1, WIDGET_ZNORMAL, &WidProp);

ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_ImageWidget,(void **)&piwImage2);
IPropContainer_Insert(pMe->picPropCnt, piwImage2, WIDGET_ZNORMAL, &WidProp);

ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_ImageWidget,(void **)&piwImage3);
IPropContainer_Insert(pMe->picPropCnt, piwImage3, WIDGET_ZNORMAL, &WidProp);

ISHELL_CreateInstance(pMe->piShell,AEECLSID_XYContainer,(void **)&piXYCnt);
IXYContainer_QueryInterface(piXYCnt,AEEIID_IWidget,(void **)&piXYCntwgt);

// Create a static widget to display the strings we created.
ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_StaticWidget, (void**) &piwStatic1);

pWExtent.width = 100;
pWExtent.height = 20;
IWidget_SetExtent(piwStatic1,&pWExtent);
ppos.bVisible = TRUE;
ppos.x = 0;
ppos.y = 0;
IXYContainer_Insert(piXYCnt, piwStatic1, WIDGET_ZNORMAL, &ppos);

ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_StaticWidget, (void**) &piwStatic2);
IWidget_SetExtent(piwStatic2,&pWExtent);

ppos.bVisible = TRUE;
ppos.x = 0;
ppos.y = 15;
IXYContainer_Insert(piXYCnt, piwStatic2, WIDGET_ZNORMAL, &ppos);

IPropContainer_Insert(pMe->picPropCnt, piXYCntwgt, WIDGET_ZNORMAL, &WidProp);

ISHELL_CreateInstance(pMe->piShell,AEECLSID_XYContainer,(void **)&piXYCnt1);
IXYContainer_QueryInterface(piXYCnt1,AEEIID_IWidget,(void **)&piXYCntwgt1);

// Create a static widget to display the strings we created.
ret = ISHELL_CreateInstance(pMe->piShell, AEECLSID_StaticWidget, (void**) &piwStatic3);
IWidget_SetExtent(piwStatic3,&pWExtent);

ppos.bVisible = TRUE;
ppos.x = 0;
ppos.y = 0;
IXYContainer_Insert(piXYCnt1, piwStatic3, WIDGET_ZNORMAL, &ppos);

IPropContainer_Insert(pMe->picPropCnt, piXYCntwgt1, WIDGET_ZNORMAL, &WidProp);
// Set the background colors
IWidget_SetActiveBGColor(piwPropCnt, LIST_UA_RGBA_BACKGROUND);
IWidget_SetSelectedActiveBGColor(piwPropCnt, LIST_SA_RGBA_BACKGROUND);

// Set the widget's gradient colors and style (if applicable)
IWidget_SetGradientStyle(piwPropCnt, LIST_GRADIENT_STYLE);
if (LIST_GRADIENT_STYLE != GRADIENT_STYLE_NONE)
{
IWidget_SetActiveGradientColor(piwPropCnt, LIST_UA_RGBA_GRADIENT);
IWidget_SetSelectedActiveGradientColor(piwPropCnt, LIST_SA_RGBA_GRADIENT);
}

// Set the border widths and colors
// IWidget_SetActiveBorderWidth(piwPropCnt, LIST_ACTIVE_BORDERWIDTH);
IWidget_SetActiveBorderWidth(piwPropCnt, LIST_ACTIVE_BORDERWIDTH);
IWidget_SetActiveBorderColor(piwPropCnt, LIST_UA_RGBA_BORDER);
IWidget_SetSelectedActiveBorderColor(piwPropCnt, LIST_SA_RGBA_BORDER);

// Set the foreground (text) color (if applicable)
IWidget_SetActiveFGColor(piwPropCnt, LIST_UA_RGBA_FOREGROUND);
IWidget_SetSelectedActiveFGColor(piwPropCnt, LIST_SA_RGBA_FOREGROUND);

IWidget_SetActiveBorderWidth(pMe->piwlist, LIST_ACTIVE_BORDERWIDTH);

// Attach our static widget to the list widget so that the user can see all those strings
// we are trying to display.
IDecorator_SetWidget(pidList, piwPropCnt);

pWExtent.width = pMe->deviceInfo.cxScreen ;
pWExtent.height = pMe->deviceInfo.cyScreen ;
IWidget_SetItemHeight(pMe->piwlist, pWExtent.height / 8);

IWidget_SetFlags(pMe->piwlist, LWF_LIVESCROLL | LWF_PIXELSCROLL);
IWidget_SetExtent(pMe->piwlist, &pWExtent);

(void)IWidget_AddRef(pMe->piwlist);
ppos.bVisible = TRUE;
ppos.x = 0;
ppos.y = 0;
IRootContainer_Insert(pMe->picRootMenu, pMe->piwlist, WIDGET_ZNORMAL, &ppos);
IWidget_SetModel(pMe->piwlist, IMenuModel_to_IModel(pMe->m_pIMenuModel));

// Apply our list item listener to the list widget so we know when important
// events, such as a change in the selected item, occurs
IWidget_GetViewModel(pMe->piwlist, &piViewModel);
LISTENER_Init(&pMe->mlList, listwidgetapp_listviewlistener, (void*)pMe);
(void)IModel_AddListener(piViewModel, &pMe->mlList);
//Move focus to list widget
IWidget_MoveFocus(pMe->piwRootMenu, (IWidget *)WIDGET_FOCUS_FIRST);

// Clean up. Release local references.
RELEASEIF(piXYCnt);
RELEASEIF(piXYCntwgt);
RELEASEIF(piXYCnt1);
RELEASEIF(piXYCntwgt1);
RELEASEIF(piwImage1);
RELEASEIF(piwImage2);
RELEASEIF(piwImage3);
RELEASEIF(pidList);
RELEASEIF(piwStatic1);
RELEASEIF(piwStatic2);
RELEASEIF(piwPropCnt);
RELEASEIF(piViewModel);
RELEASEIF(pDisplayCanvas);

boolean Add_Items_VectorModel(IMenuModel *m_pIMenuModel, int nSize)
{
int i = 0, itemID = 1000;
for(i = 0; i < nSize; i++)
IMenuModel_Add(m_pIMenuModel, &i, itemID++, MMF_ENABLED);

void listwidgetapp_listviewlistener(listwidgetapp* pme, ModelEvent *pEvt)
{
WidgetElemStateEvent *wese = (WidgetElemStateEvent *)pEvt;
if (pEvt->evCode == EVT_MDL_FOCUS_SELECT) {
switch(pEvt->dwParam)
{
case 0:
break;
case 1:
case 2:
case 3:
break;
default:
break;
}
}

For optimized performance, you can use list container instead of list widget. Refer https://developer.brewmp.com/forum/custom-items-list-container
 

Hi,
Since the indexer and the list item's value model listener are called each time the list is redrawn, you may want to consider caching the images and text possibly in pMe or even the model data for the list.  Otherwise, you may incur a performance penalty by constantly reloading the strings and images.  Avoiding re-loading the images is especially important because each time it is loaded the image needs to be decoded, which can lead to further performance issues.
 
-Jason F.

Hi,
Since the indexer and the list item's value model listener are called each time the list is redrawn, you may want to consider caching the images and text possibly in pMe or even the model data for the list.  Otherwise, you may incur a performance penalty by constantly reloading the strings and images.  Avoiding re-loading the images is especially important because each time it is loaded the image needs to be decoded, which can lead to further performance issues.
 
-Jason F.

HI Adhudase
 
I tried the above code what u have given but the problem what i am facing is with the ListIndexer call back functio. Its not going to that call back function, so images and datas are not displayed at all.. Please can u tell where i am going wrong??????
The problem with the Listcontainer with refernce the link what you provided (https://developer.brewmp.com/forum/custom-items-list-container) is that the focus sets for the double click but i want the focus to be changed for the single click...
Please suggest some ideas for the above query?
Regards 
Srinag

HI Adhudase
 
I tried the above code what u have given but the problem what i am facing is with the ListIndexer call back functio. Its not going to that call back function, so images and datas are not displayed at all.. Please can u tell where i am going wrong??????
The problem with the Listcontainer with refernce the link what you provided (https://developer.brewmp.com/forum/custom-items-list-container) is that the focus sets for the double click but i want the focus to be changed for the single click...
Please suggest some ideas for the above query?
Regards 
Srinag

Please make sure IWidget_SetIndexer is called properly. Did you try debugging?
 
In list container, focus changes on single click and selection happens on double click. To highlight the item on single click (to changes the focus), you need to set proper BG colors to list item. Use IWidget_SetActiveBGColor() and IWidget_SetSelectedActiveBGColor().

Please make sure IWidget_SetIndexer is called properly. Did you try debugging?
 
In list container, focus changes on single click and selection happens on double click. To highlight the item on single click (to changes the focus), you need to set proper BG colors to list item. Use IWidget_SetActiveBGColor() and IWidget_SetSelectedActiveBGColor().

Hi  Adhudase
According to above mail replied by Jason F we are the facing the issue what he has mentioned above, it is redrawing agian n again n making it more difficult to handle touch and key events.. I am not able cache the images. PLease suggest what i need to do????????/
 
Regards
Gautam

Hi  Adhudase
According to above mail replied by Jason F we are the facing the issue what he has mentioned above, it is redrawing agian n again n making it more difficult to handle touch and key events.. I am not able cache the images. PLease suggest what i need to do????????/
 
Regards
Gautam

Jason suggested having one copy of a image instead of loading same image multiple times. As you can see in code above we are loading images in indexer function which will be loaded multiple times. So load all the images used in list once and keep that as a part of applet structure (or vector model) and use them in list indexer function.

Jason suggested having one copy of a image instead of loading same image multiple times. As you can see in code above we are loading images in indexer function which will be loaded multiple times. So load all the images used in list once and keep that as a part of applet structure (or vector model) and use them in list indexer function.