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

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.  * Unitconvertor.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  * MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  * This file implements Unit Convertor 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.  * removed!
  88.  * removed!
  89.  * removed!
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * removed!
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * removed!
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * removed!
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * removed!
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * removed!
  114.  *
  115.  * removed!
  116.  * removed!
  117.  * removed!
  118.  *
  119.  * removed!
  120.  * removed!
  121.  * removed!
  122.  *
  123.  * removed!
  124.  * removed!
  125.  * removed!
  126.  *
  127.  * removed!
  128.  * removed!
  129.  * removed!
  130.  *
  131.  *------------------------------------------------------------------------------
  132.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  133.  *============================================================================
  134.  ****************************************************************************/
  135. /**********************************************************************************
  136.  * Copyright Notice
  137.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  138.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  139.  *  (It is illegal to remove this copyright notice from this software or any
  140.  *  portion of it)
  141.  */
  142. /**********************************************************************************
  143.    Filename:      Unitconvertor.c
  144.    Author:        Vandana M
  145.    Date Created:  June-14-2003
  146.    Contains:      Unit Convertor
  147. **********************************************************************************/
  148. #ifndef _MMI_UNITCONVERTOR_C
  149. #define _MMI_UNITCONVERTOR_C
  150. /*  Include: MMI header file */
  151. #include "MMI_features.h"
  152. #if defined (__MMI_UNIT_CONVERTER__) || defined (__MMI_EXTENDED_UNIT_CONVERTER__)
  153. #include "PixtelDataTypes.h"
  154. #include "unitconvertor.h"
  155. #if defined (__MMI_EXTENDED_CURRENCY_CONVERTER__)
  156. #include "CurrencyConvertorE.h"
  157. #elif defined (__MMI_CURRENCY_CONVERTER__)
  158. #include "currencyconvertor.h"
  159. #endif 
  160. #include "Unicodexdcl.h"
  161. #include "HistoryGprot.h"
  162. #include "GlobalDefs.h"
  163. #include "SettingProfile.h"
  164. #include "DebugInitDef.h"
  165. #include "CommonScreens.h"
  166. #include "EventsGprot.h"
  167. #include "wgui_inputs.h"
  168. #include "wgui_categories.h"
  169. #include "wgui_categories_inputs.h"
  170. #include "OrganizerDef.h"
  171. #if defined(__MMI_TOUCH_SCREEN__)
  172. #include "EditorPen.h"
  173. #endif 
  174. /*  Include: PS header file */
  175. /* 
  176.  * Define
  177.  */
  178. #define  UCONV_MAX_RESULT     12        /* 12 digits */
  179. #define  UCONV_MAX_INPUT         8
  180. #if defined (__MMI_UNIT_CONVERTER__)
  181. #define  UCONV_NUM_UNITS         4
  182. #define  KM2MILE              0.62137
  183. #define  M2YARD               1.09361
  184. #define  M2FOOT               3.28084
  185. #define  CM2INCH              0.3937
  186. #define  KG2POUND          2.20462
  187. #define  KG2OUNCE          35.274
  188. #elif defined (__MMI_EXTENDED_UNIT_CONVERTER__)
  189. #define UCONV_NUM_UNITS2      11
  190. #define UCONV_VOLUME_UNIT_NUM    11
  191. #define UCONV_TEMPERATURE_UNIT_NUM  2
  192. #define UCONV_VELOCITY_UNIT_NUM     4
  193. #define UCONV_LENGTH_UNIT_NUM    8
  194. #define UCONV_WEIGHT_UNIT_NUM    6
  195. #define UCONV_SHOES_UNIT_NUM     3
  196. #define UCONV_CLOTHES_UNIT_NUM      6
  197. #define UCONV_SURFACE_UNIT_NUM      10
  198. #endif 
  199. #ifndef __MTK_TARGET__
  200. #define UCONV_MAX_VALUE          999999999999l
  201. #else 
  202. #define UCONV_MAX_VALUE          999999999999ll
  203. #endif 
  204. #define UCONV_MIN_VALUE          0.0000000001
  205. /* 
  206.  * Typedef 
  207.  */
  208. typedef struct
  209. {
  210.     S32 CurrInlineSelectUnit;
  211.     U8 CurrSelectedItem;
  212.     U8 ClearResultFlag;
  213.     U8 CurrHiliteUnitType;
  214. #if defined (__MMI_UNIT_CONVERTER__)
  215.     S8 *UnitList[UCONV_NUM_UNITS];
  216.     UI_character_type MetricBuf[UCONV_MAX_RESULT + 2];
  217.     UI_character_type EngBuf[UCONV_MAX_RESULT + 2];
  218. #elif defined (__MMI_EXTENDED_UNIT_CONVERTER__)
  219.     S32 CurrInlineSelectUnit1;
  220.     S32 CurrInlineSelectUnit2;
  221.     S8 *UnitListLg[UCONV_NUM_UNITS2];   /* inline selector items */
  222.     UI_character_type InputBuf1[UCONV_MAX_RESULT + 2];
  223.     UI_character_type InputBuf2[UCONV_MAX_RESULT + 2];
  224.     S8 title[64];
  225.     S8 *UnitListLg2[1]; /* inline selector items, only support two unit toggling (now only for Temperature application) */
  226.     MMI_BOOL inputflag; /* flag to record the validation of input, only for shoes and clothes */
  227. #endif 
  228. } uconv_context_struct;
  229. /* 
  230.  * Global Variable
  231.  */
  232. uconv_context_struct *g_uconv_cntx = NULL;
  233. extern wgui_inline_item wgui_inline_items[];
  234. #ifdef __MMI_EXTENDED_UNIT_CONVERTER__
  235. const DOUBLE g_volume_rate[UCONV_VOLUME_UNIT_NUM][UCONV_VOLUME_UNIT_NUM] =
  236.     { {1, 0.001, 1000, 1, 1E-6, 0.06102, 2.2E-4, 0.00176, 0.0352, 0.0352, 6.29E-6},
  237. {1000, 1, 1E+6, 1000, 0.001, 61.02376, 0.21996, 1.76, 35.195, 35.195, 0.00629},
  238. {0.001, 1E-6, 1, 0.001, 1E-9, 6.102E-5, 2.2E-7, 1.76E-6, 3.52E-5, 3.52E-5, 6.29E-9},
  239. {1, 0.001, 1000, 1, 1E-6, 0.06102, 2.2E-4, 0.00176, 0.0352, 0.0352, 6.29E-6},
  240. {1E+6, 1000, 1E+9, 1E+6, 1, 6.1E+4, 219.969, 1759.754, 3.5195, 3.5195, 6.2898},
  241. {16.387, 0.01639, 16387.1, 16.387, 1.639E-5, 1, 0.0036, 0.02884, 0.57674, 0.57674, 1.031E-4},
  242. {4546.1, 4.5461, 4.546E+6, 4546.1, 0.00455, 277.42, 1, 8, 160, 160, 0.02859},
  243. {568.26, 0.5683, 5.683E+5, 568.26, 5.683E-4, 34.677, 0.125, 1, 20, 20, 0.00357},
  244. {28.413, 0.02841, 28413, 28.413, 2.841E-5, 1.7339, 0.00625, 0.05, 1, 1, 1.787E-4},
  245. {28.413, 0.02841, 28413, 28.413, 2.841E-5, 1.7339, 0.00625, 0.05, 1, 1, 1.787E-4},
  246. {1.59E+5, 158.99, 1.59E+8, 1.59E+5, 0.159, 9702, 34.972, 279.78, 5595.57, 5595.57, 1}
  247. };
  248. const DOUBLE g_velocity_rate[UCONV_VELOCITY_UNIT_NUM][UCONV_VELOCITY_UNIT_NUM] = { {1, 0.27778, 0.62137, 0.91134},
  249. {3.6, 1, 2.237, 3.28083},
  250. {1.60935, 0.44703, 1, 1.4667},
  251. {1.09728, 0.30480, 0.68182, 1}
  252. };
  253. S8 g_unitlist2[32];
  254. const DOUBLE g_length_rate[UCONV_LENGTH_UNIT_NUM][UCONV_LENGTH_UNIT_NUM] =
  255.     { {1, 0.1, 0.001, 1E-6, 0.03937, 0.00328, 0.00109, 6.2137E-7},
  256. {10, 1, 0.01, 1E-5, 0.3937, 0.0328, 0.0109, 6.2137E-6},
  257. {1000, 100, 1, 0.001, 39.37, 3.28084, 1.09361, 0.00062},
  258. {1E+6, 1E+5, 1E+3, 1, 39370, 3280.84, 1093.6, 0.62137},
  259. {25.4, 2.54, 0.0254, 0.00003, 1, 0.08333, 0.02778, 0.00002},
  260. {304.801, 30.4801, 0.3048, 0.00031, 12, 1, 0.33333, 0.00019},
  261. {914.402, 91.4402, 0.9144, 0.00091, 36, 3, 1, 0.00057},
  262. {1609350, 160935, 1609.35, 1.60935, 63360, 5280, 1760, 1}
  263. };
  264. const DOUBLE g_weight_rate[UCONV_WEIGHT_UNIT_NUM][UCONV_WEIGHT_UNIT_NUM] = { {1, 1E-3, 1E-6, 1E-9, 3.527E-5, 2.21E-6},
  265. {1E+3, 1, 1E-3, 1E-6, 0.03527, 0.00221},
  266. {1E+6, 1E+3, 1, 1E-3, 35.274, 2.20462},
  267. {1E+9, 1E+6, 1E+3, 1, 35274, 2204.62},
  268. {0.0283495, 28.3495, 0.02835, 0.00003, 1, 0.0625},
  269. {0.453592, 453.592, 0.45359, 0.00045, 16, 1}
  270. };
  271. const DOUBLE g_shoes_rate_pluspara[UCONV_SHOES_UNIT_NUM][UCONV_SHOES_UNIT_NUM] = { {0, 30.5, 170},
  272. {-30.5, 0, -135},
  273. {17, 13.5, 0}
  274. };
  275. const DOUBLE g_shoes_rate_multipara[UCONV_SHOES_UNIT_NUM][UCONV_SHOES_UNIT_NUM] = { {1, 1, 10},
  276. {1, 1, 10},
  277. {0.1, 0.1, 1}
  278. };
  279. /* clothes unit converter formula : (x - subtractpara) / dividepara * multipara + pluspara */
  280. const S32 g_clothes_rate_subtractpara[UCONV_CLOTHES_UNIT_NUM][UCONV_CLOTHES_UNIT_NUM] = { {0, 34, 34, 0, 0, 0},
  281. {44, 0, 44, 44, 44, 44},
  282. {85, 85, 0, 85, 85, 85},
  283. {0, -1, -1, 0, 0, 0},
  284. {0, 0, 0, 0, 0, 0},
  285. {0, 2, 2, 0, 0, 0}
  286. };
  287. const S32 g_clothes_rate_dividepara[UCONV_CLOTHES_UNIT_NUM][UCONV_CLOTHES_UNIT_NUM] = { {1, 4, 4, 1, 1, 1},
  288. {11, 1, 11, 11, 11, 11},
  289. {5, 5, 1, 5, 5, 5},
  290. {1, 4, 4, 1, 1, 1},
  291. {1, 4, 4, 1, 1, 1},
  292. {1, 4, 4, 1, 1, 1}
  293. };
  294. const S32 g_clothes_rate_multipara[UCONV_CLOTHES_UNIT_NUM][UCONV_CLOTHES_UNIT_NUM] = { {1, 11, 5, 1, 1, 1},
  295. {4, 1, 5, 4, 4, 4},
  296. {4, 11, 1, 4, 4, 4},
  297. {1, 11, 5, 1, 1, 1},
  298. {1, 11, 5, 1, 1, 1},
  299. {1, 11, 5, 1, 1, 1}
  300. };
  301. const S32 g_clothes_rate_pluspara[UCONV_CLOTHES_UNIT_NUM][UCONV_CLOTHES_UNIT_NUM] = { {0, 44, 85, -35, -34, -32},
  302. {36, 0, 85, 1, 2, 4},
  303. {36, 44, 0, 1, 2, 4},
  304. {35, 44, 85, 0, 1, 3},
  305. {34, 44, 85, -1, 0, 2},
  306. {32, 44, 85, -3, -2, 0}
  307. };
  308. const DOUBLE g_surface_rate[2][UCONV_SURFACE_UNIT_NUM] = 
  309. {
  310.     {1, 0.40469, 4.046E+9, 4.046E+7, 4046.85, 4.046E-3, 6268570, 43537.631, 4840.0326, 1.5556E-3},
  311.     {2.47106, 1, 1E+10, 1E+8, 1E+4, 1E-2, 1.549E+7, 1.07584E+5, 1.196E+4, 3.844E-3}
  312. };
  313. #endif /* __MMI_EXTENDED_UNIT_CONVERTER__ */ 
  314. /* 
  315.  * Global Function
  316.  */
  317. extern DOUBLE gui_atof(UI_string_type s);
  318. extern void gui_float_string(DOUBLE dob_val, S32 prec_val, S8 *out_buffer);
  319. extern void set_leading_zero(U8 u8type);
  320. extern S32 CalcComputePrecision(DOUBLE result, S16 max_digits);
  321. extern void CconvClearResult(void);
  322. /* Local Function */
  323. U8 mmi_uconv_del_scr_callback(void *p);
  324. #ifdef __MMI_UNIT_CONVERTER__
  325. void HighlightUConvLength(void);
  326. void HighlightUConvWeight(void);
  327. void ComputeLengthResult(void);
  328. void ComputeWeightResult(void);
  329. #else /* __MMI_UNIT_CONVERTER__ */ 
  330. void mmi_uconv_highlight_volume(void);
  331. void mmi_uconv_highlight_temperature(void);
  332. void mmi_uconv_highlight_velocity(void);
  333. void mmi_uconv_highlight_length(void);
  334. void mmi_uconv_highlight_weight(void);
  335. void mmi_uconv_highlight_shoes(void);
  336. void mmi_uconv_highlight_clothes(void);
  337. void mmi_uconv_highlight_surface(void);
  338. extern void playRequestedTone(ALL_TONE_ENUM playtone);
  339. #endif /* __MMI_UNIT_CONVERTER__ */ 
  340. /*****************************************************************************
  341.  * FUNCTION
  342.  *  HighlightUConvMenu
  343.  * DESCRIPTION
  344.  *  Highlight handler of Unit Conveter menu item.
  345.  *  Register key handlers.
  346.  * PARAMETERS
  347.  *  void
  348.  * RETURNS
  349.  *  void
  350.  *****************************************************************************/
  351. void HighlightUConvMenu(void)
  352. {
  353.     /*----------------------------------------------------------------*/
  354.     /* Local Variables                                                */
  355.     /*----------------------------------------------------------------*/
  356.     /*----------------------------------------------------------------*/
  357.     /* Code Body                                                      */
  358.     /*----------------------------------------------------------------*/
  359.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  360.     SetLeftSoftkeyFunction(EntryUConvMenu, KEY_EVENT_UP);
  361.     SetKeyHandler(EntryUConvMenu, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  362. }
  363. /*****************************************************************************
  364.  * FUNCTION
  365.  *  UConvRedrawResult
  366.  * DESCRIPTION
  367.  *  Redraw result after computing
  368.  * PARAMETERS
  369.  *  void
  370.  * RETURNS
  371.  *  void
  372.  *****************************************************************************/
  373. void UConvRedrawResult(void)
  374. {
  375. #ifdef __MMI_CONVERTER_KEEP_INLINE_FOCUS__
  376.     /*----------------------------------------------------------------*/
  377.     /* Local Variables                                                */
  378.     /*----------------------------------------------------------------*/
  379.     /*----------------------------------------------------------------*/
  380.     /* Code Body                                                      */
  381.     /*----------------------------------------------------------------*/
  382.     RedrawCategoryFunction();
  383. #else /* __MMI_CONVERTER_KEEP_INLINE_FOCUS__ */ 
  384.     SetHighlightedItem(0);
  385. #endif /* __MMI_CONVERTER_KEEP_INLINE_FOCUS__ */ 
  386. }
  387. /*****************************************************************************
  388.  * FUNCTION
  389.  *  UconvDeInit
  390.  * DESCRIPTION
  391.  *  Free memory and go back to previous screen.
  392.  * PARAMETERS
  393.  *  void
  394.  * RETURNS
  395.  *  void
  396.  *****************************************************************************/
  397. void UconvDeInit(void)
  398. {
  399.     /*----------------------------------------------------------------*/
  400.     /* Local Variables                                                */
  401.     /*----------------------------------------------------------------*/
  402.     /*----------------------------------------------------------------*/
  403.     /* Code Body                                                      */
  404.     /*----------------------------------------------------------------*/
  405.     if (g_uconv_cntx)
  406.     {
  407.         OslMfree(g_uconv_cntx);
  408.         g_uconv_cntx = NULL;
  409.     }
  410. }
  411. /*****************************************************************************
  412.  * FUNCTION
  413.  *  mmi_uconv_del_scr_callback
  414.  * DESCRIPTION
  415.  *  Callback function of delete unit converter screen
  416.  * PARAMETERS
  417.  *  p       [?]     
  418.  * RETURNS
  419.  *  void
  420.  *****************************************************************************/
  421. U8 mmi_uconv_del_scr_callback(void *p)
  422. {
  423.     /*----------------------------------------------------------------*/
  424.     /* Local Variables                                                */
  425.     /*----------------------------------------------------------------*/
  426.     U16 ScrID = (SCR_ID_UCONV_WEIGHT + g_uconv_cntx->CurrHiliteUnitType);
  427.     /*----------------------------------------------------------------*/
  428.     /* Code Body                                                      */
  429.     /*----------------------------------------------------------------*/
  430.     if (GetActiveScreenId() == ScrID)
  431.     {
  432.         CloseCategory57Screen();
  433.     }
  434.     UconvDeInit();
  435.     return MMI_FALSE;
  436. }
  437. /*****************************************************************************
  438.  * FUNCTION
  439.  *  EntryUConvMenu
  440.  * DESCRIPTION
  441.  *  Entry function of unit convertor
  442.  * PARAMETERS
  443.  *  void
  444.  * RETURNS
  445.  *  void
  446.  *****************************************************************************/
  447. void EntryUConvMenu(void)
  448. {
  449.     /*----------------------------------------------------------------*/
  450.     /* Local Variables                                                */
  451.     /*----------------------------------------------------------------*/
  452.     U16 UC_list_of_items[8];    /* Autumn {Bad!! Hardcode!!} */
  453.     U8 *guiBuffer;
  454.     S32 num_of_items;
  455.     /*----------------------------------------------------------------*/
  456.     /* Code Body                                                      */
  457.     /*----------------------------------------------------------------*/
  458.     if (g_uconv_cntx == NULL)
  459.     {
  460.         g_uconv_cntx = OslMalloc(sizeof(uconv_context_struct));
  461.     }
  462.     g_uconv_cntx->ClearResultFlag = FALSE;
  463.     EntryNewScreen(SCR_ID_UCONV_MENU, NULL, EntryUConvMenu, NULL);
  464.     /* shoes and clothes are not supported temporary */
  465.     mmi_frm_hide_menu_item(MENU_ID_EXTRA_UNITCONVERTOR_SHOEW);
  466.     mmi_frm_hide_menu_item(MENU_ID_EXTRA_UNITCONVERTOR_CLOTHES);
  467.     guiBuffer = GetCurrGuiBuffer(SCR_ID_UCONV_MENU);
  468.     num_of_items = GetNumOfChild_Ext(EXTRA_UNITCONVERTOR_MENU);
  469.     GetSequenceStringIds_Ext(EXTRA_UNITCONVERTOR_MENU, UC_list_of_items);
  470.     SetParentHandler(EXTRA_UNITCONVERTOR_MENU);
  471.     RegisterHighlightHandler(ExecuteCurrHiliteHandler_Ext);
  472.     ShowCategory15Screen(
  473.         EXTRA_MENU_UNITSCONVERTOR_STRINGID,
  474.         GetRootTitleIcon(EXTRA_UNITCONVERTOR_MENU),
  475.         STR_GLOBAL_OK,
  476.         0,
  477.         STR_GLOBAL_BACK,
  478.         0,
  479.         num_of_items,
  480.         UC_list_of_items,
  481.         (U16*) gIndexIconsImageList,
  482.         LIST_MENU,
  483.         0,
  484.         guiBuffer);
  485.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  486.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  487. }
  488. /*****************************************************************************
  489.  * FUNCTION
  490.  *  UconvInit
  491.  * DESCRIPTION
  492.  *  Set highlight handlers
  493.  * PARAMETERS
  494.  *  void
  495.  * RETURNS
  496.  *  void
  497.  *****************************************************************************/
  498. void UconvInit(void)
  499. {
  500.     /*----------------------------------------------------------------*/
  501.     /* Local Variables                                                */
  502.     /*----------------------------------------------------------------*/
  503.     /*----------------------------------------------------------------*/
  504.     /* Code Body                                                      */
  505.     /*----------------------------------------------------------------*/
  506.     SetHiliteHandler(EXTRA_UNITCONVERTOR_MENU, HighlightUConvMenu);
  507. #ifndef __MMI_EXTENDED_UNIT_CONVERTER__
  508.     SetHiliteHandler(EXTRA_UNITCONVERTOR_LENGTH, HighlightUConvLength);
  509.     SetHiliteHandler(EXTRA_UNITCONVERTOR_WEIGHT, HighlightUConvWeight);
  510. #else /* __MMI_EXTENDED_UNIT_CONVERTER__ */ 
  511.     SetHiliteHandler(EXTRA_UNITCONVERTOR_LENGTH, mmi_uconv_highlight_length);
  512.     SetHiliteHandler(EXTRA_UNITCONVERTOR_WEIGHT, mmi_uconv_highlight_weight);
  513.     SetHiliteHandler(MENU_ID_EXTRA_UNITCONVERTOR_VOLUME, mmi_uconv_highlight_volume);
  514.     SetHiliteHandler(MENU_ID_EXTRA_UNITCONVERTOR_TEMPERATURE, mmi_uconv_highlight_temperature);
  515.     SetHiliteHandler(MENU_ID_EXTRA_UNITCONVERTOR_VELOCITY, mmi_uconv_highlight_velocity);
  516.     SetHiliteHandler(MENU_ID_EXTRA_UNITCONVERTOR_SHOEW, mmi_uconv_highlight_shoes);
  517.     SetHiliteHandler(MENU_ID_EXTRA_UNITCONVERTOR_CLOTHES, mmi_uconv_highlight_clothes);
  518.     SetHiliteHandler(MENU_ID_EXTRA_UNITCONVERTOR_SURFACE, mmi_uconv_highlight_surface);
  519. #endif /* __MMI_EXTENDED_UNIT_CONVERTER__ */ 
  520. }
  521. /*****************************************************************************
  522.  * FUNCTION
  523.  *  UConvCustomInlineFunction
  524.  * DESCRIPTION
  525.  *  Set group key handlers of inline editor
  526.  * PARAMETERS
  527.  *  void
  528.  * RETURNS
  529.  *  void
  530.  *****************************************************************************/
  531. void UConvCustomInlineFunction(void)
  532. {
  533. #ifdef __MMI_CONVERTER_KEEP_INLINE_FOCUS__
  534.     /*----------------------------------------------------------------*/
  535.     /* Local Variables                                                */
  536.     /*----------------------------------------------------------------*/
  537.     U16 keyCodes[] = {KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_POUND};
  538.     U8 nKeyCodes = (U8) 11;
  539.     /*----------------------------------------------------------------*/
  540.     /* Code Body                                                      */
  541.     /*----------------------------------------------------------------*/
  542.     if (g_uconv_cntx->ClearResultFlag)
  543.     {
  544.         g_uconv_cntx->ClearResultFlag = FALSE;
  545.         SetGroupKeyHandler(CconvClearResult, keyCodes, nKeyCodes, KEY_EVENT_DOWN);
  546.     #if !defined(__MMI_WITH_C_KEY__)
  547.         SetRightSoftkeyFunction(CconvClearResult, KEY_EVENT_UP);
  548.         SetRightSoftkeyFunction(CconvClearResult, KEY_EVENT_LONG_PRESS);
  549.         SetRightSoftkeyFunction(NULL, KEY_EVENT_DOWN);
  550.     #else /* !defined(__MMI_WITH_C_KEY__) */ 
  551.         SetKeyHandler(CconvClearResult, KEY_CLEAR, KEY_EVENT_UP);
  552.         SetKeyHandler(CconvClearResult, KEY_CLEAR, KEY_EVENT_LONG_PRESS);
  553.         SetKeyHandler(NULL, KEY_CLEAR, KEY_EVENT_DOWN);
  554.     #endif /* !defined(__MMI_WITH_C_KEY__) */ 
  555.     #if defined(__MMI_TOUCH_SCREEN__)
  556.         mmi_pen_editor_disable_input(PEN_EDITOR_DISABLE_HANDWRITNG | PEN_EDITOR_DISABLE_VIRTUAL_KEYBOARD);
  557.         ChangeRightSoftkey(STR_ID_UNITCONVERTOR_RESET, 0);
  558.     #endif /* defined(__MMI_TOUCH_SCREEN__) */ 
  559.     }
  560. #endif /* __MMI_CONVERTER_KEEP_INLINE_FOCUS__ */ 
  561. }
  562. #ifdef __MMI_UNIT_CONVERTER__
  563. /*****************************************************************************
  564.  * FUNCTION
  565.  *  HighlightUConvLength
  566.  * DESCRIPTION
  567.  *  Highlight handler of Length menu in Unit Convertor
  568.  *  Register key handlers.
  569.  * PARAMETERS
  570.  *  void
  571.  * RETURNS
  572.  *  void
  573.  *****************************************************************************/
  574. void HighlightUConvLength(void)
  575. {
  576.     /*----------------------------------------------------------------*/
  577.     /* Local Variables                                                */
  578.     /*----------------------------------------------------------------*/
  579.     /*----------------------------------------------------------------*/
  580.     /* Code Body                                                      */
  581.     /*----------------------------------------------------------------*/
  582.     g_uconv_cntx->CurrHiliteUnitType = UCONV_LENGTH;
  583.     SetLeftSoftkeyFunction(UConvGoToComputeScreen, KEY_EVENT_UP);
  584.     SetKeyHandler(UConvGoToComputeScreen, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  585. }
  586. /*****************************************************************************
  587.  * FUNCTION
  588.  *  HighlightUConvWeight
  589.  * DESCRIPTION
  590.  *  Highlight handler of Weight menu in Unit Convertor
  591.  *  Register key handlers.
  592.  * PARAMETERS
  593.  *  void
  594.  * RETURNS
  595.  *  void
  596.  *****************************************************************************/
  597. void HighlightUConvWeight(void)
  598. {
  599.     /*----------------------------------------------------------------*/
  600.     /* Local Variables                                                */
  601.     /*----------------------------------------------------------------*/
  602.     /*----------------------------------------------------------------*/
  603.     /* Code Body                                                      */
  604.     /*----------------------------------------------------------------*/
  605.     g_uconv_cntx->CurrHiliteUnitType = UCONV_WEIGHT;
  606.     SetLeftSoftkeyFunction(UConvGoToComputeScreen, KEY_EVENT_UP);
  607.     SetKeyHandler(UConvGoToComputeScreen, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  608. }
  609. /*****************************************************************************
  610.  * FUNCTION
  611.  *  UConvFillInlineStruct
  612.  * DESCRIPTION
  613.  *  Fill inline structure of inline items in Length convertor
  614.  * PARAMETERS
  615.  *  void
  616.  *  UnitType(?)     [IN]        Type of unit   0 == length, 1 == weight
  617.  * RETURNS
  618.  *  void
  619.  *****************************************************************************/
  620. void UConvFillInlineStruct(void)
  621. {
  622.     /*----------------------------------------------------------------*/
  623.     /* Local Variables                                                */
  624.     /*----------------------------------------------------------------*/
  625.     UI_character_type *Caption1, *Caption2;
  626.     /*----------------------------------------------------------------*/
  627.     /* Code Body                                                      */
  628.     /*----------------------------------------------------------------*/
  629.     DisableInlineInputMethodHints();
  630.     if (g_uconv_cntx->CurrHiliteUnitType == UCONV_LENGTH)   /* length */
  631.     {
  632.         g_uconv_cntx->UnitList[0] = GetString(STR_UNITCONVERTOR_KMMILE);
  633.         g_uconv_cntx->UnitList[1] = GetString(STR_UNITCONVERTOR_MYARD);
  634.         g_uconv_cntx->UnitList[2] = GetString(STR_UNITCONVERTOR_MFOOT);
  635.         g_uconv_cntx->UnitList[3] = GetString(STR_UNITCONVERTOR_CMINCH);
  636.         /* caption strings */
  637.         Caption2 =
  638.             (UI_character_type*) (GetString((U16) (STR_UNITCONVERTOR_MILE + g_uconv_cntx->CurrInlineSelectUnit)));
  639.         switch (g_uconv_cntx->CurrInlineSelectUnit)
  640.         {
  641.             case 0:
  642.                 Caption1 = (UI_character_type*) (GetString(STR_UNITCONVERTOR_KM));
  643.                 break;
  644.             case 3:
  645.                 Caption1 = (UI_character_type*) (GetString(STR_UNITCONVERTOR_CM));
  646.                 break;
  647.             default:
  648.                 Caption1 = (UI_character_type*) (GetString(STR_UNITCONVERTOR_METER));
  649.                 break;
  650.         }
  651.         /* units */
  652.         SetInlineItemSelect(
  653.             &wgui_inline_items[UCONV_UNIT],
  654.             4,
  655.             (U8 **) g_uconv_cntx->UnitList,
  656.             &g_uconv_cntx->CurrInlineSelectUnit);
  657.         RegisterInlineSelectHighlightHandler(&wgui_inline_items[UCONV_UNIT], HighlightUConvInlineLenghSelect);
  658.     }
  659.     else    /* weight */
  660.     {
  661.         g_uconv_cntx->UnitList[0] = GetString(STR_UNITCONVERTOR_KGPOUND);
  662.         Caption1 = (UI_character_type*) (GetString(STR_UNITCONVERTOR_KG));
  663.         g_uconv_cntx->UnitList[1] = GetString(STR_UCONV_KGOUNCE);
  664.         if (g_uconv_cntx->CurrInlineSelectUnit == 0)    /* kg <-> pound */
  665.         {
  666.             Caption2 = (UI_character_type*) (GetString(STR_UNITCONVERTOR_POUND));
  667.         }
  668.         else    /* Kg <-> Ounce */
  669.         {
  670.             Caption2 = (UI_character_type*) (GetString(STR_UCONV_OUNCE));
  671.         }
  672.         /* unit */
  673.         SetInlineItemSelect(
  674.             &wgui_inline_items[UCONV_UNIT],
  675.             2,
  676.             (U8 **) g_uconv_cntx->UnitList,
  677.             &g_uconv_cntx->CurrInlineSelectUnit);
  678.         RegisterInlineSelectHighlightHandler(&wgui_inline_items[UCONV_UNIT], HighlightUConvInlineWeightSelect);
  679.     }
  680.     SetInlineItemActivation(&wgui_inline_items[UCONV_UNIT], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  681.     /* metric caption */
  682.     SetInlineItemActivation(&wgui_inline_items[UCONV_METRIC_CAP], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  683.     SetInlineItemCaption(&wgui_inline_items[UCONV_METRIC_CAP], (U8*) Caption1);
  684.     /* metric unit */
  685.     SetInlineItemActivation(&wgui_inline_items[UCONV_METIRC], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  686.     SetInlineItemTextEdit(
  687.         &wgui_inline_items[UCONV_METIRC],
  688.         (U8*) g_uconv_cntx->MetricBuf,
  689.         (UCONV_MAX_INPUT + 1),
  690.         INPUT_TYPE_DECIMAL_NUMERIC);
  691.     EnableInlineItemBoundary(&wgui_inline_items[UCONV_METIRC]);
  692.     RightJustifyInlineItem(&wgui_inline_items[UCONV_METIRC]);
  693.     SetInlineTextEditCustomFunction(&wgui_inline_items[UCONV_METIRC], UConvCustomInlineFunction);
  694.     /* English caption */
  695.     SetInlineItemActivation(&wgui_inline_items[UCONV_ENG_CAP], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  696.     SetInlineItemCaption(&wgui_inline_items[UCONV_ENG_CAP], (U8*) Caption2);
  697.     /* English unit */
  698.     SetInlineItemActivation(&wgui_inline_items[UCONV_ENG], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  699.     SetInlineItemTextEdit(
  700.         &wgui_inline_items[UCONV_ENG],
  701.         (U8*) g_uconv_cntx->EngBuf,
  702.         (UCONV_MAX_INPUT + 1),
  703.         INPUT_TYPE_DECIMAL_NUMERIC);
  704.     EnableInlineItemBoundary(&wgui_inline_items[UCONV_ENG]);
  705.     RightJustifyInlineItem(&wgui_inline_items[UCONV_ENG]);
  706.     SetInlineTextEditCustomFunction(&wgui_inline_items[UCONV_ENG], UConvCustomInlineFunction);
  707. }
  708. /*****************************************************************************
  709.  * FUNCTION
  710.  *  ComputeLengthResult
  711.  * DESCRIPTION
  712.  *  To calculate the result of length conversion
  713.  * PARAMETERS
  714.  *  void
  715.  * RETURNS
  716.  *  void
  717.  *****************************************************************************/
  718. void ComputeLengthResult(void)
  719. {
  720.     /*----------------------------------------------------------------*/
  721.     /* Local Variables                                                */
  722.     /*----------------------------------------------------------------*/
  723.     DOUBLE conversion_factor;
  724.     S32 precision = 0;  /* ,temp_int = 0; */
  725.     DOUBLE result;
  726.     UI_character_type *ResultBuf = NULL, *SourceBuf = NULL;
  727.     S32 len;
  728.     /*----------------------------------------------------------------*/
  729.     /* Code Body                                                      */
  730.     /*----------------------------------------------------------------*/
  731.     CloseCategory57Screen();
  732.     /* conversion rate */
  733.     switch (g_uconv_cntx->CurrInlineSelectUnit)
  734.     {
  735.         case 0:
  736.             conversion_factor = KM2MILE;    /* 0.62137 */
  737.             break;
  738.         case 1:
  739.             conversion_factor = M2YARD;     /* 1.09361 */
  740.             break;
  741.         case 2:
  742.             conversion_factor = M2FOOT;     /* 3.28084 */
  743.             break;
  744.         default:                            /* case 3: */
  745.             conversion_factor = CM2INCH;    /* 0.3937 */
  746.             break;
  747.     }
  748.     if (g_uconv_cntx->CurrSelectedItem == UCONV_METIRC)
  749.     {
  750.         SourceBuf = g_uconv_cntx->MetricBuf;
  751.         ResultBuf = g_uconv_cntx->EngBuf;
  752.     }
  753.     else
  754.     {
  755.         SourceBuf = g_uconv_cntx->EngBuf;
  756.         ResultBuf = g_uconv_cntx->MetricBuf;
  757.         conversion_factor = 1 / conversion_factor;
  758.     }
  759.     len = gui_strlen((UI_string_type) SourceBuf);
  760.     if ((len == 0) || ((len == 1) && (SourceBuf[0] == 46)))
  761.     {
  762.         DisplayPopup(
  763.             (U8*) GetString(UC_ERROR_EMPTY_STRING),
  764.             IMG_GLOBAL_WARNING,
  765.             0,
  766.             UI_POPUP_NOTIFYDURATION_TIME,
  767.             WARNING_TONE);
  768.         return;
  769.     }
  770.     g_uconv_cntx->ClearResultFlag = TRUE;
  771.     result = (DOUBLE) (conversion_factor * gui_atof(SourceBuf));
  772.     precision = CalcComputePrecision(result, (S16) UCONV_MAX_RESULT);
  773.     gui_float_string(result, precision, (S8*) ResultBuf);
  774.     UConvRedrawResult();
  775.     SetLeftSoftkeyFunction(ComputeLengthResult, KEY_EVENT_UP);
  776. }
  777. /*****************************************************************************
  778.  * FUNCTION
  779.  *  ComputeWeightResult
  780.  * DESCRIPTION
  781.  *  To calculate the result of weight conversion
  782.  * PARAMETERS
  783.  *  void
  784.  * RETURNS
  785.  *  void
  786.  *****************************************************************************/
  787. void ComputeWeightResult(void)
  788. {
  789.     /*----------------------------------------------------------------*/
  790.     /* Local Variables                                                */
  791.     /*----------------------------------------------------------------*/
  792.     DOUBLE result = 0;
  793.     S32 prec_val = 0;
  794.     DOUBLE conversion_factor = 0;
  795.     UI_character_type *ResultBuf = NULL, *SourceBuf = NULL;
  796.     S32 len;
  797.     /*----------------------------------------------------------------*/
  798.     /* Code Body                                                      */
  799.     /*----------------------------------------------------------------*/
  800.     CloseCategory57Screen();
  801.     /* determine rate */
  802.     if (g_uconv_cntx->CurrInlineSelectUnit == 0)    /* Kg to Pound */
  803.     {
  804.         conversion_factor = KG2POUND;
  805.     }
  806.     else
  807.     {
  808.         conversion_factor = KG2OUNCE;
  809.     }
  810.     /* determine conversion direction */
  811.     if (g_uconv_cntx->CurrSelectedItem == UCONV_METIRC)
  812.     {
  813.         SourceBuf = g_uconv_cntx->MetricBuf;
  814.         ResultBuf = g_uconv_cntx->EngBuf;
  815.     }
  816.     else    /* UCONV_ENGLISH */
  817.     {
  818.         SourceBuf = g_uconv_cntx->EngBuf;
  819.         ResultBuf = g_uconv_cntx->MetricBuf;
  820.         conversion_factor = 1 / conversion_factor;
  821.     }
  822.     len = gui_strlen((UI_string_type) SourceBuf);
  823.     if ((len == 0) || ((len == 1) && (ResultBuf[0] == 46)))
  824.     {
  825.         DisplayPopup(
  826.             (U8*) GetString(UC_ERROR_EMPTY_STRING),
  827.             IMG_GLOBAL_WARNING,
  828.             0,
  829.             UI_POPUP_NOTIFYDURATION_TIME,
  830.             WARNING_TONE);
  831.         return;
  832.     }
  833.     g_uconv_cntx->ClearResultFlag = TRUE;
  834.     result = (DOUBLE) (conversion_factor * gui_atof(SourceBuf));
  835.     prec_val = CalcComputePrecision(result, UCONV_MAX_RESULT);
  836.     gui_float_string(result, prec_val, (S8*) ResultBuf);
  837.     UConvRedrawResult();
  838.     SetLeftSoftkeyFunction(ComputeWeightResult, KEY_EVENT_UP);
  839. }
  840. /*****************************************************************************
  841.  * FUNCTION
  842.  *  UConvGoToComputeScreen
  843.  * DESCRIPTION
  844.  *  Intialize state variables and enter weight convertor
  845.  * PARAMETERS
  846.  *  void
  847.  * RETURNS
  848.  *  void
  849.  *****************************************************************************/
  850. void UConvGoToComputeScreen(void)
  851. {
  852.     /*----------------------------------------------------------------*/
  853.     /* Local Variables                                                */
  854.     /*----------------------------------------------------------------*/
  855.     /*----------------------------------------------------------------*/
  856.     /* Code Body                                                      */
  857.     /*----------------------------------------------------------------*/
  858.     g_uconv_cntx->CurrInlineSelectUnit = 0;
  859.     g_uconv_cntx->CurrSelectedItem = 0;
  860.     memset(g_uconv_cntx->EngBuf, 0, 2);
  861.     memset(g_uconv_cntx->MetricBuf, 0, 2);
  862.     EntryUConvCompute();
  863. }
  864. /*****************************************************************************
  865.  * FUNCTION
  866.  *  ExitUConvCompute
  867.  * DESCRIPTION
  868.  *  Exit function of conterting screen
  869.  * PARAMETERS
  870.  *  void
  871.  * RETURNS
  872.  *  void
  873.  *****************************************************************************/
  874. void ExitUConvCompute(void)
  875. {
  876.     /*----------------------------------------------------------------*/
  877.     /* Local Variables                                                */
  878.     /*----------------------------------------------------------------*/
  879.     history HistoryUCWeight;
  880.     U16 inputBufferSize;    /* added for inline edit history */
  881.     S16 nHistory = 0;
  882.     /*----------------------------------------------------------------*/
  883.     /* Code Body                                                      */
  884.     /*----------------------------------------------------------------*/
  885.     set_leading_zero(TRUE);
  886.     if (g_uconv_cntx)
  887.     {
  888.         CloseCategory57Screen();
  889.         HistoryUCWeight.scrnID = SCR_ID_UCONV_WEIGHT + g_uconv_cntx->CurrHiliteUnitType;
  890.     }
  891.     HistoryUCWeight.entryFuncPtr = EntryUConvCompute;
  892.     GetCategory57History(HistoryUCWeight.guiBuffer);
  893.     pfnUnicodeStrcpy((S8*) HistoryUCWeight.inputBuffer, (S8*) & nHistory);
  894.     inputBufferSize = (U16) GetCategory57DataSize();        /* added for inline edit history */
  895.     GetCategory57Data((U8*) HistoryUCWeight.inputBuffer);   /* added for inline edit history */
  896.     AddNHistory(HistoryUCWeight, inputBufferSize);          /* added for inline edit history */
  897. }
  898. /*****************************************************************************
  899.  * FUNCTION
  900.  *  EntryUConvCompute
  901.  * DESCRIPTION
  902.  *  Entry function of conterting screen
  903.  * PARAMETERS
  904.  *  void
  905.  * RETURNS
  906.  *  void
  907.  *****************************************************************************/
  908. void EntryUConvCompute(void)
  909. {
  910.     /*----------------------------------------------------------------*/
  911.     /* Local Variables                                                */
  912.     /*----------------------------------------------------------------*/
  913.     U8 *guiBuffer;
  914.     U8 *inputBuffer;        /* added for inline edit history */
  915.     U16 inputBufferSize;    /* added for inline edit history */
  916.     U16 ScrID = (SCR_ID_UCONV_WEIGHT + g_uconv_cntx->CurrHiliteUnitType);
  917.     /*----------------------------------------------------------------*/
  918.     /* Code Body                                                      */
  919.     /*----------------------------------------------------------------*/
  920.     EntryNewScreen(ScrID, ExitUConvCompute, NULL, NULL);
  921.     SetDelScrnIDCallbackHandler(ScrID, (HistoryDelCBPtr) mmi_uconv_del_scr_callback);
  922.     set_leading_zero(FALSE);
  923.     guiBuffer = GetCurrGuiBuffer(ScrID);
  924.     InitializeCategory57Screen();
  925.     UConvFillInlineStruct();
  926.     RegisterHighlightHandler(HighlightUConvInlineItem);
  927.     inputBuffer = GetCurrNInputBuffer(ScrID, &inputBufferSize); /* added for inline edit history */
  928.     if (inputBuffer)    /* added for inline edit history */
  929.     {
  930.         SetCategory57Data(wgui_inline_items, UCONV_INLINE_TOTAL, inputBuffer);  /* sets the data */
  931.     }
  932.     DisableCategory57ScreenDone();
  933.     ShowCategory57Screen(
  934.         STR_UNITCONVERTOR_CAPTION1,
  935.         GetRootTitleIcon(EXTRA_UNITCONVERTOR_MENU),
  936.         STR_GLOBAL_OK,
  937.         IMG_GLOBAL_OK,
  938.         STR_GLOBAL_BACK,
  939.         IMG_GLOBAL_BACK,
  940.         UCONV_INLINE_TOTAL,
  941.         NULL,
  942.         wgui_inline_items,
  943.         g_uconv_cntx->CurrSelectedItem,
  944.         guiBuffer);
  945.     if (g_uconv_cntx->CurrHiliteUnitType == UCONV_WEIGHT)
  946.     {
  947.         SetCategory57RightSoftkeyFunctions(ComputeWeightResult, GoBackHistory);
  948.     }
  949.     else
  950.     {
  951.         SetCategory57RightSoftkeyFunctions(ComputeLengthResult, GoBackHistory);
  952.     }
  953. }
  954. /*****************************************************************************
  955.  * FUNCTION
  956.  *  HighlightUConvInlineItem
  957.  * DESCRIPTION
  958.  *  Highlight handler of inline items
  959.  * PARAMETERS
  960.  *  index       [IN]        
  961.  * RETURNS
  962.  *  void
  963.  *****************************************************************************/
  964. void HighlightUConvInlineItem(S32 index)
  965. {
  966.     /*----------------------------------------------------------------*/
  967.     /* Local Variables                                                */
  968.     /*----------------------------------------------------------------*/
  969.     /*----------------------------------------------------------------*/
  970.     /* Code Body                                                      */
  971.     /*----------------------------------------------------------------*/
  972.     if (index == 0) /* inline selection */
  973.     {
  974.         ChangeLeftSoftkey(STRING_ID_NULL, IMAGE_ID_NULL);
  975.         ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  976.         SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  977.     }
  978.     else
  979.     {
  980.     #ifdef __MMI_CONVERTER_KEEP_INLINE_FOCUS__
  981.         if ((U8) index != g_uconv_cntx->CurrSelectedItem)
  982.         {
  983.             memset(g_uconv_cntx->MetricBuf, 0, 2);
  984.             memset(g_uconv_cntx->EngBuf, 0, 2);
  985.         }
  986.         /* if re-entry screen because of displaying result */
  987. else if(!g_uconv_cntx->ClearResultFlag && *(g_uconv_cntx->EngBuf) != 0 && *(g_uconv_cntx->MetricBuf) != 0)
  988. {
  989.             g_uconv_cntx->ClearResultFlag = TRUE;
  990.         }
  991.         ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  992.         if (g_uconv_cntx->CurrHiliteUnitType == UCONV_WEIGHT)
  993.         {
  994.             SetLeftSoftkeyFunction(ComputeWeightResult, KEY_EVENT_UP);
  995.         }
  996.         else
  997.         {
  998.             SetLeftSoftkeyFunction(ComputeLengthResult, KEY_EVENT_UP);
  999.         }
  1000.     #else /* __MMI_CONVERTER_KEEP_INLINE_FOCUS__ */ 
  1001.         if (index != g_uconv_cntx->CurrSelectedItem)
  1002.         {
  1003.             memset(g_uconv_cntx->MetricBuf, 0, 2);
  1004.             memset(g_uconv_cntx->EngBuf, 0, 2);
  1005.         }
  1006.         ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  1007.         if (g_uconv_cntx->CurrHiliteUnitType == UCONV_WEIGHT)
  1008.         {
  1009.             SetLeftSoftkeyFunction(ComputeWeightResult, KEY_EVENT_UP);
  1010.         }
  1011.         else
  1012.         {
  1013.             SetLeftSoftkeyFunction(ComputeLengthResult, KEY_EVENT_UP);
  1014.         }
  1015.     #endif /* __MMI_CONVERTER_KEEP_INLINE_FOCUS__ */ 
  1016.     }
  1017.     g_uconv_cntx->CurrSelectedItem = (U8) index;
  1018.     return;
  1019. }
  1020. /*****************************************************************************
  1021.  * FUNCTION
  1022.  *  HighlightUConvInlineWeightSelect
  1023.  * DESCRIPTION
  1024.  *  Highlight handler inline selection item in Weight convertor.
  1025.  *  Redraw caption according to select.
  1026.  * PARAMETERS
  1027.  *  index       [IN]        
  1028.  * RETURNS
  1029.  *  void
  1030.  *****************************************************************************/
  1031. void HighlightUConvInlineWeightSelect(S32 index)
  1032. {
  1033.     /*----------------------------------------------------------------*/
  1034.     /* Local Variables                                                */
  1035.     /*----------------------------------------------------------------*/
  1036.     UI_character_type *Caption1, *Caption2;
  1037.     /*----------------------------------------------------------------*/
  1038.     /* Code Body                                                      */
  1039.     /*----------------------------------------------------------------*/
  1040.     g_uconv_cntx->CurrInlineSelectUnit = (U8) index;
  1041.     Caption1 = (UI_character_type*) (GetString(STR_UNITCONVERTOR_KG));
  1042.     if (index == 0) /* Kg <-> Pound */
  1043.     {
  1044.         Caption2 = (UI_character_type*) (GetString(STR_UNITCONVERTOR_POUND));
  1045.     }
  1046.     else
  1047.     {
  1048.         Caption2 = (UI_character_type*) (GetString(STR_UCONV_OUNCE));
  1049.     }
  1050.     memset(g_uconv_cntx->MetricBuf, 0, 2);
  1051.     memset(g_uconv_cntx->EngBuf, 0, 2);
  1052.     Category57ChangeItemText(1, (U8*) Caption1);
  1053.     Category57ChangeItemText(3, (U8*) Caption2);
  1054.     RedrawCategoryFunction();
  1055. }
  1056. /*****************************************************************************
  1057.  * FUNCTION
  1058.  *  HighlightUConvInlineLenghSelect
  1059.  * DESCRIPTION
  1060.  *  Highlight handler inline selection item in Length convertor.
  1061.  *  Redraw caption according to select.
  1062.  * PARAMETERS
  1063.  *  index       [IN]        
  1064.  * RETURNS
  1065.  *  void
  1066.  *****************************************************************************/
  1067. void HighlightUConvInlineLenghSelect(S32 index)
  1068. {
  1069.     /*----------------------------------------------------------------*/
  1070.     /* Local Variables                                                */
  1071.     /*----------------------------------------------------------------*/
  1072.     UI_character_type *Caption1, *Caption2;
  1073.     /*----------------------------------------------------------------*/
  1074.     /* Code Body                                                      */
  1075.     /*----------------------------------------------------------------*/
  1076.     g_uconv_cntx->CurrInlineSelectUnit = index;
  1077.     Caption2 = (UI_character_type*) (GetString((U16) (STR_UNITCONVERTOR_MILE + g_uconv_cntx->CurrInlineSelectUnit)));
  1078.     switch (g_uconv_cntx->CurrInlineSelectUnit)
  1079.     {
  1080.         case 0:
  1081.             Caption1 = (UI_character_type*) (GetString(STR_UNITCONVERTOR_KM));
  1082.             break;
  1083.         case 3:
  1084.             Caption1 = (UI_character_type*) (GetString(STR_UNITCONVERTOR_CM));
  1085.             break;
  1086.         default:
  1087.             Caption1 = (UI_character_type*) (GetString(STR_UNITCONVERTOR_METER));
  1088.             break;
  1089.     }
  1090.     memset(g_uconv_cntx->MetricBuf, 0, 2);
  1091.     memset(g_uconv_cntx->EngBuf, 0, 2);
  1092.     Category57ChangeItemText(1, (U8*) Caption1);
  1093.     Category57ChangeItemText(3, (U8*) Caption2);
  1094.     RedrawCategoryFunction();
  1095. }
  1096. #else /* __MMI_UNIT_CONVERTER__ */ /* else of ifdef __MMI_UNIT_CONVERTER__ */
  1097. /*****************************************************************************
  1098.  * FUNCTION
  1099.  *  mmi_uconv_highlight_volume
  1100.  * DESCRIPTION
  1101.  *  Highlight handler of Volume menu in Unit Convertor
  1102.  *  Register key handlers.
  1103.  * PARAMETERS
  1104.  *  void
  1105.  * RETURNS
  1106.  *  void
  1107.  *****************************************************************************/
  1108. void mmi_uconv_highlight_volume(void)
  1109. {
  1110.     /*----------------------------------------------------------------*/
  1111.     /* Local Variables                                                */
  1112.     /*----------------------------------------------------------------*/
  1113.     /*----------------------------------------------------------------*/
  1114.     /* Code Body                                                      */
  1115.     /*----------------------------------------------------------------*/
  1116.     g_uconv_cntx->CurrHiliteUnitType = UCONV_VOLUME;
  1117.     SetLeftSoftkeyFunction(mmi_uconv_goto_compute_screen_lg, KEY_EVENT_UP);
  1118.     SetKeyHandler(mmi_uconv_goto_compute_screen_lg, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1119. }
  1120. /*****************************************************************************
  1121.  * FUNCTION
  1122.  *  mmi_uconv_highlight_temperature
  1123.  * DESCRIPTION
  1124.  *  Highlight handler of Temperature menu in Unit Convertor
  1125.  *  Register key handlers.
  1126.  * PARAMETERS
  1127.  *  void
  1128.  * RETURNS
  1129.  *  void
  1130.  *****************************************************************************/
  1131. void mmi_uconv_highlight_temperature(void)
  1132. {
  1133.     /*----------------------------------------------------------------*/
  1134.     /* Local Variables                                                */
  1135.     /*----------------------------------------------------------------*/
  1136.     /*----------------------------------------------------------------*/
  1137.     /* Code Body                                                      */
  1138.     /*----------------------------------------------------------------*/
  1139.     g_uconv_cntx->CurrHiliteUnitType = UCONV_TEMPERATURE;
  1140.     SetLeftSoftkeyFunction(mmi_uconv_goto_compute_screen_lg, KEY_EVENT_UP);
  1141.     SetKeyHandler(mmi_uconv_goto_compute_screen_lg, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1142. }
  1143. /*****************************************************************************
  1144.  * FUNCTION
  1145.  *  mmi_uconv_highlight_velocity
  1146.  * DESCRIPTION
  1147.  *  Highlight handler of Velocity menu in Unit Convertor
  1148.  *  Register key handlers.
  1149.  * PARAMETERS
  1150.  *  void
  1151.  * RETURNS
  1152.  *  void
  1153.  *****************************************************************************/
  1154. void mmi_uconv_highlight_velocity(void)
  1155. {
  1156.     /*----------------------------------------------------------------*/
  1157.     /* Local Variables                                                */
  1158.     /*----------------------------------------------------------------*/
  1159.     /*----------------------------------------------------------------*/
  1160.     /* Code Body                                                      */
  1161.     /*----------------------------------------------------------------*/
  1162.     g_uconv_cntx->CurrHiliteUnitType = UCONV_VELOCITY;
  1163.     SetLeftSoftkeyFunction(mmi_uconv_goto_compute_screen_lg, KEY_EVENT_UP);
  1164.     SetKeyHandler(mmi_uconv_goto_compute_screen_lg, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1165. }
  1166. /*****************************************************************************
  1167.  * FUNCTION
  1168.  *  mmi_uconv_highlight_length
  1169.  * DESCRIPTION
  1170.  *  Highlight handler of Length menu in Unit Convertor
  1171.  *  Register key handlers.
  1172.  * PARAMETERS
  1173.  *  void
  1174.  * RETURNS
  1175.  *  void
  1176.  *****************************************************************************/
  1177. void mmi_uconv_highlight_length(void)
  1178. {
  1179.     /*----------------------------------------------------------------*/
  1180.     /* Local Variables                                                */
  1181.     /*----------------------------------------------------------------*/
  1182.     /*----------------------------------------------------------------*/
  1183.     /* Code Body                                                      */
  1184.     /*----------------------------------------------------------------*/
  1185.     g_uconv_cntx->CurrHiliteUnitType = UCONV_LENGTH;
  1186.     SetLeftSoftkeyFunction(mmi_uconv_goto_compute_screen_lg, KEY_EVENT_UP);
  1187.     SetKeyHandler(mmi_uconv_goto_compute_screen_lg, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1188. }
  1189. /*****************************************************************************
  1190.  * FUNCTION
  1191.  *  mmi_uconv_highlight_weight
  1192.  * DESCRIPTION
  1193.  *  Highlight handler of Weight menu in Unit Convertor
  1194.  *  Register key handlers.
  1195.  * PARAMETERS
  1196.  *  void
  1197.  * RETURNS
  1198.  *  void
  1199.  *****************************************************************************/
  1200. void mmi_uconv_highlight_weight(void)
  1201. {
  1202.     /*----------------------------------------------------------------*/
  1203.     /* Local Variables                                                */
  1204.     /*----------------------------------------------------------------*/
  1205.     /*----------------------------------------------------------------*/
  1206.     /* Code Body                                                      */
  1207.     /*----------------------------------------------------------------*/
  1208.     g_uconv_cntx->CurrHiliteUnitType = UCONV_WEIGHT;
  1209.     SetLeftSoftkeyFunction(mmi_uconv_goto_compute_screen_lg, KEY_EVENT_UP);
  1210.     SetKeyHandler(mmi_uconv_goto_compute_screen_lg, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1211. }
  1212. /*****************************************************************************
  1213.  * FUNCTION
  1214.  *  mmi_uconv_highlight_shoes
  1215.  * DESCRIPTION
  1216.  *  Highlight handler of Shoes menu in Unit Convertor
  1217.  *  Register key handlers.
  1218.  * PARAMETERS
  1219.  *  void
  1220.  * RETURNS
  1221.  *  void
  1222.  *****************************************************************************/
  1223. void mmi_uconv_highlight_shoes(void)
  1224. {
  1225.     /*----------------------------------------------------------------*/
  1226.     /* Local Variables                                                */
  1227.     /*----------------------------------------------------------------*/
  1228.     /*----------------------------------------------------------------*/
  1229.     /* Code Body                                                      */
  1230.     /*----------------------------------------------------------------*/
  1231.     g_uconv_cntx->CurrHiliteUnitType = UCONV_SHOES;
  1232.     SetLeftSoftkeyFunction(mmi_uconv_goto_compute_screen_lg, KEY_EVENT_UP);
  1233.     SetKeyHandler(mmi_uconv_goto_compute_screen_lg, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1234. }
  1235. /*****************************************************************************
  1236.  * FUNCTION
  1237.  *  mmi_uconv_highlight_clothes
  1238.  * DESCRIPTION
  1239.  *  Highlight handler of Clothes menu in Unit Convertor
  1240.  *  Register key handlers.
  1241.  * PARAMETERS
  1242.  *  void
  1243.  * RETURNS
  1244.  *  void
  1245.  *****************************************************************************/
  1246. void mmi_uconv_highlight_clothes(void)
  1247. {
  1248.     /*----------------------------------------------------------------*/
  1249.     /* Local Variables                                                */
  1250.     /*----------------------------------------------------------------*/
  1251.     /*----------------------------------------------------------------*/
  1252.     /* Code Body                                                      */
  1253.     /*----------------------------------------------------------------*/
  1254.     g_uconv_cntx->CurrHiliteUnitType = UCONV_CLOTHES;
  1255.     SetLeftSoftkeyFunction(mmi_uconv_goto_compute_screen_lg, KEY_EVENT_UP);
  1256.     SetKeyHandler(mmi_uconv_goto_compute_screen_lg, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1257. }
  1258. /*****************************************************************************
  1259.  * FUNCTION
  1260.  *  mmi_uconv_highlight_surface
  1261.  * DESCRIPTION
  1262.  *  Highlight handler of Surface menu in Unit Convertor
  1263.  *  Register key handlers.
  1264.  * PARAMETERS
  1265.  *  void
  1266.  * RETURNS
  1267.  *  void
  1268.  *****************************************************************************/
  1269. void mmi_uconv_highlight_surface(void)
  1270. {
  1271.     /*----------------------------------------------------------------*/
  1272.     /* Local Variables                                                */
  1273.     /*----------------------------------------------------------------*/
  1274.     /*----------------------------------------------------------------*/
  1275.     /* Code Body                                                      */
  1276.     /*----------------------------------------------------------------*/
  1277.     g_uconv_cntx->CurrHiliteUnitType = UCONV_SURFACE;
  1278.     SetLeftSoftkeyFunction(mmi_uconv_goto_compute_screen_lg, KEY_EVENT_UP);
  1279.     SetKeyHandler(mmi_uconv_goto_compute_screen_lg, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1280. }
  1281. /*****************************************************************************
  1282.  * FUNCTION
  1283.  *  mmi_uconv_fill_inline_struct_lg
  1284.  * DESCRIPTION
  1285.  *  Fill inline structure of inline items in convertor with LG style
  1286.  * PARAMETERS
  1287.  *  void
  1288.  * RETURNS
  1289.  *  void
  1290.  *****************************************************************************/
  1291. void mmi_uconv_fill_inline_struct_lg(void)
  1292. {
  1293.     /*----------------------------------------------------------------*/
  1294.     /* Local Variables                                                */
  1295.     /*----------------------------------------------------------------*/
  1296.     S8 ansii_str_i[32], unicode_str_o[32];
  1297.     /*----------------------------------------------------------------*/
  1298.     /* Code Body                                                      */
  1299.     /*----------------------------------------------------------------*/
  1300.     DisableInlineInputMethodHints();
  1301.     /* Selectors */
  1302.     SetInlineItemActivation(&wgui_inline_items[UCONV_UNIT1], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1303.     SetInlineItemActivation(&wgui_inline_items[UCONV_UNIT2], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1304.     /* unit1 input */
  1305.     SetInlineItemActivation(&wgui_inline_items[UCONV_INPUT1], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1306.     SetInlineItemTextEdit(
  1307.         &wgui_inline_items[UCONV_INPUT1],
  1308.         (U8*) g_uconv_cntx->InputBuf1,
  1309.         (UCONV_MAX_INPUT + 1),
  1310.         INPUT_TYPE_DECIMAL_NUMERIC);
  1311.     EnableInlineItemBoundary(&wgui_inline_items[UCONV_INPUT1]);
  1312.     RightJustifyInlineItem(&wgui_inline_items[UCONV_INPUT1]);
  1313.     /* unit2 result */
  1314.     SetInlineItemActivation(&wgui_inline_items[UCONV_RESULT], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1315.     SetInlineItemTextEdit(
  1316.         &wgui_inline_items[UCONV_RESULT],
  1317.         (U8*) g_uconv_cntx->InputBuf2,
  1318.         (UCONV_MAX_INPUT + 1),
  1319.         INPUT_TYPE_DECIMAL_NUMERIC);
  1320.     EnableInlineItemBoundary(&wgui_inline_items[UCONV_RESULT]);
  1321.     RightJustifyInlineItem(&wgui_inline_items[UCONV_RESULT]);
  1322.     DisableInlineItem(&wgui_inline_items[UCONV_RESULT], UCONV_RESULT);
  1323.     if (g_uconv_cntx->CurrHiliteUnitType == UCONV_LENGTH)   /* length */
  1324.     {
  1325.         g_uconv_cntx->UnitListLg[0] = GetString(STR_ID_UNITCONVERTOR_LENGTH_MM);
  1326.         g_uconv_cntx->UnitListLg[1] = GetString(STR_ID_UNITCONVERTOR_LENGTH_CM);
  1327.         g_uconv_cntx->UnitListLg[2] = GetString(STR_ID_UNITCONVERTOR_LENGTH_M);
  1328.         g_uconv_cntx->UnitListLg[3] = GetString(STR_ID_UNITCONVERTOR_LENGTH_KM);
  1329.         g_uconv_cntx->UnitListLg[4] = GetString(STR_ID_UNITCONVERTOR_LENGTH_INCH);
  1330.         g_uconv_cntx->UnitListLg[5] = GetString(STR_ID_UNITCONVERTOR_LENGTH_FEET);
  1331.         g_uconv_cntx->UnitListLg[6] = GetString(STR_ID_UNITCONVERTOR_LENGTH_YARD);
  1332.         g_uconv_cntx->UnitListLg[7] = GetString(STR_ID_UNITCONVERTOR_LENGTH_MILES);
  1333.         /* units */
  1334.         SetInlineItemSelect(
  1335.             &wgui_inline_items[UCONV_UNIT1],
  1336.             UCONV_LENGTH_UNIT_NUM,
  1337.             (U8 **) g_uconv_cntx->UnitListLg,
  1338.             &g_uconv_cntx->CurrInlineSelectUnit1);
  1339.         SetInlineItemSelect(
  1340.             &wgui_inline_items[UCONV_UNIT2],
  1341.             UCONV_LENGTH_UNIT_NUM,
  1342.             (U8 **) g_uconv_cntx->UnitListLg,
  1343.             &g_uconv_cntx->CurrInlineSelectUnit2);
  1344.         RegisterInlineSelectHighlightHandler(&wgui_inline_items[UCONV_UNIT1], mmi_uconv_highlight_inline_select1);
  1345.         RegisterInlineSelectHighlightHandler(&wgui_inline_items[UCONV_UNIT2], mmi_uconv_highlight_inline_select2);
  1346.         RegisterInlineFullScreenEditValidationFunction(&wgui_inline_items[UCONV_INPUT1], mmi_uconv_compute_result);
  1347.     }
  1348.     else if (g_uconv_cntx->CurrHiliteUnitType == UCONV_WEIGHT)  /* weight */
  1349.     {
  1350.         g_uconv_cntx->UnitListLg[0] = GetString(STR_ID_UNITCONVERTOR_WEIGHT_MG);
  1351.         g_uconv_cntx->UnitListLg[1] = GetString(STR_ID_UNITCONVERTOR_WEIGHT_G);
  1352.         g_uconv_cntx->UnitListLg[2] = GetString(STR_ID_UNITCONVERTOR_WEIGHT_KG);
  1353.         g_uconv_cntx->UnitListLg[3] = GetString(STR_ID_UNITCONVERTOR_WEIGHT_TON);
  1354.         g_uconv_cntx->UnitListLg[4] = GetString(STR_ID_UNITCONVERTOR_WEIGHT_OUNCE);
  1355.         g_uconv_cntx->UnitListLg[5] = GetString(STR_ID_UNITCONVERTOR_WEIGHT_POUND);
  1356.         /* units */
  1357.         SetInlineItemSelect(
  1358.             &wgui_inline_items[UCONV_UNIT1],
  1359.             UCONV_WEIGHT_UNIT_NUM,
  1360.             (U8 **) g_uconv_cntx->UnitListLg,
  1361.             &g_uconv_cntx->CurrInlineSelectUnit1);
  1362.         SetInlineItemSelect(
  1363.             &wgui_inline_items[UCONV_UNIT2],
  1364.             UCONV_WEIGHT_UNIT_NUM,
  1365.             (U8 **) g_uconv_cntx->UnitListLg,
  1366.             &g_uconv_cntx->CurrInlineSelectUnit2);
  1367.         RegisterInlineSelectHighlightHandler(&wgui_inline_items[UCONV_UNIT1], mmi_uconv_highlight_inline_select1);
  1368.         RegisterInlineSelectHighlightHandler(&wgui_inline_items[UCONV_UNIT2], mmi_uconv_highlight_inline_select2);
  1369.         RegisterInlineFullScreenEditValidationFunction(&wgui_inline_items[UCONV_INPUT1], mmi_uconv_compute_result);
  1370.     }
  1371.     else if (g_uconv_cntx->CurrHiliteUnitType == UCONV_VOLUME)  /* volume */
  1372.     {
  1373.         g_uconv_cntx->UnitListLg[0] = GetString(STR_ID_UNITCONVERTOR_MILLILITER);
  1374.         g_uconv_cntx->UnitListLg[1] = GetString(STR_ID_UNITCONVERTOR_LITER);
  1375.         g_uconv_cntx->UnitListLg[2] = GetString(STR_ID_UNITCONVERTOR_CUBICMM);
  1376.         g_uconv_cntx->UnitListLg[3] = GetString(STR_ID_UNITCONVERTOR_CUBICCM);
  1377.         g_uconv_cntx->UnitListLg[4] = GetString(STR_ID_UNITCONVERTOR_CUBICMETER);
  1378.         g_uconv_cntx->UnitListLg[5] = GetString(STR_ID_UNITCONVERTOR_CUBICINCH);
  1379.         g_uconv_cntx->UnitListLg[6] = GetString(STR_ID_UNITCONVERTOR_GALLON);
  1380.         g_uconv_cntx->UnitListLg[7] = GetString(STR_ID_UNITCONVERTOR_LIQPT);
  1381.         g_uconv_cntx->UnitListLg[8] = GetString(STR_ID_UNITCONVERTOR_LIQOZ);
  1382.         g_uconv_cntx->UnitListLg[9] = GetString(STR_ID_UNITCONVERTOR_FLOZ);
  1383.         g_uconv_cntx->UnitListLg[10] = GetString(STR_ID_UNITCONVERTOR_BARREL);
  1384.         /* units */
  1385.         SetInlineItemSelect(
  1386.             &wgui_inline_items[UCONV_UNIT1],
  1387.             UCONV_VOLUME_UNIT_NUM,
  1388.             (U8 **) g_uconv_cntx->UnitListLg,
  1389.             &g_uconv_cntx->CurrInlineSelectUnit1);
  1390.         SetInlineItemSelect(
  1391.             &wgui_inline_items[UCONV_UNIT2],
  1392.             UCONV_VOLUME_UNIT_NUM,
  1393.             (U8 **) g_uconv_cntx->UnitListLg,
  1394.             &g_uconv_cntx->CurrInlineSelectUnit2);
  1395.         RegisterInlineSelectHighlightHandler(&wgui_inline_items[UCONV_UNIT1], mmi_uconv_highlight_inline_select1);
  1396.         RegisterInlineSelectHighlightHandler(&wgui_inline_items[UCONV_UNIT2], mmi_uconv_highlight_inline_select2);
  1397.         RegisterInlineFullScreenEditValidationFunction(&wgui_inline_items[UCONV_INPUT1], mmi_uconv_compute_result);
  1398.     }
  1399.     else if (g_uconv_cntx->CurrHiliteUnitType == UCONV_TEMPERATURE)     /* Temperature */
  1400.     {
  1401.         g_uconv_cntx->UnitListLg[0] = GetString(STR_ID_UNITCONVERTOR_CELSIUS);
  1402.         g_uconv_cntx->UnitListLg[1] = GetString(STR_ID_UNITCONVERTOR_FAHRENHEIT);
  1403.         g_uconv_cntx->UnitListLg2[0] = g_unitlist2;
  1404.         pfnUnicodeStrcpy(g_uconv_cntx->UnitListLg2[0], g_uconv_cntx->UnitListLg[1]);
  1405.         /* units */
  1406.         SetInlineItemSelect(
  1407.             &wgui_inline_items[UCONV_UNIT1],
  1408.             UCONV_TEMPERATURE_UNIT_NUM,
  1409.             (U8 **) g_uconv_cntx->UnitListLg,
  1410.             &g_uconv_cntx->CurrInlineSelectUnit1);
  1411.         SetInlineItemSelect(
  1412.             &wgui_inline_items[UCONV_UNIT2],
  1413.             UCONV_TEMPERATURE_UNIT_NUM - 1,
  1414.             (U8 **) g_uconv_cntx->UnitListLg2,
  1415.             &g_uconv_cntx->CurrInlineSelectUnit2);
  1416.         RegisterInlineSelectHighlightHandler(&wgui_inline_items[UCONV_UNIT1], mmi_uconv_highlight_inline_select1);
  1417.         RegisterInlineSelectHighlightHandler(&wgui_inline_items[UCONV_UNIT2], mmi_uconv_highlight_inline_select2);
  1418.         RegisterInlineFullScreenEditValidationFunction(
  1419.             &wgui_inline_items[UCONV_INPUT1],
  1420.             mmi_uconv_compute_temperature_result);
  1421.     }
  1422.     else if (g_uconv_cntx->CurrHiliteUnitType == UCONV_VELOCITY)        /* Velocity */
  1423.     {
  1424.         g_uconv_cntx->UnitListLg[0] = GetString(STR_ID_UNITCONVERTOR_KMH);
  1425.         g_uconv_cntx->UnitListLg[1] = GetString(STR_ID_UNITCONVERTOR_METERSEC);
  1426.         g_uconv_cntx->UnitListLg[2] = GetString(STR_ID_UNITCONVERTOR_MPH);
  1427.         g_uconv_cntx->UnitListLg[3] = GetString(STR_ID_UNITCONVERTOR_FEETSEC);
  1428.         /* units */
  1429.         SetInlineItemSelect(
  1430.             &wgui_inline_items[UCONV_UNIT1],
  1431.             UCONV_VELOCITY_UNIT_NUM,
  1432.             (U8 **) g_uconv_cntx->UnitListLg,
  1433.             &g_uconv_cntx->CurrInlineSelectUnit1);
  1434.         SetInlineItemSelect(
  1435.             &wgui_inline_items[UCONV_UNIT2],
  1436.             UCONV_VELOCITY_UNIT_NUM,
  1437.             (U8 **) g_uconv_cntx->UnitListLg,
  1438.             &g_uconv_cntx->CurrInlineSelectUnit2);
  1439.         RegisterInlineSelectHighlightHandler(&wgui_inline_items[UCONV_UNIT1], mmi_uconv_highlight_inline_select1);
  1440.         RegisterInlineSelectHighlightHandler(&wgui_inline_items[UCONV_UNIT2], mmi_uconv_highlight_inline_select2);
  1441.         RegisterInlineFullScreenEditValidationFunction(&wgui_inline_items[UCONV_INPUT1], mmi_uconv_compute_result);
  1442.     }   /* Sophie { */
  1443.     else if (g_uconv_cntx->CurrHiliteUnitType == UCONV_SHOES)   /* SHOES */
  1444.     {
  1445.         g_uconv_cntx->UnitListLg[0] = GetString(STR_ID_UNITCONVERTOR_SHOES_USA);
  1446.         g_uconv_cntx->UnitListLg[1] = GetString(STR_ID_UNITCONVERTOR_SHOES_EUROPE);
  1447.         g_uconv_cntx->UnitListLg[2] = GetString(STR_ID_UNITCONVERTOR_SHOES_KOREA);
  1448.         /* units */
  1449.         SetInlineItemSelect(
  1450.             &wgui_inline_items[UCONV_UNIT1],
  1451.             UCONV_SHOES_UNIT_NUM,
  1452.             (U8 **) g_uconv_cntx->UnitListLg,
  1453.             &g_uconv_cntx->CurrInlineSelectUnit1);
  1454.         SetInlineItemSelect(
  1455.             &wgui_inline_items[UCONV_UNIT2],
  1456.             UCONV_SHOES_UNIT_NUM,
  1457.             (U8 **) g_uconv_cntx->UnitListLg,
  1458.             &g_uconv_cntx->CurrInlineSelectUnit2);
  1459.         RegisterInlineSelectHighlightHandler(&wgui_inline_items[UCONV_UNIT1], mmi_uconv_highlight_inline_select1);
  1460.         RegisterInlineSelectHighlightHandler(&wgui_inline_items[UCONV_UNIT2], mmi_uconv_highlight_inline_select2);
  1461.         SetInlineTextEditCustomFunction(&wgui_inline_items[UCONV_INPUT1], UConvCustomInlineFunction);
  1462.     }
  1463.     else if (g_uconv_cntx->CurrHiliteUnitType == UCONV_CLOTHES) /* CLOTHES */
  1464.     {
  1465.         g_uconv_cntx->UnitListLg[0] = GetString(STR_ID_UNITCONVERTOR_CLOTHES_EUROPE);
  1466.         g_uconv_cntx->UnitListLg[1] = GetString(STR_ID_UNITCONVERTOR_CLOTHES_KOREA1);
  1467.         g_uconv_cntx->UnitListLg[2] = GetString(STR_ID_UNITCONVERTOR_CLOTHES_KOREA2);
  1468.         g_uconv_cntx->UnitListLg[3] = GetString(STR_ID_UNITCONVERTOR_CLOTHES_JAPAN);
  1469.         g_uconv_cntx->UnitListLg[4] = GetString(STR_ID_UNITCONVERTOR_CLOTHES_USA);
  1470.         g_uconv_cntx->UnitListLg[5] = GetString(STR_ID_UNITCONVERTOR_CLOTHES_UK);
  1471.         /* units */
  1472.         SetInlineItemSelect(
  1473.             &wgui_inline_items[UCONV_UNIT1],
  1474.             UCONV_CLOTHES_UNIT_NUM,
  1475.             (U8 **) g_uconv_cntx->UnitListLg,
  1476.             &g_uconv_cntx->CurrInlineSelectUnit1);
  1477.         SetInlineItemSelect(
  1478.             &wgui_inline_items[UCONV_UNIT2],
  1479.             UCONV_CLOTHES_UNIT_NUM,
  1480.             (U8 **) g_uconv_cntx->UnitListLg,
  1481.             &g_uconv_cntx->CurrInlineSelectUnit2);
  1482.         RegisterInlineSelectHighlightHandler(&wgui_inline_items[UCONV_UNIT1], mmi_uconv_highlight_inline_select1);
  1483.         RegisterInlineSelectHighlightHandler(&wgui_inline_items[UCONV_UNIT2], mmi_uconv_highlight_inline_select2);
  1484.         SetInlineTextEditCustomFunction(&wgui_inline_items[UCONV_INPUT1], UConvCustomInlineFunction);
  1485.     }
  1486.     else if (g_uconv_cntx->CurrHiliteUnitType == UCONV_SURFACE) /* surface */
  1487.     {
  1488.         g_uconv_cntx->UnitListLg[0] = GetString(STR_ID_UNITCONVERTOR_SURFACE_ACRE);
  1489.         g_uconv_cntx->UnitListLg[1] = GetString(STR_ID_UNITCONVERTOR_SURFACE_HECTARE);
  1490.         g_uconv_cntx->UnitListLg[2] = GetString(STR_ID_UNITCONVERTOR_SURFACE_SQUARE_MM);
  1491.         g_uconv_cntx->UnitListLg[3] = GetString(STR_ID_UNITCONVERTOR_SURFACE_SQUARE_CM);
  1492.         g_uconv_cntx->UnitListLg[4] = GetString(STR_ID_UNITCONVERTOR_SURFACE_SQUARE_M);
  1493.         g_uconv_cntx->UnitListLg[5] = GetString(STR_ID_UNITCONVERTOR_SURFACE_SQUARE_KM);
  1494.         g_uconv_cntx->UnitListLg[6] = GetString(STR_ID_UNITCONVERTOR_SURFACE_SQUARE_IN);
  1495.         g_uconv_cntx->UnitListLg[7] = GetString(STR_ID_UNITCONVERTOR_SURFACE_SQUARE_FEET);
  1496.         g_uconv_cntx->UnitListLg[8] = GetString(STR_ID_UNITCONVERTOR_SURFACE_SQUARE_YD);
  1497.         g_uconv_cntx->UnitListLg[9] = GetString(STR_ID_UNITCONVERTOR_SURFACE_SQUARE_MILES);
  1498.         /* units */
  1499.         SetInlineItemSelect(
  1500.             &wgui_inline_items[UCONV_UNIT1],
  1501.             UCONV_SURFACE_UNIT_NUM,
  1502.             (U8 **) g_uconv_cntx->UnitListLg,
  1503.             &g_uconv_cntx->CurrInlineSelectUnit1);
  1504.         SetInlineItemSelect(
  1505.             &wgui_inline_items[UCONV_UNIT2],
  1506.             UCONV_SURFACE_UNIT_NUM,
  1507.             (U8 **) g_uconv_cntx->UnitListLg,
  1508.             &g_uconv_cntx->CurrInlineSelectUnit2);
  1509.         RegisterInlineSelectHighlightHandler(&wgui_inline_items[UCONV_UNIT1], mmi_uconv_highlight_inline_select1);
  1510.         RegisterInlineSelectHighlightHandler(&wgui_inline_items[UCONV_UNIT2], mmi_uconv_highlight_inline_select2);
  1511.         RegisterInlineFullScreenEditValidationFunction(&wgui_inline_items[UCONV_INPUT1], mmi_uconv_compute_result);
  1512.     }
  1513.     memset(ansii_str_i, 0, 32);
  1514.     sprintf(ansii_str_i, " : ");
  1515.     AnsiiToUnicodeString(unicode_str_o, ansii_str_i);
  1516.     pfnUnicodeStrcpy(g_uconv_cntx->title, g_uconv_cntx->UnitListLg[g_uconv_cntx->CurrInlineSelectUnit1]);
  1517.     pfnUnicodeStrcat(g_uconv_cntx->title, unicode_str_o);
  1518.     if (g_uconv_cntx->CurrHiliteUnitType == UCONV_TEMPERATURE)  /* Temperature */
  1519.     {
  1520.         pfnUnicodeStrcat(g_uconv_cntx->title, g_uconv_cntx->UnitListLg2[g_uconv_cntx->CurrInlineSelectUnit2]);
  1521.     }
  1522.     else
  1523.     {
  1524.         pfnUnicodeStrcat(g_uconv_cntx->title, g_uconv_cntx->UnitListLg[g_uconv_cntx->CurrInlineSelectUnit2]);
  1525.     }
  1526.     /* caption */
  1527.     SetInlineItemActivation(&wgui_inline_items[UCONV_CAPTION], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1528.     SetInlineItemCaption(&wgui_inline_items[UCONV_CAPTION], (U8*) g_uconv_cntx->title);
  1529. }
  1530. /*****************************************************************************
  1531.  * FUNCTION
  1532.  *  mmi_uconv_reset_current_input
  1533.  * DESCRIPTION
  1534.  *  To reset the input (and result)
  1535.  * PARAMETERS
  1536.  *  void
  1537.  * RETURNS
  1538.  *  void
  1539.  *****************************************************************************/
  1540. void mmi_uconv_reset_current_input(void)
  1541. {
  1542.     /*----------------------------------------------------------------*/
  1543.     /* Local Variables                                                */
  1544.     /*----------------------------------------------------------------*/
  1545.     /*----------------------------------------------------------------*/
  1546.     /* Code Body                                                      */
  1547.     /*----------------------------------------------------------------*/
  1548.     CloseCategory57Screen();
  1549.     memset(g_uconv_cntx->InputBuf1, 0, 2);
  1550.     ChangeLeftSoftkey(STR_ID_UNITCONVERTOR_RESET, IMG_ID_UNITCONVERTOR_RESET);
  1551.     RedrawCategoryFunction();
  1552.     SetLeftSoftkeyFunction(mmi_uconv_reset_current_input, KEY_EVENT_UP);
  1553. }
  1554. /*****************************************************************************
  1555.  * FUNCTION
  1556.  *  mmi_uconv_compute_result
  1557.  * DESCRIPTION
  1558.  *  Handler to represent the calculated length/weight/velocity/volume result
  1559.  * PARAMETERS
  1560.  *  text            [?]         input
  1561.  *  cursor          [?]         not used
  1562.  *  text_length     [IN]        not used
  1563.  * RETURNS
  1564.  *  void
  1565.  *****************************************************************************/
  1566. void mmi_uconv_compute_result(U8 *text, U8 *cursor, S32 text_length)
  1567. {
  1568.     /*----------------------------------------------------------------*/
  1569.     /* Local Variables                                                */
  1570.     /*----------------------------------------------------------------*/
  1571.     DOUBLE result = 0;
  1572.     S32 prec_val = 0;
  1573.     UI_character_type *ResultBuf = NULL;
  1574.     S32 sourceUnit = 0, resultUnit = 0;
  1575.     /*----------------------------------------------------------------*/
  1576.     /* Code Body                                                      */
  1577.     /*----------------------------------------------------------------*/
  1578.     if (!(*text))   /* input field is blank */
  1579.     {
  1580.         memset(g_uconv_cntx->InputBuf2, 0, 2);
  1581.     }
  1582.     else    /* input field is not blank */
  1583.     {
  1584.         ResultBuf = g_uconv_cntx->InputBuf2;
  1585.         sourceUnit = g_uconv_cntx->CurrInlineSelectUnit1;
  1586.         resultUnit = g_uconv_cntx->CurrInlineSelectUnit2;
  1587.         switch (g_uconv_cntx->CurrHiliteUnitType)
  1588.         {
  1589.             case UCONV_LENGTH:
  1590.                 result = (DOUBLE) (g_length_rate[sourceUnit][resultUnit] * gui_atof((UI_string_type) text));
  1591.                 break;
  1592.             case UCONV_WEIGHT:
  1593.                 result = (DOUBLE) (g_weight_rate[sourceUnit][resultUnit] * gui_atof((UI_string_type) text));
  1594.                 break;
  1595.             case UCONV_VELOCITY:
  1596.                 result = (DOUBLE) (g_velocity_rate[sourceUnit][resultUnit] * gui_atof((UI_string_type) text));
  1597.                 break;
  1598.             case UCONV_VOLUME:
  1599.                 result = (DOUBLE) (g_volume_rate[sourceUnit][resultUnit] * gui_atof((UI_string_type) text));
  1600.                 break;
  1601.             case UCONV_SURFACE:
  1602.                 if (sourceUnit + STR_ID_UNITCONVERTOR_SURFACE_ACRE == STR_ID_UNITCONVERTOR_SURFACE_ACRE ||
  1603.                     sourceUnit + STR_ID_UNITCONVERTOR_SURFACE_ACRE == STR_ID_UNITCONVERTOR_SURFACE_HECTARE)
  1604.                 {
  1605.                     result = (DOUBLE) (g_surface_rate[sourceUnit][resultUnit] * gui_atof((UI_string_type) text));
  1606.                 }
  1607.                 else
  1608.                 {
  1609.                     /* 1 square m = g_length_rate[sourceUnit-2][2] * g_length_rate[sourceUnit-2][2] square (length_unit) */
  1610.                     if (resultUnit + STR_ID_UNITCONVERTOR_SURFACE_ACRE == STR_ID_UNITCONVERTOR_SURFACE_ACRE)
  1611.                     {
  1612.                         result =
  1613.                             (DOUBLE) (2.5E-4 * g_length_rate[sourceUnit - 2][2] * g_length_rate[sourceUnit - 2][2] *
  1614.                                       gui_atof((UI_string_type) text));
  1615.                     }
  1616.                     else if (resultUnit + STR_ID_UNITCONVERTOR_SURFACE_ACRE == STR_ID_UNITCONVERTOR_SURFACE_HECTARE)
  1617.                     {
  1618.                         result =
  1619.                             (DOUBLE) (1E-4 * g_length_rate[sourceUnit - 2][2] * g_length_rate[sourceUnit - 2][2] *
  1620.                                       gui_atof((UI_string_type) text));
  1621.                     }
  1622.                     else
  1623.                     {
  1624.                         result =
  1625.                             (DOUBLE) (g_length_rate[sourceUnit - 2][resultUnit - 2] *
  1626.                                       g_length_rate[sourceUnit - 2][resultUnit - 2] * gui_atof((UI_string_type) text));
  1627.                     }
  1628.                 }
  1629.                 break;
  1630.             default:
  1631.                 break;
  1632.         }
  1633.         if (result > UCONV_MAX_VALUE)   /* boundary check: 12 digits */
  1634.         {
  1635.             int input_len;
  1636.             CloseCategory57Screen();
  1637.             input_len = pfnUnicodeStrlen((S8*) g_uconv_cntx->InputBuf1);
  1638.             memset((g_uconv_cntx->InputBuf1 + input_len - 1), 0, 2);    /* Backspace */
  1639.             playRequestedTone(WARNING_TONE);
  1640.         }
  1641.         else
  1642.         {
  1643.             prec_val = CalcComputePrecision(result, UCONV_MAX_RESULT);
  1644.             gui_float_string(result, prec_val, (S8*) ResultBuf);
  1645.         }
  1646.     }
  1647.     UConvRedrawResult();
  1648.     ChangeLeftSoftkey(STR_ID_UNITCONVERTOR_RESET, IMG_ID_UNITCONVERTOR_RESET);
  1649.     SetLeftSoftkeyFunction(mmi_uconv_reset_current_input, KEY_EVENT_UP);
  1650. }
  1651. /*****************************************************************************
  1652.  * FUNCTION
  1653.  *  mmi_uconv_compute_temperature_result
  1654.  * DESCRIPTION
  1655.  *  Handler to represent the calculated result
  1656.  * PARAMETERS
  1657.  *  text            [?]         input
  1658.  *  cursor          [?]         not used
  1659.  *  text_length     [IN]        not used
  1660.  * RETURNS
  1661.  *  void
  1662.  *****************************************************************************/
  1663. void mmi_uconv_compute_temperature_result(U8 *text, U8 *cursor, S32 text_length)
  1664. {
  1665.     /*----------------------------------------------------------------*/
  1666.     /* Local Variables                                                */
  1667.     /*----------------------------------------------------------------*/
  1668.     DOUBLE result = 0;
  1669.     S32 prec_val = 0;
  1670.     UI_character_type *ResultBuf = NULL;
  1671.     S32 sourceUnit = 0, resultUnit = 0;
  1672.     DOUBLE inputValue = 0;
  1673.     /*----------------------------------------------------------------*/
  1674.     /* Code Body                                                      */
  1675.     /*----------------------------------------------------------------*/
  1676.     if (!(*text))   /* input field is blank */
  1677.     {
  1678.         memset(g_uconv_cntx->InputBuf2, 0, 2);
  1679.     }
  1680.     else    /* input field is not blank */
  1681.     {
  1682.         inputValue = gui_atof((UI_string_type) text);
  1683.         ResultBuf = g_uconv_cntx->InputBuf2;
  1684.         sourceUnit = g_uconv_cntx->CurrInlineSelectUnit1;
  1685.         resultUnit = g_uconv_cntx->CurrInlineSelectUnit2;
  1686.         if (sourceUnit == 0)    /* C->F */
  1687.         {
  1688.             result = (DOUBLE) (inputValue * 9.0 / 5.0 + 32.0);
  1689.         }
  1690.         else    /* F->C */
  1691.         {
  1692.             result = (DOUBLE) ((inputValue - 32.0) * 5.0 / 9.0);
  1693.         }
  1694.         if (result > 999999999999)  /* 12 digits */
  1695.         {
  1696.             int input_len;
  1697.             CloseCategory57Screen();
  1698.             input_len = pfnUnicodeStrlen((S8*) g_uconv_cntx->InputBuf1);
  1699.             memset((g_uconv_cntx->InputBuf1 + input_len - 1), 0, 2);
  1700.             playRequestedTone(WARNING_TONE);
  1701.         }
  1702.         else
  1703.         {
  1704.             prec_val = CalcComputePrecision(result, UCONV_MAX_RESULT);
  1705.             gui_float_string(result, prec_val, (S8*) ResultBuf);
  1706.         }
  1707.     }
  1708.     ChangeLeftSoftkey(STR_ID_UNITCONVERTOR_RESET, IMG_ID_UNITCONVERTOR_RESET);
  1709.     UConvRedrawResult();
  1710.     SetLeftSoftkeyFunction(mmi_uconv_reset_current_input, KEY_EVENT_UP);
  1711. }
  1712. /* Autumn } */
  1713. /* Sophie { */
  1714. /*****************************************************************************
  1715.  * FUNCTION
  1716.  *  mmi_uconv_compute_sc_result
  1717.  * DESCRIPTION
  1718.  *  Handler to represent the calculated result
  1719.  * PARAMETERS
  1720.  *  void
  1721.  *  text: input(?)
  1722.  *  cursor: not used(?)
  1723.  *  text_length: not used(?)
  1724.  * RETURNS
  1725.  *  void
  1726.  *****************************************************************************/
  1727. void mmi_uconv_compute_sc_result(void)
  1728. {
  1729.     /*----------------------------------------------------------------*/
  1730.     /* Local Variables                                                */
  1731.     /*----------------------------------------------------------------*/
  1732.     DOUBLE result = 0;
  1733.     S32 prec_val = 0;
  1734.     UI_character_type *ResultBuf = NULL;
  1735.     S32 sourceUnit = 0, resultUnit = 0;
  1736.     /*----------------------------------------------------------------*/
  1737.     /* Code Body                                                      */
  1738.     /*----------------------------------------------------------------*/
  1739.     g_uconv_cntx->inputflag = MMI_FALSE;
  1740.     switch (g_uconv_cntx->CurrHiliteUnitType)
  1741.     {
  1742.         case UCONV_SHOES:
  1743.             mmi_uconv_verify_shoes_input((U16*) g_uconv_cntx->InputBuf1);
  1744.             break;
  1745.         case UCONV_CLOTHES:
  1746.             mmi_uconv_verify_clothes_input((U16*) g_uconv_cntx->InputBuf1);
  1747.             break;
  1748.         default:
  1749.             break;
  1750.     }
  1751.     if (g_uconv_cntx->inputflag == MMI_FALSE)
  1752.     {
  1753.         return;
  1754.     }
  1755.     ResultBuf = g_uconv_cntx->InputBuf2;
  1756.     sourceUnit = g_uconv_cntx->CurrInlineSelectUnit1;
  1757.     resultUnit = g_uconv_cntx->CurrInlineSelectUnit2;
  1758.     switch (g_uconv_cntx->CurrHiliteUnitType)
  1759.     {
  1760.         case UCONV_SHOES:
  1761.             result =
  1762.                 (DOUBLE) (g_shoes_rate_multipara[sourceUnit][resultUnit] * gui_atof((U16*) g_uconv_cntx->InputBuf1) +
  1763.                           g_shoes_rate_pluspara[sourceUnit][resultUnit]);
  1764.             break;
  1765.         case UCONV_CLOTHES:
  1766.             result =
  1767.                 ((S32) gui_atof((U16*) g_uconv_cntx->InputBuf1) -
  1768.                  g_clothes_rate_subtractpara[sourceUnit][resultUnit]) /
  1769.                 g_clothes_rate_dividepara[sourceUnit][resultUnit] * g_clothes_rate_multipara[sourceUnit][resultUnit] +
  1770.                 g_clothes_rate_pluspara[sourceUnit][resultUnit];
  1771.             break;
  1772.         default:
  1773.             break;
  1774.     }
  1775.     if (result > 999999999999)  /* 12 digits */
  1776.     {
  1777.         int input_len;
  1778.         CloseCategory57Screen();
  1779.         input_len = pfnUnicodeStrlen((S8*) g_uconv_cntx->InputBuf1);
  1780.         memset((g_uconv_cntx->InputBuf1 + input_len - 1), 0, 2);
  1781.         playRequestedTone(WARNING_TONE);
  1782.     }
  1783.     else
  1784.     {
  1785.         prec_val = CalcComputePrecision(result, UCONV_MAX_RESULT);
  1786.         gui_float_string(result, prec_val, (S8*) ResultBuf);
  1787.     }
  1788.     g_uconv_cntx->ClearResultFlag = TRUE;
  1789.     UConvRedrawResult();
  1790.     SetLeftSoftkeyFunction(mmi_uconv_compute_sc_result, KEY_EVENT_UP);
  1791. }
  1792. /*****************************************************************************
  1793.  * FUNCTION
  1794.  *  mmi_uconv_verify_shoes_input
  1795.  * DESCRIPTION
  1796.  *  Handler to verify the calculated input
  1797.  * PARAMETERS
  1798.  *  input       [?]     input
  1799.  *  inputflag: result flag(?)
  1800.  * RETURNS
  1801.  *  void
  1802.  *****************************************************************************/
  1803. void mmi_uconv_verify_shoes_input(U16 *input)
  1804. {
  1805.     /*----------------------------------------------------------------*/
  1806.     /* Local Variables                                                */
  1807.     /*----------------------------------------------------------------*/
  1808.     DOUBLE verifier = gui_atof(input);
  1809.     /*----------------------------------------------------------------*/
  1810.     /* Code Body                                                      */
  1811.     /*----------------------------------------------------------------*/
  1812.     switch (g_uconv_cntx->CurrInlineSelectUnit1 + STR_ID_UNITCONVERTOR_SHOES_USA)
  1813.     {
  1814.         case STR_ID_UNITCONVERTOR_SHOES_USA:    /* 5.0, 5.5,...,10.5 */
  1815.             if ((S32) verifier * 10 % 5 == 0 && verifier >= 5.0 && verifier <= 10.5)
  1816.             {
  1817.                 g_uconv_cntx->inputflag = MMI_TRUE;
  1818.             }
  1819.             break;
  1820.         case STR_ID_UNITCONVERTOR_SHOES_EUROPE: /* 35.5, 36.0,...,41.0 */
  1821.             if ((S32) verifier * 10 % 5 == 0 && verifier >= 35.5 && verifier / 5 <= 41)
  1822.             {
  1823.                 g_uconv_cntx->inputflag = MMI_TRUE;
  1824.             }
  1825.             break;
  1826.         case STR_ID_UNITCONVERTOR_SHOES_KOREA:  /* 220,225,...,275 */
  1827.             if ((S32) verifier % 5 == 0 && verifier >= 220 && verifier / 5 <= 275)
  1828.             {
  1829.                 g_uconv_cntx->inputflag = MMI_TRUE;
  1830.             }
  1831.             break;
  1832.         default:
  1833.             break;
  1834.     }
  1835.     if (g_uconv_cntx->inputflag == MMI_FALSE)
  1836.     {
  1837.         DisplayPopup(
  1838.             (U8*) GetString(UC_ERROR_UNCORRECT_INPUT),
  1839.             IMG_GLOBAL_WARNING,
  1840.             0,
  1841.             UI_POPUP_NOTIFYDURATION_TIME,
  1842.             WARNING_TONE);
  1843.         /* mmi_uconv_reset_current_input2(); */
  1844.     }
  1845. }
  1846. /*****************************************************************************
  1847.  * FUNCTION
  1848.  *  mmi_uconv_verify_clothes_input
  1849.  * DESCRIPTION
  1850.  *  Handler to verify the calculated input
  1851.  * PARAMETERS
  1852.  *  input       [?]     input
  1853.  *  inputflag: result flag(?)
  1854.  * RETURNS
  1855.  *  void
  1856.  *****************************************************************************/
  1857. void mmi_uconv_verify_clothes_input(U16 *input)
  1858. {
  1859.     /*----------------------------------------------------------------*/
  1860.     /* Local Variables                                                */
  1861.     /*----------------------------------------------------------------*/
  1862.     S32 verifier = gui_atoi(input);
  1863.     /*----------------------------------------------------------------*/
  1864.     /* Code Body                                                      */
  1865.     /*----------------------------------------------------------------*/
  1866.     switch (g_uconv_cntx->CurrInlineSelectUnit1 + STR_ID_UNITCONVERTOR_CLOTHES_EUROPE)
  1867.     {
  1868.         case STR_ID_UNITCONVERTOR_CLOTHES_EUROPE:   /* 36, 38, ..., 52 */
  1869.             if (verifier % 2 == 0 && verifier >= 36 && verifier <= 52)
  1870.             {
  1871.                 g_uconv_cntx->inputflag = MMI_TRUE;
  1872.             }
  1873.             break;
  1874.         case STR_ID_UNITCONVERTOR_CLOTHES_KOREA1:   /* 44, 55,..., 88 */
  1875.             if (verifier % 11 == 0 && verifier >= 44 && verifier <= 88)
  1876.             {
  1877.                 g_uconv_cntx->inputflag = MMI_TRUE;
  1878.             }
  1879.             break;
  1880.         case STR_ID_UNITCONVERTOR_CLOTHES_KOREA2:   /* 85, 90, ...,105 */
  1881.             if (verifier % 5 == 0 && verifier >= 85 && verifier / 5 <= 105)
  1882.             {
  1883.                 g_uconv_cntx->inputflag = MMI_TRUE;
  1884.             }
  1885.             break;
  1886.         case STR_ID_UNITCONVERTOR_CLOTHES_JAPAN:    /* 1, 3, 5, ...,17 */
  1887.             if ((verifier + 1) % 2 == 0 && verifier >= 1 && verifier <= 17)
  1888.             {
  1889.                 g_uconv_cntx->inputflag = MMI_TRUE;
  1890.             }
  1891.             break;
  1892.         case STR_ID_UNITCONVERTOR_CLOTHES_USA:  /* 2, 4, 6, ..., 18 */
  1893.             if (verifier % 2 == 0 && verifier >= 2 && verifier <= 18)
  1894.             {
  1895.                 g_uconv_cntx->inputflag = MMI_TRUE;
  1896.             }
  1897.             break;
  1898.         case STR_ID_UNITCONVERTOR_CLOTHES_UK:   /* 4, 6, 8,... , 20 */
  1899.             if (verifier % 2 == 0 && verifier >= 4 && verifier <= 20)
  1900.             {
  1901.                 g_uconv_cntx->inputflag = MMI_TRUE;
  1902.             }
  1903.             break;
  1904.         default:
  1905.             break;
  1906.     }
  1907.     if (g_uconv_cntx->inputflag == MMI_FALSE)
  1908.     {
  1909.         DisplayPopup(
  1910.             (U8*) GetString(UC_ERROR_UNCORRECT_INPUT),
  1911.             IMG_GLOBAL_WARNING,
  1912.             0,
  1913.             UI_POPUP_NOTIFYDURATION_TIME,
  1914.             WARNING_TONE);
  1915.         /* mmi_uconv_reset_current_input2(); */
  1916.     }
  1917. }
  1918. /*****************************************************************************
  1919.  * FUNCTION
  1920.  *  mmi_uconv_goto_compute_screen_lg
  1921.  * DESCRIPTION
  1922.  *  Intialize state variables and enter velocity/temperature/volume convertor with LG style
  1923.  * PARAMETERS
  1924.  *  void
  1925.  * RETURNS
  1926.  *  void
  1927.  *****************************************************************************/
  1928. void mmi_uconv_goto_compute_screen_lg(void)
  1929. {
  1930.     /*----------------------------------------------------------------*/
  1931.     /* Local Variables                                                */
  1932.     /*----------------------------------------------------------------*/
  1933.     /*----------------------------------------------------------------*/
  1934.     /* Code Body                                                      */
  1935.     /*----------------------------------------------------------------*/
  1936.     g_uconv_cntx->CurrInlineSelectUnit1 = 0;
  1937.     g_uconv_cntx->CurrInlineSelectUnit2 = 0;
  1938.     g_uconv_cntx->CurrSelectedItem = 0;
  1939.     memset(g_uconv_cntx->InputBuf1, 0, 2);
  1940.     memset(g_uconv_cntx->InputBuf2, 0, 2);
  1941.     mmi_uconv_entry_compute_lg();
  1942. }
  1943. /*****************************************************************************
  1944.  * FUNCTION
  1945.  *  mmi_uconv_exit_compute_lg
  1946.  * DESCRIPTION
  1947.  *  Exit function of converting screen with LG style
  1948.  * PARAMETERS
  1949.  *  void
  1950.  * RETURNS
  1951.  *  void
  1952.  *****************************************************************************/
  1953. void mmi_uconv_exit_compute_lg(void)
  1954. {
  1955.     /*----------------------------------------------------------------*/
  1956.     /* Local Variables                                                */
  1957.     /*----------------------------------------------------------------*/
  1958.     history HistoryUCWeight;
  1959.     U16 inputBufferSize;    /* added for inline edit history */
  1960.     S16 nHistory = 0;
  1961.     /*----------------------------------------------------------------*/
  1962.     /* Code Body                                                      */
  1963.     /*----------------------------------------------------------------*/
  1964.     set_leading_zero(TRUE);
  1965.     if (g_uconv_cntx)
  1966.     {
  1967.         CloseCategory57Screen();
  1968.         HistoryUCWeight.scrnID = SCR_ID_UCONV_WEIGHT + g_uconv_cntx->CurrHiliteUnitType;
  1969.     }
  1970.     HistoryUCWeight.entryFuncPtr = mmi_uconv_entry_compute_lg;
  1971.     GetCategory57History(HistoryUCWeight.guiBuffer);
  1972.     pfnUnicodeStrcpy((S8*) HistoryUCWeight.inputBuffer, (S8*) & nHistory);
  1973.     inputBufferSize = (U16) GetCategory57DataSize();        /* added for inline edit history */
  1974.     GetCategory57Data((U8*) HistoryUCWeight.inputBuffer);   /* added for inline edit history */
  1975.     AddNHistory(HistoryUCWeight, inputBufferSize);          /* added for inline edit history */
  1976. }
  1977. /*****************************************************************************
  1978.  * FUNCTION
  1979.  *  mmi_uconv_entry_compute_lg
  1980.  * DESCRIPTION
  1981.  *  Entry function of converting screen with LG style
  1982.  * PARAMETERS
  1983.  *  void
  1984.  * RETURNS
  1985.  *  void
  1986.  *****************************************************************************/
  1987. void mmi_uconv_entry_compute_lg(void)
  1988. {
  1989.     /*----------------------------------------------------------------*/
  1990.     /* Local Variables                                                */
  1991.     /*----------------------------------------------------------------*/
  1992.     /* U16 UC_list_of_items[10]; */
  1993.     U8 *guiBuffer;
  1994.     U8 *inputBuffer;        /* added for inline edit history */
  1995.     U16 inputBufferSize;    /* added for inline edit history */
  1996.     U16 ScrID = (SCR_ID_UCONV_WEIGHT + g_uconv_cntx->CurrHiliteUnitType);
  1997.     U16 titleID;
  1998.     /*----------------------------------------------------------------*/
  1999.     /* Code Body                                                      */
  2000.     /*----------------------------------------------------------------*/
  2001.     EntryNewScreen(ScrID, mmi_uconv_exit_compute_lg, NULL, NULL);
  2002.     SetDelScrnIDCallbackHandler(ScrID, (HistoryDelCBPtr) mmi_uconv_del_scr_callback);
  2003.     set_leading_zero(FALSE);
  2004.     guiBuffer = GetCurrGuiBuffer(ScrID);
  2005.     InitializeCategory57Screen();
  2006.     mmi_uconv_fill_inline_struct_lg();
  2007.     RegisterHighlightHandler(mmi_uconv_highlight_inline_item_lg);
  2008.     inputBuffer = GetCurrNInputBuffer(ScrID, &inputBufferSize); /* added for inline edit history */
  2009.     if (inputBuffer)    /* added for inline edit history */
  2010.     {
  2011.         SetCategory57Data(wgui_inline_items, UCONV_INLINE_TOTAL2, inputBuffer); /* sets the data */
  2012.     }
  2013.     DisableCategory57ScreenDone();
  2014.     switch (g_uconv_cntx->CurrHiliteUnitType)
  2015.     {
  2016.         case UCONV_LENGTH:
  2017.             titleID = STR_UNITCONVERTOR_LENGTH;
  2018.             break;
  2019.         case UCONV_WEIGHT:
  2020.             titleID = STR_UNITCONVERTOR_WEIGHT;
  2021.             break;
  2022.         case UCONV_VOLUME:
  2023.             titleID = STR_ID_UNITCONVERTOR_VOLUME;
  2024.             break;
  2025.         case UCONV_TEMPERATURE:
  2026.             titleID = STR_ID_UNITCONVERTOR_TEMPERATURE;
  2027.             break;
  2028.         case UCONV_VELOCITY:
  2029.             titleID = STR_ID_UNITCONVERTOR_VELOCITY;
  2030.             break;
  2031.         case UCONV_SHOES:
  2032.             titleID = STR_ID_UNITCONVERTOR_SHOES;
  2033.             break;
  2034.         case UCONV_CLOTHES:
  2035.             titleID = STR_ID_UNITCONVERTOR_CLOTHES;
  2036.             break;
  2037.         case UCONV_SURFACE:
  2038.             titleID = STR_ID_UNITCONVERTOR_SURFACE;
  2039.             break;
  2040.         default:
  2041.             titleID = STR_UNITCONVERTOR_CAPTION1;
  2042.             break;
  2043.     }
  2044.     ShowCategory57Screen(
  2045.         titleID,
  2046.         GetRootTitleIcon(EXTRA_UNITCONVERTOR_MENU),
  2047.         STR_GLOBAL_OK,
  2048.         IMG_GLOBAL_OK,
  2049.         STR_GLOBAL_BACK,
  2050.         IMG_GLOBAL_BACK,
  2051.         UCONV_INLINE_TOTAL2,
  2052.         NULL,
  2053.         wgui_inline_items,
  2054.         g_uconv_cntx->CurrSelectedItem,
  2055.         guiBuffer);
  2056.     switch (g_uconv_cntx->CurrHiliteUnitType)
  2057.     {
  2058.         case UCONV_SHOES:
  2059.         case UCONV_CLOTHES:
  2060.             SetCategory57RightSoftkeyFunctions(mmi_uconv_compute_sc_result, GoBackHistory);
  2061.             break;
  2062.         default:
  2063.             SetCategory57RightSoftkeyFunctions(mmi_uconv_reset_current_input, GoBackHistory);
  2064.             break;
  2065.     }
  2066. }
  2067. /*****************************************************************************
  2068.  * FUNCTION
  2069.  *  mmi_uconv_highlight_inline_item_lg
  2070.  * DESCRIPTION
  2071.  *  Highlight handler of inline items with LG style
  2072.  * PARAMETERS
  2073.  *  index       [IN]        
  2074.  * RETURNS
  2075.  *  void
  2076.  *****************************************************************************/
  2077. void mmi_uconv_highlight_inline_item_lg(S32 index)
  2078. {
  2079.     /*----------------------------------------------------------------*/
  2080.     /* Local Variables                                                */
  2081.     /*----------------------------------------------------------------*/
  2082.     /*----------------------------------------------------------------*/
  2083.     /* Code Body                                                      */
  2084.     /*----------------------------------------------------------------*/
  2085.     if (index == UCONV_UNIT1 || index == UCONV_UNIT2)   /* inline selection */
  2086.     {
  2087.         memset(g_uconv_cntx->InputBuf1, 0, 2);
  2088.         memset(g_uconv_cntx->InputBuf2, 0, 2);
  2089.         ChangeLeftSoftkey(STRING_ID_NULL, IMAGE_ID_NULL);
  2090.         ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  2091.         SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2092.     }
  2093.     else
  2094.     {
  2095.     #ifdef __MMI_CONVERTER_KEEP_INLINE_FOCUS__
  2096.         if ((U8) index != g_uconv_cntx->CurrSelectedItem)
  2097.         {
  2098.             memset(g_uconv_cntx->InputBuf1, 0, 2);
  2099.             memset(g_uconv_cntx->InputBuf2, 0, 2);
  2100.         }
  2101.     #if !defined(__MMI_WITH_C_KEY__)
  2102.         SetCategory57ScreenRSKClear();  /* Max: set RSK to "Clear" */
  2103.     #endif 
  2104.     #else /* __MMI_CONVERTER_KEEP_INLINE_FOCUS__ */ 
  2105.         if (index != g_uconv_cntx->CurrSelectedItem)
  2106.         {
  2107.             memset(g_uconv_cntx->InputBuf1, 0, 2);
  2108.             memset(g_uconv_cntx->InputBuf2, 0, 2);
  2109.         }
  2110.     #endif /* __MMI_CONVERTER_KEEP_INLINE_FOCUS__ */ 
  2111.     }
  2112.     g_uconv_cntx->CurrSelectedItem = (U8) index;
  2113.     return;
  2114. }
  2115. /*****************************************************************************
  2116.  * FUNCTION
  2117.  *  mmi_uconv_highlight_inline_select1
  2118.  * DESCRIPTION
  2119.  *  Highlight handler for the 1st(upper) inline selection item in volume/velocity/temperature convertor.
  2120.  *  Redraw caption according to select.
  2121.  * PARAMETERS
  2122.  *  index       [IN]        
  2123.  * RETURNS
  2124.  *  void
  2125.  *****************************************************************************/
  2126. void mmi_uconv_highlight_inline_select1(S32 index)
  2127. {
  2128.     /*----------------------------------------------------------------*/
  2129.     /* Local Variables                                                */
  2130.     /*----------------------------------------------------------------*/
  2131.     S8 ansii_str_i[32], unicode_str_o[32];
  2132.     /*----------------------------------------------------------------*/
  2133.     /* Code Body                                                      */
  2134.     /*----------------------------------------------------------------*/
  2135.     g_uconv_cntx->CurrInlineSelectUnit1 = index;
  2136.     if (g_uconv_cntx->CurrHiliteUnitType == UCONV_TEMPERATURE)  /* Temperature */
  2137.     {
  2138.         pfnUnicodeStrcpy(g_uconv_cntx->UnitListLg2[0], g_uconv_cntx->UnitListLg[1 - index]);
  2139.     }
  2140.     memset(ansii_str_i, 0, 32);
  2141.     sprintf(ansii_str_i, " : ");
  2142.     AnsiiToUnicodeString(unicode_str_o, ansii_str_i);
  2143.     pfnUnicodeStrcpy(g_uconv_cntx->title, g_uconv_cntx->UnitListLg[g_uconv_cntx->CurrInlineSelectUnit1]);
  2144.     pfnUnicodeStrcat(g_uconv_cntx->title, unicode_str_o);
  2145.     if (g_uconv_cntx->CurrHiliteUnitType == UCONV_TEMPERATURE)  /* Temperature */
  2146.     {
  2147.         pfnUnicodeStrcat(g_uconv_cntx->title, g_uconv_cntx->UnitListLg2[g_uconv_cntx->CurrInlineSelectUnit2]);
  2148.     }
  2149.     else
  2150.     {
  2151.         pfnUnicodeStrcat(g_uconv_cntx->title, g_uconv_cntx->UnitListLg[g_uconv_cntx->CurrInlineSelectUnit2]);
  2152.     }
  2153.     SetInlineItemCaption(&wgui_inline_items[UCONV_CAPTION], (U8*) g_uconv_cntx->title);
  2154.     RedrawCategoryFunction();
  2155. }
  2156. /*****************************************************************************
  2157.  * FUNCTION
  2158.  *  mmi_uconv_highlight_inline_select2
  2159.  * DESCRIPTION
  2160.  *  Highlight handler for the 2nd(lower) inline selection item in volume/velocity/temperature convertor.
  2161.  *  Redraw caption according to select.
  2162.  * PARAMETERS
  2163.  *  index       [IN]        
  2164.  * RETURNS
  2165.  *  void
  2166.  *****************************************************************************/
  2167. void mmi_uconv_highlight_inline_select2(S32 index)
  2168. {
  2169.     /*----------------------------------------------------------------*/
  2170.     /* Local Variables                                                */
  2171.     /*----------------------------------------------------------------*/
  2172.     S8 ansii_str_i[32], unicode_str_o[32];
  2173.     /*----------------------------------------------------------------*/
  2174.     /* Code Body                                                      */
  2175.     /*----------------------------------------------------------------*/
  2176.     g_uconv_cntx->CurrInlineSelectUnit2 = index;
  2177.     memset(ansii_str_i, 0, 32);
  2178.     sprintf(ansii_str_i, " : ");
  2179.     AnsiiToUnicodeString(unicode_str_o, ansii_str_i);
  2180.     pfnUnicodeStrcpy(g_uconv_cntx->title, g_uconv_cntx->UnitListLg[g_uconv_cntx->CurrInlineSelectUnit1]);
  2181.     pfnUnicodeStrcat(g_uconv_cntx->title, unicode_str_o);
  2182.     if (g_uconv_cntx->CurrHiliteUnitType == UCONV_TEMPERATURE)  /* Temperature */
  2183.     {
  2184.         pfnUnicodeStrcat(g_uconv_cntx->title, g_uconv_cntx->UnitListLg2[g_uconv_cntx->CurrInlineSelectUnit2]);
  2185.     }
  2186.     else
  2187.     {
  2188.         pfnUnicodeStrcat(g_uconv_cntx->title, g_uconv_cntx->UnitListLg[g_uconv_cntx->CurrInlineSelectUnit2]);
  2189.     }
  2190.     SetInlineItemCaption(&wgui_inline_items[UCONV_CAPTION], (U8*) g_uconv_cntx->title);
  2191.     RedrawCategoryFunction();
  2192. }
  2193. #endif /* __MMI_UNIT_CONVERTER__ */ /* end of ifdef __MMI_UNIT_CONVERTER__ */
  2194. #endif /* defined (__MMI_UNIT_CONVERTER__) || defined (__MMI_EXTENDED_UNIT_CONVERTER__) */ 
  2195. #endif /* _MMI_UNITCONVERTOR_C */ // #ifndef _MMI_UNITCONVERTOR_C