bmi.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:24k
源码类别:

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  * Bmi.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   This file implements BMI application
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * removed!
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * removed!
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * removed!
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * removed!
  86.  *
  87.  *------------------------------------------------------------------------------
  88.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  89.  *============================================================================
  90.  ****************************************************************************/
  91.  /*****************************************************************************
  92. *  Copyright Statement:
  93. *  --------------------
  94. *  This software is protected by Copyright and the information contained
  95. *  herein is confidential. The software may not be copied and the information
  96. *  contained herein may not be used or disclosed except with the written
  97. *  permission of MediaTek Inc. (C) 2003
  98. *
  99. *****************************************************************************/
  100. /*****************************************************************************
  101.  *
  102.  * Filename:
  103.  * ---------
  104.  * Bmi.c
  105.  *
  106.  * Project:
  107.  * --------
  108.  * MAUI
  109.  *
  110.  * Description:
  111.  * ------------
  112.  * This file implements BMI application.
  113.  *
  114.  * Author:
  115.  * -------
  116.  * -------
  117.  *
  118.  *****************************************************************************/
  119.  /*  Include: MMI header file */
  120. #ifndef _MMI_BMI_C
  121. #define _MMI_BMI_C
  122. #include "MMI_features.h"
  123. #ifdef __MMI_BMI__
  124. #include "HistoryGprot.h"
  125. #include "GlobalDefs.h"
  126. #include "wgui_categories.h"
  127. #include "wgui_categories_inputs.h"
  128. #include "Unicodexdcl.h"
  129. #include "BMI.h"
  130. #include "settingprofile.h"
  131. #include "Organizerdef.h"
  132. #include "CommonScreens.h"
  133. #include "Calculator.h"
  134. /*  Include: PS header file */
  135. /* 
  136.  * Define
  137.  */
  138. #define  BMI_MALE_LB             20     /* Lower bound of standard BMI index of a man */
  139. #define  BMI_MALE_UB             25     /* Upper bound of standard BMI index of a man */
  140. #define  BMI_FEMALE_LB           18     /* Lower bound of standard BMI index of a woman */
  141. #define  BMI_FEMALE_UB           23     /* Upper bound of standard BMI index of a woman */
  142. #define  BMI_MAX_INPUT           8
  143. #define  BMI_DIGIT_LEN           9*ENCODING_LENGTH
  144. #define  BMI_LB_UB_LEN           4*ENCODING_LENGTH      /* buffer length to store lower and upper bound */
  145. #define  BMI_RESULT_LEN          7*ENCODING_LENGTH      /* buffer length to store resut xxx.xx */
  146. #define  BMI_MAX_HEIGHT          300
  147. #define  BMI_MIN_HEIGHT          55
  148. #define  BMI_MAX_WEIGHT          300
  149. #define  BMI_MIN_WEIGHT          1
  150. /* 
  151.  * Typedef 
  152.  */
  153. typedef struct
  154. {
  155.     DOUBLE Height;
  156.     DOUBLE Weight;
  157.     S32 Gender;
  158.     U8 *GenderList[2];
  159.     S8 UBBuf[BMI_LB_UB_LEN];
  160.     S8 LBBuf[BMI_LB_UB_LEN];
  161.     S8 ResultBuf[BMI_RESULT_LEN];
  162.     S8 HeightBuf[BMI_DIGIT_LEN];
  163.     S8 WeightBuf[BMI_DIGIT_LEN];
  164.     U8 CurrHilite;
  165. } bmi_context_struct;
  166. /* 
  167.  * Local Variable
  168.  */
  169. /* 
  170.  * Local Function
  171.  */
  172. U8 BMIDelScrCB(void *p);
  173. /* 
  174.  * Global Variable
  175.  */
  176. bmi_context_struct *g_bmi_cntx = NULL;
  177. extern wgui_inline_item wgui_inline_items[];
  178. /* 
  179.  * Global Function
  180.  */
  181. extern void gui_float_string(DOUBLE dob_val, S32 prec_val, S8 *out_buffer);
  182. extern void set_leading_zero(U8 u8type);
  183. /*****************************************************************************
  184.  * FUNCTION
  185.  *  HighlightBMIMenu
  186.  * DESCRIPTION
  187.  *  Highlight handler of BMI menu item.
  188.  *  Register key handlers.
  189.  * PARAMETERS
  190.  *  void
  191.  * RETURNS
  192.  *  void
  193.  *****************************************************************************/
  194. void HighlightBMIMenu(void)
  195. {
  196.     /*----------------------------------------------------------------*/
  197.     /* Local Variables                                                */
  198.     /*----------------------------------------------------------------*/
  199.     /*----------------------------------------------------------------*/
  200.     /* Code Body                                                      */
  201.     /*----------------------------------------------------------------*/
  202.     SetLeftSoftkeyFunction(EntryBMIWelcomeScreen, KEY_EVENT_UP);
  203.     SetKeyHandler(EntryBMIWelcomeScreen, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  204. }
  205. /*****************************************************************************
  206.  * FUNCTION
  207.  *  BmiDeInit
  208.  * DESCRIPTION
  209.  *  Free allocated memory.
  210.  * PARAMETERS
  211.  *  void
  212.  * RETURNS
  213.  *  void
  214.  *****************************************************************************/
  215. void BmiDeInit(void)
  216. {
  217.     /*----------------------------------------------------------------*/
  218.     /* Local Variables                                                */
  219.     /*----------------------------------------------------------------*/
  220.     /*----------------------------------------------------------------*/
  221.     /* Code Body                                                      */
  222.     /*----------------------------------------------------------------*/
  223.     if (g_bmi_cntx)
  224.     {
  225.         OslMfree(g_bmi_cntx);
  226.         g_bmi_cntx = NULL;
  227.     }
  228. }
  229. /*****************************************************************************
  230.  * FUNCTION
  231.  *  BMIDelScrCB
  232.  * DESCRIPTION
  233.  *  Callback function of delete bmi screen
  234.  * PARAMETERS
  235.  *  p       [?]     
  236.  * RETURNS
  237.  *  void
  238.  *****************************************************************************/
  239. U8 BMIDelScrCB(void *p)
  240. {
  241.     /*----------------------------------------------------------------*/
  242.     /* Local Variables                                                */
  243.     /*----------------------------------------------------------------*/
  244.     /*----------------------------------------------------------------*/
  245.     /* Code Body                                                      */
  246.     /*----------------------------------------------------------------*/
  247.     if (GetActiveScreenId() == SCR_BMI_INPUT)
  248.     {
  249.         CloseCategory57Screen();
  250.     }
  251.     BmiDeInit();
  252.     return MMI_FALSE;
  253. }
  254. /*****************************************************************************
  255.  * FUNCTION
  256.  *  EntryBMIWelcomeScreen
  257.  * DESCRIPTION
  258.  *  Display welcome screen of BMI application
  259.  * PARAMETERS
  260.  *  void
  261.  * RETURNS
  262.  *  void
  263.  *****************************************************************************/
  264. void EntryBMIWelcomeScreen(void)
  265. {
  266. #ifndef __MMI_MAINLCD_240X320__
  267.     /*----------------------------------------------------------------*/
  268.     /* Local Variables                                                */
  269.     /*----------------------------------------------------------------*/
  270.     U8 *guiBuffer;
  271.     /*----------------------------------------------------------------*/
  272.     /* Code Body                                                      */
  273.     /*----------------------------------------------------------------*/
  274.     guiBuffer = GetCurrGuiBuffer(SCR_BMI_WELCOME);
  275.     EntryNewScreen(SCR_BMI_WELCOME, NULL, EntryBMIWelcomeScreen, NULL);
  276.     ShowCategory129Screen(
  277.         (U8*) get_string(STR_BMI_WELCOME_CAPTION),
  278.         GetRootTitleIcon(EXTRA_HEALTH_MENU),
  279.         STR_GLOBAL_OK,
  280.         IMG_GLOBAL_OK,
  281.         STR_GLOBAL_BACK,
  282.         IMG_GLOBAL_BACK,
  283.         IMG_BMI_WELCOME_SCREEN,
  284.         guiBuffer);
  285.     SetLeftSoftkeyFunction(EntryBMIInputScreen, KEY_EVENT_UP);
  286.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  287. #else /* __MMI_MAINLCD_240X320__ */ 
  288.     EntryBMIInputScreen();
  289. #endif /* __MMI_MAINLCD_240X320__ */ 
  290. }
  291. /*****************************************************************************
  292.  * FUNCTION
  293.  *  EntryBMIInputScreen
  294.  * DESCRIPTION
  295.  *  Display inline editor screen for entering gender, height, and weight
  296.  * PARAMETERS
  297.  *  void
  298.  * RETURNS
  299.  *  void
  300.  *****************************************************************************/
  301. void EntryBMIInputScreen(void)
  302. {
  303.     /*----------------------------------------------------------------*/
  304.     /* Local Variables                                                */
  305.     /*----------------------------------------------------------------*/
  306.     U8 *guiBuffer;
  307.     U8 *inputBuffer;        /* added for inline edit history */
  308.     U16 inputBufferSize;    /* added for inline edit history */
  309.     U16 BMIImageList[6] = {0, 0, 0, 0, 0, 0};
  310.     /*----------------------------------------------------------------*/
  311.     /* Code Body                                                      */
  312.     /*----------------------------------------------------------------*/
  313.     if (g_bmi_cntx == NULL)
  314.     {
  315.         g_bmi_cntx = OslMalloc(sizeof(bmi_context_struct));
  316.         memset(g_bmi_cntx, 0, sizeof(bmi_context_struct));
  317.     }
  318.     EntryNewScreen(SCR_BMI_INPUT, ExitBMIInputScreen, NULL, NULL);
  319.     SetDelScrnIDCallbackHandler(SCR_BMI_INPUT, (HistoryDelCBPtr) BMIDelScrCB);
  320.     InitializeCategory57Screen();
  321.     guiBuffer = GetCurrGuiBuffer(SCR_BMI_INPUT);
  322.     BMIFillInlineStruct();
  323.     RegisterHighlightHandler(HighlightBMIInlineEditor);
  324.     if (g_bmi_cntx->Gender == 0)
  325.     {
  326.         BMIImageList[ENUM_GENDER] = IMG_BMI_BLUE_FLOWER;
  327.     }
  328.     else
  329.     {
  330.         BMIImageList[ENUM_GENDER] = IMG_BMI_RED_FLOWER;
  331.     }
  332.     inputBuffer = GetCurrNInputBuffer(SCR_BMI_INPUT, &inputBufferSize); /* added for inline edit history */
  333.     if (inputBuffer != NULL)    /* added for inline edit history */
  334.     {
  335.         SetCategory57Data(wgui_inline_items, ENUM_INLINE_TOTAL, inputBuffer);   /* sets the data */
  336.     }
  337.     DisableCategory57ScreenDone();
  338. #ifdef __MMI_SLIM_LISTMENU_NUMBER__
  339.     wgui_override_list_menu_slim_style(WGUI_LIST_MENU_SLIM_STYLE_DRAW_ICON);
  340. #endif 
  341.     /* 041205 Calvin added : Add an image on top of category57 */
  342.     /* Category57AppendTopImage(IMG_BMI_WELCOME_SCREEN, TRUE); */
  343.     /* Calvin end */
  344. #ifndef __MMI_MAINLCD_240X320__
  345.     ShowCategory57Screen(
  346.         STR_BMI_INPUT_CAPTION,
  347.         GetRootTitleIcon(EXTRA_HEALTH_MENU),
  348.         STR_GLOBAL_OK,
  349.         IMG_GLOBAL_OK,
  350.         STR_GLOBAL_BACK,
  351.         IMG_GLOBAL_BACK,
  352.         ENUM_INLINE_TOTAL,
  353.         BMIImageList,
  354.         wgui_inline_items,
  355.         g_bmi_cntx->CurrHilite,
  356.         guiBuffer);
  357. #else /* __MMI_MAINLCD_240X320__ */ 
  358.     ShowCategory357Screen(
  359.         STR_BMI_INPUT_CAPTION,
  360.         GetRootTitleIcon(EXTRA_HEALTH_MENU),
  361.         STR_GLOBAL_OK,
  362.         IMG_GLOBAL_OK,
  363.         STR_GLOBAL_BACK,
  364.         IMG_GLOBAL_BACK,
  365.         IMG_BMI_WELCOME_SCREEN,
  366.         ENUM_INLINE_TOTAL,
  367.         BMIImageList,
  368.         wgui_inline_items,
  369.         g_bmi_cntx->CurrHilite,
  370.         guiBuffer);
  371. #endif /* __MMI_MAINLCD_240X320__ */ 
  372.     SetCategory57RightSoftkeyFunctions(BmiComputeResult, GoBackHistory);
  373. }
  374. /*****************************************************************************
  375.  * FUNCTION
  376.  *  ExitBMIInputScreen
  377.  * DESCRIPTION
  378.  *  Exit handler of EntryBMIInputScreen
  379.  * PARAMETERS
  380.  *  void
  381.  * RETURNS
  382.  *  void
  383.  *****************************************************************************/
  384. void ExitBMIInputScreen(void)
  385. {
  386.     /*----------------------------------------------------------------*/
  387.     /* Local Variables                                                */
  388.     /*----------------------------------------------------------------*/
  389.     history h;
  390.     U16 inputBufferSize;    /* added for inline edit history */
  391.     U16 nHistory = 0;
  392.     /*----------------------------------------------------------------*/
  393.     /* Code Body                                                      */
  394.     /*----------------------------------------------------------------*/
  395.     set_leading_zero(TRUE);
  396.     if (g_bmi_cntx)
  397.     {
  398.         CloseCategory57Screen();
  399.     }
  400.     h.scrnID = SCR_BMI_INPUT;
  401.     h.entryFuncPtr = EntryBMIInputScreen;
  402.     pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  403.     GetCategoryHistory(h.guiBuffer);
  404.     inputBufferSize = (U16) GetCategory57DataSize();    /* added for inline edit history */
  405.     GetCategory57Data((U8*) h.inputBuffer);             /* added for inline edit history */
  406.     AddNHistory(h, inputBufferSize);                    /* added for inline edit history */
  407. #ifdef __MMI_SLIM_LISTMENU_NUMBER__
  408.     wgui_restore_list_menu_slim_style();
  409. #endif 
  410. }
  411. /*****************************************************************************
  412.  * FUNCTION
  413.  *  BMIFillInlineStruct
  414.  * DESCRIPTION
  415.  *  Initialize inline structure of input screen.
  416.  * PARAMETERS
  417.  *  void
  418.  * RETURNS
  419.  *  void
  420.  *****************************************************************************/
  421. void BMIFillInlineStruct(void)
  422. {
  423.     /*----------------------------------------------------------------*/
  424.     /* Local Variables                                                */
  425.     /*----------------------------------------------------------------*/
  426.     /*----------------------------------------------------------------*/
  427.     /* Code Body                                                      */
  428.     /*----------------------------------------------------------------*/
  429.     set_leading_zero(FALSE);
  430.     g_bmi_cntx->GenderList[0] = (U8*) GetString(STR_BMI_MALE_TEXT);
  431.     g_bmi_cntx->GenderList[1] = (U8*) GetString(STR_BMI_FEMALE_TEXT);
  432.     /* gender */
  433.     SetInlineItemActivation(&wgui_inline_items[ENUM_GENDER], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  434.     SetInlineItemSelect(&wgui_inline_items[ENUM_GENDER], 2, (U8 **) g_bmi_cntx->GenderList, &g_bmi_cntx->Gender);
  435.     RegisterInlineSelectHighlightHandler(&wgui_inline_items[ENUM_GENDER], HighlightBMIGender);
  436.     /* height caption */
  437.     SetInlineItemActivation(&wgui_inline_items[ENUM_HEIGHT_CAPTION], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  438.     SetInlineItemCaption(&wgui_inline_items[ENUM_HEIGHT_CAPTION], (U8*) GetString(STR_BMI_HEIGHT_TEXT));
  439.     SetInlineItemFullWidth(&wgui_inline_items[ENUM_HEIGHT_CAPTION]);
  440.     /* height */
  441.     SetInlineItemActivation(&wgui_inline_items[ENUM_HEIGHT], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  442.     SetInlineItemTextEdit(
  443.         &wgui_inline_items[ENUM_HEIGHT],
  444.         (U8*) g_bmi_cntx->HeightBuf,
  445.         (BMI_MAX_INPUT + 1),
  446.         INPUT_TYPE_DECIMAL_NUMERIC);
  447.     RightJustifyInlineItem(&wgui_inline_items[ENUM_HEIGHT]);
  448.     SetInlineItemFullWidth(&wgui_inline_items[ENUM_HEIGHT]);
  449.     EnableInlineItemBoundary(&wgui_inline_items[ENUM_HEIGHT]);
  450.     /* weight caption */
  451.     SetInlineItemActivation(&wgui_inline_items[ENUM_WEIGHT_CAPTION], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  452.     SetInlineItemCaption(&wgui_inline_items[ENUM_WEIGHT_CAPTION], (U8*) GetString(STR_BMI_WEIGHT_TEXT));
  453.     SetInlineItemFullWidth(&wgui_inline_items[ENUM_WEIGHT_CAPTION]);
  454.     /* weight */
  455.     SetInlineItemActivation(&wgui_inline_items[ENUM_WEIGHT], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  456.     SetInlineItemTextEdit(
  457.         &wgui_inline_items[ENUM_WEIGHT],
  458.         (U8*) g_bmi_cntx->WeightBuf,
  459.         (BMI_MAX_INPUT + 1),
  460.         INPUT_TYPE_DECIMAL_NUMERIC);
  461.     RightJustifyInlineItem(&wgui_inline_items[ENUM_WEIGHT]);
  462.     SetInlineItemFullWidth(&wgui_inline_items[ENUM_WEIGHT]);
  463.     EnableInlineItemBoundary(&wgui_inline_items[ENUM_WEIGHT]);
  464. }
  465. /*****************************************************************************
  466.  * FUNCTION
  467.  *  EntryBMIResultScreen
  468.  * DESCRIPTION
  469.  *  Display result screen of calculation
  470.  * PARAMETERS
  471.  *  void
  472.  * RETURNS
  473.  *  void
  474.  *****************************************************************************/
  475. void EntryBMIResultScreen(void)
  476. {
  477.     /*----------------------------------------------------------------*/
  478.     /* Local Variables                                                */
  479.     /*----------------------------------------------------------------*/
  480.     U8 *guiBuffer;
  481.     DOUBLE bmiValue;
  482.     U8 *bmiBuf;
  483.     U8 percentageValue;
  484.     U16 FolwerIndex;
  485.     U8 LB, UB, prec;
  486.     /*----------------------------------------------------------------*/
  487.     /* Code Body                                                      */
  488.     /*----------------------------------------------------------------*/
  489.     memset(g_bmi_cntx->ResultBuf, 0, sizeof(g_bmi_cntx->ResultBuf));
  490.     guiBuffer = GetCurrGuiBuffer(SCR_BMI_RESULT);
  491.     EntryNewScreen(SCR_BMI_RESULT, NULL, EntryBMIResultScreen, NULL);
  492.     bmiValue = g_bmi_cntx->Weight / (g_bmi_cntx->Height * g_bmi_cntx->Height) * 10000;
  493.     prec = CalcComputePrecision(bmiValue, BMI_MAX_DIGITS);
  494.     gui_float_string(bmiValue, prec, g_bmi_cntx->ResultBuf);
  495.     if (g_bmi_cntx->Gender == 0)
  496.     {
  497.         LB = BMI_MALE_LB;
  498.         UB = BMI_MALE_UB;
  499.         FolwerIndex = IMG_BMI_BLUE_FLOWER;
  500.     }
  501.     else
  502.     {
  503.         LB = BMI_FEMALE_LB;
  504.         UB = BMI_FEMALE_UB;
  505.         FolwerIndex = IMG_BMI_RED_FLOWER;
  506.     }
  507.     gui_itoa(LB, (U16*) g_bmi_cntx->LBBuf, 10);
  508.     gui_itoa(UB, (U16*) g_bmi_cntx->UBBuf, 10);
  509.     if (bmiValue > UB)
  510.     {
  511.         bmiBuf = (U8*) GetString(STR_BMI_FAT);
  512.         percentageValue = 2;
  513.     }
  514.     else if (bmiValue < LB)
  515.     {
  516.         bmiBuf = (U8*) GetString(STR_BMI_THIN);
  517.         percentageValue = 0;
  518.     }
  519.     else
  520.     {
  521.         bmiBuf = (U8*) GetString(STR_BMI_NORMAL);
  522.         percentageValue = 1;
  523.     }
  524.     ShowCategory122Screen(
  525.         STR_BMI_RESULT_CAPTION,
  526.         GetRootTitleIcon(EXTRA_HEALTH_MENU),
  527.         0,
  528.         0,
  529.         STR_GLOBAL_BACK,
  530.         IMG_GLOBAL_BACK,
  531.         STR_BMI_BMI_TEXT,
  532.         percentageValue,
  533.         guiBuffer,
  534.         g_bmi_cntx->ResultBuf,
  535.         bmiBuf,
  536.         FolwerIndex,
  537.         (U8*) g_bmi_cntx->LBBuf,
  538.         (U8*) g_bmi_cntx->UBBuf);
  539.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  540. }
  541. /*****************************************************************************
  542.  * FUNCTION
  543.  *  HighlightBMIInlineEditor
  544.  * DESCRIPTION
  545.  *  Highlight handler of inline editor in input screen.
  546.  * PARAMETERS
  547.  *  index       [IN]        
  548.  * RETURNS
  549.  *  void
  550.  *****************************************************************************/
  551. void HighlightBMIInlineEditor(S32 index)
  552. {
  553.     /*----------------------------------------------------------------*/
  554.     /* Local Variables                                                */
  555.     /*----------------------------------------------------------------*/
  556.     /*----------------------------------------------------------------*/
  557.     /* Code Body                                                      */
  558.     /*----------------------------------------------------------------*/
  559.     g_bmi_cntx->CurrHilite = (U8) index;
  560.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  561.     SetLeftSoftkeyFunction(BmiComputeResult, KEY_EVENT_UP);
  562.     return;
  563. }
  564. /*****************************************************************************
  565.  * FUNCTION
  566.  *  HighlightBMIGender
  567.  * DESCRIPTION
  568.  *  Highlight handler of Gender item in input screen.
  569.  *  Change display folwer when gender changed.
  570.  * PARAMETERS
  571.  *  index       [IN]        
  572.  * RETURNS
  573.  *  void
  574.  *****************************************************************************/
  575. void HighlightBMIGender(S32 index)
  576. {
  577.     /*----------------------------------------------------------------*/
  578.     /* Local Variables                                                */
  579.     /*----------------------------------------------------------------*/
  580.     /*----------------------------------------------------------------*/
  581.     /* Code Body                                                      */
  582.     /*----------------------------------------------------------------*/
  583.     if (g_bmi_cntx->Gender == 0)
  584.     {
  585.         Category57ChangeItemIcon(0, IMG_BMI_BLUE_FLOWER);
  586.     }
  587.     else
  588.     {
  589.         Category57ChangeItemIcon(0, IMG_BMI_RED_FLOWER);
  590.     }
  591.     RedrawCategory57Screen();
  592. }
  593. /*****************************************************************************
  594.  * FUNCTION
  595.  *  BmiComputeResult
  596.  * DESCRIPTION
  597.  *  Validate correctness of input data and calcalute result.
  598.  * PARAMETERS
  599.  *  void
  600.  * RETURNS
  601.  *  void
  602.  *****************************************************************************/
  603. void BmiComputeResult(void)
  604. {
  605.     /*----------------------------------------------------------------*/
  606.     /* Local Variables                                                */
  607.     /*----------------------------------------------------------------*/
  608.     S8 temp_buf[100];
  609.     /*----------------------------------------------------------------*/
  610.     /* Code Body                                                      */
  611.     /*----------------------------------------------------------------*/
  612.     CloseCategory57Screen();
  613.     UnicodeToAnsii(temp_buf, (S8*) g_bmi_cntx->HeightBuf);
  614.     g_bmi_cntx->Height = atof(temp_buf);
  615.     UnicodeToAnsii(temp_buf, (S8*) g_bmi_cntx->WeightBuf);
  616.     g_bmi_cntx->Weight = atof(temp_buf);
  617.     if (((g_bmi_cntx->Height < BMI_MIN_HEIGHT) || (g_bmi_cntx->Height > BMI_MAX_HEIGHT)) &&
  618.         ((g_bmi_cntx->Weight < BMI_MIN_WEIGHT) || (g_bmi_cntx->Weight > BMI_MAX_WEIGHT)))
  619.     {
  620.         DisplayPopup(
  621.             (U8*) GetString(STR_BMI_HEIGHT_WEIGHT_ERROR),
  622.             IMG_GLOBAL_WARNING,
  623.             0,
  624.             UI_POPUP_NOTIFYDURATION_TIME,
  625.             WARNING_TONE);
  626.         g_bmi_cntx->CurrHilite = 2;
  627.         return;
  628.     }
  629.     else if ((g_bmi_cntx->Height < BMI_MIN_HEIGHT) || (g_bmi_cntx->Height > BMI_MAX_HEIGHT))
  630.     {
  631.         DisplayPopup(
  632.             (U8*) GetString(STR_BMI_HEIGHT_ERROR_TEXT),
  633.             IMG_GLOBAL_WARNING,
  634.             0,
  635.             UI_POPUP_NOTIFYDURATION_TIME,
  636.             WARNING_TONE);
  637.         g_bmi_cntx->CurrHilite = 2;
  638.         return;
  639.     }
  640.     else if ((g_bmi_cntx->Weight < BMI_MIN_WEIGHT) || (g_bmi_cntx->Weight > BMI_MAX_WEIGHT))
  641.     {
  642.         DisplayPopup(
  643.             (U8*) GetString(STR_BMI_WEIGHT_ERROR_TEXT),
  644.             IMG_GLOBAL_WARNING,
  645.             0,
  646.             UI_POPUP_NOTIFYDURATION_TIME,
  647.             WARNING_TONE);
  648.         g_bmi_cntx->CurrHilite = 4;
  649.         return;
  650.     }
  651.     g_bmi_cntx->CurrHilite = 0;
  652.     EntryBMIResultScreen();
  653. }
  654. #endif /* __MMI_BMI__ */ // #ifdef __MMI_BMI__
  655. #endif /* _MMI_BMI_C */ // #ifndef _MMI_BMI_C