ImenuModel and ImageStaticInfo | developer.brewmp.com ImenuModel and ImageStaticInfo | developer.brewmp.com

Developer

ImenuModel and ImageStaticInfo

Hi ,

I created a SampleMenu with IMenuModel and ListeWidget. Iam using ImagestaticInfo for setting text and icons, as MenuItems.

But text and Images that i setted are not displayed. My function is follwing,

Here imgStaticInfo is a global variable.

void createsampleMenu(Buit* pApp)
{

IImage* item = ISHELL_LoadResImage(pApp->a.m_pIShell, BUIT_RES_FILE, IDI_ICON);

if(item)
DBGPRINTF("Image Not NUll");
else
DBGPRINTF("Image Nullll");

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_GRIDWIDGET, (void **)&pListWidget );

ISHELL_CreateInstance( pApp->a.m_pIShell, AEECLSID_MENUMODEL, (void **)&pMenuModel );
ISHELL_CreateInstance( pApp->a.m_pIShell, AEECLSID_STATICWIDGET , (void **)&pStaticListWidget );

imgStaticInfo = MALLOC(sizeof(ImageStaticInfo));
imgStaticInfo->pwText = L"Hello";
imgStaticInfo->piImage = item;
IMENUMODEL_Add( pMenuModel, &imgStaticInfo, 0, MMF_ENABLED);

imgStaticInfo = MALLOC(sizeof(ImageStaticInfo));
imgStaticInfo->pwText = L"Hello";
imgStaticInfo->piImage = item;
IMENUMODEL_Add( pMenuModel, &imgStaticInfo, 1, MMF_ENABLED);

imgStaticInfo = MALLOC(sizeof(ImageStaticInfo));
imgStaticInfo->pwText = L"Hello";
imgStaticInfo->piImage = item;
IMENUMODEL_Add( pMenuModel, &imgStaticInfo, 2, MMF_ENABLED);

imgStaticInfo = MALLOC(sizeof(ImageStaticInfo));
imgStaticInfo->pwText = L"Hello";
imgStaticInfo->piImage = item;
IMENUMODEL_Add( pMenuModel, (void**)&imgStaticInfo, 3, MMF_ENABLED );

imgStaticInfo = MALLOC(sizeof(ImageStaticInfo));
imgStaticInfo->pwText = L"Hello";
imgStaticInfo->piImage = item;
IMENUMODEL_Add( pMenuModel, (void**)&imgStaticInfo, 4, MMF_ENABLED );

imgStaticInfo = MALLOC(sizeof(ImageStaticInfo));
imgStaticInfo->pwText = L"Hello";
imgStaticInfo->piImage = item;
IMENUMODEL_Add( pMenuModel, &imgStaticInfo, 5, MMF_ENABLED);

imgStaticInfo = MALLOC(sizeof(ImageStaticInfo));
imgStaticInfo->pwText = L"Hello";
imgStaticInfo->piImage = item;
IMENUMODEL_Add( pMenuModel, &imgStaticInfo, 6, MMF_ENABLED);

imgStaticInfo = MALLOC(sizeof(ImageStaticInfo));
imgStaticInfo->pwText = L"Hello";
imgStaticInfo->piImage = item;
IMENUMODEL_Add( pMenuModel, &imgStaticInfo, 7, MMF_ENABLED);

IWIDGET_SetModel( pListWidget, IMENUMODEL_TO_IMODEL(pMenuModel));
IWIDGET_GetViewModel(pListWidget, (IModel*)&tmpViewModel);

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, 100);
IWIDGET_SetItemWidth(pListWidget, 100);

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

Make your list item widget an image static widget. You're using a static widget, which won't work with ImageStaticInfo.
-Erik

Make your list item widget an image static widget. You're using a static widget, which won't work with ImageStaticInfo.
-Erik

hi premlal and ebrowne
Seems that you 2 come here often, i am a newbie in brew, and need some advice about how to study it, could you pls give me some?
The examples are totally different with the VC automatically generated project, so, is there tutorial about how to build a example-like project from the very begining?
And i am still doubted by the event handle mechanism of brew UI, is there a more detailed explaination on it?
Pls share your study experience with me,
all resources like tuturials, documents, examples... etc are welcome~
thank you very much~~~

hi premlal and ebrowne
Seems that you 2 come here often, i am a newbie in brew, and need some advice about how to study it, could you pls give me some?
The examples are totally different with the VC automatically generated project, so, is there tutorial about how to build a example-like project from the very begining?
And i am still doubted by the event handle mechanism of brew UI, is there a more detailed explaination on it?
Pls share your study experience with me,
all resources like tuturials, documents, examples... etc are welcome~
thank you very much~~~

Hi,
Calculator is the best example for studying BUIT. You can download that from extranet ,if you are an authenticated developper.
Regards
premlal

Hi,
Calculator is the best example for studying BUIT. You can download that from extranet ,if you are an authenticated developper.
Regards
premlal

Hi Erik,
I tried with AEECLSID_IMAGESTATICWIDGET. But result is same.
Thanks
Premlal

Hi Erik,
I tried with AEECLSID_IMAGESTATICWIDGET. But result is same.
Thanks
Premlal

Hello Premlal,
Just verify these steps
1) Create the List or Grid widget
2) Create the ImageStatic Widget
3) Set Image static widget as item to list or grid widget
4) Set proper properties to the list and the item widget
5) Create a Menu Model and attach it to the List/Grid Widget
6) Now for adding data to the List
a) allocate memory for the ImageStaticInfo structure
b) and pass the poiter to AECHAR and IImage data member
7) set the list widget as the WID_FORM to the form
One thing I noticed that you are storing the text without allocating memory to the AECHAR type data member
Try doing it
I hope this will solve the problem
Let me know in either of the case

Hello Premlal,
Just verify these steps
1) Create the List or Grid widget
2) Create the ImageStatic Widget
3) Set Image static widget as item to list or grid widget
4) Set proper properties to the list and the item widget
5) Create a Menu Model and attach it to the List/Grid Widget
6) Now for adding data to the List
a) allocate memory for the ImageStaticInfo structure
b) and pass the poiter to AECHAR and IImage data member
7) set the list widget as the WID_FORM to the form
One thing I noticed that you are storing the text without allocating memory to the AECHAR type data member
Try doing it
I hope this will solve the problem
Let me know in either of the case

Hi lalit,
Thanks,
I think the steps that u mentioned are followed correctly in the above code.
One change i made is that AEECLSID_STATICWIDGET is replaced with AEECLSID_IMAGESTATICWIDGET.
Storing the text without allocating memory to the AECHAR type data member is working fine. This is tested in simulator only. I dont know what is "L" stands for in text creation. I got this from forum.
Thanks
Premlal

Hi lalit,
Thanks,
I think the steps that u mentioned are followed correctly in the above code.
One change i made is that AEECLSID_STATICWIDGET is replaced with AEECLSID_IMAGESTATICWIDGET.
Storing the text without allocating memory to the AECHAR type data member is working fine. This is tested in simulator only. I dont know what is "L" stands for in text creation. I got this from forum.
Thanks
Premlal

Thats nice
The "L" represent the wide-character string..

Thats nice
The "L" represent the wide-character string..

Hi lalit,,
Solved my problem .problem is that ImageStaticInfo is a pointer and i passed the address of imageStaticinfo to the IMENUMODEL_Add( pMenuModel, &imgStaticInfo, 1, MMF_ENABLED); Tried with Replacing with IMENUMODEL_Add( pMenuModel, imgStaticInfo, 1, MMF_ENABLED),then it works.
Thanks for all the helps
premlal

Hi lalit,,
Solved my problem .problem is that ImageStaticInfo is a pointer and i passed the address of imageStaticinfo to the IMENUMODEL_Add( pMenuModel, &imgStaticInfo, 1, MMF_ENABLED); Tried with Replacing with IMENUMODEL_Add( pMenuModel, imgStaticInfo, 1, MMF_ENABLED),then it works.
Thanks for all the helps
premlal

premlal wrote:
IWIDGET_GetPreferredExtent( pStaticListWidget, &we );
IWIDGET_SetItemHeight(pListWidget, 100);
IWIDGET_SetItemWidth(pListWidget, 100);
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);
HI~ALL~
I am most confused by the IWIDGET_GetPreferredExtent() function, i used it for the gridwidget here, but seems that it only counts the size of the widget's border!
ie. when i set the widget's border width to 1, the 'we' will be 2X2, set border width to 10, the 'we' will be 20X20! But i have 25X25 bmp wrapped in the gridwidget, why the function ignore it?!
below is my code, pls help me, thank you~~:
IWIDGET_SetBorderWidth( me->pIMenuWidget , 10 );
...
we.height = 40;
we.width =40;
IWIDGET_SetExtent(pImgStaticWidget, &we);
IDECORATOR_SetWidget( me->pIMenuWidget, pImgStaticWidget );
IDECORATOR_GetPreferredExtent( me->pIMenuWidget, &we );
IWIDGET_SetExtent(me->pIMenuWidget, &we);
IFORM_SetWidget(me->piForm, WID_FORM, me->pIMenuWidget);

premlal wrote:
IWIDGET_GetPreferredExtent( pStaticListWidget, &we );
IWIDGET_SetItemHeight(pListWidget, 100);
IWIDGET_SetItemWidth(pListWidget, 100);
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);
HI~ALL~
I am most confused by the IWIDGET_GetPreferredExtent() function, i used it for the gridwidget here, but seems that it only counts the size of the widget's border!
ie. when i set the widget's border width to 1, the 'we' will be 2X2, set border width to 10, the 'we' will be 20X20! But i have 25X25 bmp wrapped in the gridwidget, why the function ignore it?!
below is my code, pls help me, thank you~~:
IWIDGET_SetBorderWidth( me->pIMenuWidget , 10 );
...
we.height = 40;
we.width =40;
IWIDGET_SetExtent(pImgStaticWidget, &we);
IDECORATOR_SetWidget( me->pIMenuWidget, pImgStaticWidget );
IDECORATOR_GetPreferredExtent( me->pIMenuWidget, &we );
IWIDGET_SetExtent(me->pIMenuWidget, &we);
IFORM_SetWidget(me->piForm, WID_FORM, me->pIMenuWidget);

Have you put any data in the grid widget's model? If the model is empty then the widget will be empty, and the preferred extent will be just the size of the borders.
-Erik

Have you put any data in the grid widget's model? If the model is empty then the widget will be empty, and the preferred extent will be just the size of the borders.
-Erik

hi~
Yes i have wirte the code below:
IWIDGET_SetModel( me->pIMenuWidget, IMENUMODEL_TO_IMODEL(pMenuModel) );
but still not work
Thanks anyway

hi~
Yes i have wirte the code below:
IWIDGET_SetModel( me->pIMenuWidget, IMENUMODEL_TO_IMODEL(pMenuModel) );
but still not work
Thanks anyway