⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addrbookruim.c

📁 BREW程序:对SIM/UIM卡的电话地址本进行操作
💻 C
📖 第 1 页 / 共 4 页
字号:
    // 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 + -