IMENUMODEL and Image | developer.brewmp.com IMENUMODEL and Image | developer.brewmp.com

Developer

IMENUMODEL and Image

is possible to insert an image in a IMENUMODEL ?

Yes, but you will need to add an indexer to the list widget. The list widget can only handle item widgets which use an IValueModel, but the image widget uses an IInterfaceModel. So you need an indexer function to set the IImage to the image widget's model.
-Erik

Yes, but you will need to add an indexer to the list widget. The list widget can only handle item widgets which use an IValueModel, but the image widget uses an IInterfaceModel. So you need an indexer function to set the IImage to the image widget's model.
-Erik

I'm trying to implement the indexer solution, but am running into trouble. My approach is to pass the IWidget pointer for the List Widget as the context to the indexer, then:
- Get Model from the list widget (this doesn't seem to be working...it returns 0 SUCCESS, but doesn't change the IModel * pointer I pass in)
- Fetch data out of the model using the passed in index
- Get the item widget associated with the list widget
- Set the image on the item widget
If there is something wrong with my approach and/or anyone has any tips on why my IWIDGET_GetModel call is not working, I'd love to hear. Also, this seems horribly counter-intuitive...is it the only way to do it?

I'm trying to implement the indexer solution, but am running into trouble. My approach is to pass the IWidget pointer for the List Widget as the context to the indexer, then:
- Get Model from the list widget (this doesn't seem to be working...it returns 0 SUCCESS, but doesn't change the IModel * pointer I pass in)
- Fetch data out of the model using the passed in index
- Get the item widget associated with the list widget
- Set the image on the item widget
If there is something wrong with my approach and/or anyone has any tips on why my IWIDGET_GetModel call is not working, I'd love to hear. Also, this seems horribly counter-intuitive...is it the only way to do it?

Ok, I got this working. I was passing in the model instead of the widget in the indexer setup. Here's my indexer for anyone who is trying to attempt this:
void ListIndexer(void *data, int nIndex, boolean bSelected) {
IWidget *widget = (IWidget *)data;
IMenuModel *model;
IWIDGET_GetModel(widget, AEEIID_MENUMODEL, (IModel **)&model);
uint16 flags;
uint16 commandId;
IImage *image;
IMENUMODEL_GetAt(model, nIndex, MENUITEM_ALL, (void **)&image, &flags, &commandId);
IWidget *imageWidget;
IDecorator *decorator;
IWIDGET_QueryInterface(widget, AEEIID_DECORATOR, (void **)&decorator);
IDECORATOR_GetWidget(decorator, &imageWidget);
IWIDGET_SetImage(imageWidget, image);

Ok, I got this working. I was passing in the model instead of the widget in the indexer setup. Here's my indexer for anyone who is trying to attempt this:
void ListIndexer(void *data, int nIndex, boolean bSelected) {
IWidget *widget = (IWidget *)data;
IMenuModel *model;
IWIDGET_GetModel(widget, AEEIID_MENUMODEL, (IModel **)&model);
uint16 flags;
uint16 commandId;
IImage *image;
IMENUMODEL_GetAt(model, nIndex, MENUITEM_ALL, (void **)&image, &flags, &commandId);
IWidget *imageWidget;
IDecorator *decorator;
IWIDGET_QueryInterface(widget, AEEIID_DECORATOR, (void **)&decorator);
IDECORATOR_GetWidget(decorator, &imageWidget);
IWIDGET_SetImage(imageWidget, image);

Hi Erik,
Iam also facing the similar problem. Can u give some more explanation regarding this, with some examples.
Thanks
Premlal

Hi Erik,
Iam also facing the similar problem. Can u give some more explanation regarding this, with some examples.
Thanks
Premlal

Hi Alworld and Erik,
Is this listindexer() function is a callBack function . How to link this function to my createsampleMenu() function. My createsampleMenu() function is follows.help me...
My menufunction is,
void createsampleMenu(Buit* pApp)
{
IImage* item = ISHELL_LoadResImage(pApp->a.m_pIShell, BUIT_RES_FILE, IDI_ICON);
ISHELL_CreateInstance(pApp->a.m_pIShell, AEECLSID_FORM, (void **)&pApp->mainForm);
ISHELL_CreateInstance(pApp->a.m_pIShell, AEECLSID_XYCONTAINER, (void**)&XYcontainerWidget);
ISHELL_CreateInstance( pApp->a.m_pIShell, AEECLSID_PICKWIDGET, (void **)&pListWidget );
ISHELL_CreateInstance( pApp->a.m_pIShell, AEECLSID_MENUMODEL, (void **)&pMenuModel );
ISHELL_CreateInstance( pApp->a.m_pIShell, AEECLSID_STATICWIDGET , (void **)&pStaticListWidget );
IMENUMODEL_Add( pMenuModel, item, 0, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, item, 1, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, item, 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, item, 3, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, item, 4, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, item, 5, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, item, 6, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, item, 7, MMF_ENABLED );
IWIDGET_SetModel( pListWidget, IMENUMODEL_TO_IMODEL(pMenuModel));
IWIDGET_GetViewModel(pListWidget, (IModel*)&tmpViewModel);
ListIndexer(&tmpViewModel, 5, TRUE);
sam.pfnListener = ListenerFunc;
sam.pListenerData = pApp;
IMODEL_AddListener(tmpViewModel, &sam);
IWIDGET_SetBGColor(pListWidget, MAKE_RGB(0,255,255));
IWIDGET_SetBorderWidth(pListWidget , 2);
IWIDGET_SetSelectedFGColor( pListWidget, MAKE_RGB(255, 255, 255) );
IWIDGET_SetSelectedBGColor(pStaticListWidget, MAKE_RGB(255, 0 ,255));
IWIDGET_SetProperty( pListWidget, PROP_FLAGS, LWF_WRAP);
IWIDGET_SetTransparency( pListWidget, 10 );
IWIDGET_SetFlags(pListWidget,IDF_ALIGN_CENTER|IDF_ALIGN_MIDDLE);
IWIDGET_GetPreferredExtent( pStaticListWidget, &we );
IWIDGET_SetItemHeight(pListWidget, we.height+15 );
IWIDGET_SetItemWidth(pListWidget, we.width+50);
we.height = 320;
we.width = 240;
IWIDGET_SetExtent( pListWidget, &we );
wpos.bVisible = TRUE ;
wpos.x = 0 ; wpos.y = 0 ;
IDECORATOR_SetWidget( (IDecorator *) pListWidget, pStaticListWidget );
IXYCONTAINER_Insert(XYcontainerWidget, pListWidget, WIDGET_ZNORMAL,&wpos);
if(IXYCONTAINER_QueryInterface(XYcontainerWidget, AEEIID_WIDGET, (void**)&menuContainer)== SUCCESS)
{
IWIDGET_SetLayoutStyle(menuContainer, 0);
IWIDGET_SetBGColor(menuContainer,MAKE_RGB(0,255,0));
IWIDGET_SetBorderColor(menuContainer, MAKE_RGB(0,0,0));
IWIDGET_SetBorderWidth(menuContainer, 2);
IFORM_SetWidget(pApp->mainForm,WID_FORM, menuContainer);
IFORM_SetTitle(pApp->mainForm, L"Baby.jpg");
IFORM_SetSoftkey(pApp->mainForm, FID_SOFTKEY1 ,L"Options");
IFORM_SetSoftkey(pApp->mainForm, FID_SOFTKEY2 ,L"Back");
IROOTFORM_PushForm(pApp->rootForm,pApp->mainForm);
}
}
Thanks,
Premlal

Hi Alworld and Erik,
Is this listindexer() function is a callBack function . How to link this function to my createsampleMenu() function. My createsampleMenu() function is follows.help me...
My menufunction is,
void createsampleMenu(Buit* pApp)
{
IImage* item = ISHELL_LoadResImage(pApp->a.m_pIShell, BUIT_RES_FILE, IDI_ICON);
ISHELL_CreateInstance(pApp->a.m_pIShell, AEECLSID_FORM, (void **)&pApp->mainForm);
ISHELL_CreateInstance(pApp->a.m_pIShell, AEECLSID_XYCONTAINER, (void**)&XYcontainerWidget);
ISHELL_CreateInstance( pApp->a.m_pIShell, AEECLSID_PICKWIDGET, (void **)&pListWidget );
ISHELL_CreateInstance( pApp->a.m_pIShell, AEECLSID_MENUMODEL, (void **)&pMenuModel );
ISHELL_CreateInstance( pApp->a.m_pIShell, AEECLSID_STATICWIDGET , (void **)&pStaticListWidget );
IMENUMODEL_Add( pMenuModel, item, 0, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, item, 1, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, item, 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, item, 3, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, item, 4, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, item, 5, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, item, 6, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, item, 7, MMF_ENABLED );
IWIDGET_SetModel( pListWidget, IMENUMODEL_TO_IMODEL(pMenuModel));
IWIDGET_GetViewModel(pListWidget, (IModel*)&tmpViewModel);
ListIndexer(&tmpViewModel, 5, TRUE);
sam.pfnListener = ListenerFunc;
sam.pListenerData = pApp;
IMODEL_AddListener(tmpViewModel, &sam);
IWIDGET_SetBGColor(pListWidget, MAKE_RGB(0,255,255));
IWIDGET_SetBorderWidth(pListWidget , 2);
IWIDGET_SetSelectedFGColor( pListWidget, MAKE_RGB(255, 255, 255) );
IWIDGET_SetSelectedBGColor(pStaticListWidget, MAKE_RGB(255, 0 ,255));
IWIDGET_SetProperty( pListWidget, PROP_FLAGS, LWF_WRAP);
IWIDGET_SetTransparency( pListWidget, 10 );
IWIDGET_SetFlags(pListWidget,IDF_ALIGN_CENTER|IDF_ALIGN_MIDDLE);
IWIDGET_GetPreferredExtent( pStaticListWidget, &we );
IWIDGET_SetItemHeight(pListWidget, we.height+15 );
IWIDGET_SetItemWidth(pListWidget, we.width+50);
we.height = 320;
we.width = 240;
IWIDGET_SetExtent( pListWidget, &we );
wpos.bVisible = TRUE ;
wpos.x = 0 ; wpos.y = 0 ;
IDECORATOR_SetWidget( (IDecorator *) pListWidget, pStaticListWidget );
IXYCONTAINER_Insert(XYcontainerWidget, pListWidget, WIDGET_ZNORMAL,&wpos);
if(IXYCONTAINER_QueryInterface(XYcontainerWidget, AEEIID_WIDGET, (void**)&menuContainer)== SUCCESS)
{
IWIDGET_SetLayoutStyle(menuContainer, 0);
IWIDGET_SetBGColor(menuContainer,MAKE_RGB(0,255,0));
IWIDGET_SetBorderColor(menuContainer, MAKE_RGB(0,0,0));
IWIDGET_SetBorderWidth(menuContainer, 2);
IFORM_SetWidget(pApp->mainForm,WID_FORM, menuContainer);
IFORM_SetTitle(pApp->mainForm, L"Baby.jpg");
IFORM_SetSoftkey(pApp->mainForm, FID_SOFTKEY1 ,L"Options");
IFORM_SetSoftkey(pApp->mainForm, FID_SOFTKEY2 ,L"Back");
IROOTFORM_PushForm(pApp->rootForm,pApp->mainForm);
}
}
Thanks,
Premlal

Just like in your other post, using a static widget to display an image won't work. Use an image widget.
To set an indexer use IWIDGET_SetIndexer().
-Erik

Just like in your other post, using a static widget to display an image won't work. Use an image widget.
To set an indexer use IWIDGET_SetIndexer().
-Erik

thanls Erik..Its working...

thanls Erik..Its working...