Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

--------------------------------------------------------------------------------

Hi all,

Iam new Uiwidgets and Forms.Any body please explain how to handle the events in various widgets and forms.

Currently im stucked in handling UP nad Down keys in a list widget. My problem is bellow.

I created a main menu with list widget(AEECLSID_LISTWIDGET).
List is displayed with menu items with IMenuModel.But i don't know how to handle the events in list, means selecting UP and Down keys.Any body please advice me about the event handling in list widget with some source code.
My mainmenu creation code is bellow.

void createSampleMenu(helloformapp* pApp)
{

ISHELL_CreateInstance(pApp->pIShell, AEECLSID_ROOTFORM, (void **)&piRootForm);
ISHELL_CreateInstance(pApp->pIShell, AEECLSID_FORM, (void **)&piForm);
ISHELL_CreateInstance(pApp->pIShell, AEECLSID_XYCONTAINER, (void**)&XYcontainerWidget);
ISHELL_CreateInstance( pApp->pIShell, AEECLSID_LISTWIDGET, (void **)&pListWidget );
ISHELL_CreateInstance( pApp->pIShell, AEECLSID_MENUMODEL, (void **)&pMenuModel );
ISHELL_CreateInstance( pApp->pIShell, AEECLSID_STATICWIDGET , (void **)&pStaticListWidget );

IMENUMODEL_Add( pMenuModel, L"Browser", 0, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Camera", 1, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"BlueBox", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Morph", 3, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Settings", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Help", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"About", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Exit", 2, MMF_ENABLED );
IWIDGET_SetModel( pListWidget, IMENUMODEL_TO_IMODEL(pMenuModel) );

IWIDGET_SetBorderWidth( pListWidget , 3 );
IWIDGET_SetSelectedFGColor( pListWidget, MAKE_RGBA(125, 255, 255, 255) );
IWIDGET_SetSelectedBGColor( pListWidget, MAKE_RGBA(125, 233, 10, 5) );
IWIDGET_SetSelectedFGColor( pStaticListWidget, MAKE_RGBA(255, 255, 255, 255) );
IWIDGET_SetSelectedBGColor( pStaticListWidget, MAKE_RGB(255, 0 , 255));
IWIDGET_SetProperty(pStaticListWidget, PROP_SELECTED_FGCOLOR, MAKE_RGB(0, 255, 0));
IWIDGET_SetProperty( pListWidget, PROP_FLAGS, LWF_WRAP );
IWIDGET_SetTransparency( pListWidget, 255 );

IWIDGET_GetPreferredExtent( pStaticListWidget, &we );
IWIDGET_SetItemHeight( pListWidget, we.height+4 );
we.height =100 ;
we.width = 75;
IWIDGET_SetExtent( pListWidget, &we );
wpos.bVisible = TRUE ;
wpos.x = 240/3 ; wpos.y = 25 ;
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);

IWIDGET_SetGradientStyle(menuContainer,1);
IWIDGET_SetTransparency(menuContainer,5);
IFORM_SetWidget(piForm,WID_FORM, menuContainer);
IFORM_SetSoftkey(piForm, FID_SOFTKEY1 ,L"Options");
IFORM_SetSoftkey(piForm, FID_SOFTKEY2 ,L"Back");

IROOTFORM_PushForm(piRootForm,piForm);

}

Regars and thanks
Premlal

hi
Add a model to the listwidget.In modellistener structure u will get a PFNLISTENER.
in that u will get the events like EVT_MDL_FOCUS_SELECT, EVT_MDL_FOCUS_CHANGE ......
premlal wrote:--------------------------------------------------------------------------------
Hi all,
Iam new Uiwidgets and Forms.Any body please explain how to handle the events in various widgets and forms.
Currently im stucked in handling UP nad Down keys in a list widget. My problem is bellow.
I created a main menu with list widget(AEECLSID_LISTWIDGET).
List is displayed with menu items with IMenuModel.But i don't know how to handle the events in list, means selecting UP and Down keys.Any body please advice me about the event handling in list widget with some source code.
My mainmenu creation code is bellow.
void createSampleMenu(helloformapp* pApp)
{
ISHELL_CreateInstance(pApp->pIShell, AEECLSID_ROOTFORM, (void **)&piRootForm);
ISHELL_CreateInstance(pApp->pIShell, AEECLSID_FORM, (void **)&piForm);
ISHELL_CreateInstance(pApp->pIShell, AEECLSID_XYCONTAINER, (void**)&XYcontainerWidget);
ISHELL_CreateInstance( pApp->pIShell, AEECLSID_LISTWIDGET, (void **)&pListWidget );
ISHELL_CreateInstance( pApp->pIShell, AEECLSID_MENUMODEL, (void **)&pMenuModel );
ISHELL_CreateInstance( pApp->pIShell, AEECLSID_STATICWIDGET , (void **)&pStaticListWidget );
IMENUMODEL_Add( pMenuModel, L"Browser", 0, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Camera", 1, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"BlueBox", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Morph", 3, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Settings", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Help", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"About", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Exit", 2, MMF_ENABLED );
IWIDGET_SetModel( pListWidget, IMENUMODEL_TO_IMODEL(pMenuModel) );
IWIDGET_SetBorderWidth( pListWidget , 3 );
IWIDGET_SetSelectedFGColor( pListWidget, MAKE_RGBA(125, 255, 255, 255) );
IWIDGET_SetSelectedBGColor( pListWidget, MAKE_RGBA(125, 233, 10, 5) );
IWIDGET_SetSelectedFGColor( pStaticListWidget, MAKE_RGBA(255, 255, 255, 255) );
IWIDGET_SetSelectedBGColor( pStaticListWidget, MAKE_RGB(255, 0 , 255));
IWIDGET_SetProperty(pStaticListWidget, PROP_SELECTED_FGCOLOR, MAKE_RGB(0, 255, 0));
IWIDGET_SetProperty( pListWidget, PROP_FLAGS, LWF_WRAP );
IWIDGET_SetTransparency( pListWidget, 255 );
IWIDGET_GetPreferredExtent( pStaticListWidget, &we );
IWIDGET_SetItemHeight( pListWidget, we.height+4 );
we.height =100 ;
we.width = 75;
IWIDGET_SetExtent( pListWidget, &we );
wpos.bVisible = TRUE ;
wpos.x = 240/3 ; wpos.y = 25 ;
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);
IWIDGET_SetGradientStyle(menuContainer,1);
IWIDGET_SetTransparency(menuContainer,5);
IFORM_SetWidget(piForm,WID_FORM, menuContainer);
IFORM_SetSoftkey(piForm, FID_SOFTKEY1 ,L"Options");
IFORM_SetSoftkey(piForm, FID_SOFTKEY2 ,L"Back");
IROOTFORM_PushForm(piRootForm,piForm);

}
Regars and thanks
Premlal

hi
Add a model to the listwidget.In modellistener structure u will get a PFNLISTENER.
in that u will get the events like EVT_MDL_FOCUS_SELECT, EVT_MDL_FOCUS_CHANGE ......
premlal wrote:--------------------------------------------------------------------------------
Hi all,
Iam new Uiwidgets and Forms.Any body please explain how to handle the events in various widgets and forms.
Currently im stucked in handling UP nad Down keys in a list widget. My problem is bellow.
I created a main menu with list widget(AEECLSID_LISTWIDGET).
List is displayed with menu items with IMenuModel.But i don't know how to handle the events in list, means selecting UP and Down keys.Any body please advice me about the event handling in list widget with some source code.
My mainmenu creation code is bellow.
void createSampleMenu(helloformapp* pApp)
{
ISHELL_CreateInstance(pApp->pIShell, AEECLSID_ROOTFORM, (void **)&piRootForm);
ISHELL_CreateInstance(pApp->pIShell, AEECLSID_FORM, (void **)&piForm);
ISHELL_CreateInstance(pApp->pIShell, AEECLSID_XYCONTAINER, (void**)&XYcontainerWidget);
ISHELL_CreateInstance( pApp->pIShell, AEECLSID_LISTWIDGET, (void **)&pListWidget );
ISHELL_CreateInstance( pApp->pIShell, AEECLSID_MENUMODEL, (void **)&pMenuModel );
ISHELL_CreateInstance( pApp->pIShell, AEECLSID_STATICWIDGET , (void **)&pStaticListWidget );
IMENUMODEL_Add( pMenuModel, L"Browser", 0, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Camera", 1, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"BlueBox", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Morph", 3, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Settings", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Help", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"About", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Exit", 2, MMF_ENABLED );
IWIDGET_SetModel( pListWidget, IMENUMODEL_TO_IMODEL(pMenuModel) );
IWIDGET_SetBorderWidth( pListWidget , 3 );
IWIDGET_SetSelectedFGColor( pListWidget, MAKE_RGBA(125, 255, 255, 255) );
IWIDGET_SetSelectedBGColor( pListWidget, MAKE_RGBA(125, 233, 10, 5) );
IWIDGET_SetSelectedFGColor( pStaticListWidget, MAKE_RGBA(255, 255, 255, 255) );
IWIDGET_SetSelectedBGColor( pStaticListWidget, MAKE_RGB(255, 0 , 255));
IWIDGET_SetProperty(pStaticListWidget, PROP_SELECTED_FGCOLOR, MAKE_RGB(0, 255, 0));
IWIDGET_SetProperty( pListWidget, PROP_FLAGS, LWF_WRAP );
IWIDGET_SetTransparency( pListWidget, 255 );
IWIDGET_GetPreferredExtent( pStaticListWidget, &we );
IWIDGET_SetItemHeight( pListWidget, we.height+4 );
we.height =100 ;
we.width = 75;
IWIDGET_SetExtent( pListWidget, &we );
wpos.bVisible = TRUE ;
wpos.x = 240/3 ; wpos.y = 25 ;
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);
IWIDGET_SetGradientStyle(menuContainer,1);
IWIDGET_SetTransparency(menuContainer,5);
IFORM_SetWidget(piForm,WID_FORM, menuContainer);
IFORM_SetSoftkey(piForm, FID_SOFTKEY1 ,L"Options");
IFORM_SetSoftkey(piForm, FID_SOFTKEY2 ,L"Back");
IROOTFORM_PushForm(piRootForm,piForm);

}
Regars and thanks
Premlal

Hi Srinivas ,
Thanks for ur quick reply. Itried with follwing code
IWIDGET_GetViewModel(pListWidget, &tempList);
pListener = (ModelListener*)MALLOC(sizeof(ModelListener));
LISTENER_Init(pListener, ListenerFunc, pApp);
IMODEL_AddListener(tempList, pListener);
My handler function is follows .
boolean ListenerFunc(helloformapp* pApp, AEEEvent evt, uint16 wParam, uint32 dwParam)
{
DBGPRINTF("IN HADLE EVENT");
if(evt == EVT_KEY)
{
DBGPRINTF("TAKE HANDLE EVENT");
}
DBGPRINTF("IN HADLE EVENTTTTTTTTTTTT");
return TRUE;

This function worked only one time during the execution of that function.After that nothing happens.
Full source code is attached.
Thanks
Premlal

Hi Srinivas ,
Thanks for ur quick reply. Itried with follwing code
IWIDGET_GetViewModel(pListWidget, &tempList);
pListener = (ModelListener*)MALLOC(sizeof(ModelListener));
LISTENER_Init(pListener, ListenerFunc, pApp);
IMODEL_AddListener(tempList, pListener);
My handler function is follows .
boolean ListenerFunc(helloformapp* pApp, AEEEvent evt, uint16 wParam, uint32 dwParam)
{
DBGPRINTF("IN HADLE EVENT");
if(evt == EVT_KEY)
{
DBGPRINTF("TAKE HANDLE EVENT");
}
DBGPRINTF("IN HADLE EVENTTTTTTTTTTTT");
return TRUE;

This function worked only one time during the execution of that function.After that nothing happens.
Full source code is attached.
Thanks
Premlal

Hi
Quote:IModel *tmpViewModel =NULL;
IWIDGET_GetViewModel( pListWidget, &tmpViewModel );
ListModelListener.pfnListener = ListListener ;
ListModelListener.pListenerData = (void *)this ;
IMODEL_AddListener( tmpViewModel, &ListModelListener);
ReleaseIF( tmpViewModel );
ListListener( void *pCxt, ModelEvent *pModelEvent )
in modelevent u will get eCode dwparam .....
switch ( pModelEvent->evCode )
{
case EVT_MDL_FOCUS_SELECT:
{
...............
...........

Hi
Quote:IModel *tmpViewModel =NULL;
IWIDGET_GetViewModel( pListWidget, &tmpViewModel );
ListModelListener.pfnListener = ListListener ;
ListModelListener.pListenerData = (void *)this ;
IMODEL_AddListener( tmpViewModel, &ListModelListener);
ReleaseIF( tmpViewModel );
ListListener( void *pCxt, ModelEvent *pModelEvent )
in modelevent u will get eCode dwparam .....
switch ( pModelEvent->evCode )
{
case EVT_MDL_FOCUS_SELECT:
{
...............
...........

Hi,
I already tried with this.Then a compilation error is shown,
That Error is ,
error C2065: 'ListModelListener' : undeclared identifier
error C2065: 'ListListener' : undeclared identifier.
shall i miss any header file?
Thanks
Premlal

Hi,
I already tried with this.Then a compilation error is shown,
That Error is ,
error C2065: 'ListModelListener' : undeclared identifier
error C2065: 'ListListener' : undeclared identifier.
shall i miss any header file?
Thanks
Premlal

Why do you want to handle the up and down keys? The menu handles them for you. All you need to do is add a listener to the list widget's view model that listens for EVT_MDL_FOCUS_SELECT, which you receive when the user selects an item.
If you really need to deal with key events, use IWIDGET_SetHandler() to attach an event handler to the list widget.
-Erik

Why do you want to handle the up and down keys? The menu handles them for you. All you need to do is add a listener to the list widget's view model that listens for EVT_MDL_FOCUS_SELECT, which you receive when the user selects an item.
If you really need to deal with key events, use IWIDGET_SetHandler() to attach an event handler to the list widget.
-Erik

I tried with adding a listner to the widget .Following three ways are tried,
First way
------------
IWIDGET_GetViewModel( pListWidget, &tmpViewModel );
ModelListener.pfnListener = ListListener;
ModelListener.pListenerData = pApp ;
IMODEL_AddListener( tmpViewModel, &ModelListener);
ReleaseIF(tmpViewModel);
Second way
----------------
IWIDGET_GetViewModel(pListWidget, &tempList);
IMODEL_AddListenerEx(tempList, &listListener, (PFNLISTENER)ListenerFunc, pApp);
IMODEL_Release(tempList);
Third way
------------
IWIDGET_GetViewModel(pListWidget, &tempList);
pListener = (ModelListener*)MALLOC(sizeof(ModelListener));
LISTENER_Init(pListener, ListenerFunc, pApp);
IMODEL_AddListener(tempList, pListener);
All threes are failed,
Help with some samle code.
Thanks
Premlal

I tried with adding a listner to the widget .Following three ways are tried,
First way
------------
IWIDGET_GetViewModel( pListWidget, &tmpViewModel );
ModelListener.pfnListener = ListListener;
ModelListener.pListenerData = pApp ;
IMODEL_AddListener( tmpViewModel, &ModelListener);
ReleaseIF(tmpViewModel);
Second way
----------------
IWIDGET_GetViewModel(pListWidget, &tempList);
IMODEL_AddListenerEx(tempList, &listListener, (PFNLISTENER)ListenerFunc, pApp);
IMODEL_Release(tempList);
Third way
------------
IWIDGET_GetViewModel(pListWidget, &tempList);
pListener = (ModelListener*)MALLOC(sizeof(ModelListener));
LISTENER_Init(pListener, ListenerFunc, pApp);
IMODEL_AddListener(tempList, pListener);
All threes are failed,
Help with some samle code.
Thanks
Premlal

HI Premlal
Whare it exactly failing?is Viewmodel is created or not?

HI Premlal
Whare it exactly failing?is Viewmodel is created or not?

Hi ,
When tried the first way a compilation error is shown that ModelListLister is not defined.In BUIT Document i don't find this ModelListListener structure.I got this from forum.
Next two ways are working without compilation error.Key event is got only at the time of function calling.After that event handling is not working.As a beginer Handling events explanation in BUIT Docs are quite defficult to understand.
I also tried HANDLERDESC_Init(&listHandler, ListListener, pApp, 0);
IWIDGET_SetHandler((IWidget*)pListWidget, &listHandler);
Out put is same as the above.
can you please explain the exact steps of event handling in widgets with some samples.
Thanks,
Premlal

Hi ,
When tried the first way a compilation error is shown that ModelListLister is not defined.In BUIT Document i don't find this ModelListListener structure.I got this from forum.
Next two ways are working without compilation error.Key event is got only at the time of function calling.After that event handling is not working.As a beginer Handling events explanation in BUIT Docs are quite defficult to understand.
I also tried HANDLERDESC_Init(&listHandler, ListListener, pApp, 0);
IWIDGET_SetHandler((IWidget*)pListWidget, &listHandler);
Out put is same as the above.
can you please explain the exact steps of event handling in widgets with some samples.
Thanks,
Premlal

Hav u written the callback fn( PFNLISTENER )listlistener?

Hav u written the callback fn( PFNLISTENER )listlistener?

yes. I already wrote that function.And i tried a DBGPRINTF in that ListListener.After menu creation i called this function, IWIDGET_SetModel( pListWidget, IMENUMODEL_TO_IMODEL(pMenuModel) );
After that,
IWIDGET_GetViewModel(pListWidget,&tempList);
IMODEL_AddListenerEx(tempList, &listListener, (PFNLISTENER)ListListener, pApp);
IWIDGET_SetHandler((IWidget*)pListWidget,&listHandler);
IMODEL_Release(tempList);
is callled. DBGPRINTF in ListListener is worked only one time , that is at the time of function calling.

yes. I already wrote that function.And i tried a DBGPRINTF in that ListListener.After menu creation i called this function, IWIDGET_SetModel( pListWidget, IMENUMODEL_TO_IMODEL(pMenuModel) );
After that,
IWIDGET_GetViewModel(pListWidget,&tempList);
IMODEL_AddListenerEx(tempList, &listListener, (PFNLISTENER)ListListener, pApp);
IWIDGET_SetHandler((IWidget*)pListWidget,&listHandler);
IMODEL_Release(tempList);
is callled. DBGPRINTF in ListListener is worked only one time , that is at the time of function calling.

Quote:boolean ListenerFunc(helloformapp* pApp, AEEEvent evt, uint16 wParam, uint32 dwParam)
{
DBGPRINTF("IN HADLE EVENT");
if(evt == EVT_KEY)
{
DBGPRINTF("TAKE HANDLE EVENT");

DBGPRINTF("IN HADLE EVENTTTTTTTTTTTT");
return TRUE;

ru trying this way?
parameters of the listlistener are ListenerFunc(void * pMe, ModelEvent *pModelevent)
switch(pModelEvent->evCode)
{
case EVT_MDL_LIST_CHANGE:
DBGPRINTF("Change");
break;
case EVT_MDL_FOCUS_SELECT:
break;
case EVT_MDL_FOCUS_CHANGE:
break;
}
if u slect one item in the list it will come to EVT_MDL_FOCUS_SELECT: event,There u write whtever u want to do........
for every focus change in the list u will get the notification
try this

Quote:boolean ListenerFunc(helloformapp* pApp, AEEEvent evt, uint16 wParam, uint32 dwParam)
{
DBGPRINTF("IN HADLE EVENT");
if(evt == EVT_KEY)
{
DBGPRINTF("TAKE HANDLE EVENT");

DBGPRINTF("IN HADLE EVENTTTTTTTTTTTT");
return TRUE;

ru trying this way?
parameters of the listlistener are ListenerFunc(void * pMe, ModelEvent *pModelevent)
switch(pModelEvent->evCode)
{
case EVT_MDL_LIST_CHANGE:
DBGPRINTF("Change");
break;
case EVT_MDL_FOCUS_SELECT:
break;
case EVT_MDL_FOCUS_CHANGE:
break;
}
if u slect one item in the list it will come to EVT_MDL_FOCUS_SELECT: event,There u write whtever u want to do........
for every focus change in the list u will get the notification
try this

Hi ,
Thanks for the reply. But there is no change in output.
My full source code is here, Can you plz find where is the problem.
IMenuModel* pMenuModel = NULL;
IWidget* menuContainer = NULL;
IWidget* pListWidget = NULL;
IWidget* pStaticListWidget = NULL;
IModel *pModel =NULL;
AEERect pRect;
AECHAR* pStaticInfo[4];
int i , j= 0;
ModelListener* pListener;
IWidget* tempList;
ModelListener* listListener;
IWidget* tmpViewModel;
ModelEvent * modelEvent;
ModelListener sam;
HandlerDesc listHandler;
void createsampleMenu(helloformapp* pApp)
{
ISHELL_CreateInstance(pApp->pIShell, AEECLSID_ROOTFORM, (void **)&piRootForm);
ISHELL_CreateInstance(pApp->pIShell, AEECLSID_FORM, (void **)&piForm);
ISHELL_CreateInstance(pApp->pIShell, AEECLSID_XYCONTAINER, (void**)&XYcontainerWidget);
ISHELL_CreateInstance( pApp->pIShell, AEECLSID_LISTWIDGET, (void **)&pListWidget );
ISHELL_CreateInstance( pApp->pIShell, AEECLSID_LISTWIDGET, (void **)&tempList );
ISHELL_CreateInstance( pApp->pIShell, AEECLSID_MENUMODEL, (void **)&pMenuModel );
ISHELL_CreateInstance( pApp->pIShell, AEECLSID_STATICWIDGET , (void **)&pStaticListWidget );
IMENUMODEL_Add( pMenuModel, L"Browser", 0, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Camera", 1, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"BlueBox", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Morph", 3, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Settings", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Help", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"About", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Exit", 2, MMF_ENABLED );
IWIDGET_SetModel( pListWidget, IMENUMODEL_TO_IMODEL(pMenuModel) );
//IWIDGET_GetViewModel( pListWidget, &tmpViewModel );
//sam.pfnListener = ListListener;
//sam.pListenerData = pApp ;
//IMODEL_AddListener( tmpViewModel, &sam);
//ReleaseIF(tmpViewModel);
/*IWIDGET_GetViewModel(pListWidget,&tempList);
IMODEL_AddListenerEx(tempList, &listListener, (PFNLISTENER)ListenerFunc, pApp);
IWIDGET_SetHandler(pListWidget,&listHandler);
IMODEL_Release(tempList);*/
IWIDGET_GetViewModel(pListWidget, &tempList);
pListener = (ModelListener*)MALLOC(sizeof(ModelListener));
LISTENER_Init(pListener, (PFNLISTENER)ListenerFunc, pApp);
IMODEL_AddListener(tempList, pListener);
IWIDGET_SetBorderWidth( pListWidget , 3 );
IWIDGET_SetSelectedFGColor( pListWidget, MAKE_RGBA(125, 255, 255, 255) );
IWIDGET_SetSelectedBGColor( pListWidget, MAKE_RGBA(125, 233, 10, 5) );
IWIDGET_SetSelectedFGColor( pStaticListWidget, MAKE_RGBA(255, 255, 255, 255) );
IWIDGET_SetSelectedBGColor( pStaticListWidget, MAKE_RGB(255, 0 , 255));
IWIDGET_SetProperty(pStaticListWidget, PROP_SELECTED_FGCOLOR, MAKE_RGB(0, 255, 0));
IWIDGET_SetProperty( pListWidget, PROP_FLAGS, LWF_WRAP );
IWIDGET_SetTransparency( pListWidget, 255 );
IWIDGET_GetPreferredExtent( pStaticListWidget, &we );
IWIDGET_SetItemHeight( pListWidget, we.height+4 );
//piRootForm->GetClientRect(pRect);
we.height =100 ;
we.width = 75;
IWIDGET_SetExtent( pListWidget, &we );
wpos.bVisible = TRUE ;
wpos.x = 240/3 ; wpos.y = 25 ;
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);
IWIDGET_SetGradientStyle(menuContainer,1);
IWIDGET_SetTransparency(menuContainer,5);
IFORM_SetWidget(piForm,WID_FORM, menuContainer);
IFORM_SetTitle(piForm, L"Baby.jpg");
IFORM_SetSoftkey(piForm, FID_SOFTKEY1 ,L"Options");
IFORM_SetSoftkey(piForm, FID_SOFTKEY2 ,L"Back");
/*HANDLERDESC_Init(&listHandler, (PFNLISTENER)ListenerFunc, pApp, 0);
IWIDGET_SetHandler((IWidget*)pListWidget, &listHandler);*/
IROOTFORM_PushForm(piRootForm,piForm);
}
}
boolean ListenerFunc( void * pMe, ModelEvent *pModelevent )
{
DBGPRINTF("in LISTENER FUNCTION");
switch(pModelevent->evCode)
{
case EVT_MDL_LIST_CHANGE:
DBGPRINTF("Change");
break;
case EVT_MDL_FOCUS_SELECT:
DBGPRINTF("EVT_MDL_FOCUS_SELECT");
break;
case EVT_MDL_FOCUS_CHANGE:
break;
}
}
thanks
Premlal

Hi ,
Thanks for the reply. But there is no change in output.
My full source code is here, Can you plz find where is the problem.
IMenuModel* pMenuModel = NULL;
IWidget* menuContainer = NULL;
IWidget* pListWidget = NULL;
IWidget* pStaticListWidget = NULL;
IModel *pModel =NULL;
AEERect pRect;
AECHAR* pStaticInfo[4];
int i , j= 0;
ModelListener* pListener;
IWidget* tempList;
ModelListener* listListener;
IWidget* tmpViewModel;
ModelEvent * modelEvent;
ModelListener sam;
HandlerDesc listHandler;
void createsampleMenu(helloformapp* pApp)
{
ISHELL_CreateInstance(pApp->pIShell, AEECLSID_ROOTFORM, (void **)&piRootForm);
ISHELL_CreateInstance(pApp->pIShell, AEECLSID_FORM, (void **)&piForm);
ISHELL_CreateInstance(pApp->pIShell, AEECLSID_XYCONTAINER, (void**)&XYcontainerWidget);
ISHELL_CreateInstance( pApp->pIShell, AEECLSID_LISTWIDGET, (void **)&pListWidget );
ISHELL_CreateInstance( pApp->pIShell, AEECLSID_LISTWIDGET, (void **)&tempList );
ISHELL_CreateInstance( pApp->pIShell, AEECLSID_MENUMODEL, (void **)&pMenuModel );
ISHELL_CreateInstance( pApp->pIShell, AEECLSID_STATICWIDGET , (void **)&pStaticListWidget );
IMENUMODEL_Add( pMenuModel, L"Browser", 0, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Camera", 1, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"BlueBox", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Morph", 3, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Settings", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Help", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"About", 2, MMF_ENABLED );
IMENUMODEL_Add( pMenuModel, L"Exit", 2, MMF_ENABLED );
IWIDGET_SetModel( pListWidget, IMENUMODEL_TO_IMODEL(pMenuModel) );
//IWIDGET_GetViewModel( pListWidget, &tmpViewModel );
//sam.pfnListener = ListListener;
//sam.pListenerData = pApp ;
//IMODEL_AddListener( tmpViewModel, &sam);
//ReleaseIF(tmpViewModel);
/*IWIDGET_GetViewModel(pListWidget,&tempList);
IMODEL_AddListenerEx(tempList, &listListener, (PFNLISTENER)ListenerFunc, pApp);
IWIDGET_SetHandler(pListWidget,&listHandler);
IMODEL_Release(tempList);*/
IWIDGET_GetViewModel(pListWidget, &tempList);
pListener = (ModelListener*)MALLOC(sizeof(ModelListener));
LISTENER_Init(pListener, (PFNLISTENER)ListenerFunc, pApp);
IMODEL_AddListener(tempList, pListener);
IWIDGET_SetBorderWidth( pListWidget , 3 );
IWIDGET_SetSelectedFGColor( pListWidget, MAKE_RGBA(125, 255, 255, 255) );
IWIDGET_SetSelectedBGColor( pListWidget, MAKE_RGBA(125, 233, 10, 5) );
IWIDGET_SetSelectedFGColor( pStaticListWidget, MAKE_RGBA(255, 255, 255, 255) );
IWIDGET_SetSelectedBGColor( pStaticListWidget, MAKE_RGB(255, 0 , 255));
IWIDGET_SetProperty(pStaticListWidget, PROP_SELECTED_FGCOLOR, MAKE_RGB(0, 255, 0));
IWIDGET_SetProperty( pListWidget, PROP_FLAGS, LWF_WRAP );
IWIDGET_SetTransparency( pListWidget, 255 );
IWIDGET_GetPreferredExtent( pStaticListWidget, &we );
IWIDGET_SetItemHeight( pListWidget, we.height+4 );
//piRootForm->GetClientRect(pRect);
we.height =100 ;
we.width = 75;
IWIDGET_SetExtent( pListWidget, &we );
wpos.bVisible = TRUE ;
wpos.x = 240/3 ; wpos.y = 25 ;
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);
IWIDGET_SetGradientStyle(menuContainer,1);
IWIDGET_SetTransparency(menuContainer,5);
IFORM_SetWidget(piForm,WID_FORM, menuContainer);
IFORM_SetTitle(piForm, L"Baby.jpg");
IFORM_SetSoftkey(piForm, FID_SOFTKEY1 ,L"Options");
IFORM_SetSoftkey(piForm, FID_SOFTKEY2 ,L"Back");
/*HANDLERDESC_Init(&listHandler, (PFNLISTENER)ListenerFunc, pApp, 0);
IWIDGET_SetHandler((IWidget*)pListWidget, &listHandler);*/
IROOTFORM_PushForm(piRootForm,piForm);
}
}
boolean ListenerFunc( void * pMe, ModelEvent *pModelevent )
{
DBGPRINTF("in LISTENER FUNCTION");
switch(pModelevent->evCode)
{
case EVT_MDL_LIST_CHANGE:
DBGPRINTF("Change");
break;
case EVT_MDL_FOCUS_SELECT:
DBGPRINTF("EVT_MDL_FOCUS_SELECT");
break;
case EVT_MDL_FOCUS_CHANGE:
break;
}
}
thanks
Premlal

hey friend,
i m also new to all this..but my view model is workin so i can guarentee that urs will also work
do one think chk the code of "calculator" thats fundoo code
Calculator uses Listener..u also copy the same code and try out
one problem that i see in ur code snippet is that u have put the listener before u have created widgets and its properties
i am able to run the viewmodel code and i get the events generated
just try to simulate the calculator code, Plz use the same procedure and same steps that calculator uses, then ofcourse we can change it later
first let it run correclty then make ur own changes !!! :) :)
Thanks,
Viral

hey friend,
i m also new to all this..but my view model is workin so i can guarentee that urs will also work
do one think chk the code of "calculator" thats fundoo code
Calculator uses Listener..u also copy the same code and try out
one problem that i see in ur code snippet is that u have put the listener before u have created widgets and its properties
i am able to run the viewmodel code and i get the events generated
just try to simulate the calculator code, Plz use the same procedure and same steps that calculator uses, then ofcourse we can change it later
first let it run correclty then make ur own changes !!! :) :)
Thanks,
Viral

premlal wrote:Hi ,
Thanks for the reply. But there is no change in output.
This code is working fine. I hope it can help you:
HandlerDesc listWidgetHandler;
/*
* Special handler for list widget - hold UP/DOWN keys while processing
*/
static boolean List_MainMenu_listWidgetEventHandler(void *po, AEEEvent evt, uint16 wParam, uint32 dwParam)
{
AppForm* pMe = (AppForm*) po;
if (pMe->holdKeys && evt == EVT_KEY){
if (wParam == AVK_UP) {
DBGPRINTF("**** UP ****");
return TRUE;
}
if (wParam == AVK_DOWN) {
DBGPRINTF("**** DOWN ****");
return TRUE;
}
}
return HANDLERDESC_Call(&pMe->listWidgetHandler, evt, wParam, dwParam);

/*
* Create Main Menu (ListForm)
*/
int List_MainMenu_create(void * v_pMe) {
AppForm* pMe = (AppForm*) v_pMe;
IWidget* pListWidget = NULL; // ListWidget
....
// ------------------ Set Handlers ----------------------
....
// special handler for hold UP/DOWN keys in menu
HANDLERDESC_Init(&pMe->listWidgetHandler, List_MainMenu_listWidgetEventHandler, pMe, NULL);
IWIDGET_SetHandler(pListWidget, &pMe->listWidgetHandler);
....

premlal wrote:Hi ,
Thanks for the reply. But there is no change in output.
This code is working fine. I hope it can help you:
HandlerDesc listWidgetHandler;
/*
* Special handler for list widget - hold UP/DOWN keys while processing
*/
static boolean List_MainMenu_listWidgetEventHandler(void *po, AEEEvent evt, uint16 wParam, uint32 dwParam)
{
AppForm* pMe = (AppForm*) po;
if (pMe->holdKeys && evt == EVT_KEY){
if (wParam == AVK_UP) {
DBGPRINTF("**** UP ****");
return TRUE;
}
if (wParam == AVK_DOWN) {
DBGPRINTF("**** DOWN ****");
return TRUE;
}
}
return HANDLERDESC_Call(&pMe->listWidgetHandler, evt, wParam, dwParam);

/*
* Create Main Menu (ListForm)
*/
int List_MainMenu_create(void * v_pMe) {
AppForm* pMe = (AppForm*) v_pMe;
IWidget* pListWidget = NULL; // ListWidget
....
// ------------------ Set Handlers ----------------------
....
// special handler for hold UP/DOWN keys in menu
HANDLERDESC_Init(&pMe->listWidgetHandler, List_MainMenu_listWidgetEventHandler, pMe, NULL);
IWIDGET_SetHandler(pListWidget, &pMe->listWidgetHandler);
....

hi premlal,
i noticed that you registered the ListenerFunc as a eventhandler, and at the same time a listenerfunc... i mean, they are different, eventhandeler is eventhandler, listenerfunc is listenerfunc, to register a listenerfunc for a widget, we only need to write to following codes as you provided:
IWIDGET_GetViewModel(me->pIMenuWidget, &tempList);
pListener = (ModelListener*)MALLOC(sizeof(ModelListener));
LISTENER_Init(pListener, (PFNLISTENER)ListenerFunc, me);
IMODEL_AddListener(tempList, pListener);
do not register the ListenerFunc as a event handler like this:
HANDLERDESC_Init(&me->listWidgetHandler, ListenerFunc, me, NULL);
IWIDGET_SetHandler(me->pIMenuWidget, &me->listWidgetHandler);
Infact, you can register another function with a differenct name to be the eventhandler. They will not affect each other.

hi premlal,
i noticed that you registered the ListenerFunc as a eventhandler, and at the same time a listenerfunc... i mean, they are different, eventhandeler is eventhandler, listenerfunc is listenerfunc, to register a listenerfunc for a widget, we only need to write to following codes as you provided:
IWIDGET_GetViewModel(me->pIMenuWidget, &tempList);
pListener = (ModelListener*)MALLOC(sizeof(ModelListener));
LISTENER_Init(pListener, (PFNLISTENER)ListenerFunc, me);
IMODEL_AddListener(tempList, pListener);
do not register the ListenerFunc as a event handler like this:
HANDLERDESC_Init(&me->listWidgetHandler, ListenerFunc, me, NULL);
IWIDGET_SetHandler(me->pIMenuWidget, &me->listWidgetHandler);
Infact, you can register another function with a differenct name to be the eventhandler. They will not affect each other.

/*===========================================================================
FILE: calc.c
===========================================================================*/
/*===============================================================================
INCLUDES AND VARIABLE DEFINITIONS
=============================================================================== */
#include "AEEModGen.h" // Module interface definitions
#include "AEEAppGen.h" // Applet interface definitions
#include "AEEShell.h" // Shell interface definitions
#include "calc.bid"
//---------------------------calc widget-----------------------------------
//----resource file----
#include "calc.brh"
//----include----
#include "AEERootForm.h"
#include "AEEStaticWidget.h"
#include "AEEConstraintContainer.h"
#include "AEEMenuModel.h"
//----bid----
#include "calc.bid"
#include "bid\AEECLSID_ROOTFORM.bid"
#include "bid\AEECLSID_FORM.bid"
#include "bid\AEECLSID_STATICWIDGET.bid"
#include "AEECLSID_CONSTRAINTCONTAINER.bid"
#include "AEECLSID_LISTWIDGET.bid"
#include "AEECLSID_MENUMODEL.bid"
//---------------------------------------------------------------------------
//-----------------------------macro def-------------------------------------
#ifndef RELEASEIF
#define RELEASEIF(p) ReleaseIf((IBase**)(void *)&p)
static void ReleaseIf(IBase **ppif) {
if (*ppif) {
IBASE_Release(*ppif);
*ppif = 0;
}

#endif
#define TXT_BUFFER_SIZE 50
typedef struct _mainscreen_calc {
IDisplay *pIDisplay;
IShell *pIShell;
IRootForm *pIRootForm;
IForm *pMenuIForm;
IForm *pMainIForm;
IMenuModel *pIMenuModel;
uint16 nCmdID;
HandlerDesc handlerMainMenu;
HandlerDesc handlerMainMenuSelection;
mainscreen_calc;
/*-------------------------------------------------------------------
Applet structure. All variables in here are reference via "pMe->"
-------------------------------------------------------------------*/
// create an applet structure that's passed around. All variables in
// here will be able to be referenced as static.
typedef struct _calc {
AEEApplet a ; // First element of this structure must be AEEApplet
AEEDeviceInfo DeviceInfo; // always have access to the hardware device information
mainscreen_calc mainscreen;
} calc;
const RGBAVAL form_BGColor = MAKE_RGBA(0,0,250,255);
const RGBAVAL form_FGColor = MAKE_RGBA(255,255,0,255);
const RGBAVAL form_BorderColor = MAKE_RGBA(255,0,0,255);
/*-------------------------------------------------------------------
Function Prototypes
-------------------------------------------------------------------*/
static boolean calc_HandleEvent(calc* pMe, AEEEvent eCode,
uint16 wParam, uint32 dwParam);
boolean calc_InitAppData(calc* pMe);
void calc_FreeAppData(calc* pMe);
// Main Menu functions
int CreateMainMenu(calc* pMe);
int MainMenu_loadMenuItems(calc* pMe, IMenuModel* pMenuModel);
static boolean MainMenu_HandleEvent(calc* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam);
static void MainMenu_selectionHandler(calc *pMe, ModelEvent *pev);
/*===============================================================================
FUNCTION DEFINITIONS
=============================================================================== */
int AEEClsCreateInstance(AEECLSID ClsId, IShell *pIShell, IModule *po, void **ppObj)
{
*ppObj = NULL;
if( ClsId == AEECLSID_CALC )
{
// Create the applet and make room for the applet structure
if( AEEApplet_New(sizeof(calc),
ClsId,
pIShell,
po,
(IApplet**)ppObj,
(AEEHANDLER)calc_HandleEvent,
(PFNFREEAPPDATA)calc_FreeAppData) ) // the FreeAppData function is called after sending EVT_APP_STOP to the HandleEvent function
{
//Initialize applet data, this is called before sending EVT_APP_START
// to the HandleEvent function
if(calc_InitAppData((calc*)*ppObj))
{
//Data initialized successfully
return(AEE_SUCCESS);
}
else
{
//Release the applet. This will free the memory allocated for the applet when
// AEEApplet_New was called.
IAPPLET_Release((IApplet*)*ppObj);
return EFAILED;
}
} // end AEEApplet_New
}
return(EFAILED);

/*===========================================================================
FUNCTION SampleAppWizard_HandleEvent
DESCRIPTION
This is the EventHandler for this app. All events to this app are handled in this
function. All APPs must supply an Event Handler.
PROTOTYPE:
boolean SampleAppWizard_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)
PARAMETERS:
pi: Pointer to the AEEApplet structure. This structure contains information specific
to this applet. It was initialized during the AEEClsCreateInstance() function.
ecode: Specifies the Event sent to this applet
wParam, dwParam: Event specific data.
DEPENDENCIES
none
RETURN VALUE
TRUE: If the app has processed the event
FALSE: If the app did not process the event
SIDE EFFECTS
none
===========================================================================*/
static boolean calc_HandleEvent(calc* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
if(IROOTFORM_HandleEvent(pMe->mainscreen.pIRootForm,eCode,wParam,dwParam))
{
return TRUE;
}
switch (eCode)
{
// App is told it is starting up
case EVT_APP_START:
// Add your code here...
CreateMainMenu(pMe);
return(TRUE);
// App is told it is exiting
case EVT_APP_STOP:
// Add your code here...
return(TRUE);
// App is being suspended
case EVT_APP_SUSPEND:
// Add your code here...
return(TRUE);
// App is being resumed
case EVT_APP_RESUME:
// Add your code here...
return(TRUE);
// An SMS message has arrived for this app. Message is in the dwParam above as (char *)
// sender simply uses this format "//BREW:ClassId:Message", example //BREW:0x00000001:Hello World
case EVT_APP_MESSAGE:
// Add your code here...
return(TRUE);
// A key was pressed. Look at the wParam above to see which key was pressed. The key
// codes are in AEEVCodes.h. Example "AVK_1" means that the "1" key was pressed.
case EVT_KEY:
// Add your code here...
return(TRUE);
case EVT_KEY_PRESS:
// If nothing fits up to this point then we'll just break out
default:
break;
}
return FALSE;

// this function is called when your application is starting up
boolean calc_InitAppData(calc* pMe)
{
int nErr = SUCCESS;
// Get the device information for this handset.
// Reference all the data by looking at the pMe->DeviceInfo structure
// Check the API reference guide for all the handy device info you can get
pMe->DeviceInfo.wStructSize = sizeof(pMe->DeviceInfo);
ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&pMe->DeviceInfo);
// Insert your code here for initializing or allocating resources...
//crete root form
nErr = ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_ROOTFORM, (void**)&pMe->mainscreen.pIRootForm);
if(SUCCESS != nErr)
{
return nErr;
}
//set the theme for rootform
//IROOTFORM_SetThemeFileName(pMe->mainscreen.pIRootForm, "theme.bar");
//IROOTFORM_SetThemeFileName(pMe->mainscreen.pIRootForm, "rosa.bar");
return TRUE;

// this function is called when your application is exiting
void calc_FreeAppData(calc* pMe)
{
// insert your code here for freeing any resources you have allocated...
// example to use for releasing each interface:
// if ( pMe->pIMenuCtl != NULL ) // check for NULL first
// {
// IMENUCTL_Release(pMe->pIMenuCtl) // release the interface
// pMe->pIMenuCtl = NULL; // set to NULL so no problems trying to free later
// }
//
}

/*===========================================================================
FILE: calc.c
===========================================================================*/
/*===============================================================================
INCLUDES AND VARIABLE DEFINITIONS
=============================================================================== */
#include "AEEModGen.h" // Module interface definitions
#include "AEEAppGen.h" // Applet interface definitions
#include "AEEShell.h" // Shell interface definitions
#include "calc.bid"
//---------------------------calc widget-----------------------------------
//----resource file----
#include "calc.brh"
//----include----
#include "AEERootForm.h"
#include "AEEStaticWidget.h"
#include "AEEConstraintContainer.h"
#include "AEEMenuModel.h"
//----bid----
#include "calc.bid"
#include "bid\AEECLSID_ROOTFORM.bid"
#include "bid\AEECLSID_FORM.bid"
#include "bid\AEECLSID_STATICWIDGET.bid"
#include "AEECLSID_CONSTRAINTCONTAINER.bid"
#include "AEECLSID_LISTWIDGET.bid"
#include "AEECLSID_MENUMODEL.bid"
//---------------------------------------------------------------------------
//-----------------------------macro def-------------------------------------
#ifndef RELEASEIF
#define RELEASEIF(p) ReleaseIf((IBase**)(void *)&p)
static void ReleaseIf(IBase **ppif) {
if (*ppif) {
IBASE_Release(*ppif);
*ppif = 0;
}

#endif
#define TXT_BUFFER_SIZE 50
typedef struct _mainscreen_calc {
IDisplay *pIDisplay;
IShell *pIShell;
IRootForm *pIRootForm;
IForm *pMenuIForm;
IForm *pMainIForm;
IMenuModel *pIMenuModel;
uint16 nCmdID;
HandlerDesc handlerMainMenu;
HandlerDesc handlerMainMenuSelection;
mainscreen_calc;
/*-------------------------------------------------------------------
Applet structure. All variables in here are reference via "pMe->"
-------------------------------------------------------------------*/
// create an applet structure that's passed around. All variables in
// here will be able to be referenced as static.
typedef struct _calc {
AEEApplet a ; // First element of this structure must be AEEApplet
AEEDeviceInfo DeviceInfo; // always have access to the hardware device information
mainscreen_calc mainscreen;
} calc;
const RGBAVAL form_BGColor = MAKE_RGBA(0,0,250,255);
const RGBAVAL form_FGColor = MAKE_RGBA(255,255,0,255);
const RGBAVAL form_BorderColor = MAKE_RGBA(255,0,0,255);
/*-------------------------------------------------------------------
Function Prototypes
-------------------------------------------------------------------*/
static boolean calc_HandleEvent(calc* pMe, AEEEvent eCode,
uint16 wParam, uint32 dwParam);
boolean calc_InitAppData(calc* pMe);
void calc_FreeAppData(calc* pMe);
// Main Menu functions
int CreateMainMenu(calc* pMe);
int MainMenu_loadMenuItems(calc* pMe, IMenuModel* pMenuModel);
static boolean MainMenu_HandleEvent(calc* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam);
static void MainMenu_selectionHandler(calc *pMe, ModelEvent *pev);
/*===============================================================================
FUNCTION DEFINITIONS
=============================================================================== */
int AEEClsCreateInstance(AEECLSID ClsId, IShell *pIShell, IModule *po, void **ppObj)
{
*ppObj = NULL;
if( ClsId == AEECLSID_CALC )
{
// Create the applet and make room for the applet structure
if( AEEApplet_New(sizeof(calc),
ClsId,
pIShell,
po,
(IApplet**)ppObj,
(AEEHANDLER)calc_HandleEvent,
(PFNFREEAPPDATA)calc_FreeAppData) ) // the FreeAppData function is called after sending EVT_APP_STOP to the HandleEvent function
{
//Initialize applet data, this is called before sending EVT_APP_START
// to the HandleEvent function
if(calc_InitAppData((calc*)*ppObj))
{
//Data initialized successfully
return(AEE_SUCCESS);
}
else
{
//Release the applet. This will free the memory allocated for the applet when
// AEEApplet_New was called.
IAPPLET_Release((IApplet*)*ppObj);
return EFAILED;
}
} // end AEEApplet_New
}
return(EFAILED);

/*===========================================================================
FUNCTION SampleAppWizard_HandleEvent
DESCRIPTION
This is the EventHandler for this app. All events to this app are handled in this
function. All APPs must supply an Event Handler.
PROTOTYPE:
boolean SampleAppWizard_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)
PARAMETERS:
pi: Pointer to the AEEApplet structure. This structure contains information specific
to this applet. It was initialized during the AEEClsCreateInstance() function.
ecode: Specifies the Event sent to this applet
wParam, dwParam: Event specific data.
DEPENDENCIES
none
RETURN VALUE
TRUE: If the app has processed the event
FALSE: If the app did not process the event
SIDE EFFECTS
none
===========================================================================*/
static boolean calc_HandleEvent(calc* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
if(IROOTFORM_HandleEvent(pMe->mainscreen.pIRootForm,eCode,wParam,dwParam))
{
return TRUE;
}
switch (eCode)
{
// App is told it is starting up
case EVT_APP_START:
// Add your code here...
CreateMainMenu(pMe);
return(TRUE);
// App is told it is exiting
case EVT_APP_STOP:
// Add your code here...
return(TRUE);
// App is being suspended
case EVT_APP_SUSPEND:
// Add your code here...
return(TRUE);
// App is being resumed
case EVT_APP_RESUME:
// Add your code here...
return(TRUE);
// An SMS message has arrived for this app. Message is in the dwParam above as (char *)
// sender simply uses this format "//BREW:ClassId:Message", example //BREW:0x00000001:Hello World
case EVT_APP_MESSAGE:
// Add your code here...
return(TRUE);
// A key was pressed. Look at the wParam above to see which key was pressed. The key
// codes are in AEEVCodes.h. Example "AVK_1" means that the "1" key was pressed.
case EVT_KEY:
// Add your code here...
return(TRUE);
case EVT_KEY_PRESS:
// If nothing fits up to this point then we'll just break out
default:
break;
}
return FALSE;

// this function is called when your application is starting up
boolean calc_InitAppData(calc* pMe)
{
int nErr = SUCCESS;
// Get the device information for this handset.
// Reference all the data by looking at the pMe->DeviceInfo structure
// Check the API reference guide for all the handy device info you can get
pMe->DeviceInfo.wStructSize = sizeof(pMe->DeviceInfo);
ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&pMe->DeviceInfo);
// Insert your code here for initializing or allocating resources...
//crete root form
nErr = ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_ROOTFORM, (void**)&pMe->mainscreen.pIRootForm);
if(SUCCESS != nErr)
{
return nErr;
}
//set the theme for rootform
//IROOTFORM_SetThemeFileName(pMe->mainscreen.pIRootForm, "theme.bar");
//IROOTFORM_SetThemeFileName(pMe->mainscreen.pIRootForm, "rosa.bar");
return TRUE;

// this function is called when your application is exiting
void calc_FreeAppData(calc* pMe)
{
// insert your code here for freeing any resources you have allocated...
// example to use for releasing each interface:
// if ( pMe->pIMenuCtl != NULL ) // check for NULL first
// {
// IMENUCTL_Release(pMe->pIMenuCtl) // release the interface
// pMe->pIMenuCtl = NULL; // set to NULL so no problems trying to free later
// }
//
}

int CreateMainMenu(calc* pMe)
{
int nErr = SUCCESS;
IConstraintContainer *pIConstraintContainer = NULL;
IWidget *pIConstraintContainerWidget = NULL;
IWidget *pIWidget = NULL;
IWidget *pIMenuWidget = NULL;
WExtent extent;
WExtent size;
AEERect rc;
IDecorator *pIMenu = NULL;
IModel *tempViewModel = NULL;
ModelListener *pListener = NULL;
WidgetConstraint widgetContraint = { pMe->DeviceInfo.cxScreen + 10,
pMe->DeviceInfo.cyScreen + 10, TRUE };
AECHAR *tempText1 = NULL;
AECHAR *tempText2 = NULL;
AECHAR *tempText3 = NULL;
AECHAR *tempText4 = NULL;
AECHAR *tempText5 = NULL;
AECHAR *tempText6 = NULL;
//create MainMenu form
nErr = ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_FORM, (void **)&pMe->mainscreen.pMenuIForm);
if(SUCCESS != nErr)
{
return nErr;
}
nErr = ISHELL_CreateInstance( pMe->a.m_pIShell, AEECLSID_CONSTRAINTCONTAINER,
(void**)&pIConstraintContainer );
if(SUCCESS != nErr)
{
return nErr;
}
nErr = ICONSTRAINTCONTAINER_QueryInterface( pIConstraintContainer,
AEEIID_WIDGET,
(void**)&pIConstraintContainerWidget );
if(SUCCESS != nErr)
{
return nErr;
}
// Initialize the constraint container and attach it to the form.
IROOTFORM_GetClientRect(pMe->mainscreen.pIRootForm, NULL, &rc);
SETWEXTENT(&extent, rc.dx, rc.dy);
IWIDGET_SetExtent(pIConstraintContainerWidget, &extent);
// Create the menu item widget
//nErr = ISHELL_CreateInstance( pMe->a.m_pIShell, AEECLSID_LISTWIDGET,
// (void **)&pIMenu );
nErr = ISHELL_CreateInstance( pMe->a.m_pIShell, AEECLSID_LISTWIDGET,
(void **)&pIMenu );
if(SUCCESS != nErr)
{
return nErr;
}
nErr = IDECORATOR_QueryInterface( pIMenu, AEEIID_WIDGET,
(void **)&pIMenuWidget );
if(SUCCESS != nErr)
{
return nErr;
}
nErr = ISHELL_CreateInstance( pMe->a.m_pIShell, AEECLSID_STATICWIDGET,
(void **)&pIWidget );
if(SUCCESS != nErr)
{
return nErr;
}
nErr = ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_MENUMODEL, (void**)&pMe->mainscreen.pIMenuModel);
if(SUCCESS != nErr)
{
return nErr;
}
IWIDGET_SetModel( pIMenuWidget, IMENUMODEL_TO_IMODEL( pMe->mainscreen.pIMenuModel));
//Load resources to model
nErr = MainMenu_loadMenuItems(pMe, pMe->mainscreen.pIMenuModel);
if(nErr != TRUE)
{
return nErr;
}
//IWIDGET_SetBorderWidth( pIMenuWidget , 4 );
IWIDGET_SetSelectedFGColor( pIWidget, MAKE_RGBA(255, 0, 0, 255) );
//IWIDGET_SetSelectedBGColor( pIWidget, RGB_BLACK );
IWIDGET_SetSelectedBGColor( pIWidget, MAKE_RGB(0,0,255));
IWIDGET_GetPreferredExtent( pIWidget, &size );
IWIDGET_SetFontClass(pIWidget, AEECLSID_FONTSYSBOLD);
IWIDGET_SetBorderRadius(pIWidget, 7);
IWIDGET_SetBorderStyle(pIWidget, BORDERSTYLE_ROUNDED);
IWIDGET_SetFlags(pIWidget, SWF_NOSHORTENTEXT | IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);
//scrolling of long menu items
IWIDGET_SetProperty(pIWidget, PROP_ANIMATE, 1);
IWIDGET_SetGradientStyle(pIWidget,1);
IWIDGET_SetTransparency(pIWidget,100);
IWIDGET_SetItemHeight( pIMenuWidget, size.height );
//IWIDGET_SetItemWidth( pIMenuWidget, size.width );
IDECORATOR_SetWidget( pIMenu, pIWidget );
IDECORATOR_Release( pIMenu );
// Add the menu to the container. It's the sole item.
widgetContraint.constraint.top.type = CONSTRAINT_PARENT_TOP;
widgetContraint.constraint.top.offset = 23;
widgetContraint.constraint.left.type = CONSTRAINT_PARENT_LEFT;
widgetContraint.constraint.left.offset = 20;
widgetContraint.constraint.right.type = CONSTRAINT_PARENT_RIGHT;
widgetContraint.constraint.right.offset = -20;
//widgetContraint.constraint.bottom.type = WIDGET_SIZE_TO_FIT;
widgetContraint.constraint.bottom.type = CONSTRAINT_PARENT_BOTTOM;
//widgetContraint.constraint.bottom.offset = 0;
widgetContraint.constraint.bottom.offset = -23;
widgetContraint.bVisible = TRUE;
nErr = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIMenuWidget,
WIDGET_ZNORMAL, &widgetContraint );
//IWIDGET_MoveFocus( pIConstraintContainerWidget, pIMenuWidget );
IWIDGET_GetViewModel(pIMenuWidget, &tempViewModel);
pListener = (ModelListener*)MALLOC(sizeof(ModelListener));
LISTENER_Init(pListener, (PFNLISTENER)MainMenu_selectionHandler, pMe);
IMODEL_AddListener(tempViewModel, pListener);
IFORM_SetWidget(pMe->mainscreen.pMenuIForm, WID_FORM, pIConstraintContainerWidget);
//push the form to the root form
nErr = IROOTFORM_PushForm(pMe->mainscreen.pIRootForm, pMe->mainscreen.pMenuIForm);
return nErr;
}
int MainMenu_loadMenuItems(calc* pMe, IMenuModel* pMenuModel)
{
int nErr = SUCCESS;
AECHAR *tempText1 = NULL;
AECHAR *tempText2 = NULL;
AECHAR *tempText3 = NULL;
AECHAR *tempText4 = NULL;
AECHAR *tempText5 = NULL;
AECHAR *tempText6 = NULL;
// Allocate the memory for resource string
tempText1 = (AECHAR *)MALLOC(TXT_BUFFER_SIZE);
if(!tempText1)
{
DBGPRINTF("LoadMain: Unable allocate memory for body text");
return FALSE;
}
// Read the text from the resource
nErr = ISHELL_LoadResString(pMe->a.m_pIShell,
CALC_RES_FILE,
IDS_NEW_NOTES,
tempText1,
TXT_BUFFER_SIZE);
if(!nErr)
{
return FALSE;
}
// Allocate the memory for resource string
tempText2 = (AECHAR *)MALLOC(TXT_BUFFER_SIZE);
if(!tempText2)
{
return FALSE;
}
// Read the text from the resource
nErr = ISHELL_LoadResString(pMe->a.m_pIShell,
CALC_RES_FILE,
IDS_OPEN,
tempText2,
TXT_BUFFER_SIZE);
if(!nErr)
{
return FALSE;
}
// Allocate the memory for resource string
tempText3 = (AECHAR *)MALLOC(TXT_BUFFER_SIZE);
if(!tempText3)
{
return FALSE;
}
// Read the text from the resource
nErr = ISHELL_LoadResString(pMe->a.m_pIShell,
CALC_RES_FILE,
IDS_DELETE,
tempText3,
TXT_BUFFER_SIZE);
if(!nErr)
{
return FALSE;
}
// Allocate the memory for resource string
tempText4 = (AECHAR *)MALLOC(TXT_BUFFER_SIZE);
if(!tempText4)
{
return FALSE;
}
// Read the text from the resource
nErr = ISHELL_LoadResString(pMe->a.m_pIShell,
CALC_RES_FILE,
IDS_HELP,
tempText4,
TXT_BUFFER_SIZE);
if(!nErr)
{
return FALSE;
}
// Allocate the memory for resource string
tempText5 = (AECHAR *)MALLOC(TXT_BUFFER_SIZE);
if(!tempText5)
{
return FALSE;
}
// Read the text from the resource
nErr = ISHELL_LoadResString(pMe->a.m_pIShell,
CALC_RES_FILE,
IDS_ABOUT,
tempText5,
TXT_BUFFER_SIZE);
if(!nErr)
{
return FALSE;
}
// Allocate the memory for resource string
tempText6 = (AECHAR *)MALLOC(TXT_BUFFER_SIZE);
if(!tempText6)
{
return FALSE;
}
// Read the text from the resource
nErr = ISHELL_LoadResString(pMe->a.m_pIShell,
CALC_RES_FILE,
IDS_EXIT,
tempText6,
TXT_BUFFER_SIZE);
if(!nErr)
{
return FALSE;
}
IMENUMODEL_Add(pMe->mainscreen.pIMenuModel,tempText1 , pMe->mainscreen.nCmdID, MMF_ENABLED);
IMENUMODEL_Add(pMe->mainscreen.pIMenuModel,tempText2 , pMe->mainscreen.nCmdID++, MMF_ENABLED);
IMENUMODEL_Add(pMe->mainscreen.pIMenuModel,tempText3 , pMe->mainscreen.nCmdID++, MMF_ENABLED);
IMENUMODEL_Add(pMe->mainscreen.pIMenuModel,tempText4 , pMe->mainscreen.nCmdID++, MMF_ENABLED);
IMENUMODEL_Add(pMe->mainscreen.pIMenuModel,tempText5 , pMe->mainscreen.nCmdID++, MMF_ENABLED);
IMENUMODEL_Add(pMe->mainscreen.pIMenuModel,tempText6 , pMe->mainscreen.nCmdID++, MMF_ENABLED);
return TRUE;
}
// FUNCTION NAME : MainMenu_selectionHandler
static void MainMenu_selectionHandler(calc *pMe, ModelEvent *pev)
{
// WidgetPos wpos;
if(pev->evCode == EVT_MDL_FOCUS_CHANGE)
{
//pMe->menuFocusIdx = pev->dwParam;
//IXYCONTAINER_GetPos(pMe->assignContainer, pMe->hlImgWgt, &wpos);
//wpos.y = pMe->menuFocusIdx * KMG_MENU_ITEM_HIGHT;//pMe->hlImgInfo.cy
//IXYCONTAINER_SetPos(pMe->assignContainer,pMe->hlImgWgt,WIDGET_ZNORMAL,&wpos);
}
else if(pev->evCode == EVT_MDL_FOCUS_SELECT)
{
switch(pev->dwParam)
{
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
default:
break;
}
}
return;

int CreateMainMenu(calc* pMe)
{
int nErr = SUCCESS;
IConstraintContainer *pIConstraintContainer = NULL;
IWidget *pIConstraintContainerWidget = NULL;
IWidget *pIWidget = NULL;
IWidget *pIMenuWidget = NULL;
WExtent extent;
WExtent size;
AEERect rc;
IDecorator *pIMenu = NULL;
IModel *tempViewModel = NULL;
ModelListener *pListener = NULL;
WidgetConstraint widgetContraint = { pMe->DeviceInfo.cxScreen + 10,
pMe->DeviceInfo.cyScreen + 10, TRUE };
AECHAR *tempText1 = NULL;
AECHAR *tempText2 = NULL;
AECHAR *tempText3 = NULL;
AECHAR *tempText4 = NULL;
AECHAR *tempText5 = NULL;
AECHAR *tempText6 = NULL;
//create MainMenu form
nErr = ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_FORM, (void **)&pMe->mainscreen.pMenuIForm);
if(SUCCESS != nErr)
{
return nErr;
}
nErr = ISHELL_CreateInstance( pMe->a.m_pIShell, AEECLSID_CONSTRAINTCONTAINER,
(void**)&pIConstraintContainer );
if(SUCCESS != nErr)
{
return nErr;
}
nErr = ICONSTRAINTCONTAINER_QueryInterface( pIConstraintContainer,
AEEIID_WIDGET,
(void**)&pIConstraintContainerWidget );
if(SUCCESS != nErr)
{
return nErr;
}
// Initialize the constraint container and attach it to the form.
IROOTFORM_GetClientRect(pMe->mainscreen.pIRootForm, NULL, &rc);
SETWEXTENT(&extent, rc.dx, rc.dy);
IWIDGET_SetExtent(pIConstraintContainerWidget, &extent);
// Create the menu item widget
//nErr = ISHELL_CreateInstance( pMe->a.m_pIShell, AEECLSID_LISTWIDGET,
// (void **)&pIMenu );
nErr = ISHELL_CreateInstance( pMe->a.m_pIShell, AEECLSID_LISTWIDGET,
(void **)&pIMenu );
if(SUCCESS != nErr)
{
return nErr;
}
nErr = IDECORATOR_QueryInterface( pIMenu, AEEIID_WIDGET,
(void **)&pIMenuWidget );
if(SUCCESS != nErr)
{
return nErr;
}
nErr = ISHELL_CreateInstance( pMe->a.m_pIShell, AEECLSID_STATICWIDGET,
(void **)&pIWidget );
if(SUCCESS != nErr)
{
return nErr;
}
nErr = ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_MENUMODEL, (void**)&pMe->mainscreen.pIMenuModel);
if(SUCCESS != nErr)
{
return nErr;
}
IWIDGET_SetModel( pIMenuWidget, IMENUMODEL_TO_IMODEL( pMe->mainscreen.pIMenuModel));
//Load resources to model
nErr = MainMenu_loadMenuItems(pMe, pMe->mainscreen.pIMenuModel);
if(nErr != TRUE)
{
return nErr;
}
//IWIDGET_SetBorderWidth( pIMenuWidget , 4 );
IWIDGET_SetSelectedFGColor( pIWidget, MAKE_RGBA(255, 0, 0, 255) );
//IWIDGET_SetSelectedBGColor( pIWidget, RGB_BLACK );
IWIDGET_SetSelectedBGColor( pIWidget, MAKE_RGB(0,0,255));
IWIDGET_GetPreferredExtent( pIWidget, &size );
IWIDGET_SetFontClass(pIWidget, AEECLSID_FONTSYSBOLD);
IWIDGET_SetBorderRadius(pIWidget, 7);
IWIDGET_SetBorderStyle(pIWidget, BORDERSTYLE_ROUNDED);
IWIDGET_SetFlags(pIWidget, SWF_NOSHORTENTEXT | IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);
//scrolling of long menu items
IWIDGET_SetProperty(pIWidget, PROP_ANIMATE, 1);
IWIDGET_SetGradientStyle(pIWidget,1);
IWIDGET_SetTransparency(pIWidget,100);
IWIDGET_SetItemHeight( pIMenuWidget, size.height );
//IWIDGET_SetItemWidth( pIMenuWidget, size.width );
IDECORATOR_SetWidget( pIMenu, pIWidget );
IDECORATOR_Release( pIMenu );
// Add the menu to the container. It's the sole item.
widgetContraint.constraint.top.type = CONSTRAINT_PARENT_TOP;
widgetContraint.constraint.top.offset = 23;
widgetContraint.constraint.left.type = CONSTRAINT_PARENT_LEFT;
widgetContraint.constraint.left.offset = 20;
widgetContraint.constraint.right.type = CONSTRAINT_PARENT_RIGHT;
widgetContraint.constraint.right.offset = -20;
//widgetContraint.constraint.bottom.type = WIDGET_SIZE_TO_FIT;
widgetContraint.constraint.bottom.type = CONSTRAINT_PARENT_BOTTOM;
//widgetContraint.constraint.bottom.offset = 0;
widgetContraint.constraint.bottom.offset = -23;
widgetContraint.bVisible = TRUE;
nErr = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIMenuWidget,
WIDGET_ZNORMAL, &widgetContraint );
//IWIDGET_MoveFocus( pIConstraintContainerWidget, pIMenuWidget );
IWIDGET_GetViewModel(pIMenuWidget, &tempViewModel);
pListener = (ModelListener*)MALLOC(sizeof(ModelListener));
LISTENER_Init(pListener, (PFNLISTENER)MainMenu_selectionHandler, pMe);
IMODEL_AddListener(tempViewModel, pListener);
IFORM_SetWidget(pMe->mainscreen.pMenuIForm, WID_FORM, pIConstraintContainerWidget);
//push the form to the root form
nErr = IROOTFORM_PushForm(pMe->mainscreen.pIRootForm, pMe->mainscreen.pMenuIForm);
return nErr;
}
int MainMenu_loadMenuItems(calc* pMe, IMenuModel* pMenuModel)
{
int nErr = SUCCESS;
AECHAR *tempText1 = NULL;
AECHAR *tempText2 = NULL;
AECHAR *tempText3 = NULL;
AECHAR *tempText4 = NULL;
AECHAR *tempText5 = NULL;
AECHAR *tempText6 = NULL;
// Allocate the memory for resource string
tempText1 = (AECHAR *)MALLOC(TXT_BUFFER_SIZE);
if(!tempText1)
{
DBGPRINTF("LoadMain: Unable allocate memory for body text");
return FALSE;
}
// Read the text from the resource
nErr = ISHELL_LoadResString(pMe->a.m_pIShell,
CALC_RES_FILE,
IDS_NEW_NOTES,
tempText1,
TXT_BUFFER_SIZE);
if(!nErr)
{
return FALSE;
}
// Allocate the memory for resource string
tempText2 = (AECHAR *)MALLOC(TXT_BUFFER_SIZE);
if(!tempText2)
{
return FALSE;
}
// Read the text from the resource
nErr = ISHELL_LoadResString(pMe->a.m_pIShell,
CALC_RES_FILE,
IDS_OPEN,
tempText2,
TXT_BUFFER_SIZE);
if(!nErr)
{
return FALSE;
}
// Allocate the memory for resource string
tempText3 = (AECHAR *)MALLOC(TXT_BUFFER_SIZE);
if(!tempText3)
{
return FALSE;
}
// Read the text from the resource
nErr = ISHELL_LoadResString(pMe->a.m_pIShell,
CALC_RES_FILE,
IDS_DELETE,
tempText3,
TXT_BUFFER_SIZE);
if(!nErr)
{
return FALSE;
}
// Allocate the memory for resource string
tempText4 = (AECHAR *)MALLOC(TXT_BUFFER_SIZE);
if(!tempText4)
{
return FALSE;
}
// Read the text from the resource
nErr = ISHELL_LoadResString(pMe->a.m_pIShell,
CALC_RES_FILE,
IDS_HELP,
tempText4,
TXT_BUFFER_SIZE);
if(!nErr)
{
return FALSE;
}
// Allocate the memory for resource string
tempText5 = (AECHAR *)MALLOC(TXT_BUFFER_SIZE);
if(!tempText5)
{
return FALSE;
}
// Read the text from the resource
nErr = ISHELL_LoadResString(pMe->a.m_pIShell,
CALC_RES_FILE,
IDS_ABOUT,
tempText5,
TXT_BUFFER_SIZE);
if(!nErr)
{
return FALSE;
}
// Allocate the memory for resource string
tempText6 = (AECHAR *)MALLOC(TXT_BUFFER_SIZE);
if(!tempText6)
{
return FALSE;
}
// Read the text from the resource
nErr = ISHELL_LoadResString(pMe->a.m_pIShell,
CALC_RES_FILE,
IDS_EXIT,
tempText6,
TXT_BUFFER_SIZE);
if(!nErr)
{
return FALSE;
}
IMENUMODEL_Add(pMe->mainscreen.pIMenuModel,tempText1 , pMe->mainscreen.nCmdID, MMF_ENABLED);
IMENUMODEL_Add(pMe->mainscreen.pIMenuModel,tempText2 , pMe->mainscreen.nCmdID++, MMF_ENABLED);
IMENUMODEL_Add(pMe->mainscreen.pIMenuModel,tempText3 , pMe->mainscreen.nCmdID++, MMF_ENABLED);
IMENUMODEL_Add(pMe->mainscreen.pIMenuModel,tempText4 , pMe->mainscreen.nCmdID++, MMF_ENABLED);
IMENUMODEL_Add(pMe->mainscreen.pIMenuModel,tempText5 , pMe->mainscreen.nCmdID++, MMF_ENABLED);
IMENUMODEL_Add(pMe->mainscreen.pIMenuModel,tempText6 , pMe->mainscreen.nCmdID++, MMF_ENABLED);
return TRUE;
}
// FUNCTION NAME : MainMenu_selectionHandler
static void MainMenu_selectionHandler(calc *pMe, ModelEvent *pev)
{
// WidgetPos wpos;
if(pev->evCode == EVT_MDL_FOCUS_CHANGE)
{
//pMe->menuFocusIdx = pev->dwParam;
//IXYCONTAINER_GetPos(pMe->assignContainer, pMe->hlImgWgt, &wpos);
//wpos.y = pMe->menuFocusIdx * KMG_MENU_ITEM_HIGHT;//pMe->hlImgInfo.cy
//IXYCONTAINER_SetPos(pMe->assignContainer,pMe->hlImgWgt,WIDGET_ZNORMAL,&wpos);
}
else if(pev->evCode == EVT_MDL_FOCUS_SELECT)
{
switch(pev->dwParam)
{
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
default:
break;
}
}
return;

hey anurag, put the code in between code tag. it is very difficult for others to read the code when posted as normal text.
The code tag is the one with # symbol, in forum post editor. Select ur code and press # symbol.
This is code

hey anurag, put the code in between code tag. it is very difficult for others to read the code when posted as normal text.
The code tag is the one with # symbol, in forum post editor. Select ur code and press # symbol.
This is code