📄 currencyconvertore.c
字号:
{
g_cconv_ctx->bRateDefined = TRUE;
}
WriteValue((U8) (NVRAM_CCONV_EXCHANGE_RATE1 + i), &g_cconv_ctx->rate[i], DS_DOUBLE, &error);
/* Remap currency selections into IDs. */
g_cconv_ctx->curID[i] = mmi_cconv_get_cur_id(g_cconv_ctx->curIndex[i], g_cconv_ctx->curList[i]);
WriteValue((U8) (NVRAM_CCONV_SETTING_CURRENCY1 + i), &g_cconv_ctx->curID[i], DS_BYTE, &error);
}
if (rateflag == 0)
{
g_cconv_ctx->bRateDefined = FALSE;
}
g_cconv_ctx->prevSelectedLocalCurID = g_cconv_ctx->selectedLocalCurID;
WriteValue(NVRAM_CCONV_SETTING_LOCALCURRENCY, &g_cconv_ctx->selectedLocalCurID, DS_BYTE, &error);
if (IsScreenPresent(SCR_ID_CCONV_COMPUTE))
{
GoBackHistory();
}
else
{
mmi_cconv_entry_app();
}
}
/*****************************************************************************
* FUNCTION
* mmi_cconv_compute_item_highlight_hdlr
* DESCRIPTION
* Highlight handler of inline items in compute screen.
* PARAMETERS
* index [IN] Index of highlight item.
* RETURNS
* void
*****************************************************************************/
void mmi_cconv_compute_item_highlight_hdlr(S32 index)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
g_cconv_ctx->hiliteItemIndex = index;
ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
SetRightSoftkeyFunction(mmi_cconv_return_to_menu, KEY_EVENT_UP);
ChangeLeftSoftkey(STR_CURRENCYCONV_RATE, IMG_GLOBAL_OK);
SetLeftSoftkeyFunction(mmi_cconv_pre_entry_rate, KEY_EVENT_UP);
}
/*****************************************************************************
* FUNCTION
* mmi_cconv_fore_select_list
* DESCRIPTION
* create selection list for foreign currency.
* PARAMETERS
* void
* index index of selected item.(?)
* RETURNS
* void
*****************************************************************************/
S8 mmi_cconv_fore_select_list()
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S8 i, nItems2;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
for (i = 0, nItems2 = 0; i < CCONV_MAX_RATEENTRIES; i++)
{
if (g_cconv_ctx->rate[i] > 0)
{ /* if the rate is defined, add the correspoding cur into curList */
if (g_cconv_ctx->curID[i] == g_cconv_ctx->localCurID)
{
continue; /* skip the one selected in list 1 */
}
g_cconv_ctx->curList2[nItems2++] = curName[g_cconv_ctx->curID[i]];
}
}
if (g_cconv_ctx->bRateDefined && g_cconv_ctx->selectedLocalCurID != g_cconv_ctx->localCurID)
{
g_cconv_ctx->curList2[nItems2++] = curName[g_cconv_ctx->selectedLocalCurID];
}
g_cconv_ctx->foreignCurIndex = mmi_cconv_get_cur_index(g_cconv_ctx->foreignCurID, g_cconv_ctx->curList2, nItems2);
g_cconv_ctx->foreignCurID = mmi_cconv_get_cur_id(g_cconv_ctx->foreignCurIndex, g_cconv_ctx->curList2);
return nItems2;
}
/*****************************************************************************
* FUNCTION
* mmi_cconv_local_select_list
* DESCRIPTION
* create selection list for local currency.
* PARAMETERS
* void
* index index of selected item.(?)
* RETURNS
* void
*****************************************************************************/
S8 mmi_cconv_local_select_list()
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S8 i, nItems1;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
for (i = 0, nItems1 = 0; i < CCONV_MAX_RATEENTRIES; i++)
{
if (g_cconv_ctx->rate[i] > 0)
{ /* if the rate is defined, add the correspoding cur into curList */
g_cconv_ctx->curList1[nItems1++] = curName[g_cconv_ctx->curID[i]];
g_cconv_ctx->bRateDefined = TRUE; /* at least one exchange rate is defined for conversion. */
}
}
/* add the local cur into list as well */
if (g_cconv_ctx->bRateDefined)
{
g_cconv_ctx->curList1[nItems1++] = curName[g_cconv_ctx->selectedLocalCurID];
}
g_cconv_ctx->localCurIndex = mmi_cconv_get_cur_index(g_cconv_ctx->localCurID, g_cconv_ctx->curList1, nItems1);
g_cconv_ctx->localCurID = mmi_cconv_get_cur_id(g_cconv_ctx->localCurIndex, g_cconv_ctx->curList1);
return nItems1;
}
/*****************************************************************************
* FUNCTION
* mmi_cconv_compute_local_select_highlight_hdlr
* DESCRIPTION
* Highlight handler of local currency inline selection in compute screen.
* PARAMETERS
* index [IN] Index of selected item.
* RETURNS
* void
*****************************************************************************/
void mmi_cconv_compute_local_select_highlight_hdlr(S32 index)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S8 nItems2;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (g_cconv_ctx->localCurID != mmi_cconv_get_cur_id(index, g_cconv_ctx->curList1))
{
g_cconv_ctx->localCurID = mmi_cconv_get_cur_id(index, g_cconv_ctx->curList1);
memset(g_cconv_ctx->LocalBuff, 0, ENCODING_LENGTH);
memset(g_cconv_ctx->ForeBuff, 0, ENCODING_LENGTH);
nItems2 = mmi_cconv_fore_select_list();
change_fixed_icontext_item(
CCONV_CURRENCY_INLINE_FORE_SELECT,
(UI_string_type) g_cconv_ctx->curList2[g_cconv_ctx->foreignCurIndex],
0);
redraw_fixed_list();
}
g_cconv_ctx->selectedRate = mmi_cconv_get_exchange_rate(g_cconv_ctx->localCurID, g_cconv_ctx->foreignCurID);
return;
}
/*****************************************************************************
* FUNCTION
* mmi_cconv_compute_fore_select_highlight_hdlr
* DESCRIPTION
* Highlight handler of foreign currency inline selection in compute screen.
* PARAMETERS
* index [IN] Index of selected item.
* RETURNS
* void
*****************************************************************************/
void mmi_cconv_compute_fore_select_highlight_hdlr(S32 index)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
g_cconv_ctx->foreignCurID = mmi_cconv_get_cur_id(index, g_cconv_ctx->curList2);
g_cconv_ctx->selectedRate = mmi_cconv_get_exchange_rate(g_cconv_ctx->localCurID, g_cconv_ctx->foreignCurID);
mmi_cconv_compute_result((U8*) g_cconv_ctx->LocalBuff);
return;
}
/*****************************************************************************
* FUNCTION
* mmi_cconv_compute_inline_edit_highlight_hdlr
* DESCRIPTION
* Highlight handler of inline edit in compute screen. (To correct LSK function)
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void mmi_cconv_compute_inline_edit_highlight_hdlr(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
DisableCategory57ScreenDone();
SetCategory57RightSoftkeyFunctions(mmi_cconv_pre_entry_rate, mmi_cconv_return_to_menu);
ChangeLeftSoftkey(STR_CURRENCYCONV_RATE, IMG_GLOBAL_OK);
SetLeftSoftkeyFunction(mmi_cconv_pre_entry_rate, KEY_EVENT_UP);
}
/*****************************************************************************
* FUNCTION
* mmi_cconv_compute_inline_edit_validation_hdlr
* DESCRIPTION
* Perform currency conversion while user is typing.
* PARAMETERS
* buffer [?] Content of inline edit.
* cursor [?] Content after the cursor position
* text_length [IN] Content length
* RETURNS
* void
*****************************************************************************/
void mmi_cconv_compute_inline_edit_validation_hdlr(U8 *buffer, U8 *cursor, S32 text_length)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (UCS2Strcmp((S8*) buffer, g_cconv_ctx->LocalBuff) == 0)
{
if (text_length == 0 && (gui_strlen((UI_string_type) g_cconv_ctx->ForeBuff) > 0))
{
memset(g_cconv_ctx->ForeBuff, 0, 15);
RedrawCategoryFunction();
}
return;
}
mmi_cconv_compute_result(buffer);
}
/*****************************************************************************
* FUNCTION
* mmi_cconv_rate_item_highlight_hdlr
* DESCRIPTION
* Highlight handler of inline item in exchange screen.
* PARAMETERS
* index [IN] Index of item.
* RETURNS
* void
*****************************************************************************/
void mmi_cconv_rate_item_highlight_hdlr(S32 index)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
g_cconv_ctx->hiliteItemIndex = index;
ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
SetLeftSoftkeyFunction(mmi_cconv_rate_save_change, KEY_EVENT_UP);
}
/*****************************************************************************
* FUNCTION
* mmi_cconv_rate_local_select_hdlr
* DESCRIPTION
* Highlight handler of local currency inline selection in rate screen.
* reset all rates and redraw the screen
* PARAMETERS
* index [IN] Index of selected item.
* RETURNS
* void
*****************************************************************************/
void mmi_cconv_rate_local_select_hdlr(S32 index)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S8 i;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (g_cconv_ctx->prevSelectedLocalCurID != index)
{
for (i = 0; i < CCONV_MAX_CURRENCY; i++)
{
g_cconv_ctx->rate[i] = -1;
}
RedrawCategoryFunction();
}
}
/*****************************************************************************
* FUNCTION
* mmi_cconv_rate_inline_select_highlight_hdlr
* DESCRIPTION
* Highlight handler of foreign currency inline selection in rate screen.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -