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

📄 addrbookruim.c

📁 BREW程序:对SIM/UIM卡的电话地址本进行操作
💻 C
📖 第 1 页 / 共 4 页
字号:
    // Make sure the pointers we'll be using are valid
    if (pMe == NULL || pMe->pIShell == NULL || pMe->pIDisplay==NULL || pMe->m_pSK == NULL || pMe->m_pText1 == NULL || pMe->m_pText2 == NULL)
        return;

    ABR_Reset(pMe);

    // wItemID 是menu的ID,减去ABR_REC_LIST_ID变成其对应的address book record的ID
    // 根据record  ID获得名字和电话号码
    ABR_GetContactFieldByItemID(pMe, pMe->m_ContactCLS, wItemID-ABR_REC_LIST_ID, psNameForItemID,psNumForItemID);

    // display view edit title
    psTextBuf = (AECHAR*) MALLOC( MAX_RES_STRING_BUF_SIZE * sizeof( AECHAR ) );
    if( psTextBuf )
    {
        ISHELL_LoadResString( pMe->pIShell, ADDRBOOKRUIM_RES_FILE, IDS_EDIT_TITLE, psTextBuf, MAX_RES_STRING_BUF_SIZE * sizeof( AECHAR ) );

        // Set the position of the label's daring rectangle
        SETAEERECT( &rRect, 2, nControlYLoc, IDISPLAY_MeasureText( pMe->pIDisplay, AEE_FONT_BOLD, psTextBuf ), pMe->m_nFontHeight );
        IDISPLAY_DrawText( pMe->pIDisplay, AEE_FONT_BOLD, psTextBuf, -1, 0, 0, &rRect, IDF_ALIGN_BOTTOM | IDF_ALIGN_LEFT);
        IDISPLAY_Update( pMe->pIDisplay);
        FREEIF( psTextBuf );
    }

    nControlYLoc += pMe->m_nFontHeight + 3;
    psTextBuf = (AECHAR*) MALLOC( MAX_RES_STRING_BUF_SIZE * sizeof( AECHAR ) );

    // display add name head
    if( psTextBuf )
    {
        ISHELL_LoadResString( pMe->pIShell, ADDRBOOKRUIM_RES_FILE, IDC_ADD_NAME, psTextBuf, MAX_RES_STRING_BUF_SIZE * sizeof( AECHAR ) );

        // Set the position of the label's daring rectangle
        SETAEERECT( &rRect, 2, nControlYLoc, IDISPLAY_MeasureText( pMe->pIDisplay, AEE_FONT_NORMAL, psTextBuf ), pMe->m_nFontHeight );
        IDISPLAY_DrawText( pMe->pIDisplay, AEE_FONT_NORMAL, psTextBuf, -1, rRect.x, rRect.y, &rRect, IDF_ALIGN_BOTTOM | IDF_ALIGN_LEFT );
        IDISPLAY_Update( pMe->pIDisplay);
        FREEIF( psTextBuf );
    }

    // Display add name input text
    ITEXTCTL_Reset( pMe->m_pText1 );
    ITEXTCTL_SetProperties( pMe->m_pText1, TP_FRAME );
    // Set the starting X coordinate position of the control and its width (screen width
    // minus the width of the label string).
    rRect.x = 2 + rRect.dx;
    rRect.dx = pMe->m_rScreenRect.dx - rRect.x -2;
    ITEXTCTL_SetRect(pMe->m_pText1, &rRect );
    ITEXTCTL_SetInputMode( pMe->m_pText1, AEE_TM_LETTERS );
    pMe->m_nInputMode = IMT_LITTLE_CASE_LETTER;
    ITEXTCTL_SetMaxSize( pMe->m_pText1, MAX_CONTACT_NAME_SIZE+1 );
    ITEXTCTL_SetText( pMe->m_pText1, psNameForItemID, MAX_CONTACT_NAME_SIZE );
    ITEXTCTL_SetActive( pMe->m_pText1, TRUE );
    ITEXTCTL_Redraw( pMe->m_pText1);

    nControlYLoc += pMe->m_nFontHeight + 3;


    psTextBuf = (AECHAR*) MALLOC( MAX_RES_STRING_BUF_SIZE * sizeof( AECHAR ) );

    // display add num head
    if( psTextBuf )
    {
        ISHELL_LoadResString( pMe->pIShell, ADDRBOOKRUIM_RES_FILE, IDC_ADD_NUM, psTextBuf, MAX_RES_STRING_BUF_SIZE * sizeof( AECHAR ) );

        // Set the position of the label's daring rectangle
        SETAEERECT( &rRect, 2, nControlYLoc, IDISPLAY_MeasureText( pMe->pIDisplay, AEE_FONT_NORMAL, psTextBuf ), pMe->m_nFontHeight );
        IDISPLAY_DrawText( pMe->pIDisplay, AEE_FONT_NORMAL, psTextBuf, -1, rRect.x, rRect.y, &rRect, IDF_ALIGN_BOTTOM | IDF_ALIGN_LEFT );
        IDISPLAY_Update( pMe->pIDisplay);
        FREEIF( psTextBuf );
    }
   
    // Display add num input text
    ITEXTCTL_Reset( pMe->m_pText2 );
    ITEXTCTL_SetProperties( pMe->m_pText2, TP_FRAME );
    // Set the starting X coordinate position of the control and its width (screen width
    // minus the width of the label string).
    rRect.x = 2 + rRect.dx;
    rRect.dx = pMe->m_rScreenRect.dx - rRect.x -2;
    ITEXTCTL_SetRect(pMe->m_pText2, &rRect );
    ITEXTCTL_SetInputMode( pMe->m_pText2, AEE_TM_NUMBERS);
    pMe->m_nInputMode = IMT_NUMBER;
    ITEXTCTL_SetMaxSize( pMe->m_pText2, MAX_CONTACT_NUM_SIZE );
    ITEXTCTL_SetText( pMe->m_pText2,psNumForItemID, MAX_CONTACT_NUM_SIZE );
    ITEXTCTL_SetActive( pMe->m_pText2, FALSE );
    ITEXTCTL_Redraw( pMe->m_pText2);

    // soft key
    IMENUCTL_AddItem( pMe->m_pSK, ADDRBOOKRUIM_RES_FILE, IDC_UPDATE, IDC_UPDATE, NULL, 0 );
    IMENUCTL_AddItem( pMe->m_pSK, ADDRBOOKRUIM_RES_FILE, IDC_DELETE, IDC_DELETE, NULL, 0 );
    IMENUCTL_Redraw( pMe->m_pSK);

    pMe->m_eAppState = APP_STATE_EDIT;
}



/*===========================================================================

FUNCTION: ABR_DisplayViewMenu

DESCRIPTION:
  This function displays the application View Menu.

PARAMETERS:
  pMe [in] - Pointer to the CAddrBookRuim structure. This structure contains 
    information specific to this applet. 

DEPENDENCIES:
   None

RETURN VALUE:
   None

SIDE EFFECTS:
  Causes the phone display to be updated.
  Set application state to APP_STATE_MAIN.
===========================================================================*/

static void ABR_DisplayViewMenu( CAddrBookRuim* pMe )
{
    uint32 nTotal = 0; // record count of address book
    AEERect rRect;

    // Make sure the pointers we'll be using are valid
    if (pMe == NULL || pMe->pIShell == NULL || pMe->m_pMenu==NULL )
        return;

    ABR_Reset(pMe);

    SETAEERECT( &rRect, 0, 0, pMe->m_rScreenRect.dx, pMe->m_rScreenRect.dy);
    IMENUCTL_SetRect( pMe->m_pMenu, &rRect );

    // Get contact record and show it in menu item
    ABR_GetContactRec( pMe, pMe->m_ContactCLS, pMe->m_pMenu, &nTotal);

    if(nTotal)
    {
        IMENUCTL_SetTitle(pMe->m_pMenu, ADDRBOOKRUIM_RES_FILE, IDS_VIEW_MENU, NULL);
    }
    else
    {
        IMENUCTL_SetTitle(pMe->m_pMenu, ADDRBOOKRUIM_RES_FILE, IDS_VIEW_NO_REC, NULL);
    }

    // Active Menu
    IMENUCTL_SetActive( pMe->m_pMenu, TRUE);
    pMe->m_wSelRecId = IMENUCTL_GetSel(pMe->m_pMenu) - ABR_REC_LIST_ID;
   
    pMe->m_eAppState = APP_STATE_VIEW;
}

/*===========================================================================

FUNCTION: ABR_DisplayTotalRec

DESCRIPTION:
  This function displays the total record count of address book

PARAMETERS:
  pMe [in] - Pointer to the CAddrBookRuim structure. This structure contains 
    information specific to this applet. 

DEPENDENCIES:
   None

RETURN VALUE:
   None

SIDE EFFECTS:
   None
===========================================================================*/
static void ABR_DisplayTotalRec( CAddrBookRuim* pMe )
{
    uint16 nControlYLoc = 2;
    AECHAR* psTextBuf=NULL;
    AEERect rRect;
    char* psTextBufAscii=NULL;
    AECHAR* pwsBuf=NULL;

    // Make sure the pointers we'll be using are valid
    if (pMe == NULL || pMe->pIShell == NULL || pMe->pIDisplay==NULL || pMe->m_pSK==NULL)
        return;

    ABR_Reset(pMe);

    psTextBuf = (AECHAR*) MALLOC( MAX_RES_STRING_BUF_SIZE * sizeof( AECHAR ) );

    // display total record title
    if( psTextBuf )
    {
        ISHELL_LoadResString( pMe->pIShell, ADDRBOOKRUIM_RES_FILE, IDS_TOTAL_SCREEN_TITLE, psTextBuf, MAX_RES_STRING_BUF_SIZE * sizeof( AECHAR ) );

        // Set the position of the label's daring rectangle
        SETAEERECT( &rRect, 2, nControlYLoc, IDISPLAY_MeasureText( pMe->pIDisplay, AEE_FONT_BOLD, psTextBuf ), pMe->m_nFontHeight );
        IDISPLAY_DrawText( pMe->pIDisplay, AEE_FONT_BOLD, psTextBuf, -1, 0, 0, &rRect, IDF_ALIGN_BOTTOM | IDF_ALIGN_LEFT);
        IDISPLAY_Update( pMe->pIDisplay);
        FREEIF( psTextBuf );
    }


    nControlYLoc += pMe->m_nFontHeight + 3;
    // display add name head
    psTextBuf = (AECHAR*) MALLOC( MAX_RES_STRING_BUF_SIZE * sizeof( AECHAR ) );
    if( psTextBuf )
    {
        ISHELL_LoadResString( pMe->pIShell, ADDRBOOKRUIM_RES_FILE, IDS_TOTAL_REC_STR, psTextBuf, MAX_RES_STRING_BUF_SIZE * sizeof( AECHAR ) );

        psTextBufAscii = (char*) MALLOC( MAX_RES_STRING_BUF_SIZE * sizeof( char ) );
        pwsBuf      = (AECHAR*) MALLOC( MAX_RES_STRING_BUF_SIZE * sizeof( AECHAR ) );

        if(psTextBufAscii && pwsBuf)
        {
            // get string of record count
            SPRINTF(psTextBufAscii, "%d", ARB_GetTotalRecNum(pMe, pMe->m_ContactCLS));
            STRTOWSTR(psTextBufAscii, pwsBuf, MAX_RES_STRING_BUF_SIZE * sizeof( AECHAR ));
            WSTRCAT(psTextBuf, pwsBuf);
            // Set the position of the label's daring rectangle
            SETAEERECT( &rRect, 2, nControlYLoc, IDISPLAY_MeasureText( pMe->pIDisplay, AEE_FONT_NORMAL, psTextBuf ), pMe->m_nFontHeight );
            IDISPLAY_DrawText( pMe->pIDisplay, AEE_FONT_NORMAL, psTextBuf, -1, 0, nControlYLoc-2, &rRect, IDF_ALIGN_BOTTOM | IDF_ALIGN_LEFT );
            IDISPLAY_Update( pMe->pIDisplay);
        }
        FREEIF( pwsBuf );
        FREEIF( psTextBufAscii );
        FREEIF( psTextBuf );
    }

    // soft key
    IMENUCTL_AddItem( pMe->m_pSK, ADDRBOOKRUIM_RES_FILE, IDC_OK_SK, IDC_OK_SK, NULL, 0 );
    IMENUCTL_SetActive( pMe->m_pSK, TRUE);
    IMENUCTL_Redraw( pMe->m_pSK);

    pMe->m_eAppState = APP_STATE_TOTAL_REC;
}

/*===========================================================================

FUNCTION: ABR_DisplayStoreDevice

DESCRIPTION:
  This function displays screen of store device switch

PARAMETERS:
  pMe [in] - Pointer to the CAddrBookRuim structure. This structure contains 
    information specific to this applet. 

DEPENDENCIES:
   None

RETURN VALUE:
   None

SIDE EFFECTS:
   None
===========================================================================*/
static void ABR_DisplayStoreDevice( CAddrBookRuim* pMe )
{
    AEEPromptInfo pInfo;
    const uint16 wButtonIDs[] = {IDC_SEL_DEV_HANDSET, IDC_SEL_DEV_RUIM, 0};

    // Make sure the pointers we'll be using are valid
    if (pMe == NULL || pMe->pIShell == NULL || pMe->pIDisplay==NULL )
        return;

    ABR_Reset(pMe);

    pInfo.pszRes = ADDRBOOKRUIM_RES_FILE;
    pInfo.pTitle = NULL;
    pInfo.pText = NULL;
    pInfo.wTitleID = 0;
    pInfo.wTextID = IDS_SEL_DEV_TITLE;
    pInfo.wDefBtn = IDC_SEL_DEV_HANDSET;
    pInfo.pBtnIDs = wButtonIDs;
    pInfo.dwProps = ST_CENTERTITLE;
    pInfo.fntTitle = AEE_FONT_BOLD;
    pInfo.fntText = AEE_FONT_NORMAL;
    pInfo.dwTimeout = 0;
    // 选择"手机" 还是"RUIM"存储电话薄, 
    // 用户确认后产生IDC_SEL_DEV_HANDSET or IDC_SEL_DEV_RUIM
    ISHELL_Prompt(pMe->pIShell, &pInfo);

    pMe->m_eAppState = APP_STATE_SWITCH_STORE_DEV;
}

/*===========================================================================

FUNCTION: ABR_Reset

DESCRIPTION:
  Reset controls
  
PARAMETERS:
  pMe [in] - Pointer to the CAddrBookRuim structure. This structure contains 
    information specific to this applet. 

DEPENDENCIES:
   None

RETURN VALUE:
   None

SIDE EFFECTS:
   None
===========================================================================*/
static void ABR_Reset(CAddrBookRuim * pMe )
{
    // Reset Menu Controls
    IMENUCTL_Reset(pMe->m_pMenu);
    IMENUCTL_Reset( pMe->m_pSK);
   
    ITEXTCTL_SetActive( pMe->m_pText1, FALSE );
    ITEXTCTL_SetActive( pMe->m_pText2, FALSE );

    // Clear Screen
    IDISPLAY_ClearScreen(pMe->pIDisplay);
}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -