IMenuWindow.c
上传用户:duwei1288
上传日期:2009-12-27
资源大小:451k
文件大小:7k
源码类别:

BREW编程

开发平台:

Visual C++

  1. #include "IMenuWindow.h"
  2. #include "HandleFunc.h"
  3. #include "IBookmark.h"
  4. #include "MenuStack.h"
  5. #include "Push.h"
  6. #include "IHistory.h"
  7. #include "Menulist_res.h"
  8. #include "ISettingFile.h"
  9. #include "AEEAppGen.h"
  10. #include "CMenulist.h"
  11. /////////////////////////////////////////////////////////////
  12. const TMenuItem atDefaultPageMenu[] =
  13. {
  14. {MENUITEM_DEFAULTPAGENAME,0,IDS_DEFAULTHOMEPAGENAME,NULL,WAPSetHdl_SetDefHomePageName},
  15. {MENUITEM_DEFAULTPAGEURL,0,IDS_DEFAULTHOMEPAGEURL,NULL,WAPSetHdl_SetDefHomePageUrl},
  16. {MENUITEM_NULL,0,0,NULL}
  17. };
  18. const TMenuItem atConnectHodeMenu[] =
  19. {
  20. {MENUITEM_CONNECTUDP,0,IDS_UDP,NULL,WAPSetHdl_SetConnectTypeWSPCL},
  21. {MENUITEM_CONNECTTCP,0,IDS_TCP,NULL,WAPSetHdl_SetConnectTypeWSPCO},
  22.        {MENUITEM_CONNECTUDPWTLS,0,IDS_CONNECTUDPWTLS,NULL,WAPSetHdl_SetConnectTypeWSPCLWTLS},
  23. {MENUITEM_CONNECTTCPWTLS,0,IDS_CONNECTTCPWTLS,NULL,WAPSetHdl_SetConnectTypeWSPCOWTLS},
  24. {MENUITEM_HTTP,0,IDS_HTTP,NULL,WAPSetHdl_SetConnectTypeHTTP},
  25. {MENUITEM_HTTPWTLS,0,IDS_HTTPWTLS,NULL,WAPSetHdl_SetConnectTypeHTTPSECURITY},
  26. {MENUITEM_NULL,0,0,NULL,NULL}
  27. };
  28. const TMenuItem atGatewaySetMenu[] =
  29. {
  30. {MENUITEM_GATEWAYIP,0,IDS_IP,NULL,WAPSetHdl_SetGatewayIP},
  31. {MENUITEM_GATEWAYPORT,0,IDS_PORT,NULL,WAPSetHdl_SetGatewayPort},
  32. {MENUITEM_GATEWAYUSER,0,IDS_USER,NULL,WAPSetHdl_SetGatewayUSER},
  33. {MENUITEM_PASSWORD,0,IDS_PASSWORD,NULL,WAPSetHdl_SetGatewayPassword},
  34. {MENUITEM_NULL,0,0,NULL,NULL}
  35. };
  36. /*const TMenuItem atMainMenu[] =
  37. {
  38. {MENUITEM_CONNECT,0,IDS_CONNECTSET,atSub1Menu,NULL},
  39. {MENUITEM_GATEWAY,0,IDS_GATEWAY,atSub2Menu,NULL},
  40. {MENUITEM_NULL,0,0,NULL,NULL}
  41. };*/
  42. const TMenuItem atSettingMenu[] =
  43. {
  44. {MENUITEM_DEFAULTPAGESET,0,IDS_DEFAULTPAGESET,atDefaultPageMenu,NULL},
  45. {MENUITEM_GATEWAYSET,0,IDS_GATEWAYSET,atGatewaySetMenu,NULL},
  46. {MENUITEM_CONNECTMETHOD,0,IDS_CONNECTMETHOD,atConnectHodeMenu,NULL},
  47. {MENUITEM_ADVANCESET,0,IDS_ADVANCESET,NULL},
  48. {MENUITEM_NULL,0,0,NULL}
  49. };
  50. const TMenuItem atLoginMenu[] =
  51. {
  52. {MENUITEM_MAINPAGE,0,IDS_MAINPAGE,NULL},
  53. {MENUITEM_LASTPAGE,0,IDS_LASTPAGE,NULL},
  54. {MENUITEM_OPENURL,0,IDS_OPENURL,NULL,WAPSetHdl_SetOpenUrl},
  55. {MENUITEM_NULL,0,0,NULL}
  56. };
  57. const TMenuItem atMainMenu[] =
  58. {
  59. {MENUITEM_LOGIN,0,IDS_LOGIN,atLoginMenu},
  60. {MENUITEM_BOOKMARK,0,IDS_BOOKMARK,NULL,WAPSetHdl_SetBookMark},
  61. {MENUITEM_PUSH,0,IDS_PUSH,NULL,PushDlg},
  62. {MENUITEM_HISTORY,0,IDS_HISTORY,NULL,HistoryDlg},
  63. {MENUITEM_SETTING,0,IDS_SETTING, atSettingMenu},
  64. {MENUITEM_ABOUT,0,IDS_ABOUT,NULL},
  65. {MENUITEM_NULL,0,0,NULL}
  66. };
  67. static AECHAR* IMENUWINDOW_GetData(uint16 ResId);
  68. static uint16  IMENUWINDOW_GetSel(TMenuItem* pMenu);
  69. boolean IMENUWINDOW_EventHandle(void* pWin,AEEEvent eCode, uint16 wParam, uint32 dwParam)
  70. {
  71. return IMENUSTACK_HandleEvent(((IMenuWin*)(pWin))->m_pMenuStack,eCode,wParam,dwParam);
  72. }
  73. void*   IMENUWINDOW_Create(IShell* pShell,void* pParam)
  74. {
  75. IMenuWin* pWin=MALLOCREC(IMenuWin);
  76. if(pWin)
  77. {
  78. pWin->m_pMenuStack=IMENUSTACK_CreateInstance((TMenuItem*)atMainMenu,
  79. IMENUWINDOW_GetData,
  80. IMENUWINDOW_GetSel);
  81. if(!pWin->m_pMenuStack)
  82. FREEIF(pWin);
  83. }
  84. return pWin;
  85. }
  86. boolean IMENUWINDOW_Release(IShell* pShell,void** pWin)
  87. {
  88. if(*pWin)
  89. {
  90. IMENUSTACK_Release(&((IMenuWin*)(*pWin))->m_pMenuStack);
  91. FREEIF(*pWin);
  92. }
  93. return TRUE;
  94. }
  95. boolean IMENUWINDOW_Redraw(IShell* pShell,void* pWin)
  96. {
  97. if(!pWin) return FALSE;
  98. return IMENUSTACK_Redraw(((IMenuWin*)pWin)->m_pMenuStack);
  99. }
  100. static AECHAR* IMENUWINDOW_GetData(uint16 ResId)
  101. {
  102. AECHAR* pVal=NULL;
  103. AECHAR* pData=NULL;
  104. AECHAR  restext[80];
  105. char    cTempBuf[16];
  106. AECHAR  wTempBuf[32];
  107. int     nVal;
  108. AECHAR pInterval[]={':',0};  
  109. AEEApplet*  pApp=(AEEApplet*)GETAPPINSTANCE();
  110. AECHAR infoText[100];
  111. IBookMarkWin *ptBookmarkWin = (IBookMarkWin *)MALLOC(sizeof(IBookMarkWin));
  112. switch(ResId)
  113. {
  114. case IDS_IP:
  115. pData=ISETTINGFILE_GetStr(WAP_GATEWAYIP);
  116. break;
  117. case IDS_PORT:
  118. nVal=ISETTINGFILE_GetInt(WAP_GATEWAPPORT);
  119. SPRINTF(cTempBuf,"%d",nVal);
  120. STRTOWSTR(cTempBuf,wTempBuf,sizeof(wTempBuf));
  121. pData=wTempBuf;
  122. break;
  123. case IDS_USER:
  124. pData=ISETTINGFILE_GetStr(WAP_GATEWAPUSER);
  125. break;
  126. case IDS_PASSWORD:
  127. pData=ISETTINGFILE_GetStr(WAP_GATEWAPPASSWORD);
  128. break;
  129. case IDS_CONNECTMETHOD:
  130. nVal=ISETTINGFILE_GetInt(WAP_CONNECTSET);
  131. //SPRINTF(cTempBuf,"%d",nVal);
  132. //STRTOWSTR(cTempBuf,wTempBuf,sizeof(wTempBuf));
  133. switch(nVal)
  134. {
  135. case CONNECTION_TYPE_WSP_CO:
  136. ISHELL_LoadResString(pApp->m_pIShell, MENULIST_RES_FILE, IDS_TCP, infoText, sizeof(infoText));
  137. pData=infoText;
  138. break;
  139. case CONNECTION_TYPE_WSP_CL:
  140. ISHELL_LoadResString(pApp->m_pIShell, MENULIST_RES_FILE, IDS_UDP, infoText, sizeof(infoText));
  141. pData=infoText;
  142. break;
  143. case CONNECTION_TYPE_WSP_CO_WTLS:
  144. ISHELL_LoadResString(pApp->m_pIShell, MENULIST_RES_FILE, IDS_CONNECTTCPWTLS, infoText, sizeof(infoText));
  145. pData=infoText;
  146. break;
  147. case CONNECTION_TYPE_WSP_CL_WTLS:
  148. ISHELL_LoadResString(pApp->m_pIShell, MENULIST_RES_FILE, IDS_CONNECTUDPWTLS, infoText, sizeof(infoText));
  149. pData=infoText;
  150. break;
  151. case CONNECTION_TYPE_HTTP:
  152. ISHELL_LoadResString(pApp->m_pIShell, MENULIST_RES_FILE, IDS_HTTP, infoText, sizeof(infoText));
  153. pData=infoText;
  154. break;
  155. case CONNECTION_TYPE_HTTP_SECURITY:
  156. ISHELL_LoadResString(pApp->m_pIShell, MENULIST_RES_FILE, IDS_HTTPWTLS, infoText, sizeof(infoText));
  157. pData=infoText;
  158. break;
  159. default:
  160. return NULL;
  161. }
  162. break;
  163. case IDS_DEFAULTHOMEPAGENAME:
  164. pData=ISETTINGFILE_GetStr(WAP_DEFHOMEPAGENAME);
  165. break;
  166. case IDS_DEFAULTHOMEPAGEURL:
  167. pData=ISETTINGFILE_GetStr(WAP_DEFHOMEPAGEURL);
  168. break;
  169. default:
  170. return NULL;
  171. }
  172. if(!pData)
  173. return NULL;
  174. ISHELL_LoadResString(pApp->m_pIShell, MENULIST_RES_FILE, ResId, restext, sizeof(restext));
  175. pVal=MALLOC(WSTRSIZE(restext)+WSTRSIZE(pData));
  176. WSTRCPY(pVal,restext);
  177. WSTRCAT(pVal,pInterval);
  178. WSTRCAT(pVal,pData);
  179. return pVal;
  180. }
  181. static uint16  IMENUWINDOW_GetSel(TMenuItem* pMenu) 
  182. {
  183. int nVal;
  184. if(!pMenu) return 0;
  185. switch(pMenu->tItemId)
  186. {
  187. case MENUITEM_CONNECTUDP:
  188. nVal=ISETTINGFILE_GetInt(WAP_CONNECTSET);
  189. switch(nVal)
  190. {
  191. case CONNECTION_TYPE_WSP_CL:
  192. return MENUITEM_CONNECTUDP;
  193. case CONNECTION_TYPE_WSP_CO:
  194. return MENUITEM_CONNECTTCP;
  195. case CONNECTION_TYPE_WSP_CL_WTLS:
  196. return MENUITEM_CONNECTUDPWTLS;
  197. case CONNECTION_TYPE_WSP_CO_WTLS:
  198. return MENUITEM_CONNECTTCPWTLS;
  199. case CONNECTION_TYPE_HTTP:
  200. return CONNECTION_TYPE_HTTP;
  201. case CONNECTION_TYPE_HTTP_SECURITY:
  202. return CONNECTION_TYPE_HTTP_SECURITY;
  203. }
  204. break;
  205. default:
  206. return 0;
  207. }
  208. return 0;
  209. }
  210.