📄 bmi.c
字号:
/*****************************************************************************
* 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) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* Bmi.c
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
* This file implements BMI application
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
/*****************************************************************************
* 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) 2003
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* Bmi.c
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
* This file implements BMI application.
*
* Author:
* -------
* -------
*
*****************************************************************************/
/* Include: MMI header file */
#ifndef _MMI_BMI_C
#define _MMI_BMI_C
#include "MMI_features.h"
#ifdef __MMI_BMI__
#include "HistoryGprot.h"
#include "GlobalDefs.h"
#include "wgui_categories.h"
#include "wgui_categories_inputs.h"
#include "Unicodexdcl.h"
#include "BMI.h"
#include "settingprofile.h"
#include "Organizerdef.h"
#include "CommonScreens.h"
#include "Calculator.h"
/* Include: PS header file */
/*
* Define
*/
#define BMI_MALE_LB 20 /* Lower bound of standard BMI index of a man */
#define BMI_MALE_UB 25 /* Upper bound of standard BMI index of a man */
#define BMI_FEMALE_LB 18 /* Lower bound of standard BMI index of a woman */
#define BMI_FEMALE_UB 23 /* Upper bound of standard BMI index of a woman */
#define BMI_MAX_INPUT 8
#define BMI_DIGIT_LEN 9*ENCODING_LENGTH
#define BMI_LB_UB_LEN 4*ENCODING_LENGTH /* buffer length to store lower and upper bound */
#define BMI_RESULT_LEN 7*ENCODING_LENGTH /* buffer length to store resut xxx.xx */
#define BMI_MAX_HEIGHT 300
#define BMI_MIN_HEIGHT 55
#define BMI_MAX_WEIGHT 300
#define BMI_MIN_WEIGHT 1
/*
* Typedef
*/
typedef struct
{
DOUBLE Height;
DOUBLE Weight;
S32 Gender;
U8 *GenderList[2];
S8 UBBuf[BMI_LB_UB_LEN];
S8 LBBuf[BMI_LB_UB_LEN];
S8 ResultBuf[BMI_RESULT_LEN];
S8 HeightBuf[BMI_DIGIT_LEN];
S8 WeightBuf[BMI_DIGIT_LEN];
U8 CurrHilite;
} bmi_context_struct;
/*
* Local Variable
*/
/*
* Local Function
*/
U8 BMIDelScrCB(void *p);
/*
* Global Variable
*/
bmi_context_struct *g_bmi_cntx = NULL;
extern wgui_inline_item wgui_inline_items[];
/*
* Global Function
*/
extern void gui_float_string(DOUBLE dob_val, S32 prec_val, S8 *out_buffer);
extern void set_leading_zero(U8 u8type);
/*****************************************************************************
* FUNCTION
* HighlightBMIMenu
* DESCRIPTION
* Highlight handler of BMI menu item.
* Register key handlers.
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void HighlightBMIMenu(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
SetLeftSoftkeyFunction(EntryBMIWelcomeScreen, KEY_EVENT_UP);
SetKeyHandler(EntryBMIWelcomeScreen, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
}
/*****************************************************************************
* FUNCTION
* BmiDeInit
* DESCRIPTION
* Free allocated memory.
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void BmiDeInit(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (g_bmi_cntx)
{
OslMfree(g_bmi_cntx);
g_bmi_cntx = NULL;
}
}
/*****************************************************************************
* FUNCTION
* BMIDelScrCB
* DESCRIPTION
* Callback function of delete bmi screen
* PARAMETERS
* p [?]
* RETURNS
* void
*****************************************************************************/
U8 BMIDelScrCB(void *p)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (GetActiveScreenId() == SCR_BMI_INPUT)
{
CloseCategory57Screen();
}
BmiDeInit();
return MMI_FALSE;
}
/*****************************************************************************
* FUNCTION
* EntryBMIWelcomeScreen
* DESCRIPTION
* Display welcome screen of BMI application
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void EntryBMIWelcomeScreen(void)
{
#ifndef __MMI_MAINLCD_240X320__
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 *guiBuffer;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
guiBuffer = GetCurrGuiBuffer(SCR_BMI_WELCOME);
EntryNewScreen(SCR_BMI_WELCOME, NULL, EntryBMIWelcomeScreen, NULL);
ShowCategory129Screen(
(U8*) get_string(STR_BMI_WELCOME_CAPTION),
GetRootTitleIcon(EXTRA_HEALTH_MENU),
STR_GLOBAL_OK,
IMG_GLOBAL_OK,
STR_GLOBAL_BACK,
IMG_GLOBAL_BACK,
IMG_BMI_WELCOME_SCREEN,
guiBuffer);
SetLeftSoftkeyFunction(EntryBMIInputScreen, KEY_EVENT_UP);
SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
#else /* __MMI_MAINLCD_240X320__ */
EntryBMIInputScreen();
#endif /* __MMI_MAINLCD_240X320__ */
}
/*****************************************************************************
* FUNCTION
* EntryBMIInputScreen
* DESCRIPTION
* Display inline editor screen for entering gender, height, and weight
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void EntryBMIInputScreen(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 *guiBuffer;
U8 *inputBuffer; /* added for inline edit history */
U16 inputBufferSize; /* added for inline edit history */
U16 BMIImageList[6] = {0, 0, 0, 0, 0, 0};
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (g_bmi_cntx == NULL)
{
g_bmi_cntx = OslMalloc(sizeof(bmi_context_struct));
memset(g_bmi_cntx, 0, sizeof(bmi_context_struct));
}
EntryNewScreen(SCR_BMI_INPUT, ExitBMIInputScreen, NULL, NULL);
SetDelScrnIDCallbackHandler(SCR_BMI_INPUT, (HistoryDelCBPtr) BMIDelScrCB);
InitializeCategory57Screen();
guiBuffer = GetCurrGuiBuffer(SCR_BMI_INPUT);
BMIFillInlineStruct();
RegisterHighlightHandler(HighlightBMIInlineEditor);
if (g_bmi_cntx->Gender == 0)
{
BMIImageList[ENUM_GENDER] = IMG_BMI_BLUE_FLOWER;
}
else
{
BMIImageList[ENUM_GENDER] = IMG_BMI_RED_FLOWER;
}
inputBuffer = GetCurrNInputBuffer(SCR_BMI_INPUT, &inputBufferSize); /* added for inline edit history */
if (inputBuffer != NULL) /* added for inline edit history */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -