IInputWindow.c
资源名称:MenuList.rar [点击查看]
上传用户:duwei1288
上传日期:2009-12-27
资源大小:451k
文件大小:10k
源码类别:
BREW编程
开发平台:
Visual C++
- #include "IInputWindow.h"
- #include "AEEAppGen.h"
- #include "WindowStack.h"
- #include "MenuList_res.h"
- /////////////////////////Static Function//////////////////////
- #define INPUT_TEXT_X_START 2
- #define INPUT_TEXT_Y_START 0
- #define INPUT_TEXT_MAX_SIZE 150
- //窗口的控件
- typedef enum
- {
- INPUT_SOFTKEYCTL=0,
- INPUT_TEXT1CTL,
- INPUT_TEXT2CTL
- }TInputCtlType;
- //软键控件的ItemId定义
- typedef enum
- {
- INPUT_SOFTKEY_ITEM = 1,
- INPUT_SOFTKEY_ITEM_INPUT_MODE,
- INPUT_SOFTKEY_ITEM_DONE,
- INPUT_SOFTKEY_ITEM_CANCEL
- }TInputMesWinItems;
- //按键事件的处理
- static boolean IINPUTWINDOW_HandleKeyEvent(IInputWin* pWin,uint16 wParam);
- //软键菜单的处理
- static boolean IINPUTWINDOW_HandleCommandEvent(IInputWin* pWin,uint16 wParam);
- //设置窗口中控件的激活状态
- static boolean IINPUTWINDOW_SetActiveCtl(IInputWin* pWin,TInputCtlType nTextCtl);
- /////////////////////////Public Function//////////////////////
- boolean NewTextInputDialog(
- //svoid *pPtr,
- InputTextInfo* pTextInfo1,
- InputTextInfo* pTextInfo2,
- TInputDialogResp tpResponseFunction)
- {
- IInputWin* pWin;
- AEERect Text1Rect;
- AEERect Text2Rect;
- AEERect softkeyRect;
- AEEDeviceInfo di;
- uint32 textProps;
- AEEApplet* pApp=(AEEApplet*)GETAPPINSTANCE();
- if(!pTextInfo1||!tpResponseFunction)
- return FALSE;
- //分配窗口空间
- pWin=MALLOCREC(IInputWin);
- if(!pWin) return FALSE;
- if(IT_NUMBER==pTextInfo1->m_inputType)
- pWin->m_wMode=AEE_TM_NUMBERS;
- else
- pWin->m_wMode=AEE_TM_LETTERS;
- pWin->tpResponseFunction=tpResponseFunction;
- //创建软键控件
- if(SUCCESS!=ISHELL_CreateInstance(pApp->m_pIShell,AEECLSID_SOFTKEYCTL,
- (void **)&(pWin->m_pSoftKeyCtl)))
- {
- IINPUTWINDOW_Release(pApp->m_pIShell,&pWin);
- return FALSE;
- }
- if(AEE_TM_LETTERS==pWin->m_wMode)
- IMENUCTL_AddItem(pWin->m_pSoftKeyCtl, MENULIST_RES_FILE, IDS_INPUTLETTER,INPUT_SOFTKEY_ITEM_INPUT_MODE, NULL, 0);
- else
- IMENUCTL_AddItem(pWin->m_pSoftKeyCtl, MENULIST_RES_FILE, IDS_INPUTNUMBER,INPUT_SOFTKEY_ITEM_INPUT_MODE, NULL, 0);
- IMENUCTL_AddItem(pWin->m_pSoftKeyCtl, MENULIST_RES_FILE, IDS_CANCEL, INPUT_SOFTKEY_ITEM_CANCEL, NULL, 0);
- IMENUCTL_AddItem(pWin->m_pSoftKeyCtl,MENULIST_RES_FILE, IDS_OK, INPUT_SOFTKEY_ITEM_DONE, NULL, 0);
- IMENUCTL_GetRect(pWin->m_pSoftKeyCtl, &softkeyRect);
- ISHELL_GetDeviceInfo(pApp->m_pIShell, &di);
- //创建文本输入控件
- if(SUCCESS!=ISHELL_CreateInstance(pApp->m_pIShell,AEECLSID_TEXTCTL,(void **)&(pWin->m_pText1)))
- {
- IINPUTWINDOW_Release(pApp->m_pIShell,&pWin);
- return FALSE;
- }
- if(pTextInfo2&&SUCCESS!=ISHELL_CreateInstance(pApp->m_pIShell,AEECLSID_TEXTCTL,(void **)&(pWin->m_pText2)))
- {
- IINPUTWINDOW_Release(pApp->m_pIShell,&pWin);
- return FALSE;
- }
- //Rect
- Text1Rect.x = INPUT_TEXT_X_START;
- Text1Rect.y = INPUT_TEXT_Y_START;
- Text1Rect.dx = di.cxScreen-2*INPUT_TEXT_X_START;
- Text1Rect.dy = (int16)(softkeyRect.y -INPUT_TEXT_Y_START-1);
- if(pTextInfo2)
- {
- Text1Rect.dy/=2;
- Text2Rect.dx=Text1Rect.dx;
- Text2Rect.dy=Text1Rect.dy;
- Text2Rect.x=Text1Rect.x;
- Text2Rect.y=Text1Rect.y+Text1Rect.dy;
- ITEXTCTL_SetRect(pWin->m_pText2, &Text2Rect);
- }
- ITEXTCTL_SetRect(pWin->m_pText1, &Text1Rect);
- //Properties
- textProps = ITEXTCTL_GetProperties(pWin->m_pText1);
- textProps |= TP_FRAME;
- textProps |= TP_MULTILINE;
- if (IT_PASSWORD==pTextInfo1->m_inputType)
- textProps |= TP_PASSWORD;
- else if (IT_NUMBER==pTextInfo1->m_inputType)
- textProps |= AEE_TM_NUMBERS;
- ITEXTCTL_SetProperties(pWin->m_pText1,textProps);
- if(pTextInfo2)
- {
- textProps = ITEXTCTL_GetProperties(pWin->m_pText2);
- textProps |= TP_FRAME;
- textProps |= TP_MULTILINE;
- if (IT_PASSWORD==pTextInfo2->m_inputType)
- textProps |= TP_PASSWORD;
- else if (IT_NUMBER==pTextInfo2->m_inputType)
- textProps |= AEE_TM_NUMBERS;
- ITEXTCTL_SetProperties(pWin->m_pText2,textProps);
- }
- //Max Size
- ITEXTCTL_SetMaxSize(pWin->m_pText1,INPUT_TEXT_MAX_SIZE);
- if(pTextInfo2)
- ITEXTCTL_SetMaxSize(pWin->m_pText2,INPUT_TEXT_MAX_SIZE);
- //Set Text
- if(pTextInfo2)
- {
- ITEXTCTL_SetText(pWin->m_pText2, pTextInfo2->m_pText?pTextInfo2->m_pText:(AECHAR*)"