IMenuWindow.c
资源名称:MenuList.rar [点击查看]
上传用户:duwei1288
上传日期:2009-12-27
资源大小:451k
文件大小:7k
源码类别:
BREW编程
开发平台:
Visual C++
- #include "IMenuWindow.h"
- #include "HandleFunc.h"
- #include "IBookmark.h"
- #include "MenuStack.h"
- #include "Push.h"
- #include "IHistory.h"
- #include "MenuList.brh"
- #include "ISettingFile.h"
- #include "AEEAppGen.h"
- #include "CMenulist.h"
- /////////////////////////////////////////////////////////////
- const TMenuItem atDefaultPageMenu[] =
- {
- {MENUITEM_DEFAULTPAGENAME,0,IDS_DEFAULTHOMEPAGENAME,NULL,WAPSetHdl_SetDefHomePageName},
- {MENUITEM_DEFAULTPAGEURL,0,IDS_DEFAULTHOMEPAGEURL,NULL,WAPSetHdl_SetDefHomePageUrl},
- {MENUITEM_NULL,0,0,NULL}
- };
- const TMenuItem atConnectHodeMenu[] =
- {
- {MENUITEM_CONNECTUDP,0,IDS_UDP,NULL,WAPSetHdl_SetConnectTypeWSPCL},
- {MENUITEM_CONNECTTCP,0,IDS_TCP,NULL,WAPSetHdl_SetConnectTypeWSPCO},
- {MENUITEM_CONNECTUDPWTLS,0,IDS_CONNECTUDPWTLS,NULL,WAPSetHdl_SetConnectTypeWSPCLWTLS},
- {MENUITEM_CONNECTTCPWTLS,0,IDS_CONNECTTCPWTLS,NULL,WAPSetHdl_SetConnectTypeWSPCOWTLS},
- {MENUITEM_HTTP,0,IDS_HTTP,NULL,WAPSetHdl_SetConnectTypeHTTP},
- {MENUITEM_HTTPWTLS,0,IDS_HTTPWTLS,NULL,WAPSetHdl_SetConnectTypeHTTPSECURITY},
- {MENUITEM_NULL,0,0,NULL,NULL}
- };
- const TMenuItem atGatewaySetMenu[] =
- {
- {MENUITEM_GATEWAYIP,0,IDS_IP,NULL,WAPSetHdl_SetGatewayIP},
- {MENUITEM_GATEWAYPORT,0,IDS_PORT,NULL,WAPSetHdl_SetGatewayPort},
- {MENUITEM_GATEWAYUSER,0,IDS_USER,NULL,WAPSetHdl_SetGatewayUSER},
- {MENUITEM_PASSWORD,0,IDS_PASSWORD,NULL,WAPSetHdl_SetGatewayPassword},
- {MENUITEM_NULL,0,0,NULL,NULL}
- };
- /*const TMenuItem atMainMenu[] =
- {
- {MENUITEM_CONNECT,0,IDS_CONNECTSET,atSub1Menu,NULL},
- {MENUITEM_GATEWAY,0,IDS_GATEWAY,atSub2Menu,NULL},
- {MENUITEM_NULL,0,0,NULL,NULL}
- };*/
- const TMenuItem atSettingMenu[] =
- {
- {MENUITEM_DEFAULTPAGESET,0,IDS_DEFAULTPAGESET,atDefaultPageMenu,NULL},
- {MENUITEM_GATEWAYSET,0,IDS_GATEWAYSET,atGatewaySetMenu,NULL},
- {MENUITEM_CONNECTMETHOD,0,IDS_CONNECTMETHOD,atConnectHodeMenu,NULL},
- {MENUITEM_ADVANCESET,0,IDS_ADVANCESET,NULL},
- {MENUITEM_NULL,0,0,NULL}
- };
- const TMenuItem atLoginMenu[] =
- {
- {MENUITEM_MAINPAGE,0,IDS_MAINPAGE,NULL},
- {MENUITEM_LASTPAGE,0,IDS_LASTPAGE,NULL},
- {MENUITEM_OPENURL,0,IDS_OPENURL,NULL,WAPSetHdl_SetOpenUrl},
- {MENUITEM_NULL,0,0,NULL}
- };
- const TMenuItem atMainMenu[] =
- {
- {MENUITEM_LOGIN,0,IDS_LOGIN,atLoginMenu},
- {MENUITEM_BOOKMARK,0,IDS_BOOKMARK,NULL,WAPSetHdl_SetBookMark},
- {MENUITEM_PUSH,0,IDS_PUSH,NULL,PushDlg},
- {MENUITEM_HISTORY,0,IDS_HISTORY,NULL,HistoryDlg},
- {MENUITEM_SETTING,0,IDS_SETTING, atSettingMenu},
- {MENUITEM_ABOUT,0,IDS_ABOUT,NULL},
- {MENUITEM_NULL,0,0,NULL}
- };
- static AECHAR* IMENUWINDOW_GetData(uint16 ResId);
- static uint16 IMENUWINDOW_GetSel(TMenuItem* pMenu);
- boolean IMENUWINDOW_EventHandle(void* pWin,AEEEvent eCode, uint16 wParam, uint32 dwParam)
- {
- return IMENUSTACK_HandleEvent(((IMenuWin*)(pWin))->m_pMenuStack,eCode,wParam,dwParam);
- }
- void* IMENUWINDOW_Create(IShell* pShell,void* pParam)
- {
- IMenuWin* pWin=MALLOCREC(IMenuWin);
- if(pWin)
- {
- pWin->m_pMenuStack=IMENUSTACK_CreateInstance((TMenuItem*)atMainMenu,
- IMENUWINDOW_GetData,
- IMENUWINDOW_GetSel);
- if(!pWin->m_pMenuStack)
- FREEIF(pWin);
- }
- return pWin;
- }
- boolean IMENUWINDOW_Release(IShell* pShell,void** pWin)
- {
- if(*pWin)
- {
- IMENUSTACK_Release(&((IMenuWin*)(*pWin))->m_pMenuStack);
- FREEIF(*pWin);
- }
- return TRUE;
- }
- boolean IMENUWINDOW_Redraw(IShell* pShell,void* pWin)
- {
- if(!pWin) return FALSE;
- return IMENUSTACK_Redraw(((IMenuWin*)pWin)->m_pMenuStack);
- }
- static AECHAR* IMENUWINDOW_GetData(uint16 ResId)
- {
- AECHAR* pVal=NULL;
- AECHAR* pData=NULL;
- AECHAR restext[80];
- char cTempBuf[16];
- AECHAR wTempBuf[32];
- int nVal;
- AECHAR pInterval[]={':',0};
- AEEApplet* pApp=(AEEApplet*)GETAPPINSTANCE();
- AECHAR infoText[100];
- IBookMarkWin *ptBookmarkWin = (IBookMarkWin *)MALLOC(sizeof(IBookMarkWin));
- switch(ResId)
- {
- case IDS_IP:
- pData=ISETTINGFILE_GetStr(WAP_GATEWAYIP);
- break;
- case IDS_PORT:
- nVal=ISETTINGFILE_GetInt(WAP_GATEWAPPORT);
- SPRINTF(cTempBuf,"%d",nVal);
- STRTOWSTR(cTempBuf,wTempBuf,sizeof(wTempBuf));
- pData=wTempBuf;
- break;
- case IDS_USER:
- pData=ISETTINGFILE_GetStr(WAP_GATEWAPUSER);
- break;
- case IDS_PASSWORD:
- pData=ISETTINGFILE_GetStr(WAP_GATEWAPPASSWORD);
- break;
- case IDS_CONNECTMETHOD:
- nVal=ISETTINGFILE_GetInt(WAP_CONNECTSET);
- //SPRINTF(cTempBuf,"%d",nVal);
- //STRTOWSTR(cTempBuf,wTempBuf,sizeof(wTempBuf));
- switch(nVal)
- {
- case CONNECTION_TYPE_WSP_CO:
- ISHELL_LoadResString(pApp->m_pIShell, MENULIST_RES_FILE, IDS_TCP, infoText, sizeof(infoText));
- pData=infoText;
- break;
- case CONNECTION_TYPE_WSP_CL:
- ISHELL_LoadResString(pApp->m_pIShell, MENULIST_RES_FILE, IDS_UDP, infoText, sizeof(infoText));
- pData=infoText;
- break;
- case CONNECTION_TYPE_WSP_CO_WTLS:
- ISHELL_LoadResString(pApp->m_pIShell, MENULIST_RES_FILE, IDS_CONNECTTCPWTLS, infoText, sizeof(infoText));
- pData=infoText;
- break;
- case CONNECTION_TYPE_WSP_CL_WTLS:
- ISHELL_LoadResString(pApp->m_pIShell, MENULIST_RES_FILE, IDS_CONNECTUDPWTLS, infoText, sizeof(infoText));
- pData=infoText;
- break;
- case CONNECTION_TYPE_HTTP:
- ISHELL_LoadResString(pApp->m_pIShell, MENULIST_RES_FILE, IDS_HTTP, infoText, sizeof(infoText));
- pData=infoText;
- break;
- case CONNECTION_TYPE_HTTP_SECURITY:
- ISHELL_LoadResString(pApp->m_pIShell, MENULIST_RES_FILE, IDS_HTTPWTLS, infoText, sizeof(infoText));
- pData=infoText;
- break;
- default:
- return NULL;
- }
- break;
- case IDS_DEFAULTHOMEPAGENAME:
- pData=ISETTINGFILE_GetStr(WAP_DEFHOMEPAGENAME);
- break;
- case IDS_DEFAULTHOMEPAGEURL:
- pData=ISETTINGFILE_GetStr(WAP_DEFHOMEPAGEURL);
- break;
- default:
- return NULL;
- }
- if(!pData)
- return NULL;
- ISHELL_LoadResString(pApp->m_pIShell, MENULIST_RES_FILE, ResId, restext, sizeof(restext));
- pVal=MALLOC(WSTRSIZE(restext)+WSTRSIZE(pData));
- WSTRCPY(pVal,restext);
- WSTRCAT(pVal,pInterval);
- WSTRCAT(pVal,pData);
- return pVal;
- }
- static uint16 IMENUWINDOW_GetSel(TMenuItem* pMenu)
- {
- int nVal;
- if(!pMenu) return 0;
- switch(pMenu->tItemId)
- {
- case MENUITEM_CONNECTUDP:
- nVal=ISETTINGFILE_GetInt(WAP_CONNECTSET);
- switch(nVal)
- {
- case CONNECTION_TYPE_WSP_CL:
- return MENUITEM_CONNECTUDP;
- case CONNECTION_TYPE_WSP_CO:
- return MENUITEM_CONNECTTCP;
- case CONNECTION_TYPE_WSP_CL_WTLS:
- return MENUITEM_CONNECTUDPWTLS;
- case CONNECTION_TYPE_WSP_CO_WTLS:
- return MENUITEM_CONNECTTCPWTLS;
- case CONNECTION_TYPE_HTTP:
- return CONNECTION_TYPE_HTTP;
- case CONNECTION_TYPE_HTTP_SECURITY:
- return CONNECTION_TYPE_HTTP_SECURITY;
- }
- break;
- default:
- return 0;
- }
- return 0;
- }