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

📄 currencyconvertor.c

📁 mtk工具箱,计算器的详细设计,可以由此入手了解mtk的
💻 C
📖 第 1 页 / 共 3 页
字号:
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S32 precision;
    U8 strTemp[] = { ':', '\0', '1', '\0', '\0', '\0' };
    U8 strTemp2[] = { '1', '\0', ':', '\0', '\0', '\0' };

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    precision = CalcComputePrecision(g_cconv_cntx->Rate, 6);

    gui_float_string(g_cconv_cntx->Rate, precision, g_cconv_cntx->RateString[0]);

    UCS2Strcpy((S8*) g_cconv_cntx->RateString[1], (S8*) strTemp2);      /* 1:R */
    UCS2Strcat((S8*) g_cconv_cntx->RateString[1], (S8*) g_cconv_cntx->RateString[0]);   /* R:1 */
    UCS2Strcat((S8*) g_cconv_cntx->RateString[0], (S8*) strTemp);

    g_cconv_cntx->RateList[0] = g_cconv_cntx->RateString[0];
    g_cconv_cntx->RateList[1] = g_cconv_cntx->RateString[1];

    set_leading_zero(FALSE);
    DisableInlineInputMethodHints();

    SetInlineItemActivation(&wgui_inline_items[CCONV_INLINE_RATE], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
    SetInlineItemSelect(
        &wgui_inline_items[CCONV_INLINE_RATE],
        2,
        (U8 **) g_cconv_cntx->RateList,
        &g_cconv_cntx->CurrSelRate);
    RegisterInlineSelectHighlightHandler(&wgui_inline_items[CCONV_INLINE_RATE], HighlightCconvInlineSelHandler);

    SetInlineItemActivation(&wgui_inline_items[CCONV_INLINE_LOCAL_CAP], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
    SetInlineItemCaption(&wgui_inline_items[CCONV_INLINE_LOCAL_CAP], (U8*) GetString(STR_CURRENCYCONVERTOR_LOCAL));

    SetInlineItemActivation(&wgui_inline_items[CCONV_INLINE_LOCAL], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
    SetInlineItemTextEdit(
        &wgui_inline_items[CCONV_INLINE_LOCAL],
        (U8*) g_cconv_cntx->LocalBuff,
        (CCONV_MAX_INPUT + 1),
        INPUT_TYPE_DECIMAL_NUMERIC);
    SetInlineTextEditCustomFunction(&wgui_inline_items[CCONV_INLINE_LOCAL], CconvCustomInlineFunction);
    EnableInlineItemBoundary(&wgui_inline_items[CCONV_INLINE_LOCAL]);
    RightJustifyInlineItem(&wgui_inline_items[CCONV_INLINE_LOCAL]);

    SetInlineItemActivation(&wgui_inline_items[CCONV_INLINE_FORE_CAP], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
    SetInlineItemCaption(
        &wgui_inline_items[CCONV_INLINE_FORE_CAP],
        (U8*) (U8*) GetString(STR_CURRENCYCONVERTOR_FOREIGN));

    SetInlineItemActivation(&wgui_inline_items[CCONV_INLINE_FORE], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
    SetInlineItemTextEdit(
        &wgui_inline_items[CCONV_INLINE_FORE],
        (U8*) g_cconv_cntx->ForeBuff,
        (CCONV_MAX_INPUT + 1),
        INPUT_TYPE_DECIMAL_NUMERIC);
    EnableInlineItemBoundary(&wgui_inline_items[CCONV_INLINE_FORE]);
    RightJustifyInlineItem(&wgui_inline_items[CCONV_INLINE_FORE]);
    DisableInlineItem(&wgui_inline_items[CCONV_INLINE_FORE], CCONV_INLINE_FORE);
}


/*****************************************************************************
 * FUNCTION
 *  EntryCConvExchange
 * DESCRIPTION
 *  Entry Function of Compute currency exchange
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void EntryCConvExchange(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U8 *guiBuffer;
    U8 *inputBuffer;        /* added for inline edit history */
    U16 inputBufferSize;    /* added for inline edit history */

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    EntryNewScreen(SCR_ID_CCONV_COMPUTE, ExitCConvExchange, NULL, NULL);

    guiBuffer = GetCurrGuiBuffer(SCR_ID_CCONV_COMPUTE);

    InitializeCategory57Screen();

    CConvFillInlineStruct();

    RegisterHighlightHandler(HighlightCconvInlineItemHandler);

    inputBuffer = GetCurrNInputBuffer(SCR_ID_CCONV_COMPUTE, &inputBufferSize);  /* added for inline edit history */

    if (inputBuffer)    /* added for inline edit history */
    {
        SetCategory57Data(wgui_inline_items, CCONV_INLINE_TOTAL, inputBuffer);  /* sets the data */
    }
	DisableCategory57ScreenDone();

    ShowCategory57Screen(
        STR_CURRENCYCONVERTOR_INPUT,
        GetRootTitleIcon(EXTRA_CURRENCYCONVERTOR_MENU),
        STR_GLOBAL_OK,
        IMG_GLOBAL_OK,
        STR_GLOBAL_BACK,
        IMG_GLOBAL_BACK,
        CCONV_INLINE_TOTAL,
        NULL,
        wgui_inline_items,
        g_cconv_cntx->CurrHiliteItem,
        guiBuffer);

    SetLeftSoftkeyFunction(CconvComputeResult, KEY_EVENT_UP);
    SetCategory57RightSoftkeyFunctions(CconvComputeResult, GoBackHistory);
}


/*****************************************************************************
 * FUNCTION
 *  ExitCConvExchange
 * DESCRIPTION
 *  Entry Function of Compute currency exchange
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void ExitCConvExchange(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 inputBufferSize;    /* added for inline edit history */
    history HistoryCCComputeCurrency;
    S16 nHistory = 0;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    set_leading_zero(TRUE);
    if (g_cconv_cntx)
    {
        CloseCategory57Screen();
    }
    HistoryCCComputeCurrency.scrnID = SCR_ID_CCONV_COMPUTE;
    HistoryCCComputeCurrency.entryFuncPtr = EntryCConvExchange;
    GetCategory57History(HistoryCCComputeCurrency.guiBuffer);
    UCS2Strcpy((S8*) HistoryCCComputeCurrency.inputBuffer, (S8*) & nHistory);
    inputBufferSize = (U16) GetCategory57DataSize();        /* added for inline edit history */
    GetCategory57Data((U8*) HistoryCCComputeCurrency.inputBuffer);     /* added for inline edit history */
    AddNHistory(HistoryCCComputeCurrency, inputBufferSize); /* added for inline edit history */
}


/*****************************************************************************
 * FUNCTION
 *  HighlightCconvInlineSelHandler
 * DESCRIPTION
 *  Highlight handler of inline selection.
 * PARAMETERS
 *  index       [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void HighlightCconvInlineSelHandler(S32 index)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    memset(g_cconv_cntx->LocalBuff, 0, ENCODING_LENGTH);
    memset(g_cconv_cntx->ForeBuff, 0, ENCODING_LENGTH);
    RedrawCategoryFunction();
}


/*****************************************************************************
 * FUNCTION
 *  HighlightCconvInlineItemHandler
 * DESCRIPTION
 *  Highlight handler of inline item in exchange screen.
 * PARAMETERS
 *  index       [IN]        Index of item.
 * RETURNS
 *  void
 *****************************************************************************/
void HighlightCconvInlineItemHandler(S32 index)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (index == 0)
    {
        //              if(!g_cconv_cntx->IsComputingResult)
        //              {
        ClearKeyHandler(KEY_LSK, KEY_EVENT_UP);
        ChangeLeftSoftkey(STRING_ID_NULL, IMAGE_ID_NULL);
        ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
        SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
        /* } */
    }
    else    /* 2 */
    {
    #ifdef __MMI_CONVERTER_KEEP_INLINE_FOCUS__
        if (g_cconv_cntx->CurrHiliteItem != index)
        {
            memset(g_cconv_cntx->LocalBuff, 0, 2);
            memset(g_cconv_cntx->ForeBuff, 0, 2);
        }
        else if (!g_cconv_cntx->ClearResultFlag && *(g_cconv_cntx->ForeBuff) != 0)
        {
            g_cconv_cntx->ClearResultFlag = 1;
        }

    #if !defined(__MMI_WITH_C_KEY__)
        SetCategory57ScreenRSKClear();  /* Max: set RSK to "Clear" */
    #endif 

        ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
        SetLeftSoftkeyFunction(CconvComputeResult, KEY_EVENT_UP);
    #else /* __MMI_CONVERTER_KEEP_INLINE_FOCUS__ */ 
        if (g_cconv_cntx->CurrHiliteItem != index)
        {
            memset(g_cconv_cntx->LocalBuff, 0, 2);
            memset(g_cconv_cntx->ForeBuff, 0, 2);
        }
        ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
        SetLeftSoftkeyFunction(CconvComputeResult, KEY_EVENT_UP);
    #endif /* __MMI_CONVERTER_KEEP_INLINE_FOCUS__ */ 

    }
    g_cconv_cntx->CurrHiliteItem = (U8) index;
}


/*****************************************************************************
 * FUNCTION
 *  CconvCustomInlineFunction
 * DESCRIPTION
 *  Set group key handlers of inline editor
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void CconvCustomInlineFunction(void)
{
#ifdef __MMI_CONVERTER_KEEP_INLINE_FOCUS__
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 keyCodes[] = {KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_POUND};
    U8 nKeyCodes = (U8) 11;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (g_cconv_cntx->ClearResultFlag)
    {
        g_cconv_cntx->ClearResultFlag = 0;
        SetGroupKeyHandler(CconvClearResult, keyCodes, nKeyCodes, KEY_EVENT_DOWN);
    #if !defined(__MMI_WITH_C_KEY__)
        SetRightSoftkeyFunction(CconvClearResult, KEY_EVENT_UP);
        SetRightSoftkeyFunction(CconvClearResult, KEY_EVENT_LONG_PRESS);
        SetRightSoftkeyFunction(NULL, KEY_EVENT_DOWN);
    #else /* !defined(__MMI_WITH_C_KEY__) */ 
        SetKeyHandler(CconvClearResult, KEY_CLEAR, KEY_EVENT_UP);
        SetKeyHandler(CconvClearResult, KEY_CLEAR, KEY_EVENT_LONG_PRESS);
        SetKeyHandler(NULL, KEY_CLEAR, KEY_EVENT_DOWN);
    #endif /* !defined(__MMI_WITH_C_KEY__) */ 
    #if defined(__MMI_TOUCH_SCREEN__)
        mmi_pen_editor_disable_input(PEN_EDITOR_DISABLE_HANDWRITNG | PEN_EDITOR_DISABLE_VIRTUAL_KEYBOARD);
//WuTJ, 2007-10-16, 非笔点中右SK未变化(M510,bug31)
    #endif /* defined(__MMI_TOUCH_SCREEN__) */ 
        ChangeRightSoftkey(STR_ID_CURRENCYCONVERTOR_RESET, 0);
//    #endif /* defined(__MMI_TOUCH_SCREEN__) */ 
    }
#endif /* __MMI_CONVERTER_KEEP_INLINE_FOCUS__ */ 
}

#endif /* defined __MMI_CURRENCY_CONVERTER__ */ 


/*****************************************************************************
 * FUNCTION
 *  CconvClearResult
 * DESCRIPTION
 *  Clear buffer and input a character.
 *  This function is used for new digits input after calculation.
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void CconvClearResult(void)
{
#ifdef __MMI_CONVERTER_KEEP_INLINE_FOCUS__
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 keyCode, keyType;
    S32 hItem = GetHighlightedItem();

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    GetkeyInfo((U16*) & keyCode, (U16*) & keyType);
#if(UI_DOUBLE_BUFFER_SUPPORT)
    gui_lock_double_buffer();
#endif 
//WuTJ, 2007-10-16, 非笔点死机(M510,bug31), 加入宏__MMI_HANDWRITING_PAD__
#if defined(__MMI_TOUCH_SCREEN__) || defined(__MMI_HANDWRITING_PAD__)
    complete_inline_item_edit();
#endif 
    gui_fixed_list_menu_goto_item(&MMI_fixed_list_menu, 0);
    gui_fixed_list_menu_goto_item(&MMI_fixed_list_menu, hItem);
    show_fixed_list();
    if (keyType == KEY_EVENT_LONG_PRESS)
    {
        SetRightSoftkeyFunction(mmi_conv_reset_rsk, KEY_EVENT_UP);
    }
    if (keyCode != KEY_CLEAR)
    {
        ExecuteCurrKeyHandler(keyCode, keyType);
    }

#if(UI_DOUBLE_BUFFER_SUPPORT)
    gui_unlock_double_buffer();
    gui_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - 1);
#endif /* (UI_DOUBLE_BUFFER_SUPPORT) */ 
#endif /* __MMI_CONVERTER_KEEP_INLINE_FOCUS__ */ 
}

/*****************************************************************************
 * FUNCTION
 *  mmi_conv_reset_rsk
 * DESCRIPTION
 *  This function is used reset RSK.
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void mmi_conv_reset_rsk(void)
{
    SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
}

#endif /* _MMI_CURRENCYCONVRETOR_C */ // #ifndef _MMI_CURRENCYCONVRETOR_C

⌨️ 快捷键说明

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