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

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.  * TypicalStopwatch.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   This file is intends for phone setup 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.  *------------------------------------------------------------------------------
  68.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  69.  *============================================================================
  70.  ****************************************************************************/
  71. /**
  72.  * Copyright Notice
  73.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  74.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  75.  *  (It is illegal to remove this copyright notice from this software or any
  76.  *  portion of it)
  77.  */
  78. /***************** Stopwatch Application implementation *********************/
  79. /**************************************************************
  80.    FILENAME : TypicalStopwatch.c
  81.    PURPOSE     : Typical Stopwatch application implementation
  82.    REMARKS     : nil
  83.    AUTHOR      : Deepali Gupta
  84.    DATE     : 05/01/2004
  85. **************************************************************/
  86. #include "MMI_features.h"
  87. #ifdef __MMI_STOPWATCH__
  88. /***********  Include: MMI header file **************/
  89. #include "PixtelDataTypes.h"
  90. #include "EventsGprot.h"
  91. #include "historyGprot.h"
  92. #include "ProtocolEvents.h"
  93. #include "wgui_categories.h"
  94. #include "wgui_categories_inputs.h"
  95. #include "wgui_categories_popup.h"
  96. #include "wgui_categories_stopwatch.h"
  97. #include "Globaldefs.h"
  98. #include "GlobalScrEnum.h"
  99. #include "HardwareEvents.h"
  100. #include "CustMenuRes.h"
  101. #include "CommonScreens.h"
  102. #include "MainMenuDef.h"
  103. #include "ProfileGprots.h"
  104. #include "StopwatchGdcl.h"
  105. #include "StopwatchDef.h"
  106. #include "StopwatchGprot.h"
  107. #include "StopwatchProt.h"
  108. // #include "wallpaper.h"
  109. #include "Unicodexdcl.h"
  110. #include "NVRAMEnum.h"
  111. #include "NVRAMProt.h"
  112. #include "NVRAMType.h"
  113. #include "gpioInc.h"
  114. #include "wgui_status_icons.h"
  115. #ifndef APP_EMAIL_UI_INTERFACE_DEBUG
  116. #undef PRINT_INFORMATION
  117. #define PRINT_INFORMATION(args) NULL
  118. #endif /* APP_EMAIL_UI_INTERFACE_DEBUG */ 
  119. /***************************************************************************** 
  120. * Define
  121. *****************************************************************************/
  122. #if (!defined(MMI_ON_HARDWARE_P) && !defined(NVRAM_EF_STOPWATCH_RECORD_SIZE))
  123. #define NVRAM_EF_STOPWATCH_RECORD_SIZE sizeof(gTimerRecordList)
  124. #endif 
  125. /***************************************************************************** 
  126. * Typedef 
  127. *****************************************************************************/
  128. /***************************************************************************** 
  129. * Local Variable (Local to this file - static)
  130. *****************************************************************************/
  131. /***************************************************************************** 
  132. * Local Function (local to this file - static)
  133. *****************************************************************************/
  134. /***************************************************************************** 
  135. * Global Variable
  136. *****************************************************************************/
  137. /***************************************************************************** 
  138. * Global Function
  139. *****************************************************************************/
  140. /**********************************************************************
  141. *****************************************************************************/
  142. /*****************************************************************************
  143.  * FUNCTION
  144.  *  InitStopwatchApp
  145.  * DESCRIPTION
  146.  *  Initialize stopwatch Application
  147.  * PARAMETERS
  148.  *  void
  149.  * RETURNS
  150.  *  void
  151.  *****************************************************************************/
  152. void InitStopwatchApp(void)
  153. {
  154.     /*----------------------------------------------------------------*/
  155.     /* Local Variables                                                */
  156.     /*----------------------------------------------------------------*/
  157.     /*----------------------------------------------------------------*/
  158.     /* Code Body                                                      */
  159.     /*----------------------------------------------------------------*/
  160.     SetHiliteHandler(MENU_STOPWATCH, HighlightStopwatch);
  161.     SetHiliteHandler(MENU_TYPICALSTOPWATCH, HighlightTypicalStopwatch);
  162.     SetHiliteHandler(MENU_MULTIPURPOSEWATCH, HighlightMultipurposeStopwatch);
  163.     SetHiliteHandler(MENU_SPLIT_TIMING, HighlightSplitTiming);
  164.     SetHiliteHandler(MENU_LAP_TIMING, HighlightLapTiming);
  165.     SetHiliteHandler(MENU_VIEW_RECORD, HighlightViewRecord);
  166.     SetHiliteHandler(MENU_SAVE_DONE, HighlightOptionDone);
  167.     SetHiliteHandler(MENU_SAVE_INPUTMETHOD, HighlightOptionInputMethod);
  168.     SetHiliteHandler(MENU_OPTION_VR_VIEW, HighlightOptionView);
  169.     SetHiliteHandler(MENU_OPTION_VR_DELETE, HighlightOptionDelete);
  170.     SetHiliteHandler(MENU_OPTION_VR_DELETE_ALL, HighlightOptionDeleteAll);
  171.     InitMultipurposeStopwatch();
  172.     ResetTypicalStopwatch();
  173. }
  174. /*****************************************************************************
  175.  * FUNCTION
  176.  *  InitStopwatchNVRAM
  177.  * DESCRIPTION
  178.  *  Initialize NVRAM for Stopwatch
  179.  * PARAMETERS
  180.  *  void
  181.  * RETURNS
  182.  *  void
  183.  *****************************************************************************/
  184. void InitStopwatchNVRAM(void)
  185. {
  186.     /*----------------------------------------------------------------*/
  187.     /* Local Variables                                                */
  188.     /*----------------------------------------------------------------*/
  189.     S16 error;
  190.     /*----------------------------------------------------------------*/
  191.     /* Code Body                                                      */
  192.     /*----------------------------------------------------------------*/
  193.     if (ReadRecord
  194.         (NVRAM_EF_STOPWATCH_LID, 1, &gTimerRecordList[0], MAX_STOPWATCH_RECORDS * sizeof(stopwatchRecord), &error) < 0)
  195.     {
  196.         PRINT_INFORMATION(("TYPICAL STOPWATCH : ReadRecord to read Timer Record failed (error code %d)", (int)error));
  197.     }
  198.     if (ReadValue(NVRAM_STOPWATCH_TOTAL_RECORDS, &gStopwatchAppInfo.numOfSavedTimerRecords, DS_BYTE, &error) < 0)
  199.     {
  200.         PRINT_INFORMATION(("TYPICAL STOPWATCH : ReadValue to read total Number of records failed (error code %d)",
  201.                            (int)error));
  202.     }
  203.     if (gStopwatchAppInfo.numOfSavedTimerRecords == 0xFF)
  204.     {
  205.         gStopwatchAppInfo.numOfSavedTimerRecords = 0;
  206.         if (WriteValue(NVRAM_STOPWATCH_TOTAL_RECORDS, &gStopwatchAppInfo.numOfSavedTimerRecords, DS_BYTE, &error) < 0)
  207.         {
  208.             PRINT_INFORMATION(("TYPICAL STOPWATCH-Bootup Time : WriteValue to write total Number of records failed (error code %d)", (int)error));
  209.         }
  210.     }
  211. }
  212. /*****************************************************************************
  213.  * FUNCTION
  214.  *  HighlightStopwatch
  215.  * DESCRIPTION
  216.  *  Highlight handler fn for stopwatch.
  217.  * PARAMETERS
  218.  *  void
  219.  * RETURNS
  220.  *  void
  221.  *****************************************************************************/
  222. void HighlightStopwatch(void)
  223. {
  224.     /*----------------------------------------------------------------*/
  225.     /* Local Variables                                                */
  226.     /*----------------------------------------------------------------*/
  227.     /*----------------------------------------------------------------*/
  228.     /* Code Body                                                      */
  229.     /*----------------------------------------------------------------*/
  230.     /* 1 Change left soft key icon and label */
  231.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  232.     /* 2 Change right soft key icon and label */
  233.     ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
  234.     /* 3 Register function for left soft key */
  235.     SetLeftSoftkeyFunction(EntryWtchScrStopwatch, KEY_EVENT_UP);
  236.     SetKeyHandler(EntryWtchScrStopwatch, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  237.     /* 4 Register function for right soft key */
  238.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  239.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  240. }
  241. /*****************************************************************************
  242.  * FUNCTION
  243.  *  HighlightTypicalStopwatch
  244.  * DESCRIPTION
  245.  *  Highlight handler fn for Typical stopwatch
  246.  * PARAMETERS
  247.  *  void
  248.  * RETURNS
  249.  *  void
  250.  *****************************************************************************/
  251. void HighlightTypicalStopwatch(void)
  252. {
  253.     /*----------------------------------------------------------------*/
  254.     /* Local Variables                                                */
  255.     /*----------------------------------------------------------------*/
  256.     /*----------------------------------------------------------------*/
  257.     /* Code Body                                                      */
  258.     /*----------------------------------------------------------------*/
  259.     /* 1 Change left soft key icon and label */
  260.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  261.     /* 2 Change right soft key icon and label */
  262.     ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
  263.     /* 3 Register function for left soft key */
  264.     SetLeftSoftkeyFunction(EntryWtchScrTypicalStopwatch, KEY_EVENT_UP);
  265.     SetKeyHandler(EntryWtchScrTypicalStopwatch, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  266.     /* 4 Register function for right soft key */
  267.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  268.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  269. }
  270. /*****************************************************************************
  271.  * FUNCTION
  272.  *  HighlightMultipurposeStopwatch
  273.  * DESCRIPTION
  274.  *  Highlight handler function for Multipurpose stop watch.
  275.  * PARAMETERS
  276.  *  void
  277.  * RETURNS
  278.  *  void
  279.  *****************************************************************************/
  280. void HighlightMultipurposeStopwatch(void)
  281. {
  282.     /*----------------------------------------------------------------*/
  283.     /* Local Variables                                                */
  284.     /*----------------------------------------------------------------*/
  285.     /*----------------------------------------------------------------*/
  286.     /* Code Body                                                      */
  287.     /*----------------------------------------------------------------*/
  288.     /* 1 Change left soft key icon and label */
  289.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  290.     /* 2 Change right soft key icon and label */
  291.     ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
  292.     /* 3 Register function for left soft key */
  293.     SetLeftSoftkeyFunction(EntryWtchScrMultipurposeStopwatch, KEY_EVENT_UP);
  294.     SetKeyHandler(EntryWtchScrMultipurposeStopwatch, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  295.     /* ClearKeyHandler(KEY_RIGHT_ARROW,KEY_EVENT_DOWN); */
  296.     /* 4 Register function for right soft key */
  297.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  298.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  299. }
  300. /*****************************************************************************
  301.  * FUNCTION
  302.  *  HighlightSplitTiming
  303.  * DESCRIPTION
  304.  *  Highlight handler fn for Split timing.
  305.  * PARAMETERS
  306.  *  void
  307.  * RETURNS
  308.  *  void
  309.  *****************************************************************************/
  310. void HighlightSplitTiming(void)
  311. {
  312.     /*----------------------------------------------------------------*/
  313.     /* Local Variables                                                */
  314.     /*----------------------------------------------------------------*/
  315.     /*----------------------------------------------------------------*/
  316.     /* Code Body                                                      */
  317.     /*----------------------------------------------------------------*/
  318.     if ((gStopwatchAppInfo.TimerState != TIMER_NOT_STARTED) && (gStopwatchAppInfo.splitLapTimer == LAP_TIMER))
  319.     {
  320.         SetLeftSoftkeyFunction(DisplayDiscontinueTimerQuery, KEY_EVENT_UP);
  321.         SetKeyHandler(DisplayDiscontinueTimerQuery, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  322.     }
  323.     else
  324.     {
  325.         gStopwatchAppInfo.splitLapTimer = SPLIT_TIMER;
  326.         /* Register function for left soft key */
  327.         SetLeftSoftkeyFunction(EntryWtchScrSplitLapTimingStopwatch, KEY_EVENT_UP);
  328.         SetKeyHandler(EntryWtchScrSplitLapTimingStopwatch, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  329.     }
  330.     /* 1 Change left soft key icon and label */
  331.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  332.     /* 2 Change right soft key icon and label */
  333.     ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
  334.     /* 4 Register function for right soft key */
  335.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  336.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  337. }
  338. /*****************************************************************************
  339.  * FUNCTION
  340.  *  HighlightLapTiming
  341.  * DESCRIPTION
  342.  *  Highlight handler fn for Lap Timing.
  343.  * PARAMETERS
  344.  *  void
  345.  * RETURNS
  346.  *  void
  347.  *****************************************************************************/
  348. void HighlightLapTiming(void)
  349. {
  350.     /*----------------------------------------------------------------*/
  351.     /* Local Variables                                                */
  352.     /*----------------------------------------------------------------*/
  353.     /*----------------------------------------------------------------*/
  354.     /* Code Body                                                      */
  355.     /*----------------------------------------------------------------*/
  356.     if ((gStopwatchAppInfo.TimerState != TIMER_NOT_STARTED) && (gStopwatchAppInfo.splitLapTimer == SPLIT_TIMER))
  357.     {
  358.         SetLeftSoftkeyFunction(DisplayDiscontinueTimerQuery, KEY_EVENT_UP);
  359.         SetKeyHandler(DisplayDiscontinueTimerQuery, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  360.     }
  361.     else
  362.     {
  363.         gStopwatchAppInfo.splitLapTimer = LAP_TIMER;
  364.         /* Register function for left soft key */
  365.         SetLeftSoftkeyFunction(EntryWtchScrSplitLapTimingStopwatch, KEY_EVENT_UP);
  366.         SetKeyHandler(EntryWtchScrSplitLapTimingStopwatch, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  367.     }
  368.     /* 1 Change left soft key icon and label */
  369.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  370.     /* 2 Change right soft key icon and label */
  371.     ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
  372.     /* 4 Register function for right soft key */
  373.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  374.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  375. }
  376. /*****************************************************************************
  377.  * FUNCTION
  378.  *  HighlightViewRecord
  379.  * DESCRIPTION
  380.  *  Highlight handler fn for View record
  381.  * PARAMETERS
  382.  *  void
  383.  * RETURNS
  384.  *  void
  385.  *****************************************************************************/
  386. void HighlightViewRecord(void)
  387. {
  388.     /*----------------------------------------------------------------*/
  389.     /* Local Variables                                                */
  390.     /*----------------------------------------------------------------*/
  391.     /*----------------------------------------------------------------*/
  392.     /* Code Body                                                      */
  393.     /*----------------------------------------------------------------*/
  394.     gStopwatchAppInfo.currHilitedRecord = 0;
  395.     /* 1 Change left soft key icon and label */
  396.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  397.     /* 2 Change right soft key icon and label */
  398.     ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
  399.     /* 3 Register function for left soft key */
  400.     SetLeftSoftkeyFunction(EntryWtchScrViewRecord, KEY_EVENT_UP);
  401.     SetKeyHandler(EntryWtchScrViewRecord, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  402.     /* ClearKeyHandler(KEY_RIGHT_ARROW,KEY_EVENT_DOWN); */
  403.     /* 4 Register function for right soft key */
  404.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  405.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  406. }
  407. /*****************************************************************************
  408.  * FUNCTION
  409.  *  HighlightOptionDone
  410.  * DESCRIPTION
  411.  *  Highlight handler for option Done
  412.  * PARAMETERS
  413.  *  void
  414.  * RETURNS
  415.  *  void
  416.  *****************************************************************************/
  417. void HighlightOptionDone(void)
  418. {
  419.     /*----------------------------------------------------------------*/
  420.     /* Local Variables                                                */
  421.     /*----------------------------------------------------------------*/
  422.     /*----------------------------------------------------------------*/
  423.     /* Code Body                                                      */
  424.     /*----------------------------------------------------------------*/
  425.     /* 1 Change left soft key icon and label */
  426.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  427.     /* 2 Change right soft key icon and label */
  428.     ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
  429.     /* 3 Register function for left soft key */
  430.     if (gStopwatchAppInfo.replaceRecord == TRUE)
  431.     {
  432.         SetLeftSoftkeyFunction(ReplaceSelectedRecord, KEY_EVENT_UP);
  433.         SetKeyHandler(ReplaceSelectedRecord, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  434.     }
  435.     else
  436.     {
  437.         SetLeftSoftkeyFunction(SaveTimerRecord, KEY_EVENT_UP);
  438.         SetKeyHandler(SaveTimerRecord, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  439.     }
  440.     /* 4 Register function for right soft key */
  441.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  442.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  443.     /* ClearKeyHandler(KEY_RIGHT_ARROW,KEY_EVENT_DOWN); */
  444. }
  445. /*****************************************************************************
  446.  * FUNCTION
  447.  *  HighlightOptionInputMethod
  448.  * DESCRIPTION
  449.  *  Highlight handler fn for option Input method
  450.  * PARAMETERS
  451.  *  void
  452.  * RETURNS
  453.  *  void
  454.  *****************************************************************************/
  455. void HighlightOptionInputMethod(void)
  456. {
  457.     /*----------------------------------------------------------------*/
  458.     /* Local Variables                                                */
  459.     /*----------------------------------------------------------------*/
  460.     /*----------------------------------------------------------------*/
  461.     /* Code Body                                                      */
  462.     /*----------------------------------------------------------------*/
  463.     /* 1 Change left soft key icon and label */
  464.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  465.     /* 2 Change right soft key icon and label */
  466.     ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
  467.     RegisterInputMethodScreenCloseFunction(GoBackHistoryFnFromInputMethod);
  468.     /* 3 Register function for left soft key */
  469.     SetLeftSoftkeyFunction(EntryInputMethodScreen, KEY_EVENT_UP);
  470.     SetKeyHandler(EntryInputMethodScreen, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  471.     /* 4 Register function for right soft key */
  472.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  473.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  474. }
  475. /*****************************************************************************
  476.  * FUNCTION
  477.  *  HighlightOptionView
  478.  * DESCRIPTION
  479.  *  Highlight handler fn for option View
  480.  * PARAMETERS
  481.  *  void
  482.  * RETURNS
  483.  *  void
  484.  *****************************************************************************/
  485. void HighlightOptionView(void)
  486. {
  487.     /*----------------------------------------------------------------*/
  488.     /* Local Variables                                                */
  489.     /*----------------------------------------------------------------*/
  490.     /*----------------------------------------------------------------*/
  491.     /* Code Body                                                      */
  492.     /*----------------------------------------------------------------*/
  493.     /* 1 Change left soft key icon and label */
  494.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  495.     /* 2 Change right soft key icon and label */
  496.     ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
  497.     /* 3 Register function for left soft key */
  498.     SetLeftSoftkeyFunction(EntryWtchScrViewSavedRecord, KEY_EVENT_UP);
  499.     SetKeyHandler(EntryWtchScrViewSavedRecord, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  500.     /* 4 Register function for right soft key */
  501.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  502.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  503.     //ClearKeyHandler(KEY_RIGHT_ARROW,KEY_EVENT_DOWN);
  504.     //ClearKeyHandler(KEY_LEFT_ARROW,KEY_EVENT_DOWN);
  505. }
  506. /*****************************************************************************
  507.  * FUNCTION
  508.  *  HighlightOptionDelete
  509.  * DESCRIPTION
  510.  *  Highlight handler fn for option Delete
  511.  * PARAMETERS
  512.  *  void
  513.  * RETURNS
  514.  *  void
  515.  *****************************************************************************/
  516. void HighlightOptionDelete(void)
  517. {
  518.     /*----------------------------------------------------------------*/
  519.     /* Local Variables                                                */
  520.     /*----------------------------------------------------------------*/
  521.     /*----------------------------------------------------------------*/
  522.     /* Code Body                                                      */
  523.     /*----------------------------------------------------------------*/
  524.     /* 1 Change left soft key icon and label */
  525.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  526.     /* 2 Change right soft key icon and label */
  527.     ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
  528.     /* 3 Register function for left soft key */
  529.     SetLeftSoftkeyFunction(EntryWtchScrDeleteRecord, KEY_EVENT_UP);
  530.     /* SetKeyHandler(EntryWtchScrDeleteRecord,KEY_RIGHT_ARROW,KEY_EVENT_DOWN); */
  531.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  532.     /* 4 Register function for right soft key */
  533.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  534.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  535.     /* ClearKeyHandler(KEY_LEFT_ARROW,KEY_EVENT_DOWN); */
  536. }
  537. /*****************************************************************************
  538.  * FUNCTION
  539.  *  HighlightOptionDeleteAll
  540.  * DESCRIPTION
  541.  *  Highlight handler fn for option Delete All.
  542.  * PARAMETERS
  543.  *  void
  544.  * RETURNS
  545.  *  void
  546.  *****************************************************************************/
  547. void HighlightOptionDeleteAll(void)
  548. {
  549.     /*----------------------------------------------------------------*/
  550.     /* Local Variables                                                */
  551.     /*----------------------------------------------------------------*/
  552.     /*----------------------------------------------------------------*/
  553.     /* Code Body                                                      */
  554.     /*----------------------------------------------------------------*/
  555.     /* 1 Change left soft key icon and label */
  556.     ChangeLeftSoftkey(STR_GLOBAL_OK, 0);
  557.     /* 2 Change right soft key icon and label */
  558.     ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
  559.     /* 3 Register function for left soft key */
  560.     SetLeftSoftkeyFunction(EntryWtchScrDeleteAllRecord, KEY_EVENT_UP);
  561.     /* SetKeyHandler(EntryWtchScrDeleteAllRecord,KEY_RIGHT_ARROW,KEY_EVENT_DOWN); */
  562.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  563.     /* 4 Register function for right soft key */
  564.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  565.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  566.     /* ClearKeyHandler(KEY_LEFT_ARROW,KEY_EVENT_DOWN); */
  567. }
  568. /*****************************************************************************
  569.  * FUNCTION
  570.  *  EntryWtchScrStopwatch
  571.  * DESCRIPTION
  572.  *  Entry fn for Stopwatch
  573.  * PARAMETERS
  574.  *  void
  575.  * RETURNS
  576.  *  void
  577.  *****************************************************************************/
  578. void EntryWtchScrStopwatch(void)
  579. {
  580.     /*----------------------------------------------------------------*/
  581.     /* Local Variables                                                */
  582.     /*----------------------------------------------------------------*/
  583.     U16 nStrItemList[15];   /* Stores the strings id of submenus returned */
  584.     U16 nNumofItem;         /* Stores no of children in the submenu */
  585.     U16 nDispAttribute;     /* Stores display attribue */
  586.     U8 *guiBuffer;          /* Buffer holding history data */
  587.     /*----------------------------------------------------------------*/
  588.     /* Code Body                                                      */
  589.     /*----------------------------------------------------------------*/
  590.     /* 1 Call Exit Handler */
  591.     EntryNewScreen(SCR_STOPWATCH, NULL, EntryWtchScrStopwatch, NULL);
  592.     /* 2 Get current screen to gui buffer  for history purposes */
  593.     guiBuffer = GetCurrGuiBuffer(SCR_STOPWATCH);
  594.     /* 3. Retrieve no of child of menu item to be displayed */
  595.     nNumofItem = GetNumOfChild(MENU_STOPWATCH);
  596.     /* 4. Get attribute of menu to be displayed */
  597.     nDispAttribute = GetDispAttributeOfItem(MENU_STOPWATCH);
  598.     /* 5. Retrieve string ids in sequence of given menu item to be displayed */
  599.     GetSequenceStringIds(MENU_STOPWATCH, nStrItemList);
  600.     /* 6 Set current parent id */
  601.     SetParentHandler(MENU_STOPWATCH);
  602.     /* 7 Register highlight handler to be called in menu screen */
  603.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  604.     /* 8 Display Category Screen */
  605.     ShowCategory15Screen(
  606.         STR_STOPWATCH_TITLE,
  607.         MAIN_MENU_TITLE_FUNANDGAMES_ICON,
  608.         STR_GLOBAL_OK,
  609.         IMG_GLOBAL_OK,
  610.         STR_GLOBAL_BACK,
  611.         IMG_GLOBAL_BACK,
  612.         nNumofItem,
  613.         nStrItemList,
  614.         (PU16) gIndexIconsImageList,
  615.         LIST_MENU,
  616.         0,
  617.         guiBuffer);
  618.     /* SetExitHandler(SCR_STOPWATCH,ExitWtchScrStopwatch); */
  619. }
  620. /*****************************************************************************
  621.  * FUNCTION
  622.  *  EntryWtchScrTypicalStopwatch
  623.  * DESCRIPTION
  624.  *  Entry fn for Typical Stopwatch.
  625.  * PARAMETERS
  626.  *  void
  627.  * RETURNS
  628.  *  void
  629.  *****************************************************************************/
  630. void EntryWtchScrTypicalStopwatch(void)
  631. {
  632.     /*----------------------------------------------------------------*/
  633.     /* Local Variables                                                */
  634.     /*----------------------------------------------------------------*/
  635.     U16 nStrItemList[15];   /* Stores the strings id of submenus returned */
  636.     U16 nNumofItem;         /* Stores no of children in the submenu */
  637.     U16 nDispAttribute;     /* Stores display attribue */
  638.     U8 *guiBuffer;          /* Buffer holding history data */
  639.     /*----------------------------------------------------------------*/
  640.     /* Code Body                                                      */
  641.     /*----------------------------------------------------------------*/
  642.     /* 1 Call Exit Handler */
  643.     EntryNewScreen(SCR_TYPICAL_STOPWATCH, NULL, EntryWtchScrTypicalStopwatch, NULL);
  644.     /* 2 Get current screen to gui buffer  for history purposes */
  645.     guiBuffer = GetCurrGuiBuffer(SCR_TYPICAL_STOPWATCH);
  646.     /* 3. Retrieve no of child of menu item to be displayed */
  647.     nNumofItem = GetNumOfChild(MENU_TYPICALSTOPWATCH);
  648.     /* 4. Get attribute of menu to be displayed */
  649.     nDispAttribute = GetDispAttributeOfItem(MENU_TYPICALSTOPWATCH);
  650.     /* 5. Retrieve string ids in sequence of given menu item to be displayed */
  651.     GetSequenceStringIds(MENU_TYPICALSTOPWATCH, nStrItemList);
  652.     /* 6 Set current parent id */
  653.     SetParentHandler(MENU_TYPICALSTOPWATCH);
  654.     /* 7 Register highlight handler to be called in menu screen */
  655.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  656.     /* 8 Display Category Screen */
  657.     ShowCategory15Screen(
  658.         STR_TYPICAL_STOPWATCH,
  659.         MAIN_MENU_TITLE_FUNANDGAMES_ICON,
  660.         STR_GLOBAL_OK,
  661.         IMG_GLOBAL_OK,
  662.         STR_GLOBAL_BACK,
  663.         IMG_GLOBAL_BACK,
  664.         nNumofItem,
  665.         nStrItemList,
  666.         (PU16) gIndexIconsImageList,
  667.         LIST_MENU,
  668.         0,
  669.         guiBuffer);
  670.     /* SetExitHandler(SCR_TYPICAL_STOPWATCH,ExitWtchScrTypicalStopwatch); */
  671. }
  672. /*****************************************************************************
  673.  * FUNCTION
  674.  *  EntryWtchScrSplitLapTimingStopwatch
  675.  * DESCRIPTION
  676.  *  Entry fn for Split/Lap timing stopwatch screen
  677.  * PARAMETERS
  678.  *  void
  679.  * RETURNS
  680.  *  void
  681.  *****************************************************************************/
  682. void EntryWtchScrSplitLapTimingStopwatch(void)
  683. {
  684.     /*----------------------------------------------------------------*/
  685.     /* Local Variables                                                */
  686.     /*----------------------------------------------------------------*/
  687.     U8 *guiBuffer;  /* Buffer holding history data */
  688.     /*----------------------------------------------------------------*/
  689.     /* Code Body                                                      */
  690.     /*----------------------------------------------------------------*/
  691.     /* 1 Call Exit Handler */
  692.     EntryNewScreen(SCR_SPLIT_TIMING, ExitWtchScrSplitLapTimingStopwatch, EntryWtchScrSplitLapTimingStopwatch, NULL);
  693.     /* 2 Get current screen to gui buffer  for history purposes */
  694.     guiBuffer = GetCurrGuiBuffer(SCR_SPLIT_TIMING);
  695.     /* 6 Set current parent id */
  696.     SetParentHandler(MENU_SPLIT_TIMING);
  697.     memset(gStopwatchAppInfo.recordName, 0, (MAX_RECORD_NAME_LENGTH + 1) * ENCODING_LENGTH);
  698.     /* 8 Display Category Screen */
  699.     /* entry_full_screen();//053005 Calvin moved to inside of ShowCategory307Screen */
  700.     if (gStopwatchAppInfo.TimerState == TIMER_NOT_STARTED)
  701.     {
  702.         if (gStopwatchAppInfo.splitLapTimer == SPLIT_TIMER)
  703.         {
  704.             ShowCategory307Screen(
  705.                 STR_STOPWATCH_START,
  706.                 0,
  707.                 STR_GLOBAL_BACK,
  708.                 IMG_GLOBAL_BACK,
  709.                 0,
  710.                 NULL,
  711.                 0,
  712.                 guiBuffer,
  713.                 IMG_TYPICALSW_BACKGROUND,
  714.                 CONTINUE_TIMER);
  715.         }
  716.         else
  717.         {
  718.             ShowCategory307Screen(
  719.                 STR_STOPWATCH_START,
  720.                 0,
  721.                 STR_GLOBAL_BACK,
  722.                 IMG_GLOBAL_BACK,
  723.                 0,
  724.                 NULL,
  725.                 0,
  726.                 guiBuffer,
  727.                 IMG_TYPICALSW_BACKGROUND,
  728.                 STOP_START_AGAIN);
  729.         }
  730.         SetLeftSoftkeyFunction(StartSplitLapTimer, KEY_EVENT_UP);
  731.         SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  732.     }
  733.     else if (gStopwatchAppInfo.TimerState == TIMER_STOPPED)
  734.     {
  735.         if (gStopwatchAppInfo.splitLapTimer == SPLIT_TIMER)
  736.         {
  737.             ShowCategory307Screen(
  738.                 STR_STOPWATCH_RESUME,
  739.                 0,
  740.                 STR_GLOBAL_BACK,
  741.                 IMG_GLOBAL_BACK,
  742.                 gStopwatchAppInfo.numofCurrTimerRecords,
  743.                 gCurrentRecords,
  744.                 0,
  745.                 guiBuffer,
  746.                 IMG_TYPICALSW_BACKGROUND,
  747.                 CONTINUE_TIMER);
  748.         }
  749.         else
  750.         {
  751.             ShowCategory307Screen(
  752.                 STR_STOPWATCH_RESUME,
  753.                 0,
  754.                 STR_GLOBAL_BACK,
  755.                 IMG_GLOBAL_BACK,
  756.                 gStopwatchAppInfo.numofCurrTimerRecords,
  757.                 gCurrentRecords,
  758.                 0,
  759.                 guiBuffer,
  760.                 IMG_TYPICALSW_BACKGROUND,
  761.                 STOP_START_AGAIN);
  762.         }
  763.         SetLeftSoftkeyFunction(ResumeSplitLapTimer, KEY_EVENT_UP);
  764.         SetLeftSoftkeyFunction(ResetSplitLapTimer, KEY_LONG_PRESS);
  765.         SetRightSoftkeyFunction(ConfirmSaveTimerRecord, KEY_EVENT_UP);
  766.     }
  767.     else
  768.     {
  769.         if (gStopwatchAppInfo.numofCurrTimerRecords < MAX_TIMER_RECORDS)
  770.         {
  771.             if (gStopwatchAppInfo.splitLapTimer == SPLIT_TIMER)
  772.             {
  773.                 ShowCategory307Screen(
  774.                     STR_STOPWATCH_STOP,
  775.                     0,
  776.                     STR_STOPWATCH_SPLIT,
  777.                     IMG_GLOBAL_BACK,
  778.                     gStopwatchAppInfo.numofCurrTimerRecords,
  779.                     gCurrentRecords,
  780.                     0,
  781.                     guiBuffer,
  782.                     IMG_TYPICALSW_BACKGROUND,
  783.                     CONTINUE_TIMER);
  784.             }
  785.             else
  786.             {
  787.                 ShowCategory307Screen(
  788.                     STR_STOPWATCH_STOP,
  789.                     0,
  790.                     STR_STOPWATCH_LAP,
  791.                     IMG_GLOBAL_BACK,
  792.                     gStopwatchAppInfo.numofCurrTimerRecords,
  793.                     gCurrentRecords,
  794.                     0,
  795.                     guiBuffer,
  796.                     IMG_TYPICALSW_BACKGROUND,
  797.                     STOP_START_AGAIN);
  798.             }
  799.             SetRightSoftkeyFunction(RecordSplitLapTime, KEY_EVENT_UP);
  800.         }
  801.         else
  802.         {
  803.             if (gStopwatchAppInfo.splitLapTimer == SPLIT_TIMER)
  804.             {
  805.                 ShowCategory307Screen(
  806.                     STR_STOPWATCH_STOP,
  807.                     0,
  808.                     0,
  809.                     0,
  810.                     gStopwatchAppInfo.numofCurrTimerRecords,
  811.                     gCurrentRecords,
  812.                     0,
  813.                     guiBuffer,
  814.                     IMG_TYPICALSW_BACKGROUND,
  815.                     CONTINUE_TIMER);
  816.             }
  817.             else
  818.             {
  819.                 ShowCategory307Screen(
  820.                     STR_STOPWATCH_STOP,
  821.                     0,
  822.                     0,
  823.                     0,
  824.                     gStopwatchAppInfo.numofCurrTimerRecords,
  825.                     gCurrentRecords,
  826.                     0,
  827.                     guiBuffer,
  828.                     IMG_TYPICALSW_BACKGROUND,
  829.                     STOP_START_AGAIN);
  830.             }
  831.         }
  832.         SetLeftSoftkeyFunction(StopSplitLapTimer, KEY_EVENT_UP);
  833.     }
  834. }
  835. /*****************************************************************************
  836.  * FUNCTION
  837.  *  ExitWtchScrSplitLapTimingStopwatch
  838.  * DESCRIPTION
  839.  *  Exit fn for Split/Lap timing screen.
  840.  * PARAMETERS
  841.  *  void
  842.  * RETURNS
  843.  *  void
  844.  *****************************************************************************/
  845. void ExitWtchScrSplitLapTimingStopwatch(void)
  846. {
  847.     /*----------------------------------------------------------------*/
  848.     /* Local Variables                                                */
  849.     /*----------------------------------------------------------------*/
  850.     /*----------------------------------------------------------------*/
  851.     /* Code Body                                                      */
  852.     /*----------------------------------------------------------------*/
  853.     /* leave_full_screen(); // 111104 Calvin removed */
  854.     if (gStopwatchAppInfo.TimerState == TIMER_RUNNING || gStopwatchAppInfo.MPTimerState == TIMER_RUNNING)
  855.     {
  856.         ShowStatusIcon(STATUS_ICON_STOP_WATCH);
  857.     }
  858.     else
  859.     {
  860.         HideStatusIcon(STATUS_ICON_STOP_WATCH);
  861.     }
  862.     UpdateStatusIcons();
  863. }
  864. /*****************************************************************************
  865.  * FUNCTION
  866.  *  StartSplitLapTimer
  867.  * DESCRIPTION
  868.  *  Start Split/lap Timer.
  869.  * PARAMETERS
  870.  *  void
  871.  * RETURNS
  872.  *  void
  873.  *****************************************************************************/
  874. void StartSplitLapTimer(void)
  875. {
  876.     /*----------------------------------------------------------------*/
  877.     /* Local Variables                                                */
  878.     /*----------------------------------------------------------------*/
  879.     /*----------------------------------------------------------------*/
  880.     /* Code Body                                                      */
  881.     /*----------------------------------------------------------------*/
  882.     start_stop_watch_timer(TIMER_START);
  883.     ChangeLeftSoftkey(STR_STOPWATCH_STOP, 0);
  884.     if (gStopwatchAppInfo.splitLapTimer)
  885.     {
  886.         ChangeRightSoftkey(STR_STOPWATCH_SPLIT, 0);
  887.     }
  888.     else
  889.     {
  890.         ChangeRightSoftkey(STR_STOPWATCH_LAP, 0);
  891.     }
  892.     SetLeftSoftkeyFunction(StopSplitLapTimer, KEY_EVENT_UP);
  893.     SetLeftSoftkeyFunction(NULL, KEY_LONG_PRESS);
  894.     SetRightSoftkeyFunction(RecordSplitLapTime, KEY_EVENT_UP);
  895.     gStopwatchAppInfo.TimerState = TIMER_RUNNING;
  896.     /* TurnOnBacklight(0); */
  897. }
  898. /*****************************************************************************
  899.  * FUNCTION
  900.  *  StopSplitLapTimer
  901.  * DESCRIPTION
  902.  *  Stop split/Lap timer.
  903.  * PARAMETERS
  904.  *  void
  905.  * RETURNS
  906.  *  void
  907.  *****************************************************************************/
  908. void StopSplitLapTimer(void)
  909. {
  910.     /*----------------------------------------------------------------*/
  911.     /* Local Variables                                                */
  912.     /*----------------------------------------------------------------*/
  913.     /*----------------------------------------------------------------*/
  914.     /* Code Body                                                      */
  915.     /*----------------------------------------------------------------*/
  916.     start_stop_watch_timer(TIMER_STOP);
  917.     ChangeLeftSoftkey(STR_STOPWATCH_RESUME, 0);
  918.     ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
  919.     SetLeftSoftkeyFunction(ResumeSplitLapTimer, KEY_EVENT_UP);
  920.     SetLeftSoftkeyFunction(ResetSplitLapTimer, KEY_LONG_PRESS);
  921.     SetRightSoftkeyFunction(ConfirmSaveTimerRecord, KEY_EVENT_UP);
  922.     /* TurnOnBacklight(1); */
  923.     gStopwatchAppInfo.TimerState = TIMER_STOPPED;
  924. }
  925. /*****************************************************************************
  926.  * FUNCTION
  927.  *  ResumeSplitLapTimer
  928.  * DESCRIPTION
  929.  *  Resume current split/Lap timer.
  930.  * PARAMETERS
  931.  *  void
  932.  * RETURNS
  933.  *  void
  934.  *****************************************************************************/
  935. void ResumeSplitLapTimer(void)
  936. {
  937.     /*----------------------------------------------------------------*/
  938.     /* Local Variables                                                */
  939.     /*----------------------------------------------------------------*/
  940.     /*----------------------------------------------------------------*/
  941.     /* Code Body                                                      */
  942.     /*----------------------------------------------------------------*/
  943.     start_stop_watch_timer(TIMER_START);
  944.     ChangeLeftSoftkey(STR_STOPWATCH_STOP, 0);
  945.     if (gStopwatchAppInfo.numofCurrTimerRecords >= MAX_TIMER_RECORDS)
  946.     {
  947.         ChangeRightSoftkey(0, 0);
  948.     }
  949.     else
  950.     {
  951.         if (gStopwatchAppInfo.splitLapTimer)
  952.         {
  953.             ChangeRightSoftkey(STR_STOPWATCH_SPLIT, 0);
  954.         }
  955.         else
  956.         {
  957.             ChangeRightSoftkey(STR_STOPWATCH_LAP, 0);
  958.         }
  959.         SetRightSoftkeyFunction(RecordSplitLapTime, KEY_EVENT_UP);
  960.     }
  961.     SetLeftSoftkeyFunction(StopSplitLapTimer, KEY_EVENT_UP);
  962.     SetLeftSoftkeyFunction(NULL, KEY_LONG_PRESS);
  963.     /* TurnOnBacklight(0); */
  964.     gStopwatchAppInfo.TimerState = TIMER_RUNNING;
  965. }
  966. /*****************************************************************************
  967.  * FUNCTION
  968.  *  ResetSplitLapTimer
  969.  * DESCRIPTION
  970.  *  Reset the Split/Lap Timer when Resume is long
  971.  *  pressed.
  972.  * PARAMETERS
  973.  *  void
  974.  * RETURNS
  975.  *  void
  976.  *****************************************************************************/
  977. void ResetSplitLapTimer(void)
  978. {
  979.     /*----------------------------------------------------------------*/
  980.     /* Local Variables                                                */
  981.     /*----------------------------------------------------------------*/
  982.     /*----------------------------------------------------------------*/
  983.     /* Code Body                                                      */
  984.     /*----------------------------------------------------------------*/
  985.     reset_timer();
  986.     ResetTypicalStopwatch();
  987.     ChangeLeftSoftkey(STR_STOPWATCH_START, 0);
  988.     ChangeRightSoftkey(STR_GLOBAL_BACK, 0);
  989.     SetLeftSoftkeyFunction(SetLSKforSplitLapTimerResumeLongPress, KEY_EVENT_UP);
  990.     SetLeftSoftkeyFunction(NULL, KEY_LONG_PRESS);
  991.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  992. }
  993. /*****************************************************************************
  994.  * FUNCTION
  995.  *  SetLSKforSplitLapTimerResumeLongPress
  996.  * DESCRIPTION
  997.  *  Set LSK handler fn when Resume is long
  998.  *  pressed to reset the Split timer..
  999.  * PARAMETERS
  1000.  *  void
  1001.  * RETURNS
  1002.  *  void
  1003.  *****************************************************************************/
  1004. void SetLSKforSplitLapTimerResumeLongPress(void)
  1005. {
  1006.     /*----------------------------------------------------------------*/
  1007.     /* Local Variables                                                */
  1008.     /*----------------------------------------------------------------*/
  1009.     /*----------------------------------------------------------------*/
  1010.     /* Code Body                                                      */
  1011.     /*----------------------------------------------------------------*/
  1012.     SetLeftSoftkeyFunction(StartSplitLapTimer, KEY_EVENT_UP);
  1013. }
  1014. /*****************************************************************************
  1015.  * FUNCTION
  1016.  *  RecordSplitLapTime
  1017.  * DESCRIPTION
  1018.  *  This function splits/Laps the Time..
  1019.  * PARAMETERS
  1020.  *  void
  1021.  * RETURNS
  1022.  *  void
  1023.  *****************************************************************************/
  1024. void RecordSplitLapTime(void)
  1025. {
  1026.     /*----------------------------------------------------------------*/
  1027.     /* Local Variables                                                */
  1028.     /*----------------------------------------------------------------*/
  1029.     S32 mili, hr, min, sec;
  1030.     /*----------------------------------------------------------------*/
  1031.     /* Code Body                                                      */
  1032.     /*----------------------------------------------------------------*/
  1033.     UpdateHistoryValue(&mili, &hr, &min, &sec);
  1034.     gCurrentRecords[gStopwatchAppInfo.numofCurrTimerRecords].hour = hr;
  1035.     gCurrentRecords[gStopwatchAppInfo.numofCurrTimerRecords].min = min;
  1036.     gCurrentRecords[gStopwatchAppInfo.numofCurrTimerRecords].sec = sec;
  1037.     gCurrentRecords[gStopwatchAppInfo.numofCurrTimerRecords].mili_sec = mili;
  1038.     gStopwatchAppInfo.numofCurrTimerRecords++;
  1039.     if (gStopwatchAppInfo.numofCurrTimerRecords >= MAX_TIMER_RECORDS)
  1040.     {
  1041.         ChangeRightSoftkey(0, 0);
  1042.     }
  1043.     gStopwatchAppInfo.isRecordPresent = TRUE;
  1044. }
  1045. /*****************************************************************************
  1046.  * FUNCTION
  1047.  *  ConfirmSaveTimerRecord
  1048.  * DESCRIPTION
  1049.  *  Confirmation screen for saving the timer record.
  1050.  * PARAMETERS
  1051.  *  void
  1052.  * RETURNS
  1053.  *  void
  1054.  *****************************************************************************/
  1055. void ConfirmSaveTimerRecord(void)
  1056. {
  1057.     /*----------------------------------------------------------------*/
  1058.     /* Local Variables                                                */
  1059.     /*----------------------------------------------------------------*/
  1060.     /*----------------------------------------------------------------*/
  1061.     /* Code Body                                                      */
  1062.     /*----------------------------------------------------------------*/
  1063.     if (gStopwatchAppInfo.isRecordPresent == TRUE)
  1064.     {
  1065.         DisplayConfirm(
  1066.             STR_GLOBAL_YES,
  1067.             IMG_GLOBAL_YES,
  1068.             STR_GLOBAL_NO,
  1069.             IMG_GLOBAL_NO,
  1070.             get_string(STR_GLOBAL_SAVE),
  1071.             IMG_GLOBAL_QUESTION,
  1072.             WARNING_TONE);
  1073.         /* 9.Register function with right softkey */
  1074.         SetRightSoftkeyFunction(GoBackToStopwatchMenu, KEY_EVENT_UP);
  1075.         if (gStopwatchAppInfo.numOfSavedTimerRecords < MAX_STOPWATCH_RECORDS)
  1076.         {
  1077.             SetLeftSoftkeyFunction(EntryWtchScrEnterRecordName, KEY_EVENT_UP);
  1078.         }
  1079.         else
  1080.         {
  1081.             SetLeftSoftkeyFunction(EntryWtchScrMemoryFull, KEY_EVENT_UP);
  1082.         }
  1083.     }
  1084.     else
  1085.     {
  1086.         ResetTypicalStopwatch();
  1087.         GoBackHistory();
  1088.     }
  1089. }
  1090. /*****************************************************************************
  1091.  * FUNCTION
  1092.  *  GoBackToStopwatchMenu
  1093.  * DESCRIPTION
  1094.  *  This fn takes user to StopwatchMenu screen.
  1095.  * PARAMETERS
  1096.  *  void
  1097.  * RETURNS
  1098.  *  void
  1099.  *****************************************************************************/
  1100. void GoBackToStopwatchMenu(void)
  1101. {
  1102.     /*----------------------------------------------------------------*/
  1103.     /* Local Variables                                                */
  1104.     /*----------------------------------------------------------------*/
  1105.     /*----------------------------------------------------------------*/
  1106.     /* Code Body                                                      */
  1107.     /*----------------------------------------------------------------*/
  1108.     DeleteUptoScrID(SCR_TYPICAL_STOPWATCH);
  1109.     ResetTypicalStopwatch();
  1110.     GoBackHistory();
  1111. }
  1112. /*****************************************************************************
  1113.  * FUNCTION
  1114.  *  EntryWtchScrEnterRecordName
  1115.  * DESCRIPTION
  1116.  *  This function gets the record name.
  1117.  * PARAMETERS
  1118.  *  void
  1119.  * RETURNS
  1120.  *  void
  1121.  *****************************************************************************/
  1122. void EntryWtchScrEnterRecordName(void)
  1123. {
  1124.     /*----------------------------------------------------------------*/
  1125.     /* Local Variables                                                */
  1126.     /*----------------------------------------------------------------*/
  1127.     U8 *guiBuffer;
  1128.     /*----------------------------------------------------------------*/
  1129.     /* Code Body                                                      */
  1130.     /*----------------------------------------------------------------*/
  1131.     EntryNewScreen(SCR_ENTER_RECORD_NAME, ExitWtchScrRecordName, NULL, NULL);
  1132.     guiBuffer = GetCurrGuiBuffer(SCR_ENTER_RECORD_NAME);
  1133.     ShowCategory5Screen(
  1134.         STR_STOPWATCH_SAVE_STOPWATCH,
  1135.         MAIN_MENU_TITLE_FUNANDGAMES_ICON,
  1136.         STR_GLOBAL_OPTIONS,
  1137.         IMG_GLOBAL_OPTIONS,
  1138.         STR_GLOBAL_BACK,
  1139.         IMG_GLOBAL_BACK,
  1140.         INPUT_TYPE_ALPHANUMERIC_SENTENCECASE,
  1141.         (PU8) gStopwatchAppInfo.recordName,
  1142.         (MAX_RECORD_NAME_LENGTH + 1),
  1143.         guiBuffer);
  1144.     SetLeftSoftkeyFunction(EntryWtchRecordSaveOption, KEY_EVENT_UP);
  1145.     SetCategory5RightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1146. }
  1147. /*****************************************************************************
  1148.  * FUNCTION
  1149.  *  ExitWtchScrRecordName
  1150.  * DESCRIPTION
  1151.  *  Exit function for Record Name Screen
  1152.  * PARAMETERS
  1153.  *  void
  1154.  * RETURNS
  1155.  *  void
  1156.  *****************************************************************************/
  1157. void ExitWtchScrRecordName(void)
  1158. {
  1159.     /*----------------------------------------------------------------*/
  1160.     /* Local Variables                                                */
  1161.     /*----------------------------------------------------------------*/
  1162.     history scr;
  1163.     /*----------------------------------------------------------------*/
  1164.     /* Code Body                                                      */
  1165.     /*----------------------------------------------------------------*/
  1166.     scr.scrnID = SCR_ENTER_RECORD_NAME;
  1167.     scr.entryFuncPtr = EntryWtchScrEnterRecordName;
  1168.     pfnUnicodeStrcpy((S8*) scr.inputBuffer, (S8*) gStopwatchAppInfo.recordName);
  1169.     GetCategoryHistory(scr.guiBuffer);
  1170.     AddHistory(scr);
  1171. }
  1172. /*****************************************************************************
  1173.  * FUNCTION
  1174.  *  EntryWtchRecordSaveOption
  1175.  * DESCRIPTION
  1176.  *  This function Displays the options for record save.
  1177.  * PARAMETERS
  1178.  *  void
  1179.  * RETURNS
  1180.  *  void
  1181.  *****************************************************************************/
  1182. void EntryWtchRecordSaveOption(void)
  1183. {
  1184.     /*----------------------------------------------------------------*/
  1185.     /* Local Variables                                                */
  1186.     /*----------------------------------------------------------------*/
  1187.     U8 *guiBuffer = NULL;
  1188.     U16 itemList[2];
  1189.     U16 nItems;
  1190.     /*----------------------------------------------------------------*/
  1191.     /* Code Body                                                      */
  1192.     /*----------------------------------------------------------------*/
  1193.     EntryNewScreen(SCR_SAVE_OPTIONS, NULL, EntryWtchRecordSaveOption, NULL);
  1194.     SetParentHandler(MENU_RECORD_SAVE_OPTIONS);
  1195.     guiBuffer = GetCurrGuiBuffer(SCR_SAVE_OPTIONS);
  1196.     nItems = GetNumOfChild(MENU_RECORD_SAVE_OPTIONS);
  1197.     GetSequenceStringIds(MENU_RECORD_SAVE_OPTIONS, itemList);
  1198.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  1199.     ShowCategory52Screen(
  1200.         STR_GLOBAL_OPTIONS,
  1201.         MAIN_MENU_TITLE_FUNANDGAMES_ICON,
  1202.         STR_GLOBAL_OK,
  1203.         IMG_GLOBAL_OK,
  1204.         STR_GLOBAL_BACK,
  1205.         IMG_GLOBAL_BACK,
  1206.         nItems,
  1207.         itemList,
  1208.         (PU16) gIndexIconsImageList,
  1209.         0,
  1210.         0,
  1211.         0,
  1212.         guiBuffer);
  1213. }
  1214. /*****************************************************************************
  1215.  * FUNCTION
  1216.  *  GoBackHistoryFnFromInputMethod
  1217.  * DESCRIPTION
  1218.  *  Fn to be register for go back history from Input method screen
  1219.  * PARAMETERS
  1220.  *  void
  1221.  * RETURNS
  1222.  *  void
  1223.  *****************************************************************************/
  1224. void GoBackHistoryFnFromInputMethod(void)
  1225. {
  1226.     /*----------------------------------------------------------------*/
  1227.     /* Local Variables                                                */
  1228.     /*----------------------------------------------------------------*/
  1229.     /*----------------------------------------------------------------*/
  1230.     /* Code Body                                                      */
  1231.     /*----------------------------------------------------------------*/
  1232.     GoBacknHistory(1);
  1233. }
  1234. /*****************************************************************************
  1235.  * FUNCTION
  1236.  *  SaveTimerRecord
  1237.  * DESCRIPTION
  1238.  *  Saves Timer Record in NVRAM.
  1239.  * PARAMETERS
  1240.  *  void
  1241.  * RETURNS
  1242.  *  void
  1243.  *****************************************************************************/
  1244. void SaveTimerRecord(void)
  1245. {
  1246.     /*----------------------------------------------------------------*/
  1247.     /* Local Variables                                                */
  1248.     /*----------------------------------------------------------------*/
  1249.     U8 index;
  1250.     S16 error;
  1251.     /*----------------------------------------------------------------*/
  1252.     /* Code Body                                                      */
  1253.     /*----------------------------------------------------------------*/
  1254.     if (pfnUnicodeStrlen((S8*) gStopwatchAppInfo.recordName) != 0)
  1255.     {
  1256.         memset(&gTimerRecordList[gStopwatchAppInfo.numOfSavedTimerRecords], 0, sizeof(stopwatchRecord));
  1257.         memcpy(
  1258.             &gTimerRecordList[gStopwatchAppInfo.numOfSavedTimerRecords].name,
  1259.             gStopwatchAppInfo.recordName,
  1260.             MAX_RECORD_NAME_LENGTH * ENCODING_LENGTH);
  1261.         gTimerRecordList[gStopwatchAppInfo.numOfSavedTimerRecords].numOfRecords =
  1262.             (U8) gStopwatchAppInfo.numofCurrTimerRecords;
  1263.         for (index = 0; index < gStopwatchAppInfo.numofCurrTimerRecords; index++)
  1264.         {
  1265.             gTimerRecordList[gStopwatchAppInfo.numOfSavedTimerRecords].nRecordData[index].recHr =
  1266.                 (U8) gCurrentRecords[index].hour;
  1267.             gTimerRecordList[gStopwatchAppInfo.numOfSavedTimerRecords].nRecordData[index].recMin =
  1268.                 (U8) gCurrentRecords[index].min;
  1269.             gTimerRecordList[gStopwatchAppInfo.numOfSavedTimerRecords].nRecordData[index].recSec =
  1270.                 (U8) gCurrentRecords[index].sec;
  1271.             gTimerRecordList[gStopwatchAppInfo.numOfSavedTimerRecords].nRecordData[index].recMsec =
  1272.                 (U8) gCurrentRecords[index].mili_sec;
  1273.         }
  1274.         gStopwatchAppInfo.numOfSavedTimerRecords++;
  1275.         if (WriteValue(NVRAM_STOPWATCH_TOTAL_RECORDS, &gStopwatchAppInfo.numOfSavedTimerRecords, DS_BYTE, &error) < 0)
  1276.         {
  1277.             PRINT_INFORMATION(("TYPICAL STOPWATCH - Save Record : WriteValue to write total Number of records failed (error code %d)", (int)error));
  1278.         }
  1279.         if (WriteRecord(NVRAM_EF_STOPWATCH_LID, 1, &gTimerRecordList[0], NVRAM_EF_STOPWATCH_RECORD_SIZE, &error) < 0)
  1280.         {
  1281.             PRINT_INFORMATION(("TYPICAL STOPWATCH - Save Record : WriteRecord to write Timer record failed (error code %d)", (int)error));
  1282.         }
  1283.         DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, POPUP_TIME, SUCCESS_TONE);
  1284.         ResetTypicalStopwatch();
  1285.         DeleteUptoScrID(SCR_TYPICAL_STOPWATCH);
  1286.     }
  1287.     else
  1288.     {
  1289.         DisplayPopup((PU8) GetString(STR_EMPTY_NAME), IMG_GLOBAL_EMPTY, 1, POPUP_TIME, ERROR_TONE);
  1290.         DeleteUptoScrID(SCR_ENTER_RECORD_NAME);
  1291.     }
  1292. }
  1293. /*****************************************************************************
  1294.  * FUNCTION
  1295.  *  FailedSaveTimerRecord
  1296.  * DESCRIPTION
  1297.  *  Failed in saving timer record.
  1298.  * PARAMETERS
  1299.  *  void
  1300.  * RETURNS
  1301.  *  void
  1302.  *****************************************************************************/
  1303. void FailedSaveTimerRecord(void)
  1304. {
  1305.     /*----------------------------------------------------------------*/
  1306.     /* Local Variables                                                */
  1307.     /*----------------------------------------------------------------*/
  1308.     /*----------------------------------------------------------------*/
  1309.     /* Code Body                                                      */
  1310.     /*----------------------------------------------------------------*/
  1311.     DisplayPopup((PU8) GetString(STR_STOPWATCH_NOT_SAVED), IMG_GLOBAL_WARNING, 1, POPUP_TIME, WARNING_TONE);
  1312.     DeleteUptoScrID(SCR_TYPICAL_STOPWATCH);
  1313.     ResetTypicalStopwatch();
  1314. }
  1315. /*****************************************************************************
  1316.  * FUNCTION
  1317.  *  EntryWtchScrViewRecord
  1318.  * DESCRIPTION
  1319.  *  Entry fn for view record list.
  1320.  * PARAMETERS
  1321.  *  void
  1322.  * RETURNS
  1323.  *  void
  1324.  *****************************************************************************/
  1325. void EntryWtchScrViewRecord(void)
  1326. {
  1327.     /*----------------------------------------------------------------*/
  1328.     /* Local Variables                                                */
  1329.     /*----------------------------------------------------------------*/
  1330.     U8 *guiBuffer = NULL;
  1331.     U8 count = 0;
  1332.     /*----------------------------------------------------------------*/
  1333.     /* Code Body                                                      */
  1334.     /*----------------------------------------------------------------*/
  1335.     if (gStopwatchAppInfo.numOfSavedTimerRecords > 0)
  1336.     {
  1337.         for (count = 0; count < gStopwatchAppInfo.numOfSavedTimerRecords; count++)
  1338.         {
  1339.             pfnUnicodeStrcpy((S8*) subMenuDataPtrs[count], (S8*) gTimerRecordList[count].name);
  1340.         }
  1341.     }
  1342.     if (gStopwatchAppInfo.numOfSavedTimerRecords == 0)
  1343.     {
  1344.         /* Robin 0726, use global string defination */
  1345.         DisplayPopup(
  1346.             (PU8) GetString(STR_GLOBAL_EMPTY /* STR_STOPWATCH_LIST_EMPTY */ ),
  1347.             IMG_GLOBAL_EMPTY,
  1348.             1,
  1349.             POPUP_TIME,
  1350.             EMPTY_LIST_TONE);
  1351.     }
  1352.     else
  1353.     {
  1354.         guiBuffer = GetCurrGuiBuffer(SCR_VIEW_RECORD);
  1355.         EntryNewScreen(SCR_VIEW_RECORD, NULL, EntryWtchScrViewRecord, NULL);
  1356.         SetParentHandler(MENU_VIEW_RECORD);
  1357.         RegisterHighlightHandler(GetSelectedItemIndex);
  1358.         /* Register function for left soft key */
  1359.         ShowCategory84Screen(
  1360.             STR_VIEW_RECORD,
  1361.             MAIN_MENU_TITLE_FUNANDGAMES_ICON,
  1362.             STR_GLOBAL_OPTIONS,
  1363.             IMG_GLOBAL_OPTIONS,
  1364.             STR_GLOBAL_BACK,
  1365.             IMG_GLOBAL_BACK,
  1366.             gStopwatchAppInfo.numOfSavedTimerRecords,
  1367.             (U8 **) subMenuDataPtrs,
  1368.             (PU16) gIndexIconsImageList,
  1369.             0,
  1370.             gStopwatchAppInfo.currHilitedRecord,
  1371.             guiBuffer);
  1372.         SetLeftSoftkeyFunction(EntryWtchScrViewRecordOptions, KEY_EVENT_UP);
  1373.         /* Register function for right soft key */
  1374.         SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1375.     }
  1376. }
  1377. /*****************************************************************************
  1378.  * FUNCTION
  1379.  *  GetSelectedItemIndex
  1380.  * DESCRIPTION
  1381.  *  Function to store current hilited record in global variable.
  1382.  * PARAMETERS
  1383.  *  hilitedIndex        [IN]        
  1384.  *  Current(?)          [IN]        Hilite Index
  1385.  * RETURNS
  1386.  *  void
  1387.  *****************************************************************************/
  1388. void GetSelectedItemIndex(S32 hilitedIndex)
  1389. {
  1390.     /*----------------------------------------------------------------*/
  1391.     /* Local Variables                                                */
  1392.     /*----------------------------------------------------------------*/
  1393.     /*----------------------------------------------------------------*/
  1394.     /* Code Body                                                      */
  1395.     /*----------------------------------------------------------------*/
  1396.     gStopwatchAppInfo.currHilitedRecord = hilitedIndex;
  1397. }
  1398. /*****************************************************************************
  1399.  * FUNCTION
  1400.  *  EntryWtchScrViewRecordOptions
  1401.  * DESCRIPTION
  1402.  *  Entry fn for view record options list.
  1403.  * PARAMETERS
  1404.  *  void
  1405.  * RETURNS
  1406.  *  void
  1407.  *****************************************************************************/
  1408. void EntryWtchScrViewRecordOptions(void)
  1409. {
  1410.     /*----------------------------------------------------------------*/
  1411.     /* Local Variables                                                */
  1412.     /*----------------------------------------------------------------*/
  1413.     U16 nStrItemList[MAX_SUB_MENUS];    /* Stores the strings id of submenus returned */
  1414.     U16 nNumofItem;                     /* Stores no of children in the submenu */
  1415.     U16 nDispAttribute;                 /* Stores display attribue */
  1416.     U8 *guiBuffer;                      /* Buffer holding history data */
  1417.     /*----------------------------------------------------------------*/
  1418.     /* Code Body                                                      */
  1419.     /*----------------------------------------------------------------*/
  1420.     /* 1 Call Exit Handler */
  1421.     EntryNewScreen(SCR_VIEW_RECORD_OPTIONS, NULL, EntryWtchScrViewRecordOptions, NULL);
  1422.     /* 2 Get current screen to gui buffer  for history purposes */
  1423.     guiBuffer = GetCurrGuiBuffer(SCR_VIEW_RECORD_OPTIONS);
  1424.     /* 3. Retrieve no of child of menu item to be displayed */
  1425.     nNumofItem = GetNumOfChild(MENU_VIEW_RECORD_OPTIONS);
  1426.     /* 4. Get attribute of menu to be displayed */
  1427.     nDispAttribute = GetDispAttributeOfItem(MENU_VIEW_RECORD_OPTIONS);
  1428.     /* 5. Retrieve string ids in sequence of given menu item to be displayed */
  1429.     GetSequenceStringIds(MENU_VIEW_RECORD_OPTIONS, nStrItemList);
  1430.     /* 6 Set current parent id */
  1431.     SetParentHandler(MENU_VIEW_RECORD_OPTIONS);
  1432.     /* 7 Register highlight handler to be called in menu screen */
  1433.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  1434.     ShowCategory15Screen(
  1435.         STR_GLOBAL_OPTIONS,
  1436.         MAIN_MENU_TITLE_FUNANDGAMES_ICON,
  1437.         STR_GLOBAL_OK,
  1438.         IMG_GLOBAL_OK,
  1439.         STR_GLOBAL_BACK,
  1440.         IMG_GLOBAL_BACK,
  1441.         nNumofItem,
  1442.         nStrItemList,
  1443.         (PU16) gIndexIconsImageList,
  1444.         LIST_MENU,
  1445.         0,
  1446.         guiBuffer);
  1447.     /* 9.Register function with right softkey */
  1448.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1449.     /* 10. Register Exit handler */
  1450. }
  1451. /*****************************************************************************
  1452.  * FUNCTION
  1453.  *  EntryWtchScrViewSavedRecord
  1454.  * DESCRIPTION
  1455.  *  Entry fn To view saved record.
  1456.  * PARAMETERS
  1457.  *  void
  1458.  * RETURNS
  1459.  *  void
  1460.  *****************************************************************************/
  1461. void EntryWtchScrViewSavedRecord(void)
  1462. {
  1463.     /*----------------------------------------------------------------*/
  1464.     /* Local Variables                                                */
  1465.     /*----------------------------------------------------------------*/
  1466.     U8 *guiBuffer = NULL;
  1467.     U8 currRecordNum = 0;
  1468.     U8 *listItemsIcons[MAX_SUB_MENUS];
  1469.     nRecordDetail *localRecord;
  1470.     U8 localRecordString[(MAX_TIMER_RECORD_DIGITS + 1) * ENCODING_LENGTH];
  1471.     /*----------------------------------------------------------------*/
  1472.     /* Code Body                                                      */
  1473.     /*----------------------------------------------------------------*/
  1474.     EntryNewScreen(SCR_VIEW_SAVED_RECORD, NULL, EntryWtchScrViewSavedRecord, NULL);
  1475.     for (currRecordNum = 0; currRecordNum < gTimerRecordList[gStopwatchAppInfo.currHilitedRecord].numOfRecords;
  1476.          currRecordNum++)
  1477.     {
  1478.         memset(localRecordString, 0, (MAX_TIMER_RECORD_DIGITS + 1) * ENCODING_LENGTH);
  1479.         localRecord = &gTimerRecordList[gStopwatchAppInfo.currHilitedRecord].nRecordData[currRecordNum];
  1480.         change_stopwatchtime_to_string(
  1481.             (S32) localRecord->recMsec,
  1482.             (S32) localRecord->recHr,
  1483.             (S32) localRecord->recMin,
  1484.             (S32) localRecord->recSec,
  1485.             &localRecordString[0],
  1486.             DISPLAY_MILISEC_TRUE);
  1487.         pfnUnicodeStrcpy((S8*) subMenuDataPtrs[currRecordNum], (S8*) localRecordString);
  1488.         listItemsIcons[currRecordNum] = (U8*) GetImage(gIndexIconsImageList[currRecordNum]);
  1489.     }
  1490.     guiBuffer = GetCurrGuiBuffer(SCR_VIEW_SAVED_RECORD);
  1491.     SetParentHandler(MENU_OPTION_VR_VIEW);
  1492.     /* Register function for left soft key */
  1493.     ShowCategory32Screen(
  1494.         (U8*) gTimerRecordList[gStopwatchAppInfo.currHilitedRecord].name,
  1495.         NULL,
  1496.         NULL,
  1497.         NULL,
  1498.         (PU8) GetString(STR_GLOBAL_BACK),
  1499.         (PU8) GetImage(IMG_GLOBAL_BACK),
  1500.         currRecordNum,
  1501.         (U8 **) subMenuDataPtrs,
  1502.         listItemsIcons,
  1503.         0,
  1504.         0,
  1505.         guiBuffer);
  1506.     /* Register function for right soft key */
  1507.     DeleteUptoScrID(SCR_VIEW_RECORD);
  1508.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1509. }
  1510. /*****************************************************************************
  1511.  * FUNCTION
  1512.  *  EntryWtchScrDeleteRecord
  1513.  * DESCRIPTION
  1514.  *  Entry fn To Delete record.
  1515.  * PARAMETERS
  1516.  *  void
  1517.  * RETURNS
  1518.  *  void
  1519.  *****************************************************************************/
  1520. void EntryWtchScrDeleteRecord(void)
  1521. {
  1522.     /*----------------------------------------------------------------*/
  1523.     /* Local Variables                                                */
  1524.     /*----------------------------------------------------------------*/
  1525.     /*----------------------------------------------------------------*/
  1526.     /* Code Body                                                      */
  1527.     /*----------------------------------------------------------------*/
  1528.     DisplayConfirm(
  1529.         STR_GLOBAL_YES,
  1530.         IMG_GLOBAL_YES,
  1531.         STR_GLOBAL_NO,
  1532.         IMG_GLOBAL_NO,
  1533.         get_string(STR_GLOBAL_DELETE),
  1534.         IMG_GLOBAL_QUESTION,
  1535.         WARNING_TONE);
  1536.     /* 9.Register function with right softkey */
  1537.     DeleteUptoScrID(SCR_VIEW_RECORD);
  1538.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1539.     SetLeftSoftkeyFunction(DeleteSelectedRecord, KEY_EVENT_UP);
  1540. }
  1541. /*****************************************************************************
  1542.  * FUNCTION
  1543.  *  DeleteSelectedRecord
  1544.  * DESCRIPTION
  1545.  *  This function deletes curently selected record.
  1546.  * PARAMETERS
  1547.  *  void
  1548.  * RETURNS
  1549.  *  void
  1550.  *****************************************************************************/
  1551. void DeleteSelectedRecord(void)
  1552. {
  1553.     /*----------------------------------------------------------------*/
  1554.     /* Local Variables                                                */
  1555.     /*----------------------------------------------------------------*/
  1556.     U8 count;
  1557.     S16 error;
  1558.     /*----------------------------------------------------------------*/
  1559.     /* Code Body                                                      */
  1560.     /*----------------------------------------------------------------*/
  1561.     memset(&gTimerRecordList[gStopwatchAppInfo.currHilitedRecord], 0, sizeof(stopwatchRecord));
  1562.     for (count = (U8) gStopwatchAppInfo.currHilitedRecord; count + 1 < gStopwatchAppInfo.numOfSavedTimerRecords;
  1563.          count++)
  1564.     {
  1565.         memcpy(&gTimerRecordList[count], &gTimerRecordList[count + 1], sizeof(stopwatchRecord));
  1566.     }
  1567.     memset(&gTimerRecordList[--gStopwatchAppInfo.numOfSavedTimerRecords], 0, sizeof(stopwatchRecord));
  1568.     if (WriteValue(NVRAM_STOPWATCH_TOTAL_RECORDS, &gStopwatchAppInfo.numOfSavedTimerRecords, DS_BYTE, &error) < 0)
  1569.     {
  1570.         PRINT_INFORMATION(("TYPICAL STOPWATCH - Delete Record : WriteValue to write total Number of records failed (error code %d)", (int)error));
  1571.     }
  1572.     if (WriteRecord(NVRAM_EF_STOPWATCH_LID, 1, &gTimerRecordList[0], NVRAM_EF_STOPWATCH_RECORD_SIZE, &error) < 0)
  1573.     {
  1574.         PRINT_INFORMATION(("TYPICAL STOPWATCH - Delete Record : WriteRecord to write Timer record failed (error code %d)", (int)error));
  1575.     }
  1576.     DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, POPUP_TIME, SUCCESS_TONE);
  1577.     if (gStopwatchAppInfo.numOfSavedTimerRecords == 0)
  1578.     {
  1579.         DeleteUptoScrID(SCR_TYPICAL_STOPWATCH);
  1580.     }
  1581.     else
  1582.     {
  1583.         DeleteUptoScrID(SCR_VIEW_RECORD);
  1584.     }
  1585. }
  1586. /*****************************************************************************
  1587.  * FUNCTION
  1588.  *  EntryWtchScrDeleteAllRecord
  1589.  * DESCRIPTION
  1590.  *  Entry fn To confirm Delete all record.
  1591.  * PARAMETERS
  1592.  *  void
  1593.  * RETURNS
  1594.  *  void
  1595.  *****************************************************************************/
  1596. void EntryWtchScrDeleteAllRecord(void)
  1597. {
  1598.     /*----------------------------------------------------------------*/
  1599.     /* Local Variables                                                */
  1600.     /*----------------------------------------------------------------*/
  1601.     /*----------------------------------------------------------------*/
  1602.     /* Code Body                                                      */
  1603.     /*----------------------------------------------------------------*/
  1604.     DisplayConfirm(
  1605.         STR_GLOBAL_YES,
  1606.         IMG_GLOBAL_YES,
  1607.         STR_GLOBAL_NO,
  1608.         IMG_GLOBAL_NO,
  1609.         get_string(STR_GLOBAL_DELETE_ALL) /* STR_CONFIRM_DELETE_ALL_RECORD */ ,
  1610.         IMG_GLOBAL_QUESTION,
  1611.         WARNING_TONE);
  1612.     /* 9.Register function with right softkey */
  1613.     DeleteUptoScrID(SCR_VIEW_RECORD);
  1614.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1615.     SetLeftSoftkeyFunction(DeleteAllTimerRecord, KEY_EVENT_UP);
  1616. }
  1617. /*****************************************************************************
  1618.  * FUNCTION
  1619.  *  DeleteAllTimerRecord
  1620.  * DESCRIPTION
  1621.  *  This function deletes all Saved Timer Records.
  1622.  * PARAMETERS
  1623.  *  void
  1624.  * RETURNS
  1625.  *  void
  1626.  *****************************************************************************/
  1627. void DeleteAllTimerRecord(void)
  1628. {
  1629.     /*----------------------------------------------------------------*/
  1630.     /* Local Variables                                                */
  1631.     /*----------------------------------------------------------------*/
  1632.     S16 error;
  1633.     /*----------------------------------------------------------------*/
  1634.     /* Code Body                                                      */
  1635.     /*----------------------------------------------------------------*/
  1636.     memset(gTimerRecordList, 0, sizeof(stopwatchRecord) * MAX_STOPWATCH_RECORDS);
  1637.     gStopwatchAppInfo.numOfSavedTimerRecords = 0;
  1638.     if (WriteValue(NVRAM_STOPWATCH_TOTAL_RECORDS, &gStopwatchAppInfo.numOfSavedTimerRecords, DS_BYTE, &error) < 0)
  1639.     {
  1640.         PRINT_INFORMATION(("TYPICAL STOPWATCH - Delete All Record: WriteValue to write total Number of records failed (error code %d)", (int)error));
  1641.     }
  1642.     if (WriteRecord(NVRAM_EF_STOPWATCH_LID, 1, &gTimerRecordList[0], NVRAM_EF_STOPWATCH_RECORD_SIZE, &error) < 0)
  1643.     {
  1644.         PRINT_INFORMATION(("TYPICAL STOPWATCH - Delete All Record : WriteRecord to write Timer record failed (error code %d)", (int)error));
  1645.     }
  1646.     DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, POPUP_TIME, SUCCESS_TONE);
  1647.     DeleteUptoScrID(SCR_TYPICAL_STOPWATCH);
  1648. }
  1649. /*****************************************************************************
  1650.  * FUNCTION
  1651.  *  EntryWtchScrMemoryFull
  1652.  * DESCRIPTION
  1653.  *  Displays the screen for memory full
  1654.  * PARAMETERS
  1655.  *  void
  1656.  * RETURNS
  1657.  *  void
  1658.  *****************************************************************************/
  1659. void EntryWtchScrMemoryFull(void)
  1660. {
  1661.     /*----------------------------------------------------------------*/
  1662.     /* Local Variables                                                */
  1663.     /*----------------------------------------------------------------*/
  1664.     /*----------------------------------------------------------------*/
  1665.     /* Code Body                                                      */
  1666.     /*----------------------------------------------------------------*/
  1667.     DisplayConfirm(
  1668.         STR_GLOBAL_YES,
  1669.         IMG_GLOBAL_YES,
  1670.         STR_GLOBAL_NO,
  1671.         IMG_GLOBAL_NO,
  1672.         get_string(STR_STOPWATCH_MEMORY_FULL),
  1673.         IMG_GLOBAL_QUESTION,
  1674.         WARNING_TONE);
  1675.     /* 9.Register function with right softkey */
  1676.     SetRightSoftkeyFunction(FailedSaveTimerRecord, KEY_EVENT_UP);
  1677.     SetLeftSoftkeyFunction(EntryWtchScrReplaceRecord, KEY_EVENT_UP);
  1678. }
  1679. /*****************************************************************************
  1680.  * FUNCTION
  1681.  *  EntryWtchScrReplaceRecord
  1682.  * DESCRIPTION
  1683.  *  Entry fn To replace previous record when memory is full
  1684.  * PARAMETERS
  1685.  *  void
  1686.  * RETURNS
  1687.  *  void
  1688.  *****************************************************************************/
  1689. void EntryWtchScrReplaceRecord(void)
  1690. {
  1691.     /*----------------------------------------------------------------*/
  1692.     /* Local Variables                                                */
  1693.     /*----------------------------------------------------------------*/
  1694.     U8 *guiBuffer = NULL;
  1695.     U8 count = 0;
  1696.     /*----------------------------------------------------------------*/
  1697.     /* Code Body                                                      */
  1698.     /*----------------------------------------------------------------*/
  1699.     EntryNewScreen(SCR_REPLACE_RECORD, NULL, EntryWtchScrReplaceRecord, NULL);
  1700.     for (count = 0; count < gStopwatchAppInfo.numOfSavedTimerRecords; count++)
  1701.     {
  1702.         pfnUnicodeStrcpy((S8*) subMenuDataPtrs[count], (S8*) gTimerRecordList[count].name);
  1703.     }
  1704.     guiBuffer = GetCurrGuiBuffer(SCR_REPLACE_RECORD);
  1705.     gStopwatchAppInfo.replaceRecord = TRUE;
  1706.     RegisterHighlightHandler(GetSelectedItemIndex);
  1707.     /* Register function for left soft key */
  1708.     ShowCategory84Screen(
  1709.         STR_STOPWATCH_REPLACE_RECORD,
  1710.         MAIN_MENU_TITLE_FUNANDGAMES_ICON,
  1711.         STR_GLOBAL_OK,
  1712.         IMG_GLOBAL_OK,
  1713.         STR_GLOBAL_CANCEL,
  1714.         0,
  1715.         gStopwatchAppInfo.numOfSavedTimerRecords,
  1716.         (U8 **) subMenuDataPtrs,
  1717.         (PU16) gIndexIconsImageList,
  1718.         0,
  1719.         0,
  1720.         guiBuffer);
  1721.     SetLeftSoftkeyFunction(EntryWtchScrEnterRecordName, KEY_EVENT_UP);
  1722.     SetRightSoftkeyFunction(FailedSaveTimerRecord, KEY_EVENT_UP);
  1723. }
  1724. /*****************************************************************************
  1725.  * FUNCTION
  1726.  *  ReplaceSelectedRecord
  1727.  * DESCRIPTION
  1728.  *  Replace Existing Record.
  1729.  * PARAMETERS
  1730.  *  void
  1731.  * RETURNS
  1732.  *  void
  1733.  *****************************************************************************/
  1734. void ReplaceSelectedRecord(void)
  1735. {
  1736.     /*----------------------------------------------------------------*/
  1737.     /* Local Variables                                                */
  1738.     /*----------------------------------------------------------------*/
  1739.     U8 count;
  1740.     S16 error;
  1741.     /*----------------------------------------------------------------*/
  1742.     /* Code Body                                                      */
  1743.     /*----------------------------------------------------------------*/
  1744.     if (pfnUnicodeStrlen((S8*) gStopwatchAppInfo.recordName) != 0)
  1745.     {
  1746.         gStopwatchAppInfo.replaceRecord = FALSE;
  1747.         memset(&gTimerRecordList[gStopwatchAppInfo.currHilitedRecord], 0, sizeof(stopwatchRecord));
  1748.         memcpy(
  1749.             &gTimerRecordList[gStopwatchAppInfo.currHilitedRecord].name,
  1750.             gStopwatchAppInfo.recordName,
  1751.             MAX_RECORD_NAME_LENGTH * ENCODING_LENGTH);
  1752.         gTimerRecordList[gStopwatchAppInfo.currHilitedRecord].numOfRecords =
  1753.             (U8) gStopwatchAppInfo.numofCurrTimerRecords;
  1754.         for (count = 0; count < gStopwatchAppInfo.numofCurrTimerRecords; count++)
  1755.         {
  1756.             gTimerRecordList[gStopwatchAppInfo.currHilitedRecord].nRecordData[count].recHr =
  1757.                 (U8) gCurrentRecords[count].hour;
  1758.             gTimerRecordList[gStopwatchAppInfo.currHilitedRecord].nRecordData[count].recMin =
  1759.                 (U8) gCurrentRecords[count].min;
  1760.             gTimerRecordList[gStopwatchAppInfo.currHilitedRecord].nRecordData[count].recSec =
  1761.                 (U8) gCurrentRecords[count].sec;
  1762.             gTimerRecordList[gStopwatchAppInfo.currHilitedRecord].nRecordData[count].recMsec =
  1763.                 (U8) gCurrentRecords[count].mili_sec;
  1764.         }
  1765.         if (WriteValue(NVRAM_STOPWATCH_TOTAL_RECORDS, &gStopwatchAppInfo.numOfSavedTimerRecords, DS_BYTE, &error) < 0)
  1766.         {
  1767.             PRINT_INFORMATION(("TYPICAL STOPWATCH - Replace Record: WriteValue to write total Number of records failed (error code %d)", (int)error));
  1768.         }
  1769.         if (WriteRecord(NVRAM_EF_STOPWATCH_LID, 1, &gTimerRecordList[0], NVRAM_EF_STOPWATCH_RECORD_SIZE, &error) < 0)
  1770.         {
  1771.             PRINT_INFORMATION(("TYPICAL STOPWATCH - Replace Record : WriteRecord to write Timer record failed (error code %d)", (int)error));
  1772.         }
  1773.         DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, POPUP_TIME, SUCCESS_TONE);
  1774.         DeleteUptoScrID(SCR_TYPICAL_STOPWATCH);
  1775.         ResetTypicalStopwatch();
  1776.     }
  1777.     else
  1778.     {
  1779.         DisplayPopup((PU8) GetString(STR_EMPTY_NAME), IMG_GLOBAL_EMPTY, 1, POPUP_TIME, ERROR_TONE);
  1780.         DeleteUptoScrID(SCR_ENTER_RECORD_NAME);
  1781.     }
  1782. }
  1783. /********************For Stopwatch running in background***************************/
  1784. /*****************************************************************************
  1785.  * FUNCTION
  1786.  *  DisplayDiscontinueTimerQuery
  1787.  * DESCRIPTION
  1788.  *  
  1789.  * PARAMETERS
  1790.  *  void
  1791.  * RETURNS
  1792.  *  void
  1793.  *****************************************************************************/
  1794. void DisplayDiscontinueTimerQuery(void)
  1795. {
  1796.     /*----------------------------------------------------------------*/
  1797.     /* Local Variables                                                */
  1798.     /*----------------------------------------------------------------*/
  1799.     /*----------------------------------------------------------------*/
  1800.     /* Code Body                                                      */
  1801.     /*----------------------------------------------------------------*/
  1802.     DisplayConfirm(
  1803.         STR_GLOBAL_YES,
  1804.         IMG_GLOBAL_YES,
  1805.         STR_GLOBAL_NO,
  1806.         IMG_GLOBAL_NO,
  1807.         get_string(STR_DISCONTINUE_TIMER_QUERY),
  1808.         IMG_GLOBAL_QUESTION,
  1809.         WARNING_TONE);
  1810.     /* 9.Register function with right softkey */
  1811.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1812.     SetLeftSoftkeyFunction(DiscontinuePreviousStopwatch, KEY_EVENT_UP);
  1813. }
  1814. /*****************************************************************************
  1815.  * FUNCTION
  1816.  *  DiscontinuePreviousStopwatch
  1817.  * DESCRIPTION
  1818.  *  
  1819.  * PARAMETERS
  1820.  *  void
  1821.  * RETURNS
  1822.  *  void
  1823.  *****************************************************************************/
  1824. void DiscontinuePreviousStopwatch(void)
  1825. {
  1826.     /*----------------------------------------------------------------*/
  1827.     /* Local Variables                                                */
  1828.     /*----------------------------------------------------------------*/
  1829.     /*----------------------------------------------------------------*/
  1830.     /* Code Body                                                      */
  1831.     /*----------------------------------------------------------------*/
  1832.     ResetTypicalStopwatch();
  1833.     if (gStopwatchAppInfo.splitLapTimer == LAP_TIMER)
  1834.     {
  1835.         gStopwatchAppInfo.splitLapTimer = SPLIT_TIMER;
  1836.     }
  1837.     else
  1838.     {
  1839.         gStopwatchAppInfo.splitLapTimer = LAP_TIMER;
  1840.     }
  1841.     EntryWtchScrSplitLapTimingStopwatch();
  1842. }
  1843. /*****************************************************************************
  1844.  * FUNCTION
  1845.  *  ResetTypicalStopwatch
  1846.  * DESCRIPTION
  1847.  *  
  1848.  * PARAMETERS
  1849.  *  void
  1850.  * RETURNS
  1851.  *  void
  1852.  *****************************************************************************/
  1853. void ResetTypicalStopwatch(void)
  1854. {
  1855.     /*----------------------------------------------------------------*/
  1856.     /* Local Variables                                                */
  1857.     /*----------------------------------------------------------------*/
  1858.     /*----------------------------------------------------------------*/
  1859.     /* Code Body                                                      */
  1860.     /*----------------------------------------------------------------*/
  1861.     gStopwatchAppInfo.replaceRecord = FALSE;
  1862.     gStopwatchAppInfo.isRecordPresent = FALSE;
  1863.     gStopwatchAppInfo.numofCurrTimerRecords = 0;
  1864.     gStopwatchAppInfo.TimerState = TIMER_NOT_STARTED;
  1865.     memset(gCurrentRecords, 0, sizeof(UI_stop_watch) * MAX_TIMER_RECORDS);
  1866.     initialize_stop_watch_timer();
  1867. }
  1868. #endif /* __MMI_STOPWATCH__ */