?? addrbookruim.c
字號:
// Let each of the controls have a crack at the event. If one of them is able to handle
// the event then return TRUE indicating that the event has been handled.
if (IMENUCTL_HandleEvent(pMe->m_pMenu, eCode, wParam, dwParam))
return TRUE;
if (IMENUCTL_HandleEvent(pMe->m_pSK, eCode, wParam, dwParam))
return TRUE;
/* text控件處理DOWN鍵后,后面程序繼續處理*/
if (ITEXTCTL_HandleEvent(pMe->m_pText1, eCode, wParam, dwParam))
{
if ( eCode==EVT_KEY && wParam==AVK_DOWN)
{
// 不返回TRUE,使后面程序繼續處理
}
else
{
return TRUE;
}
}
/* text控件處理DOWN鍵后,后面程序繼續處理*/
if (ITEXTCTL_HandleEvent(pMe->m_pText2, eCode, wParam, dwParam))
{
if ( eCode==EVT_KEY && wParam==AVK_DOWN)
{
// 不返回TRUE,使后面程序繼續處理
}
else
{
return TRUE;
}
}
switch (eCode)
{
// App is told it is starting up
case EVT_APP_START:
// Add your code here...
ABR_DisplayMainMenu( 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...
// Set all controls to InActive
IMENUCTL_SetActive( pMe->m_pMenu, FALSE );
IMENUCTL_SetActive( pMe->m_pSK, FALSE );
ITEXTCTL_SetActive( pMe->m_pText1, FALSE );
ITEXTCTL_SetActive( pMe->m_pText2, FALSE );
return(TRUE);
// App is being resumed
case EVT_APP_RESUME:
// Add your code here...
switch( pMe->m_eAppState )
{
case APP_STATE_MAIN:
ABR_DisplayMainMenu( pMe );
return TRUE;
case APP_STATE_ADD:
ABR_DisplayAddScreen(pMe);
return TRUE;
case APP_STATE_EDIT:
ABR_DisplayEditScreen(pMe, pMe->m_wSelRecId+ABR_REC_LIST_ID);
return TRUE;
case APP_STATE_VIEW:
ABR_DisplayViewMenu(pMe);
return TRUE;
case APP_STATE_TOTAL_REC:
ABR_DisplayTotalRec( pMe );
return TRUE;
default:
break;
}
return TRUE;
case EVT_CTL_SEL_CHANGED:
// If the record menu is showing and the user changes the selected
// record in the menu control, get the record id and save it to m_wSelRecId
if (pMe->m_eAppState == APP_STATE_VIEW)
{
IMenuCtl * pMenu = (IMenuCtl*)dwParam;
// IMENUCTL_GetSel()得到menu的ID,減去ABR_REC_LIST_ID得到address book record的ID
pMe->m_wSelRecId = IMENUCTL_GetSel(pMenu) - ABR_REC_LIST_ID;
return TRUE;
}
break;
// 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);
case EVT_COMMAND: // Handle 'SELECT' button events
switch(wParam)
{
case IDC_ADD: // User pressed the 'Add' menu
ABR_DisplayAddScreen(pMe);
return TRUE;
case IDC_VIEW: // User pressed the 'View' menu
ABR_DisplayViewMenu(pMe);
return TRUE;
case IDC_TOTAL_REC: // User pressed the 'Total Rec' menu
ABR_DisplayTotalRec(pMe);
return TRUE;
case IDC_SWITCH_STORE_DEV:
ABR_DisplayStoreDevice(pMe);
return TRUE;
case IDC_ADD_SK: // User pressed the 'Add soft key' menu
// 只可能在APP_STATE_ADD狀態下發生
if( pMe->m_eAppState == APP_STATE_ADD && pMe->m_pText1 && pMe->m_pText2 )
{
AECHAR * pTextName=NULL;
AECHAR * pTextNum=NULL;
pTextName= ITEXTCTL_GetTextPtr( pMe->m_pText1 );
pTextNum = ITEXTCTL_GetTextPtr( pMe->m_pText2 );
// 將名字和電話作為一個記錄增加到address book
nRet = ABR_AddContactRec( pMe, pMe->m_ContactCLS, pTextName, pTextNum);
if(nRet == AEE_SUCCESS)
{
wTextID = IDS_PROMPT_TEXT_SUC;
}
else
{
wTextID = IDS_PROMPT_TEXT_FAIL;
}
pInfo.pszRes = ADDRBOOKRUIM_RES_FILE;
pInfo.pTitle = NULL;
pInfo.pText = NULL;
pInfo.wTitleID = 0;
pInfo.wTextID = wTextID;
pInfo.wDefBtn = IDC_OK_PROMPT;
pInfo.pBtnIDs = wButtonIDs;
pInfo.dwProps = ST_CENTERTITLE;
pInfo.fntTitle = AEE_FONT_BOLD;
pInfo.fntText = AEE_FONT_NORMAL;
pInfo.dwTimeout = 0;
// 顯示成功或失敗消息,同時prompt OK按鈕
// 用戶按按鈕后產生IDC_OK_PROMPT command
ISHELL_Prompt(pMe->pIShell, &pInfo);
}
else
{
ABR_DisplayMainMenu(pMe);
}
return TRUE;
case IDC_UPDATE: // User pressed the 'Update' soft key in Edit screen
if( pMe->m_eAppState == APP_STATE_EDIT && pMe->m_pText1 && pMe->m_pText2 )
{
AECHAR * pTextName=NULL;
AECHAR * pTextNum=NULL;
pTextName= ITEXTCTL_GetTextPtr( pMe->m_pText1 );
pTextNum = ITEXTCTL_GetTextPtr( pMe->m_pText2 );
// 以新的名字(pTextName)和電話(pTextNum)更新電話本中記錄id為pMe->m_wSelRecId的記錄
nRet = ABR_UpdateContactRec( pMe, pMe->m_ContactCLS, pMe->m_wSelRecId, pTextName, pTextNum);
if(nRet == AEE_SUCCESS)
{
wTextID = IDS_PROMPT_TEXT_SUC;
}
else
{
wTextID = IDS_PROMPT_TEXT_FAIL;
}
pInfo.pszRes = ADDRBOOKRUIM_RES_FILE;
pInfo.pTitle = NULL;
pInfo.pText = NULL;
pInfo.wTitleID = 0;
pInfo.wTextID = wTextID;
pInfo.wDefBtn = IDC_OK_PROMPT;
pInfo.pBtnIDs = wButtonIDs;
pInfo.dwProps = ST_CENTERTITLE;
pInfo.fntTitle = AEE_FONT_BOLD;
pInfo.fntText = AEE_FONT_NORMAL;
pInfo.dwTimeout = 0;
// 顯示成功或失敗消息,同時prompt OK按鈕
// 用戶按按鈕后產生IDC_OK_PROMPT command
ISHELL_Prompt(pMe->pIShell, &pInfo);
}
else
{
ABR_DisplayMainMenu(pMe);
}
return TRUE;
case IDC_DELETE: // User pressed the 'Delete' soft key on Edit screen
if( pMe->m_eAppState == APP_STATE_EDIT)
{
// 刪除電話本中記錄id為pMe->m_wSelRecId的記錄
nRet = ABR_DeleteContactRec( pMe, pMe->m_ContactCLS, pMe->m_wSelRecId);
if(nRet == AEE_SUCCESS)
{
wTextID = IDS_PROMPT_TEXT_SUC;
}
else
{
wTextID = IDS_PROMPT_TEXT_FAIL;
}
pInfo.pszRes = ADDRBOOKRUIM_RES_FILE;
pInfo.pTitle = NULL;
pInfo.pText = NULL;
pInfo.wTitleID = 0;
pInfo.wTextID = wTextID;
pInfo.wDefBtn = IDC_OK_PROMPT;
pInfo.pBtnIDs = wButtonIDs;
pInfo.dwProps = ST_CENTERTITLE;
pInfo.fntTitle = AEE_FONT_BOLD;
pInfo.fntText = AEE_FONT_NORMAL;
pInfo.dwTimeout = 0;
ISHELL_Prompt(pMe->pIShell, &pInfo);
}
else
{
ABR_DisplayMainMenu(pMe);
}
return TRUE;
case IDC_OK_SK: // User pressed the 'OK' soft key
ABR_DisplayMainMenu( pMe );
return TRUE;
case IDC_OK_PROMPT: // User pressed the 'OK' soft key
if( pMe->m_eAppState != APP_STATE_ADD && pMe->m_eAppState != APP_STATE_EDIT )
{
DBGPRINTF("Wrong condition IDC_OK_SK");
}
ABR_DisplayMainMenu( pMe );
return TRUE;
case IDC_SEL_DEV_HANDSET: // 選擇手機中的電話薄
if( pMe->m_eAppState == APP_STATE_SWITCH_STORE_DEV)
{
pMe->m_ContactCLS = AEECLSID_ADDRBOOK;
}
else
{
DBGPRINTF("Wrong condition IDC_SEL_DEV_HANDSET");
}
ABR_DisplayMainMenu( pMe );
return TRUE;
case IDC_SEL_DEV_RUIM: // 選擇RUIM 中的電話薄
if( pMe->m_eAppState == APP_STATE_SWITCH_STORE_DEV)
{
pMe->m_ContactCLS = AEECLSID_ADDRBOOK_RUIM;
}
else
{
DBGPRINTF("Wrong condition IDC_SEL_DEV_RUIM");
}
ABR_DisplayMainMenu( pMe );
return TRUE;
default:
// If the wParam ID matches the ID of a contact record
// load the record and display it on the screen.
if (wParam >= ABR_REC_LIST_ID)
{
ABR_DisplayEditScreen(pMe, wParam);
return TRUE;
}
break;
}
break;
// 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...
switch(wParam)
{
case AVK_SOFT2:
case AVK_CLR:
// If the clear button is pressed, back up one screen depending on the
// current application state
switch (pMe->m_eAppState)
{
case APP_STATE_ADD:
case APP_STATE_VIEW:
case APP_STATE_TOTAL_REC:
ABR_DisplayMainMenu(pMe);
return TRUE;
case APP_STATE_EDIT:
ABR_DisplayViewMenu(pMe);
return TRUE;
default:
break;
}
case AVK_UP: // Handle 'UP' button presses if the text control has focus.
if(pMe->m_eAppState == APP_STATE_ADD ||pMe->m_eAppState == APP_STATE_EDIT)
{
// the focus switch from soft key to TEXT2
if (IMENUCTL_IsActive(pMe->m_pSK))
{
IMENUCTL_SetActive(pMe->m_pSK, FALSE);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -