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

📄 currencyconvertore.c

📁 mtk工具箱,计算器的详细设计,可以由此入手了解mtk的
💻 C
📖 第 1 页 / 共 5 页
字号:
/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2004
*
*****************************************************************************/

/*****************************************************************************
*
* Filename:
* ---------
*  CurrencyConvertorE.c
*
* Project:
* --------
*  MAUI
*
* Description:
* ------------
*  This file implements Cur Convertor application.
*
* Author:
* -------
*  Cecil Wei
*
*============================================================================
*             HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* $Log$
 *
 * removed!
 * removed!
 * created by clearfsimport
 *
 * removed!
 * removed!
 * 
 *
 * removed!
 * removed!
 * Update foreign rate immediately when local rate has been changed.
 *
 * removed!
 * removed!
 * Redraw the single text line after updating its position.
 *
 * removed!
 * removed!
 * 
 *
 * removed!
 * removed!
 * Add screen check when executing closecategory57.
 *
 * removed!
 * removed!
 * Execute closeCategory57 in delete callback function.
 *
 * removed!
 * removed!
 * Move CconvClearResult out of __MMI_CURRENCY_CONVERTER__ and __MMI_EXTENDED_CURRENCY_CONVERTER__
 * 
 *
 * removed!
 * removed!
 * Skip CloseCategory57Screen() if global context has already been freed by delete callback function.
 *
 * removed!
 * removed!
 * Save the gui buffer to history when exiting screen.
 *
 * removed!
 * removed!
 * 
 *
 * removed!
 * removed!
 * 
 *
 * removed!
 * removed!
 * Remove CconvClearResult function
 *
 * removed!
 * removed!
 * 
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================*/

#ifndef _MMI_CURRENCYCONVERTORE_C
#define _MMI_CURRENCYCONVERTORE_C
/*  Include: MMI header file */
#include "MMI_features.h"
#ifdef __MMI_EXTENDED_CURRENCY_CONVERTER__
#include "PixtelDataTypes.h"
#include "WrapperGprot.h"
#include "currencyconvertorE.h"
#include "CurrencyConvertor.h"
#include "Unicodexdcl.h"
#include "HistoryGprot.h"
#include "GlobalDefs.h"
#include "TimerEvents.h"
#include "DebugInitDef.h"
#include "EventsGprot.h"
#include "SettingProfile.h"
#include "wgui_inputs.h"
#include "wgui_categories.h"
#include "wgui_categories_inputs.h"
#include "string.h"
#include "NVRAMType.h"
#include "NVRAMProt.h"
#include "NVRAMEnum.h"
#include "ExtraDef.h"
#include "CustDataProts.h"
#include "CommonScreens.h"
/*  Include: PS header file */
/* ... Add More PS header */

/* 
 * Define
 */
#define  CCONV_MAX_CURRENCY      9      /* total number of currencies */
#define  CCONV_NAMED_CURRENCY    6      /* number of named currencies */
#define  CCONV_MAX_RATE          10
#define  CCONV_MAX_INPUT         8
#define  CCONV_MAX_RESULT        12
#define  CCONV_SEL_BUF_LEN       12*ENCODING_LENGTH     /* length of inline selection string */
#define  CCONV_RESULT_BUF_LEN    (12+1)*ENCODING_LENGTH
#define  CCONV_MAX_RATEENTRIES   5      /* number of exchange rate entries */
#define  ITEM_BASE               CCONV_RATE_INLINE_FORE_SELECT1
/* 
 * Typedef 
 */
typedef struct
{
    DOUBLE selectedRate;    /* active exchange rate */
    DOUBLE rate[CCONV_MAX_RATEENTRIES];

    S32 localCurID;     /* selected local cur */
    S32 foreignCurID;   /* selected foreign cur */

    S32 localCurIndex;      /* selected local cur */
    S32 foreignCurIndex;    /* selected foreign cur */

    S32 curID[CCONV_MAX_RATEENTRIES];       /* Setting selected foreign cur */
    S32 curIndex[CCONV_MAX_RATEENTRIES];    /* Setting selected foreign cur */
    S32 selectedLocalCurID;                 /* selected local cur */
    S32 prevSelectedLocalCurID;             /* previous selected local cur */

    S8 LocalBuff[CCONV_RESULT_BUF_LEN];
    S8 ForeBuff[CCONV_RESULT_BUF_LEN];
    S8 strRate[CCONV_MAX_RATEENTRIES][CCONV_SEL_BUF_LEN];
    S32 hiliteItemIndex;
    /* U8   IsComputingResult; */
    S8 *curList1[CCONV_MAX_CURRENCY];
    S8 *curList2[CCONV_MAX_CURRENCY];
    S8 *curList[CCONV_MAX_RATEENTRIES][CCONV_MAX_CURRENCY];

    U8 reloadFromNVRAM;
    U8 isRedrawScreen;
    S8 bRateDefined;

} cconv_context_struct;

/* 
 * Local Variable
 */

/* 
 * Local Function
 */
/* Utility functions */
S32 mmi_cconv_get_cur_id(S32 index, S8 **list);
S32 mmi_cconv_get_cur_index(S32 id, S8 **list, S8 nItems);
DOUBLE mmi_cconv_get_exchange_rate(S32 cur1Idx, S32 cur2Idx);
void mmi_cconv_compute_result(U8 *buffer);
void mmi_cconv_return_to_menu(void);
void mmi_cconv_fill_inline(void);
U8 mmi_cconv_del_scr_callback(void *p);
S8 mmi_cconv_local_select_list();
S8 mmi_cconv_fore_select_list();

/* Highlight handlers */
void mmi_cconv_compute_item_highlight_hdlr(S32 index);
void mmi_cconv_compute_local_select_highlight_hdlr(S32 index);
void mmi_cconv_compute_fore_select_highlight_hdlr(S32 index);
void mmi_cconv_compute_inline_edit_highlight_hdlr(void);
void mmi_cconv_rate_item_highlight_hdlr(S32 index);
void mmi_cconv_rate_local_select_hdlr(S32 index);
void mmi_cconv_rate_inline_select_highlight_hdlr(S32 index);
void mmi_cconv_rate_inline_edit_highlight_hdlr(void);
void mmi_cconv_rate_inline_edit_key_hdlr(void);

/* Validation handler */
void mmi_cconv_compute_inline_edit_validation_hdlr(U8 *buffer, U8 *cursor, S32 text_length);
void mmi_cconv_rate_inline_edit_validation_hdlr(U8 *buffer, U8 *cursor, S32 text_length);

/* Key Handlers */
void mmi_cconv_rate_save_change(void);

/* 
 * Global Variable
 */
cconv_context_struct *g_cconv_ctx = NULL;
extern wgui_inline_item wgui_inline_items[];
extern single_line_input_box MMI_inline_singleline_inputbox;
S8 *curShortName[CCONV_MAX_CURRENCY];
S8 *curName[CCONV_MAX_CURRENCY];
S8 *strEmpty = "\0\0";

/* 
 * Global Function
 */
extern void set_leading_zero(U8 u8type);
extern DOUBLE gui_atof(UI_string_type s);
extern void gui_float_string(DOUBLE dob_val, S32 prec_val, S8 *out_buffer);
extern S32 CalcComputePrecision(DOUBLE result, S16 max_digits);
extern void inline_edit_singleline_inputbox_next_character(void);


/*****************************************************************************
 * FUNCTION
 *  mmi_cconv_init
 * DESCRIPTION
 *  Initialize cur converter application.
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void mmi_cconv_init(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    SetHiliteHandler(EXTRA_CURRENCYCONVERTOR_MENU, mmi_cconv_menu_highlight_hdlr);
}


/*****************************************************************************
 * FUNCTION
 *  mmi_cconv_deinit
 * DESCRIPTION
 *  Free allocated memory.
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void mmi_cconv_deinit(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (g_cconv_ctx)
    {
        OslMfree(g_cconv_ctx);
        g_cconv_ctx = NULL;
    }
}


/*****************************************************************************
 * FUNCTION
 *  mmi_cconv_del_scr_callback
 * DESCRIPTION
 *  Callback function of delete currencty converter screen
 * PARAMETERS
 *  p       [?]     
 * RETURNS
 *  void
 *****************************************************************************/
U8 mmi_cconv_del_scr_callback(void *p)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (GetActiveScreenId() == SCR_ID_CCONV_RATE_INPUT || GetActiveScreenId() == SCR_ID_CCONV_COMPUTE)
    {
        CloseCategory57Screen();
    }
    mmi_cconv_deinit();
    return MMI_FALSE;
}


/*****************************************************************************
 * FUNCTION
 *  mmi_cconv_pre_entry_app
 * DESCRIPTION
 *  Init the Application memory and entry application.
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void mmi_cconv_pre_entry_app(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U8 i;
    S16 error;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (g_cconv_ctx)
    {
        OslMfree(g_cconv_ctx);
    }

    g_cconv_ctx = OslMalloc(sizeof(cconv_context_struct));
    memset(g_cconv_ctx, 0, sizeof(cconv_context_struct));

    /* Preload currency name */
    for (i = 0; i < CCONV_MAX_CURRENCY; i++)
    {
        curName[i] = GetString((U16) (STR_CURRENCYCONV_USD + i));
        if (i < CCONV_NAMED_CURRENCY)

⌨️ 快捷键说明

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