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

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.  *   wgui_categories_stopwatch.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   Maui_Software
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *  Functions to display Stop Watch related Screens
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * removed!
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * removed!
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * removed!
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * removed!
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * removed!
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * removed!
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * removed!
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * removed!
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * removed!
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * removed!
  114.  *
  115.  *------------------------------------------------------------------------------
  116.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  117.  *============================================================================
  118.  ****************************************************************************/
  119. #include "MMI_features.h"
  120. #ifdef __MMI_STOPWATCH__
  121. #include "stdC.h"
  122. #include "L4Dr1.h"
  123. #include "PixtelDataTypes.h"
  124. #include "GlobalDefs.h"
  125. #include "gui_data_types.h"
  126. #include "CustDataProts.h"
  127. #include "CustMenuRes.h"
  128. #include "EventsDef.h"
  129. #include "gdi_lcd_config.h"     /* LCD_WIDTH */
  130. #include "gui_themes.h"
  131. #include "gui.h"
  132. #include "wgui.h"
  133. #include "CustThemesRes.h"
  134. #include "wgui_categories.h"
  135. #include "wgui_categories_defs.h"
  136. #include "wgui_fixed_menus.h"   /* 041205 Calvin added */
  137. /* Stopwatch Header Files */
  138. #include "wgui_categories_stopwatch.h"
  139. #include "StopwatchDef.h"
  140. #include "StopwatchStruct.h"
  141. #ifdef __MMI_TOUCH_SCREEN__
  142. #include "wgui_touch_screen.h"  /* PMT MANISH   20050401 */
  143. #endif 
  144. /*  Include: PS header file */
  145. #ifdef MMI_ON_HARDWARE_P
  146. #include "l1_const.h"
  147. #include "l1_types.h"
  148. #endif /* MMI_ON_HARDWARE_P */ 
  149. #include "wgui_draw_manager.h"
  150. /***************************************************************************** 
  151. * Local Variable
  152. *****************************************************************************/
  153. U8 stop_play_flag = 0;
  154. #ifdef MMI_ON_HARDWARE_P
  155. static U32 gInitialTime = 0;
  156. static U32 gCurrentTime = 0;
  157. static U32 gMPInitialTime = 0;
  158. static U32 gMPCurrentTime = 0;
  159. #endif /* MMI_ON_HARDWARE_P */ 
  160. /* Component coordinate setup */
  161. #if ( (LCD_WIDTH == 128) && (LCD_HEIGHT == 128) )
  162. #define STPWACH_NW_SPAC_SIDE 0
  163. #define STPWACH_NW_SPAC_TOP 0
  164. #define STPWACH_NW_FRAM_BORDER   3
  165. wtchSkinResStruct wtch_pos = 
  166. {
  167.     /* wtch_coor_type typ_timer */ {(LCD_WIDTH >> 1), 70},
  168.     /* wtch_coor_type typ_milsec */ {(LCD_WIDTH >> 1), 85},
  169.     /* typ_history_height, 2 line */ {MMI_MENUITEM_HEIGHT << 1},
  170.     /* U16 separator_height */ {0},
  171.     /* nWay_maintimer_start */ {0, 0},
  172.     /* nWay_maintimer_end */ {LCD_WIDTH, MMI_MENUITEM_HEIGHT},
  173.     /* nWay_dialog_start */ {0, MMI_MENUITEM_HEIGHT},
  174.     /* nWay_dialog_end   */ {LCD_WIDTH, LCD_HEIGHT - MMI_BUTTON_BAR_HEIGHT - STPWACH_NW_FRAM_BORDER},
  175. };
  176. #elif ( (LCD_WIDTH == 128) && (LCD_HEIGHT == 160) )
  177. #define STPWACH_NW_SPAC_SIDE 0
  178. #define STPWACH_NW_SPAC_TOP 0
  179. #define STPWACH_NW_FRAM_BORDER   1
  180. wtchSkinResStruct wtch_pos = 
  181. {
  182.     /* wtch_coor_type typ_timer */ {(LCD_WIDTH >> 1), 88},
  183.     /* wtch_coor_type typ_milsec */ {(LCD_WIDTH >> 1), 105},
  184.     /* typ_history_height, 2 line */ {MMI_MENUITEM_HEIGHT << 1},
  185.     /* U16 separator_height */ {MMI_MENUITEM_HEIGHT},
  186.     /* nWay_maintimer_start */ {0, 0},
  187.     /* nWay_maintimer_end */ {LCD_WIDTH, MMI_MENUITEM_HEIGHT},
  188.     /* nWay_dialog_start */ {0, MMI_MENUITEM_HEIGHT},
  189.     /* nWay_dialog_end   */ {LCD_WIDTH, LCD_HEIGHT - MMI_BUTTON_BAR_HEIGHT - STPWACH_NW_FRAM_BORDER},
  190. };
  191. #elif ( (LCD_WIDTH == 176) && (LCD_HEIGHT == 220) )
  192. #define STPWACH_NW_SPAC_SIDE 0
  193. #define STPWACH_NW_SPAC_TOP 0
  194. #define STPWACH_NW_FRAM_BORDER   3
  195. wtchSkinResStruct wtch_pos = 
  196. {
  197.     /* wtch_coor_type typ_timer */ {(LCD_WIDTH >> 1), (MMI_MENUITEM_HEIGHT << 2) + 61},
  198.     /* wtch_coor_type typ_milsec */ {(LCD_WIDTH >> 1), (MMI_MENUITEM_HEIGHT << 2) + 73},
  199.     /* typ_history_height, 4 line */ {(MMI_MENUITEM_HEIGHT << 2)},
  200.     /* U16 separator_height */ {30},
  201.     /* nWay_maintimer_start */ {10, 10},
  202.     /* nWay_maintimer_end */ {LCD_WIDTH - 10, 40},
  203.     /* nWay_dialog_start */ {10, 40},
  204.     /* nWay_dialog_end   */ {LCD_WIDTH - 10, LCD_HEIGHT - MMI_BUTTON_BAR_HEIGHT - 10},
  205. };
  206. #elif ( (LCD_WIDTH == 240) && (LCD_HEIGHT == 320) )     /* 041205 Calvin modified */
  207. #define STPWACH_NW_SPAC_SIDE 0
  208. #define STPWACH_NW_SPAC_TOP 0
  209. #define STPWACH_NW_FRAM_BORDER   3
  210. wtchSkinResStruct wtch_pos = 
  211. {
  212.     /* wtch_coor_type typ_timer */ {(LCD_WIDTH >> 1), (MMI_MENUITEM_HEIGHT << 2) + 61},
  213.     /* wtch_coor_type typ_milsec */ {(LCD_WIDTH >> 1), (MMI_MENUITEM_HEIGHT << 2) + 73},
  214.     /* typ_history_height, 4 line */ {(MMI_MENUITEM_HEIGHT *5)},
  215.     /* U16 separator_height */ {30},
  216.     /* nWay_maintimer_start */ {10, 10},
  217.     /* nWay_maintimer_end */ {LCD_WIDTH - 10, 40},
  218.     /* nWay_dialog_start */ {10, 40},
  219.     /* nWay_dialog_end   */ {LCD_WIDTH - 10, LCD_HEIGHT - MMI_BUTTON_BAR_HEIGHT - 10},
  220. };
  221. #else 
  222. // #error "LCD size not support!"
  223. #define STPWACH_NW_SPAC_SIDE 0
  224. #define STPWACH_NW_SPAC_TOP 0
  225. #define STPWACH_NW_FRAM_BORDER   3
  226. wtchSkinResStruct wtch_pos = 
  227. {
  228.     /* wtch_coor_type typ_timer */ {(LCD_WIDTH >> 1), (MMI_MENUITEM_HEIGHT << 2) + 61},
  229.     /* wtch_coor_type typ_milsec */ {(LCD_WIDTH >> 1), (MMI_MENUITEM_HEIGHT << 2) + 73},
  230.     /* typ_history_height, 4 line */ {(MMI_MENUITEM_HEIGHT << 2)},
  231.     /* U16 separator_height */ {30},
  232.     /* nWay_maintimer_start */ {10, 10},
  233.     /* nWay_maintimer_end */ {LCD_WIDTH - 10, 40},
  234.     /* nWay_dialog_start */ {10, 40},
  235.     /* nWay_dialog_end   */ {LCD_WIDTH - 10, LCD_HEIGHT - MMI_BUTTON_BAR_HEIGHT - 10},
  236. };
  237. #endif 
  238. /***************************************************************************** 
  239. * Type Defination
  240. *****************************************************************************/
  241. typedef enum _SCREEN_NAME
  242. {
  243.     NOT_STOPWATCH_SCREEN = 0,
  244.     MP_TIMER_SCR,
  245.     TYPICAL_TIMER_SCR
  246. } SCREEN_NAME;
  247. SCREEN_NAME g_current_screen = NOT_STOPWATCH_SCREEN;
  248. #ifdef MMI_ON_HARDWARE_P
  249. typedef enum _INCREMENT_TYPE
  250. {
  251.     NO_INCREMENT,
  252.     TYP_TIMER_INCREMENT,
  253.     MP_TITLE_TIME_INCREMENT,
  254.     MP_LIST_TIMER_INCREMENT
  255. } INCREMENT_TYPE;
  256. INCREMENT_TYPE gDoNotIncrement;
  257. #endif /* MMI_ON_HARDWARE_P */ 
  258. /***************************************************************************** 
  259. * External variable / function
  260. *****************************************************************************/
  261. extern S32 GUI_current_fixed_icontext_list_menuitem_column;
  262. extern BOOL r2lMMIFlag;
  263. extern void _show_bitmap(S32 x1, S32 y1, bitmap *b);
  264. extern void _get_bitmap(S32 x1, S32 y1, S32 x2, S32 y2, bitmap *b);
  265. #ifdef MMI_ON_HARDWARE_P
  266. extern void L1I_GetTime(Time *);
  267. extern kal_uint32 L1I_GetTimeStamp(void);
  268. #endif /* MMI_ON_HARDWARE_P */ 
  269. /*****************************************************************************/
  270. /***  N-way Stopwatch                                                      ***/
  271. /*****************************************************************************/
  272. /**********************************************************************************/
  273. /*** nWay Stopwatch Screen                                                      ***/
  274. /*** Screen ID: 306                                                             ***/
  275. /**********************************************************************************/
  276. /***                                                                            ***/
  277. /***                                                                            ***/
  278. /***   CategoryScreen306:                                                       ***/
  279. /***                                                                            ***/
  280. /***   ====================                                                     ***/
  281. /***   =   00:14:56:07    =    <-- Main timer (title_time)                      ***/
  282. /***   ====================                                                     ***/
  283. /***   =    StopWatch     =    <-- Tile Bar, might be removed in 128 x 128 Scr  ***/
  284. /***   ====================        (top_title_msg)                              ***/
  285. /***   = A 00:01:12:33    =    <-- individual timer #1                          ***/
  286. /***   = B 00:03:25:36    =    <-- individual timer #2                          ***/
  287. /***   = C 00:02:56:11    =    <-- individual timer #3                          ***/
  288. /***   = D 00:07:23:27    =    <-- individual timer #4  (list_watch[])          ***/
  289. /***   ====================                                                     ***/
  290. /***   == LSK ==||== RSK ==                                                     ***/
  291. /***   ====================                                                     ***/
  292. /***                                                                            ***/
  293. /***                                                                            ***/
  294. /**********************************************************************************/
  295. /***************************************************************************** 
  296. * Local Variable
  297. *****************************************************************************/
  298. /* Timer Variable Declearation */
  299. static UI_stop_watch title_time;                            /* Main Timer */
  300. static UI_stop_watch list_watch[MAX_MULTIPURPOSE_TIMER];    /* Individual Timer */
  301. /* String Variable Declaration */
  302. // UI_string_type title_side_message;   /* Side message (total), Reserved */
  303. static UI_string_type top_title_msg;    /* nWay stopwatch separate title bar ("StopWatch") */
  304. /* Position Variable Declearation */
  305. /* S32 dialog_x1,dialog_y1,dialog_x2,dialog_y2; */
  306. static U16 bkg_stop_watch_img = 0;          /* Background image, Reserved */
  307. static U16 multi_stop_watch_title_img = 0;  /* Title image, Reserved */
  308. static S32 category306_text_x_offset;   /* Active indivial timer text x coordinate */
  309. static S32 category306_text_y_offset;   /* Active indivial timer text y coordinate */
  310. static S32 category306_img_x_offset;    /* Active indivial timer image x coordinate */
  311. static S32 category306_img_y_offset;    /* Active indivial timer image y coordinate */
  312. static S32 category306_area_height;     /* Active indivial timer area height */
  313. static S32 category306_img_width;       /* Active indivial timer image height */
  314. static S32 category306_img_height;      /* Active indivial timer image height */
  315. static S32 category306_text_width;      /* Active indivial timer text height */
  316. static S32 category306_text_height;     /* Active indivial timer text height */
  317. static S32 current_stop_watch_highlight = 0;    /* The current highligh timer idx */
  318. /* Using in increement timer */
  319. #ifdef MMI_ON_HARDWARE_P
  320. static DOUBLE gTypTimerLogMSecValue = 0;
  321. static DOUBLE gMPTimerLogMSecValue = 0;
  322. #endif /* MMI_ON_HARDWARE_P */ 
  323. /***************************************************************************** 
  324. * Local Function Defination
  325. *****************************************************************************/
  326. void update_stop_watch_time(void);
  327. void display_stop_watch_list_content(S32, S32, S32, S32);
  328. void clean_active_timer(void);
  329. void display_stop_watch_list_header(S32, S32, S32, S32);
  330. void draw_stopwatch_title(void);
  331. void redraw_stop_watch_list(void);
  332. static S32 category306_get_text_y_offset(S32 idx);
  333. static S32 category306_get_img_y_offset(S32 idx);
  334. static S32 category306_get_timer_text_width(S32 idx);
  335. /*****************************************************************************
  336.  * FUNCTION
  337.  *  GetMultipurposeTimeValues
  338.  * DESCRIPTION
  339.  *  This function is to retrieve current active timer
  340.  * PARAMETERS
  341.  *  high_light      [?]     
  342.  * RETURNS
  343.  *  void
  344.  *****************************************************************************/
  345. void GetMultipurposeTimeValues(S32 *high_light)
  346. {
  347.     /*----------------------------------------------------------------*/
  348.     /* Local Variables                                                */
  349.     /*----------------------------------------------------------------*/
  350.     /*----------------------------------------------------------------*/
  351.     /* Code Body                                                      */
  352.     /*----------------------------------------------------------------*/
  353.     *high_light = current_stop_watch_highlight;
  354. }
  355. /*****************************************************************************
  356.  * FUNCTION
  357.  *  stop_multipurpose_timers
  358.  * DESCRIPTION
  359.  *  This function is to retrieve current active timer
  360.  * PARAMETERS
  361.  *  void
  362.  * RETURNS
  363.  *  void
  364.  *****************************************************************************/
  365. void stop_multipurpose_timers(void)
  366. {
  367.     /*----------------------------------------------------------------*/
  368.     /* Local Variables                                                */
  369.     /*----------------------------------------------------------------*/
  370.     /*----------------------------------------------------------------*/
  371.     /* Code Body                                                      */
  372.     /*----------------------------------------------------------------*/
  373.     gui_cancel_timer(update_stop_watch_time);
  374.     stop_play_flag = TIMER_STOP;
  375. }
  376. /*****************************************************************************
  377.  * FUNCTION
  378.  *  start_multipurpose_list_watch
  379.  * DESCRIPTION
  380.  *  This function is to start certain individual timer
  381.  * PARAMETERS
  382.  *  index       [IN]        
  383.  * RETURNS
  384.  *  void
  385.  *****************************************************************************/
  386. void start_multipurpose_list_watch(U8 index)
  387. {
  388.     /*----------------------------------------------------------------*/
  389.     /* Local Variables                                                */
  390.     /*----------------------------------------------------------------*/
  391.     /*----------------------------------------------------------------*/
  392.     /* Code Body                                                      */
  393.     /*----------------------------------------------------------------*/
  394.     gui_cancel_timer(update_stop_watch_time);
  395.     if (stop_play_flag == TIMER_STOP)
  396.     {
  397.     #ifdef MMI_ON_HARDWARE_P
  398.         gMPInitialTime = L1I_GetTimeStamp();
  399.     #endif 
  400.         stop_play_flag = TIMER_START;
  401.     }
  402.     else
  403.     {
  404.         update_stop_watch_time();
  405.         gui_cancel_timer(update_stop_watch_time);
  406.     }
  407.     current_stop_watch_highlight = index;
  408.     gui_start_timer(STPWACH_UI_UPDATE_PERIOD, update_stop_watch_time);
  409.     gui_lock_double_buffer();
  410.     gui_reset_clip();
  411.     gui_reset_text_clip();
  412.     category306_text_y_offset = category306_get_text_y_offset(current_stop_watch_highlight);
  413.     category306_img_y_offset = category306_get_img_y_offset(current_stop_watch_highlight);
  414.     draw_stopwatch_title();
  415.     redraw_stop_watch_list();
  416.     /* Draw Separator */
  417.     display_stop_watch_list_header(
  418.         wtch_pos.nWay_dialog_start.x,
  419.         wtch_pos.nWay_dialog_start.y,
  420.         wtch_pos.nWay_dialog_end.x,
  421.         wtch_pos.nWay_dialog_start.y + wtch_pos.separator_height);
  422.     gui_unlock_double_buffer();
  423.     gui_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - MMI_button_bar_height);
  424. }
  425. /*****************************************************************************
  426.  * FUNCTION
  427.  *  set_stop_watch_history
  428.  * DESCRIPTION
  429.  *  This function is to set stopwatch history
  430.  * PARAMETERS
  431.  *  history_ID          [IN]        
  432.  *  history_buffer      [?]         
  433.  * RETURNS
  434.  *  void
  435.  *****************************************************************************/
  436. U8 set_stop_watch_history(U16 history_ID, U8 *history_buffer)
  437. {
  438.     /*----------------------------------------------------------------*/
  439.     /* Local Variables                                                */
  440.     /*----------------------------------------------------------------*/
  441.     /*----------------------------------------------------------------*/
  442.     /* Code Body                                                      */
  443.     /*----------------------------------------------------------------*/
  444.     if (history_buffer != NULL)
  445.     {
  446.         UI_stop_watch_history *h = (UI_stop_watch_history*) history_buffer;
  447.         if (history_valid(h->history_ID, history_ID))
  448.         {
  449.             current_stop_watch_highlight = h->highlight_item;
  450.             stop_play_flag = h->cur_stop_play_flag;
  451.             return (1);
  452.         }
  453.     }
  454.     return (0);
  455. }
  456. /*****************************************************************************
  457.  * FUNCTION
  458.  *  get_stop_watch_history
  459.  * DESCRIPTION
  460.  *  This function is to get stopwatch history
  461.  * PARAMETERS
  462.  *  history_ID          [IN]        
  463.  *  history_buffer      [?]         
  464.  * RETURNS
  465.  *  void
  466.  *****************************************************************************/
  467. void get_stop_watch_history(U16 history_ID, U8 *history_buffer)
  468. {
  469.     /*----------------------------------------------------------------*/
  470.     /* Local Variables                                                */
  471.     /*----------------------------------------------------------------*/
  472.     /*----------------------------------------------------------------*/
  473.     /* Code Body                                                      */
  474.     /*----------------------------------------------------------------*/
  475.     if (history_buffer != NULL)
  476.     {
  477.         U16 hID = (U16) (history_ID | 0x8000);
  478.         UI_stop_watch_history *h = (UI_stop_watch_history*) history_buffer;
  479.         h->history_ID = hID;
  480.         h->cur_stop_play_flag = stop_play_flag;
  481.         h->highlight_item = current_stop_watch_highlight;
  482.     }
  483. }
  484. /*****************************************************************************
  485.  * FUNCTION
  486.  *  reset_all_multipurpose_time
  487.  * DESCRIPTION
  488.  *  This function is to reset all timer when long press LSK
  489.  * PARAMETERS
  490.  *  void
  491.  * RETURNS
  492.  *  void
  493.  *****************************************************************************/
  494. void reset_all_multipurpose_time(void)
  495. {
  496.     /*----------------------------------------------------------------*/
  497.     /* Local Variables                                                */
  498.     /*----------------------------------------------------------------*/
  499.     S32 index = 0;
  500.     /*----------------------------------------------------------------*/
  501.     /* Code Body                                                      */
  502.     /*----------------------------------------------------------------*/
  503.     gui_cancel_timer(update_stop_watch_time);
  504.     stop_play_flag = TIMER_STOP;
  505.     /* Reset main timer */
  506.     memset(&title_time, 0, sizeof(UI_stop_watch));
  507.     /* Reset individual timer */
  508.     for (index = 0; index < MAX_MULTIPURPOSE_TIMER; index++)
  509.     {
  510.         list_watch[index].hour = list_watch[index].mili_sec = list_watch[index].min = list_watch[index].sec = 0;
  511.         memset(list_watch[index].watch_string, 0, 40);
  512.     }
  513.     current_stop_watch_highlight = 0;
  514.     category306_text_y_offset = category306_get_text_y_offset(current_stop_watch_highlight);
  515.     category306_img_y_offset = category306_get_img_y_offset(current_stop_watch_highlight);
  516.     /* Update screen */
  517.     gui_lock_double_buffer();
  518.     change_stopwatchtime_to_string(
  519.         title_time.mili_sec,
  520.         title_time.hour,
  521.         title_time.min,
  522.         title_time.sec,
  523.         title_time.watch_string,
  524.         DISPLAY_MILISEC_TRUE);
  525.     /* MMI_title_string = (UI_string_type) title_time.watch_string ; */
  526.     draw_stopwatch_title();
  527.     redraw_stop_watch_list();
  528.     /* Draw Separator */
  529.     display_stop_watch_list_header(
  530.         wtch_pos.nWay_dialog_start.x,
  531.         wtch_pos.nWay_dialog_start.y,
  532.         wtch_pos.nWay_dialog_end.x,
  533.         wtch_pos.nWay_dialog_start.y + wtch_pos.separator_height);
  534.     gui_unlock_double_buffer();
  535.     gui_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - MMI_button_bar_height);
  536. }
  537. /*****************************************************************************
  538.  * FUNCTION
  539.  *  clean_active_timer
  540.  * DESCRIPTION
  541.  *  This function is to clear (drew white background on) active individual timer
  542.  * PARAMETERS
  543.  *  void
  544.  * RETURNS
  545.  *  void
  546.  *****************************************************************************/
  547. void clean_active_timer()
  548. {
  549.     /*----------------------------------------------------------------*/
  550.     /* Local Variables                                                */
  551.     /*----------------------------------------------------------------*/
  552.     /*----------------------------------------------------------------*/
  553.     /* Code Body                                                      */
  554.     /*----------------------------------------------------------------*/
  555.     if (r2lMMIFlag)
  556.     {
  557.         gui_fill_rectangle(
  558.             category306_text_x_offset + category306_text_width - category306_get_timer_text_width(current_stop_watch_highlight),
  559.             category306_text_y_offset,
  560.             category306_text_x_offset + category306_text_width,
  561.             category306_text_y_offset + category306_text_height,
  562.             UI_COLOR_WHITE);
  563.     }
  564.     else
  565.     {
  566.         gui_fill_rectangle(
  567.             category306_text_x_offset,
  568.             category306_text_y_offset,
  569.             category306_text_x_offset + category306_get_timer_text_width(current_stop_watch_highlight),
  570.             category306_text_y_offset + category306_text_height,
  571.             UI_COLOR_WHITE);
  572.     }
  573. }
  574. /*****************************************************************************
  575.  * FUNCTION
  576.  *  redraw_stop_watch_list
  577.  * DESCRIPTION
  578.  *  This function is to redraw the individual timer list
  579.  * PARAMETERS
  580.  *  void
  581.  * RETURNS
  582.  *  void
  583.  *****************************************************************************/
  584. void redraw_stop_watch_list(void)
  585. {
  586.     /*----------------------------------------------------------------*/
  587.     /* Local Variables                                                */
  588.     /*----------------------------------------------------------------*/
  589.     /*----------------------------------------------------------------*/
  590.     /* Code Body                                                      */
  591.     /*----------------------------------------------------------------*/
  592.     display_stop_watch_list_content(
  593.         wtch_pos.nWay_dialog_start.x,
  594.         wtch_pos.nWay_dialog_start.y,
  595.         wtch_pos.nWay_dialog_end.x,
  596.         wtch_pos.nWay_dialog_end.y);
  597. }
  598. /*****************************************************************************
  599.  * FUNCTION
  600.  *  display_stop_watch_list_content
  601.  * DESCRIPTION
  602.  *  This function is nWay stopwatch to drew individual timer
  603.  * PARAMETERS
  604.  *  x1      [IN]        
  605.  *  y1      [IN]        
  606.  *  x2      [IN]        
  607.  *  y2      [IN]        
  608.  * RETURNS
  609.  *  void
  610.  *****************************************************************************/
  611. void display_stop_watch_list_content(S32 x1, S32 y1, S32 x2, S32 y2)
  612. {
  613.     /*----------------------------------------------------------------*/
  614.     /* Local Variables                                                */
  615.     /*----------------------------------------------------------------*/
  616.     S32 index = 0;
  617.     S32 list_y = 0;
  618.     S32 img_y = 0, text_y = 0;
  619.     PU8 cur_image;
  620.     /*----------------------------------------------------------------*/
  621.     /* Code Body                                                      */
  622.     /*----------------------------------------------------------------*/
  623.     if (g_current_screen == MP_TIMER_SCR)
  624.     {
  625.         list_y = y1 + wtch_pos.separator_height;
  626.         /* Draw nWay stopwatch content background */
  627.         gui_fill_rectangle(x1, list_y, x2, y2, UI_COLOR_GREY);
  628.         gui_fill_rectangle(
  629.             x1 + STPWACH_NW_FRAM_BORDER,
  630.             list_y + STPWACH_NW_FRAM_BORDER,
  631.             x2 - STPWACH_NW_FRAM_BORDER,
  632.             y2 - STPWACH_NW_FRAM_BORDER,
  633.             UI_COLOR_WHITE);
  634.         for (index = 0; index < MAX_MULTIPURPOSE_TIMER; index++)
  635.         {
  636.             img_y = category306_get_img_y_offset(index);
  637.             text_y = category306_get_text_y_offset(index);
  638.             if (index == current_stop_watch_highlight)
  639.             {
  640.                 clean_active_timer();
  641.                 cur_image = (PU8) list_watch[index].highlightimagedata;
  642.                 gui_set_text_color(UI_COLOR_RED);
  643.             }
  644.             else
  645.             {
  646.                 cur_image = (PU8) list_watch[index].normalimagedata;
  647.                 gui_set_text_color(UI_COLOR_BLACK);
  648.             }
  649.             /* Make timer string */
  650.             change_stopwatchtime_to_string(
  651.                 list_watch[index].mili_sec,
  652.                 list_watch[index].hour,
  653.                 list_watch[index].min,
  654.                 list_watch[index].sec,
  655.                 list_watch[index].watch_string,
  656.                 DISPLAY_MILISEC_TRUE);
  657.             /* Draw image */
  658.             gui_show_image(category306_img_x_offset, img_y, cur_image);
  659.             /* Draw text */
  660.             if (r2lMMIFlag)
  661.             {
  662.                 gui_move_text_cursor(category306_text_x_offset + category306_text_width, text_y);
  663.             }
  664.             else
  665.             {
  666.                 gui_move_text_cursor(category306_text_x_offset, text_y);
  667.             }
  668.             gui_print_text((UI_string_type) list_watch[index].watch_string);
  669.         }   /* end of for loop */
  670.     }
  671. }
  672. /*****************************************************************************
  673.  * FUNCTION
  674.  *  draw_stopwatch_title
  675.  * DESCRIPTION
  676.  *  This function is to draw main timer
  677.  * PARAMETERS
  678.  *  void
  679.  * RETURNS
  680.  *  void
  681.  *****************************************************************************/
  682. void draw_stopwatch_title(void)
  683. {
  684.     /*----------------------------------------------------------------*/
  685.     /* Local Variables                                                */
  686.     /*----------------------------------------------------------------*/
  687.     /*----------------------------------------------------------------*/
  688.     /* Code Body                                                      */
  689.     /*----------------------------------------------------------------*/
  690.     if (g_current_screen == MP_TIMER_SCR)
  691.     {
  692.         S32 maintimer_height;
  693.         S32 title_x, title_y;
  694.         maintimer_height =
  695.             wtch_pos.nWay_maintimer_end.y - wtch_pos.nWay_maintimer_start.y - (STPWACH_NW_FRAM_BORDER << 1);
  696.         gui_fill_rectangle(
  697.             wtch_pos.nWay_maintimer_start.x,
  698.             wtch_pos.nWay_maintimer_start.y,
  699.             wtch_pos.nWay_maintimer_end.x,
  700.             wtch_pos.nWay_maintimer_end.y,
  701.             UI_COLOR_GREY);
  702.         gui_fill_rectangle(
  703.             wtch_pos.nWay_maintimer_start.x + STPWACH_NW_FRAM_BORDER,
  704.             wtch_pos.nWay_maintimer_start.y + STPWACH_NW_FRAM_BORDER,
  705.             wtch_pos.nWay_maintimer_end.x - STPWACH_NW_FRAM_BORDER,
  706.             wtch_pos.nWay_maintimer_end.y - STPWACH_NW_FRAM_BORDER,
  707.             UI_COLOR_WHITE);
  708.         /* Main timer start x, y coordinate */
  709.         title_x = wtch_pos.nWay_maintimer_start.x + STPWACH_NW_FRAM_BORDER
  710.             + ((wtch_pos.nWay_maintimer_end.x - wtch_pos.nWay_maintimer_start.x - category306_text_width) >> 1);
  711.         title_y = wtch_pos.nWay_maintimer_start.y + STPWACH_NW_FRAM_BORDER
  712.             + ((maintimer_height >> 1) - (category306_text_height >> 1));
  713.         if (r2lMMIFlag)
  714.         {
  715.             gui_move_text_cursor(title_x + category306_text_width, title_y);
  716.         }
  717.         else
  718.         {
  719.             gui_move_text_cursor(title_x, title_y);
  720.         }
  721.         gui_set_text_color(UI_COLOR_BLACK);
  722.         MMI_title_string = (UI_string_type) title_time.watch_string;
  723.         gui_print_text((UI_string_type) MMI_title_string);
  724.     }
  725. }
  726. /*****************************************************************************
  727.  * FUNCTION
  728.  *  display_stop_watch_list_header
  729.  * DESCRIPTION
  730.  *  This function is to draw separator
  731.  * PARAMETERS
  732.  *  x1      [IN]        
  733.  *  y1      [IN]        
  734.  *  x2      [IN]        
  735.  *  y2      [IN]        
  736.  * RETURNS
  737.  *  void
  738.  *****************************************************************************/
  739. void display_stop_watch_list_header(S32 x1, S32 y1, S32 x2, S32 y2)
  740. {
  741.     /*----------------------------------------------------------------*/
  742.     /* Local Variables                                                */
  743.     /*----------------------------------------------------------------*/
  744.     S32 fh = 0;
  745.     S32 width, height;
  746.     /*----------------------------------------------------------------*/
  747.     /* Code Body                                                      */
  748.     /*----------------------------------------------------------------*/
  749.     /* Don't drew separator */
  750.     if (wtch_pos.separator_height == 0)
  751.     {
  752.         return;
  753.     }
  754.     if (g_current_screen == MP_TIMER_SCR)
  755.     {
  756.         /* Draw Separator window frame and background */
  757.         gui_fill_rectangle(
  758.             x1 /* + STPWACH_NW_FRAM_BORDER */ ,
  759.             y1 /* + STPWACH_NW_FRAM_BORDER */ ,
  760.             x2 /*- STPWACH_NW_FRAM_BORDER */ ,
  761.             y2 /*- STPWACH_NW_FRAM_BORDER */ ,
  762.             UI_COLOR_DARK_GREY);
  763.         gui_fill_rectangle(
  764.             x1 + STPWACH_NW_FRAM_BORDER /* *2 */ ,
  765.             y1 + STPWACH_NW_FRAM_BORDER /* *2 */ ,
  766.             x2 - STPWACH_NW_FRAM_BORDER /* *2 */ ,
  767.             y2 - STPWACH_NW_FRAM_BORDER /* *2 */ ,
  768.             UI_COLOR_GREY);
  769.         /* Config Text */
  770.         gui_set_font(&MMI_medium_font);
  771.         gui_set_text_color(UI_COLOR_BLACK);
  772.         fh = gui_get_character_height();
  773.         gui_measure_string(top_title_msg, &width, &height);
  774.         /* Show Separator text */
  775.         if (r2lMMIFlag)
  776.         {
  777.             /* gui_move_text_cursor((x1 + (((x2 - x1) >>1) - (width>>1))) +width, y1 + (row_height>>1)-(height>>1)); */
  778.             gui_move_text_cursor(
  779.                 x1 + STPWACH_NW_FRAM_BORDER + ((x2 - x1 - (2 * STPWACH_NW_FRAM_BORDER) - width) >> 1) + width,
  780.                 y1 + STPWACH_NW_FRAM_BORDER + ((y2 - y1 - (2 * STPWACH_NW_FRAM_BORDER) - height) >> 1));
  781.         }
  782.         else
  783.         {
  784.             /* gui_move_text_cursor((x1 + (((x2 - x1) >>1) - (width>>1))) , y1 + (row_height>>1)-(height>>1)); */
  785.             gui_move_text_cursor(
  786.                 x1 + STPWACH_NW_FRAM_BORDER + ((x2 - x1 - (2 * STPWACH_NW_FRAM_BORDER) - width) >> 1),
  787.                 y1 + STPWACH_NW_FRAM_BORDER + ((y2 - y1 - (2 * STPWACH_NW_FRAM_BORDER) - height) >> 1));
  788.         }
  789.         gui_print_text(top_title_msg);
  790.     }
  791. }
  792. /*****************************************************************************
  793.  * FUNCTION
  794.  *  increment_time_stopwatch
  795.  * DESCRIPTION
  796.  *  This function is to increase time different for certain timer record
  797.  * PARAMETERS
  798.  *  stop_watch      [?]     
  799.  * RETURNS
  800.  *  void
  801.  *****************************************************************************/
  802. void increment_time_stopwatch(UI_stop_watch *stop_watch)
  803. {
  804. #ifdef MMI_ON_HARDWARE_P
  805.     /*----------------------------------------------------------------*/
  806.     /* Local Variables                                                */
  807.     /*----------------------------------------------------------------*/
  808.     {
  809.         U32 initTime = 0, currTime = 0;
  810.         DOUBLE TotalTime;
  811.         /*----------------------------------------------------------------*/
  812.         /* Code Body                                                      */
  813.         /*----------------------------------------------------------------*/
  814.         if (gDoNotIncrement == TYP_TIMER_INCREMENT || gDoNotIncrement == NO_INCREMENT)
  815.         {
  816.             initTime = gInitialTime;
  817.             currTime = gCurrentTime;
  818.         }
  819.         else if (gDoNotIncrement == MP_TITLE_TIME_INCREMENT || gDoNotIncrement == MP_LIST_TIMER_INCREMENT)
  820.         {
  821.             initTime = gMPInitialTime;
  822.             currTime = gMPCurrentTime;
  823.         }
  824.         if (initTime > currTime)
  825.         {
  826.             TotalTime = (0xffffffff - initTime) + currTime;
  827.         }
  828.         else
  829.         {
  830.             TotalTime = currTime - initTime;
  831.         }
  832.         TotalTime = TotalTime * 4.6153846;
  833.         if (TotalTime >= 10)
  834.         {
  835.             stop_watch->mili_sec += (U32) TotalTime / 10;
  836.             TotalTime = TotalTime - ((U32) TotalTime / 10) * 10;
  837.         }
  838.         if (TotalTime)
  839.         {
  840.             if (gDoNotIncrement == TYP_TIMER_INCREMENT)
  841.             {
  842.                 gTypTimerLogMSecValue = gTypTimerLogMSecValue + TotalTime;
  843.                 if (gTypTimerLogMSecValue >= 10.0)
  844.                 {
  845.                     stop_watch->mili_sec++;
  846.                     gTypTimerLogMSecValue = gTypTimerLogMSecValue - 10.0;
  847.                 }
  848.             }
  849.             else if (gDoNotIncrement == MP_TITLE_TIME_INCREMENT || gDoNotIncrement == MP_LIST_TIMER_INCREMENT)
  850.             {
  851.                 if (gDoNotIncrement == MP_TITLE_TIME_INCREMENT)
  852.                 {
  853.                     gMPTimerLogMSecValue = gMPTimerLogMSecValue + TotalTime;
  854.                 }
  855.                 if (gMPTimerLogMSecValue >= 10.0)
  856.                 {
  857.                     stop_watch->mili_sec++;
  858.                     if (gDoNotIncrement == MP_LIST_TIMER_INCREMENT)
  859.                     {
  860.                         gMPTimerLogMSecValue = gMPTimerLogMSecValue - 10.0;
  861.                     }
  862.                 }
  863.             }
  864.         }
  865.     }
  866. #else /* MMI_ON_HARDWARE_P */ 
  867.     stop_watch->mili_sec += 10;
  868. #endif /* MMI_ON_HARDWARE_P */ 
  869.     if (stop_watch->mili_sec >= 100)
  870.     {
  871.         stop_watch->sec += stop_watch->mili_sec / 100;
  872.         stop_watch->mili_sec -= (stop_watch->mili_sec / 100) * 100;
  873.         if (stop_watch->sec >= 60)
  874.         {
  875.             stop_watch->min += stop_watch->sec / 60;
  876.             stop_watch->sec -= (stop_watch->sec / 60) * 60;
  877.             if (stop_watch->min >= 60)
  878.             {
  879.                 stop_watch->hour += stop_watch->min / 60;
  880.                 stop_watch->min -= (stop_watch->min / 60) * 60;
  881.                 if (stop_watch->hour >= 100)
  882.                 {
  883.                     stop_watch->hour = 0;
  884.                 }
  885.             }
  886.         }
  887.     }
  888. }
  889. /*****************************************************************************
  890.  * FUNCTION
  891.  *  UpdateMPTime
  892.  * DESCRIPTION
  893.  *  This function is to start timer to update stopwatch screen
  894.  * PARAMETERS
  895.  *  void
  896.  * RETURNS
  897.  *  void
  898.  *****************************************************************************/
  899. void UpdateMPTime(void)
  900. {
  901.     /*----------------------------------------------------------------*/
  902.     /* Local Variables                                                */
  903.     /*----------------------------------------------------------------*/
  904.     /*----------------------------------------------------------------*/
  905.     /* Code Body                                                      */
  906.     /*----------------------------------------------------------------*/
  907.     if (stop_play_flag == TIMER_START)
  908.     {
  909.     #ifdef MMI_ON_HARDWARE_P
  910.         gMPCurrentTime = L1I_GetTimeStamp();
  911.         gDoNotIncrement = MP_TITLE_TIME_INCREMENT;
  912.     #endif /* MMI_ON_HARDWARE_P */ 
  913.         increment_time_stopwatch(&title_time);
  914.     #ifdef MMI_ON_HARDWARE_P
  915.         gDoNotIncrement = MP_LIST_TIMER_INCREMENT;
  916.     #endif 
  917.         increment_time_stopwatch(&list_watch[current_stop_watch_highlight]);
  918.     #ifdef MMI_ON_HARDWARE_P
  919.         gMPInitialTime = gMPCurrentTime;
  920.     #endif 
  921.         gui_start_timer(STPWACH_UI_UPDATE_PERIOD, update_stop_watch_time);
  922.     }
  923. }
  924. /*****************************************************************************
  925.  * FUNCTION
  926.  *  update_stop_watch_time
  927.  * DESCRIPTION
  928.  *  This function UI update timeout handler (every STPWACH_UI_UPDATE_PERIOD )
  929.  * PARAMETERS
  930.  *  void
  931.  * RETURNS
  932.  *  void
  933.  *****************************************************************************/
  934. void update_stop_watch_time(void)
  935. {
  936.     /*----------------------------------------------------------------*/
  937.     /* Local Variables                                                */
  938.     /*----------------------------------------------------------------*/
  939.     /*----------------------------------------------------------------*/
  940.     /* Code Body                                                      */
  941.     /*----------------------------------------------------------------*/
  942.     UpdateMPTime();
  943.     /* See the stopwatch is running in the background or not */
  944.     if (g_current_screen == MP_TIMER_SCR)
  945.     {
  946.         gui_lock_double_buffer();
  947.         clean_active_timer();
  948.         /* update main timer string */
  949.         change_stopwatchtime_to_string(
  950.             title_time.mili_sec,
  951.             title_time.hour,
  952.             title_time.min,
  953.             title_time.sec,
  954.             title_time.watch_string,
  955.             DISPLAY_MILISEC_TRUE);
  956.         /* update active individual timer string */
  957.         change_stopwatchtime_to_string(
  958.             list_watch[current_stop_watch_highlight].mili_sec,
  959.             list_watch[current_stop_watch_highlight].hour,
  960.             list_watch[current_stop_watch_highlight].min,
  961.             list_watch[current_stop_watch_highlight].sec,
  962.             list_watch[current_stop_watch_highlight].watch_string,
  963.             DISPLAY_MILISEC_TRUE);
  964.         /* Draw main timer */
  965.         draw_stopwatch_title();
  966.         /* Draw Separator */
  967.         display_stop_watch_list_header(
  968.             wtch_pos.nWay_dialog_start.x,
  969.             wtch_pos.nWay_dialog_start.y,
  970.             wtch_pos.nWay_dialog_end.x,
  971.             wtch_pos.nWay_dialog_start.y + wtch_pos.separator_height);
  972.         gui_set_font(&MMI_medium_font);
  973.         gui_set_text_color(UI_COLOR_RED);
  974.         /* Move cursor */
  975.         if (r2lMMIFlag)
  976.         {
  977.             gui_move_text_cursor(category306_text_x_offset + category306_text_width, category306_text_y_offset);
  978.         }
  979.         else
  980.         {
  981.             gui_move_text_cursor(category306_text_x_offset, category306_text_y_offset);
  982.         }
  983.         /* Draw timer text */
  984.         gui_print_text((UI_string_type) list_watch[current_stop_watch_highlight].watch_string);
  985.         gui_unlock_double_buffer();
  986.         gui_BLT_double_buffer(
  987.             wtch_pos.nWay_maintimer_start.x,
  988.             wtch_pos.nWay_maintimer_start.y,
  989.             wtch_pos.nWay_maintimer_end.x,
  990.             wtch_pos.nWay_maintimer_end.y);
  991.         gui_BLT_double_buffer(
  992.             category306_text_x_offset,
  993.             category306_text_y_offset,
  994.             wtch_pos.nWay_dialog_end.x,
  995.             category306_text_y_offset + category306_area_height);
  996.     }
  997. }
  998. /*****************************************************************************
  999.  * FUNCTION
  1000.  *  ExitCategory306Screen
  1001.  * DESCRIPTION
  1002.  *  This function is nWay stopwatch exit function
  1003.  * PARAMETERS
  1004.  *  void
  1005.  * RETURNS
  1006.  *  void
  1007.  *****************************************************************************/
  1008. void ExitCategory306Screen(void)
  1009. {
  1010.     /*----------------------------------------------------------------*/
  1011.     /* Local Variables                                                */
  1012.     /*----------------------------------------------------------------*/
  1013.     /*----------------------------------------------------------------*/
  1014.     /* Code Body                                                      */
  1015.     /*----------------------------------------------------------------*/
  1016. #ifdef MMI_ON_HARDWARE_P
  1017.     gui_cancel_timer(update_stop_watch_time);
  1018. #endif 
  1019.     ClearHighlightHandler();
  1020.     //MP Stop Watch UI Changes - Gurinder - 26/4/2004
  1021.     //      clear_screen();
  1022.     //      clear_buttonbar();
  1023.     reset_softkeys();
  1024.     reset_menu_shortcut_handler();
  1025.     ExitCategoryFunction = MMI_dummy_function;
  1026.     RedrawCategoryFunction = MMI_dummy_function;
  1027.     GetCategoryHistory = dummy_get_history;
  1028.     GetCategoryHistorySize = dummy_get_history_size;
  1029.     g_current_screen = NOT_STOPWATCH_SCREEN;
  1030. }
  1031. /*****************************************************************************
  1032.  * FUNCTION
  1033.  *  ShowCategory306Screen
  1034.  * DESCRIPTION
  1035.  *  This function is to Display nWay stopwatch
  1036.  * PARAMETERS
  1037.  *  title_values            [?]         
  1038.  *  title_img               [IN]        Title String
  1039.  *  title_side_msg          [IN]        
  1040.  *  left_softkey            [IN]        LSK string
  1041.  *  left_softkey_icon       [IN]        LSK icon
  1042.  *  right_softkey           [IN]        RSK string
  1043.  *  right_softkey_icon      [IN]        RSK icon
  1044.  *  number_of_items         [IN]        Number of stopwatch items
  1045.  *  stop_watch_list         [?]         Stopwatch list
  1046.  *  bkgrd_image             [IN]        Background image ID
  1047.  *  title_text              [IN]        
  1048.  *  history_buffer          [?]         History buffer
  1049.  *  highlight_item          [IN]        Default highlight item
  1050.  * RETURNS
  1051.  *  void
  1052.  *****************************************************************************/
  1053. void ShowCategory306Screen(
  1054.         UI_stop_watch *title_values,
  1055.         U16 title_img,
  1056.         U16 title_side_msg,
  1057.         U16 left_softkey,
  1058.         U16 left_softkey_icon,
  1059.         U16 right_softkey,
  1060.         U16 right_softkey_icon,
  1061.         S32 number_of_items,
  1062.         UI_stop_watch *stop_watch_list,
  1063.         U16 bkgrd_image,
  1064.         U16 title_text,
  1065.         U8 *history_buffer,
  1066.         S32 highlight_item)
  1067. {
  1068.     /*----------------------------------------------------------------*/
  1069.     /* Local Variables                                                */
  1070.     /*----------------------------------------------------------------*/
  1071.     dm_data_struct dm_data;
  1072.     U8 h_flag;
  1073.     S32 img_width_1, img_height_1, img_width_2, img_height_2;
  1074.     /*----------------------------------------------------------------*/
  1075.     /* Code Body                                                      */
  1076.     /*----------------------------------------------------------------*/
  1077.     g_current_screen = MP_TIMER_SCR;
  1078.     UpdateMPTime();
  1079.     gui_lock_double_buffer();
  1080.     entry_full_screen();
  1081.     MMI_menu_shortcut_number = -1;
  1082.     clear_category_screen_key_handlers();
  1083.     gui_set_font(&MMI_medium_font);
  1084.     /* Side message (total), Reserved */
  1085.     /* title_side_message = (UI_string_type) GetString(title_side_msg); */
  1086.     bkg_stop_watch_img = bkgrd_image;
  1087.     multi_stop_watch_title_img = title_img;
  1088.     current_stop_watch_highlight = highlight_item;
  1089.     /* Make main timer string */
  1090.     change_stopwatchtime_to_string(
  1091.         title_time.mili_sec,
  1092.         title_time.hour,
  1093.         title_time.min,
  1094.         title_time.sec,
  1095.         title_time.watch_string,
  1096.         DISPLAY_MILISEC_TRUE);
  1097.     /* Full screen stopwatch, the screen title is main timer */
  1098.     MMI_title_string = (UI_string_type) title_time.watch_string;
  1099.     /* The separator title of main timer and individual timer ("Stopwatch") */
  1100.     top_title_msg = (UI_string_type) GetString(title_text);
  1101.     /* Store the icon ID in front of each individual timer */
  1102.     {
  1103.         U8 count = 0;
  1104.         for (count = 0; count < MAX_MULTIPURPOSE_TIMER; count++)
  1105.         {
  1106.             list_watch[count].normalimagedata = stop_watch_list[count].normalimagedata;
  1107.             list_watch[count].highlightimagedata = stop_watch_list[count].highlightimagedata;
  1108.         }
  1109.     }
  1110.     /* Store the screen information */
  1111.     gui_measure_image((PU8) list_watch[0].normalimagedata, &img_width_1, &img_height_1);
  1112.     gui_measure_image((PU8) list_watch[0].highlightimagedata, &img_width_2, &img_height_2);
  1113.     category306_text_width = gui_get_string_width((UI_string_type) MMI_title_string);
  1114.     category306_text_height = gui_get_character_height();
  1115.     ASSERT((img_width_1 == img_width_2) && (img_height_1 == img_height_2));
  1116.     category306_img_height = img_height_1;
  1117.     category306_img_width = img_width_1;
  1118.     /* Set key handler  */
  1119.     change_left_softkey(left_softkey, left_softkey_icon);
  1120.     change_right_softkey(right_softkey, right_softkey_icon);
  1121.     clear_left_softkey();
  1122.     clear_right_softkey();
  1123.     register_left_softkey_handler();
  1124.     register_right_softkey_handler();
  1125.     register_default_hide_softkeys();
  1126.     h_flag = set_stop_watch_history(MMI_CATEGORY306_ID, history_buffer);
  1127.     gui_unlock_double_buffer();
  1128.     /* Register screen function pointer */
  1129.     ExitCategoryFunction = ExitCategory306Screen;
  1130.     dm_setup_category_functions(dm_redraw_category_screen, dm_get_category_history, dm_get_category_history_size);
  1131.     dm_data.s32ScrId = (S32) GetActiveScreenId();
  1132.     dm_data.s32CatId = MMI_CATEGORY306_ID;
  1133.     dm_data.s32flags = DM_CLEAR_SCREEN_BACKGROUND;
  1134.     dm_setup_data(&dm_data);
  1135.     dm_redraw_category_screen();
  1136. }
  1137. /*****************************************************************************
  1138.  * FUNCTION
  1139.  *  category306_get_text_y_offset
  1140.  * DESCRIPTION
  1141.  *  This function is to get active timer text y coordinator
  1142.  * PARAMETERS
  1143.  *  idx     [IN]        
  1144.  * RETURNS
  1145.  *  void
  1146.  *****************************************************************************/
  1147. static S32 category306_get_text_y_offset(S32 idx)
  1148. {
  1149.     /*----------------------------------------------------------------*/
  1150.     /* Local Variables                                                */
  1151.     /*----------------------------------------------------------------*/
  1152.     /*----------------------------------------------------------------*/
  1153.     /* Code Body                                                      */
  1154.     /*----------------------------------------------------------------*/
  1155.     return (wtch_pos.nWay_dialog_start.y + wtch_pos.separator_height + STPWACH_NW_FRAM_BORDER)
  1156.         + (idx * category306_area_height) + (category306_area_height >> 1) - (category306_text_height >> 1);
  1157. }
  1158. /*****************************************************************************
  1159.  * FUNCTION
  1160.  *  category306_get_img_y_offset
  1161.  * DESCRIPTION
  1162.  *  This function is to get active timer imgage y coordinator
  1163.  * PARAMETERS
  1164.  *  idx     [IN]        
  1165.  * RETURNS
  1166.  *  void
  1167.  *****************************************************************************/
  1168. static S32 category306_get_img_y_offset(S32 idx)
  1169. {
  1170.     /*----------------------------------------------------------------*/
  1171.     /* Local Variables                                                */
  1172.     /*----------------------------------------------------------------*/
  1173.     /*----------------------------------------------------------------*/
  1174.     /* Code Body                                                      */
  1175.     /*----------------------------------------------------------------*/
  1176.     return (wtch_pos.nWay_dialog_start.y + wtch_pos.separator_height + STPWACH_NW_FRAM_BORDER)
  1177.         + (idx * category306_area_height) + (category306_area_height >> 1) - (category306_img_height >> 1);
  1178. }
  1179. /*****************************************************************************
  1180.  * FUNCTION
  1181.  *  category306_get_timer_text_width
  1182.  * DESCRIPTION
  1183.  *  This function is to get active timer imgage y coordinator
  1184.  * PARAMETERS
  1185.  *  idx     [IN]        
  1186.  * RETURNS
  1187.  *  void
  1188.  *****************************************************************************/
  1189. static S32 category306_get_timer_text_width(S32 idx)
  1190. {
  1191.     /*----------------------------------------------------------------*/
  1192.     /* Local Variables                                                */
  1193.     /*----------------------------------------------------------------*/
  1194.     /*----------------------------------------------------------------*/
  1195.     /* Code Body                                                      */
  1196.     /*----------------------------------------------------------------*/
  1197.     return gui_get_string_width((UI_string_type) list_watch[idx].watch_string);
  1198. }
  1199. /*****************************************************************************/
  1200. /***  Typical Stopwatch                                                    ***/
  1201. /*****************************************************************************/
  1202. /**********************************************************************************/
  1203. /*** Typical Stopwatch Screen                                                   ***/
  1204. /*** Screen ID: 307                                                             ***/
  1205. /**********************************************************************************/
  1206. /***                                                                            ***/
  1207. /***                                                                            ***/
  1208. /***   CategoryScreen307:                                                       ***/
  1209. /***                                                                            ***/
  1210. /***   ====================                                                     ***/
  1211. /***   = Split/Lap 1      =     <--   Split/Lap window, the number of items is  ***/
  1212. /***   = Split/Lap 2      =         depends on screen size. In 128x128 and 120  ***/
  1213. /***   = Split/Lap 3      =         x160, there are 2 itmes. In 176x220, there  ***/
  1214. /***   = ...              =         are 4 items. It is adjusting dynamically.   ***/
  1215. /***   ====================                                                     ***/
  1216. /***   =  xx xxxxxxxx xx  =                                                     ***/
  1217. /***   =  xxxxxxxxxxxxxx  =                                                     ***/
  1218. /***   =   x==========x   =                                                     ***/
  1219. /***   =   x 10:22:03 x   =     <--   Main window, with a background image and  ***/
  1220. /***   =   x    50    x   =          timer running on it. Because there is no   ***/
  1221. /***   =   x==========x   =          image cache mechanism implemented, suggest ***/
  1222. /***   =  xxxxxxxxxxxxxx  =          use plan color as background color.        ***/
  1223. /***   =  xx xxxxxxxx xx  =                                                     ***/
  1224. /***   ====================                                                     ***/
  1225. /***   == LSK ==||== RSK ==                                                     ***/
  1226. /***   ====================                                                     ***/
  1227. /***                                                                            ***/
  1228. /***                                                                            ***/
  1229. /**********************************************************************************/
  1230. S32 stop_watch_total_frames = 0, stop_watch_n_frame = 0;
  1231. U16 stop_watch_bkg_img = 0;
  1232. S32 stop_watch_x = 0, stop_watch_y = 0, stop_watch_width = 0, stop_watch_height = 0;
  1233. S32 center_mili = 0, center_sec = 0, center_hr = 0, center_min = 0;
  1234. S32 start_timer_again = -1;
  1235. U8 timer_flag_stop_start = 0;
  1236. U8 gResetTimer = 0;
  1237. extern S32 fixed_icontext_list_menuitem_total(void);
  1238. void stop_watch_animation_processor(void);
  1239. void show_center_time(void);
  1240. U8 stop_watch_values_data[MAX_TIMER_RECORDS][40];
  1241. /* extern U8    category89_string_list[]; */
  1242. extern U8 category89_string_list[MAX_CATEGORY89_STRINGS][MAX_CATEGORY89_STRING_LENGTH];
  1243. /*****************************************************************************
  1244.  * FUNCTION
  1245.  *  reset_timer
  1246.  * DESCRIPTION
  1247.  *  
  1248.  * PARAMETERS
  1249.  *  void
  1250.  * RETURNS
  1251.  *  void
  1252.  *****************************************************************************/
  1253. void reset_timer(void)
  1254. {
  1255.     /*----------------------------------------------------------------*/
  1256.     /* Local Variables                                                */
  1257.     /*----------------------------------------------------------------*/
  1258.     /*----------------------------------------------------------------*/
  1259.     /* Code Body                                                      */
  1260.     /*----------------------------------------------------------------*/
  1261.     gui_cancel_timer(show_center_time);
  1262.     memset(stop_watch_values_data, 0, sizeof(stop_watch_values_data));
  1263.     memset(category89_string_list, 0, (MAX_CATEGORY89_STRINGS * MAX_CATEGORY89_STRING_LENGTH));
  1264.     timer_flag_stop_start = TIMER_STOP;
  1265.     center_mili = center_sec = center_hr = center_min = 0;
  1266.     remove_all_fixed_icontext_item();
  1267.     MMI_fixed_list_menu.highlighted_item = -1;
  1268.     show_fixed_list();
  1269.     gResetTimer = 1;
  1270.     show_center_time();
  1271.     if (stop_watch_total_frames > 1)
  1272.     {
  1273.         stop_watch_n_frame = -1;
  1274.         stop_watch_animation_processor();
  1275.     }
  1276.     /* Gurinder - 28/4/2004 - Stop Scroll Timer On List Reset. */
  1277.     wgui_text_menuitem_reset_scrolling();
  1278. }
  1279. /*****************************************************************************
  1280.  * FUNCTION
  1281.  *  initialize_stop_watch_timer
  1282.  * DESCRIPTION
  1283.  *  
  1284.  * PARAMETERS
  1285.  *  void
  1286.  * RETURNS
  1287.  *  void
  1288.  *****************************************************************************/
  1289. void initialize_stop_watch_timer(void)
  1290. {
  1291.     /*----------------------------------------------------------------*/
  1292.     /* Local Variables                                                */
  1293.     /*----------------------------------------------------------------*/
  1294.     /*----------------------------------------------------------------*/
  1295.     /* Code Body                                                      */
  1296.     /*----------------------------------------------------------------*/
  1297.     gui_cancel_timer(stop_watch_animation_processor);
  1298.     gui_cancel_timer(show_center_time);
  1299.     timer_flag_stop_start = TIMER_STOP;
  1300.     center_mili = center_sec = center_hr = center_min = 0;
  1301.     if (stop_watch_total_frames > 1)
  1302.     {
  1303.         stop_watch_n_frame = 0;
  1304.     }
  1305. }
  1306. /*****************************************************************************
  1307.  * FUNCTION
  1308.  *  UpdateHistoryValue
  1309.  * DESCRIPTION
  1310.  *  
  1311.  * PARAMETERS
  1312.  *  mili        [?]     
  1313.  *  hr          [?]     
  1314.  *  min         [?]     
  1315.  *  sec         [?]     
  1316.  * RETURNS
  1317.  *  void
  1318.  *****************************************************************************/
  1319. void UpdateHistoryValue(S32 *mili, S32 *hr, S32 *min, S32 *sec)
  1320. {
  1321.     /*----------------------------------------------------------------*/
  1322.     /* Local Variables                                                */
  1323.     /*----------------------------------------------------------------*/
  1324.     S32 total = 0, index = 0;
  1325.     U32 TempPrevCurrentValue = 0;
  1326.     UI_stop_watch temp_watch;
  1327.     /*----------------------------------------------------------------*/
  1328.     /* Code Body                                                      */
  1329.     /*----------------------------------------------------------------*/
  1330.     temp_watch.hour = center_hr;
  1331.     temp_watch.mili_sec = center_mili;
  1332.     temp_watch.min = center_min;
  1333.     temp_watch.sec = center_sec;
  1334. #ifdef MMI_ON_HARDWARE_P
  1335.     TempPrevCurrentValue = gCurrentTime;
  1336.     gCurrentTime = L1I_GetTimeStamp();
  1337.     gDoNotIncrement = NO_INCREMENT;
  1338. #endif /* MMI_ON_HARDWARE_P */ 
  1339.     increment_time_stopwatch(&temp_watch);
  1340. #ifdef MMI_ON_HARDWARE_P
  1341.     gCurrentTime = TempPrevCurrentValue;
  1342. #endif 
  1343.     *mili = temp_watch.mili_sec;
  1344.     *hr = temp_watch.hour;
  1345.     *min = temp_watch.min;
  1346.     *sec = temp_watch.sec;
  1347.     if (start_timer_again == STOP_START_AGAIN)
  1348.     {
  1349.         center_mili = center_hr = center_min = center_sec = 0;
  1350.         gResetTimer = 1;
  1351.     #ifdef MMI_ON_HARDWARE_P
  1352.         gInitialTime = L1I_GetTimeStamp();
  1353.     #endif 
  1354.     }
  1355.     if (g_current_screen == TYPICAL_TIMER_SCR)
  1356.     {
  1357.         MMI_menu_shortcut_number = -1;
  1358.         total = fixed_icontext_list_menuitem_total();
  1359.         if (total > 0)
  1360.         {
  1361.             index = total;
  1362.         }
  1363.         else
  1364.         {
  1365.             index = 0;
  1366.         }
  1367.         fixed_icontext_list_item_insert(index);
  1368.         gui_itoa(total + 1, (UI_string_type) category89_string_list[index], 10);
  1369.         gui_strcat((UI_string_type) category89_string_list[index], (UI_string_type) ".");
  1370.         add_fixed_icontext_list_item_text(index, 0, (UI_string_type) category89_string_list[index]);
  1371.         change_stopwatchtime_to_string(*mili, *hr, *min, *sec, stop_watch_values_data[index], DISPLAY_MILISEC_TRUE);
  1372.         add_fixed_icontext_list_item_text(index, 1, (UI_string_type) stop_watch_values_data[index]);
  1373.         if (index == 0)
  1374.         {
  1375.             fixed_list_goto_item_no_redraw(index);
  1376.         }
  1377.         else
  1378.         {
  1379.             fixed_list_goto_item(index);
  1380.         }
  1381.         show_fixed_list();
  1382.         gui_BLT_double_buffer(
  1383.             MMI_fixed_list_menu.x,
  1384.             MMI_fixed_list_menu.y,
  1385.             MMI_fixed_list_menu.x + MMI_fixed_list_menu.width,
  1386.             MMI_fixed_list_menu.y + MMI_fixed_list_menu.height);
  1387.     }
  1388. }
  1389. /*****************************************************************************
  1390.  * FUNCTION
  1391.  *  start_stop_watch_timer
  1392.  * DESCRIPTION
  1393.  *  
  1394.  * PARAMETERS
  1395.  *  start_stop_flag     [IN]        
  1396.  * RETURNS
  1397.  *  void
  1398.  *****************************************************************************/
  1399. void start_stop_watch_timer(U8 start_stop_flag)
  1400. {
  1401.     /*----------------------------------------------------------------*/
  1402.     /* Local Variables                                                */
  1403.     /*----------------------------------------------------------------*/
  1404.     /*----------------------------------------------------------------*/
  1405.     /* Code Body                                                      */
  1406.     /*----------------------------------------------------------------*/
  1407.     if (start_stop_flag == TIMER_STOP)
  1408.     {
  1409.         gui_cancel_timer(show_center_time);
  1410.         if (timer_flag_stop_start == TIMER_START)
  1411.         {
  1412.             show_center_time();
  1413.         }
  1414.     }
  1415.     else if (start_stop_flag == TIMER_START)
  1416.     {
  1417.     #ifdef MMI_ON_HARDWARE_P
  1418.         gInitialTime = L1I_GetTimeStamp();
  1419.     #endif 
  1420.         gui_start_timer(STPWACH_UI_UPDATE_PERIOD, show_center_time);
  1421.         if (stop_watch_total_frames > 1)
  1422.         {
  1423.             gui_start_timer(STOP_WATCH_ANIMATION_DELAY, stop_watch_animation_processor);
  1424.         }
  1425.     }
  1426.     timer_flag_stop_start = start_stop_flag;
  1427. }
  1428. U8 gMainTimeUpdatedFlag = 0;
  1429. /*****************************************************************************
  1430.  * FUNCTION
  1431.  *  UpdateTypicalTimer
  1432.  * DESCRIPTION
  1433.  *  
  1434.  * PARAMETERS
  1435.  *  void
  1436.  * RETURNS
  1437.  *  void
  1438.  *****************************************************************************/
  1439. void UpdateTypicalTimer(void)
  1440. {
  1441.     /*----------------------------------------------------------------*/
  1442.     /* Local Variables                                                */
  1443.     /*----------------------------------------------------------------*/
  1444.     UI_stop_watch temp_watch;
  1445.     /*----------------------------------------------------------------*/
  1446.     /* Code Body                                                      */
  1447.     /*----------------------------------------------------------------*/
  1448.     if (timer_flag_stop_start == TIMER_START)
  1449.     {
  1450.         temp_watch.hour = center_hr;
  1451.         temp_watch.mili_sec = center_mili;
  1452.         temp_watch.min = center_min;
  1453.         temp_watch.sec = center_sec;
  1454.     #ifdef MMI_ON_HARDWARE_P
  1455.         gCurrentTime = L1I_GetTimeStamp();
  1456.         gDoNotIncrement = TYP_TIMER_INCREMENT;
  1457.     #endif /* MMI_ON_HARDWARE_P */ 
  1458.         increment_time_stopwatch(&temp_watch);
  1459.     #ifdef MMI_ON_HARDWARE_P
  1460.         gInitialTime = gCurrentTime;
  1461.     #endif 
  1462.         if ((center_hr == temp_watch.hour) && (center_min == temp_watch.min) && (center_sec == temp_watch.sec))
  1463.         {
  1464.             gMainTimeUpdatedFlag = 0;
  1465.         }
  1466.         else
  1467.         {
  1468.             gMainTimeUpdatedFlag = 1;
  1469.         }
  1470.         center_hr = temp_watch.hour;
  1471.         center_mili = temp_watch.mili_sec;
  1472.         center_min = temp_watch.min;
  1473.         center_sec = temp_watch.sec;
  1474.     }
  1475. }
  1476. /*****************************************************************************
  1477.  * FUNCTION
  1478.  *  print_center_time
  1479.  * DESCRIPTION
  1480.  *  
  1481.  * PARAMETERS
  1482.  *  void
  1483.  * RETURNS
  1484.  *  void
  1485.  *****************************************************************************/
  1486. void print_center_time(void)
  1487. {
  1488.     /*----------------------------------------------------------------*/
  1489.     /* Local Variables                                                */
  1490.     /*----------------------------------------------------------------*/
  1491.     U8 time_string[40];
  1492.     U8 mili_string[20], uni_mili_string[40];
  1493.     color text_col = gui_color(0, 0, 0);
  1494.     S32 w, h;
  1495.     /*----------------------------------------------------------------*/
  1496.     /* Code Body                                                      */
  1497.     /*----------------------------------------------------------------*/
  1498.     UpdateTypicalTimer();
  1499. #if(UI_DOUBLE_BUFFER_SUPPORT)
  1500.     gui_lock_double_buffer();
  1501. #endif 
  1502.     /* 041205 Calvin modified */
  1503. #if defined (__MMI_MAINLCD_240X320__)
  1504.     gui_set_font(&MMI_large_font);
  1505. #else 
  1506.     gui_set_font(&MMI_small_font);
  1507. #endif 
  1508.     /* Calvin end */
  1509.     change_stopwatchtime_to_string(0, center_hr, center_min, center_sec, time_string, DISPLAY_MILISEC_FALSE);
  1510.     /* sprintf((S8*)mili_string, "%02d", center_mili); */
  1511.     sprintf((S8*) mili_string, "%02d", center_mili);
  1512.     AnsiiToUnicodeString((PS8) uni_mili_string, (PS8) mili_string);
  1513.     gui_measure_string((UI_string_type) time_string, &w, &h);
  1514.     if (r2lMMIFlag)
  1515.     {
  1516.         gui_move_text_cursor(wtch_pos.typ_timer.x + w, wtch_pos.typ_timer.y);
  1517.     }
  1518.     else
  1519.     {
  1520.         gui_move_text_cursor(wtch_pos.typ_timer.x, wtch_pos.typ_timer.y);
  1521.     }
  1522.     gui_set_text_color(text_col);
  1523.     gui_print_text((UI_string_type) time_string);
  1524.     gui_measure_string((UI_string_type) uni_mili_string, &w, &h);
  1525.     if (r2lMMIFlag)
  1526.     {
  1527.         gui_move_text_cursor(wtch_pos.typ_milsec.x + w, wtch_pos.typ_milsec.y);
  1528.     }
  1529.     else
  1530.     {
  1531.         gui_move_text_cursor(wtch_pos.typ_milsec.x, wtch_pos.typ_milsec.y);
  1532.     }
  1533.     gui_print_text((UI_string_type) uni_mili_string);
  1534. #if(UI_DOUBLE_BUFFER_SUPPORT)
  1535.     gui_unlock_double_buffer();
  1536. #endif 
  1537. }
  1538. bitmap gdata_maintimer;
  1539. bitmap gdata_millitimer;
  1540. #if defined (__MMI_MAINLCD_240X320__)
  1541. U8 gbuffer_millitime[1150];
  1542. U8 gbuffer_maintime[3680];
  1543. #else /* defined (__MMI_MAINLCD_240X320__) */ 
  1544. U8 gbuffer_millitime[600 /* 550 */ ];   /* 32(row bytes) * 16 (y offset) = 512 */
  1545. U8 gbuffer_maintime[1200 /* 1100 */ ];  /* 102(row bytes) * 11(y offset) = 1122 */
  1546. #endif /* defined (__MMI_MAINLCD_240X320__) */ 
  1547. /* 051605 Calvin added: should move to .h */
  1548. extern void reset_fixed_list_show_empty(void);
  1549. extern void disable_fixed_list_show_empty(void);
  1550. /* Calvin end */
  1551. /*****************************************************************************
  1552.  * FUNCTION
  1553.  *  show_center_time
  1554.  * DESCRIPTION
  1555.  *  
  1556.  * PARAMETERS
  1557.  *  void
  1558.  * RETURNS
  1559.  *  void
  1560.  *****************************************************************************/
  1561. void show_center_time(void)
  1562. {
  1563.     /*----------------------------------------------------------------*/
  1564.     /* Local Variables                                                */
  1565.     /*----------------------------------------------------------------*/
  1566.     S32 w;
  1567.     U8 time_string[40];
  1568.     U8 mili_string[20], uni_mili_string[40];
  1569.     color text_col = gui_color(0, 0, 0);
  1570.     /*----------------------------------------------------------------*/
  1571.     /* Code Body                                                      */
  1572.     /*----------------------------------------------------------------*/
  1573.     /* PU8 stop_watch_img =get_image(stop_watch_bkg_img); */
  1574.     UpdateTypicalTimer();
  1575.     if (g_current_screen == TYPICAL_TIMER_SCR)
  1576.     {
  1577.         gui_lock_double_buffer();
  1578.         gui_reset_clip();
  1579.         gui_reset_text_clip();
  1580.         /* 041205 Calvin modified */
  1581.     #if defined (__MMI_MAINLCD_240X320__)
  1582.         gui_set_font(&MMI_large_font);
  1583.     #else 
  1584.         gui_set_font(&MMI_small_font);
  1585.     #endif 
  1586.         /* Calvin end */
  1587.         gui_set_text_color(text_col);
  1588.         if (stop_watch_total_frames > 1)
  1589.         {
  1590.             _show_bitmap(wtch_pos.typ_timer.x, wtch_pos.typ_timer.y, &gdata_maintimer);
  1591.             _show_bitmap(wtch_pos.typ_milsec.x, wtch_pos.typ_milsec.y, &gdata_millitimer);
  1592.             print_center_time();
  1593.         }
  1594.         else
  1595.         {
  1596.             if ((gMainTimeUpdatedFlag == 1) || (gResetTimer))
  1597.             {
  1598.                 change_stopwatchtime_to_string(
  1599.                     0,
  1600.                     center_hr,
  1601.                     center_min,
  1602.                     center_sec,
  1603.                     time_string,
  1604.                     DISPLAY_MILISEC_FALSE);
  1605.                 sprintf((S8*) mili_string, "%02d", center_mili);
  1606.                 AnsiiToUnicodeString((PS8) uni_mili_string, (PS8) mili_string);
  1607.                 _show_bitmap(wtch_pos.typ_timer.x, wtch_pos.typ_timer.y, &gdata_maintimer);
  1608.                 /* MTK Elvis for R2L characters */
  1609.                 w = gui_get_string_width((UI_string_type) time_string);
  1610.                 if (r2lMMIFlag)
  1611.                 {
  1612.                     gui_move_text_cursor(wtch_pos.typ_timer.x + w, wtch_pos.typ_timer.y);
  1613.                 }
  1614.                 else
  1615.                 {
  1616.                     gui_move_text_cursor(wtch_pos.typ_timer.x, wtch_pos.typ_timer.y);
  1617.                 }
  1618.                 /* MTK end */
  1619.                 gui_print_text((UI_string_type) time_string);
  1620.                 _show_bitmap(wtch_pos.typ_milsec.x, wtch_pos.typ_milsec.y, &gdata_millitimer);
  1621.                 /* MTK Elvis for R2L characters */
  1622.                 w = gui_get_string_width((UI_string_type) uni_mili_string);
  1623.                 if (r2lMMIFlag)
  1624.                 {
  1625.                     gui_move_text_cursor(wtch_pos.typ_milsec.x + w, wtch_pos.typ_milsec.y);
  1626.                 }
  1627.                 else
  1628.                 {
  1629.                     gui_move_text_cursor(wtch_pos.typ_milsec.x, wtch_pos.typ_milsec.y);
  1630.                 }
  1631.                 /* MTK end */
  1632.                 gui_print_text((UI_string_type) uni_mili_string);
  1633.                 gResetTimer = 0;
  1634.             }
  1635.             else
  1636.             {
  1637.                 sprintf((S8*) mili_string, "%02d", center_mili);
  1638.                 AnsiiToUnicodeString((PS8) uni_mili_string, (PS8) mili_string);
  1639.                 _show_bitmap(wtch_pos.typ_milsec.x, wtch_pos.typ_milsec.y, &gdata_millitimer);
  1640.                 /* MTK Elvis for R2L characters */
  1641.                 w = gui_get_string_width((UI_string_type) uni_mili_string);
  1642.                 if (r2lMMIFlag)
  1643.                 {
  1644.                     gui_move_text_cursor(wtch_pos.typ_milsec.x + w, wtch_pos.typ_milsec.y);
  1645.                 }
  1646.                 else
  1647.                 {
  1648.                     gui_move_text_cursor(wtch_pos.typ_milsec.x, wtch_pos.typ_milsec.y);
  1649.                 }
  1650.                 /* MTK end */
  1651.                 gui_print_text((UI_string_type) uni_mili_string);
  1652.             }
  1653.         }
  1654.         gui_unlock_double_buffer();
  1655.         gui_BLT_double_buffer(
  1656.             0,
  1657.             (wtch_pos.typ_history_height + 2),
  1658.             UI_device_width - 1,
  1659.             (UI_device_height - MMI_button_bar_height));
  1660.     }
  1661.     if (timer_flag_stop_start == TIMER_START)
  1662.     {
  1663.         gui_start_timer(STPWACH_UI_UPDATE_PERIOD, show_center_time);
  1664.     }
  1665. }
  1666. /* 070505 Calvin Start */
  1667. #if defined (__MMI_WALLPAPER_ON_BOTTOM__)
  1668. MMI_ID_TYPE stopwatch_scr_bg_ID;
  1669. S8 *stopwatch_scr_bg_filename;
  1670. S32 stopwatch_scr_bg_x, stopwatch_scr_bg_y;
  1671. U8 stopwatch_scr_bg_opacity;    /* 070505 Calvin added */
  1672. #endif /* defined (__MMI_WALLPAPER_ON_BOTTOM__) */ 
  1673. /* 061705 Calvin End */
  1674. extern void dm_set_scr_bg_image_no_draw(U16 image_id, S8 *file_name, S32 x, S32 y, U8 opacity);        /* 092005 grayscale Calvin */
  1675. /*****************************************************************************
  1676.  * FUNCTION
  1677.  *  ExitCategory307Screen
  1678.  * DESCRIPTION
  1679.  *  
  1680.  * PARAMETERS
  1681.  *  void
  1682.  * RETURNS
  1683.  *  void
  1684.  *****************************************************************************/
  1685. void ExitCategory307Screen(void)
  1686. {
  1687.     /*----------------------------------------------------------------*/
  1688.     /* Local Variables                                                */
  1689.     /*----------------------------------------------------------------*/
  1690.     /*----------------------------------------------------------------*/
  1691.     /* Code Body                                                      */
  1692.     /*----------------------------------------------------------------*/
  1693. #ifdef MMI_ON_HARDWARE_P
  1694.     gui_cancel_timer(show_center_time);
  1695. #endif 
  1696.     gui_cancel_timer(stop_watch_animation_processor);
  1697.     ClearHighlightHandler();
  1698.     reset_softkeys();
  1699.     /* 070505 Calvin added */
  1700. #if defined (__MMI_WALLPAPER_ON_BOTTOM__)
  1701.     /* dm_set_scr_bg_image(stopwatch_scr_bg_ID, stopwatch_scr_bg_filename, stopwatch_scr_bg_x, stopwatch_scr_bg_y, stopwatch_scr_bg_opacity);//092005 grayscale Calvin */
  1702.     dm_set_scr_bg_image_no_draw(
  1703.         stopwatch_scr_bg_ID,
  1704.         stopwatch_scr_bg_filename,
  1705.         stopwatch_scr_bg_x,
  1706.         stopwatch_scr_bg_y,
  1707.         stopwatch_scr_bg_opacity);
  1708. #endif /* defined (__MMI_WALLPAPER_ON_BOTTOM__) */ 
  1709.     /* Calvin end */
  1710.     /* reset_fixed_list_show_empty();//051605 Calvin added */
  1711.     ExitCategoryFunction = MMI_dummy_function;
  1712.     RedrawCategoryFunction = MMI_dummy_function;
  1713.     GetCategoryHistory = dummy_get_history;
  1714.     GetCategoryHistorySize = dummy_get_history_size;
  1715.     g_current_screen = NOT_STOPWATCH_SCREEN;
  1716.     wgui_text_menuitem_reset_scrolling();
  1717. }
  1718. /*****************************************************************************
  1719.  * FUNCTION
  1720.  *  stop_watch_animation_processor
  1721.  * DESCRIPTION
  1722.  *  
  1723.  * PARAMETERS
  1724.  *  void
  1725.  * RETURNS
  1726.  *  void
  1727.  *****************************************************************************/
  1728. void stop_watch_animation_processor()
  1729. {
  1730.     /*----------------------------------------------------------------*/
  1731.     /* Local Variables                                                */
  1732.     /*----------------------------------------------------------------*/
  1733.     int i;
  1734.     PU8 stop_watch_img = get_image(stop_watch_bkg_img);
  1735.     /*----------------------------------------------------------------*/
  1736.     /* Code Body                                                      */
  1737.     /*----------------------------------------------------------------*/
  1738.     stop_watch_n_frame++;
  1739.     if (stop_watch_n_frame >= stop_watch_total_frames)
  1740.     {
  1741.         stop_watch_n_frame = 0;
  1742.     }
  1743.     gui_cancel_timer(stop_watch_animation_processor);
  1744.     gui_cancel_timer(show_center_time);
  1745.     gui_lock_double_buffer();
  1746.     gui_reset_clip();
  1747.     gui_reset_text_clip();
  1748.     gui_set_clip(0, wtch_pos.typ_history_height + 2, UI_device_width - 1, UI_device_height - MMI_button_bar_height - 1);
  1749.     gui_draw_filled_area(
  1750.         0,
  1751.         wtch_pos.typ_history_height + 2,
  1752.         UI_device_width - 1,
  1753.         UI_device_height - 1,
  1754.         current_MMI_theme->general_background_filler);
  1755.     /* gui_show_animated_image_frame(stop_watch_x,stop_watch_y,stop_watch_img,(S16)stop_watch_n_frame); */
  1756.     for (i = 0; i <= stop_watch_n_frame; i++)
  1757.     {
  1758.         gdi_image_draw_animation_single_frame(stop_watch_x, stop_watch_y, stop_watch_img, (S16) i);
  1759.     }
  1760.     /* gdi_image_draw_animation_single_frame(stop_watch_x,stop_watch_y,stop_watch_img,(S16)stop_watch_n_frame); */
  1761.    /***********************************************************/
  1762.     /* Notices!!!                                              */
  1763.     /* Change the X,Y offset should change the buffer size of  */
  1764.     /* gbuffer_millitime[] and gbuffer_maintime[] as well      */
  1765.    /***********************************************************/
  1766.     memset(gbuffer_maintime, 0, sizeof(gbuffer_maintime));
  1767.     gdata_maintimer.data = gbuffer_maintime;
  1768. #if defined (__MMI_MAINLCD_240X320__)
  1769.     _get_bitmap(
  1770.         wtch_pos.typ_timer.x,
  1771.         wtch_pos.typ_timer.y,
  1772.         (wtch_pos.typ_timer.x + 79),
  1773.         (wtch_pos.typ_timer.y + 15),
  1774.         &gdata_maintimer);
  1775. #else /* defined (__MMI_MAINLCD_240X320__) */ 
  1776.     _get_bitmap(
  1777.         wtch_pos.typ_timer.x,
  1778.         wtch_pos.typ_timer.y,
  1779.         (wtch_pos.typ_timer.x + 50),
  1780.         (wtch_pos.typ_timer.y + 10),
  1781.         &gdata_maintimer);
  1782. #endif /* defined (__MMI_MAINLCD_240X320__) */ 
  1783.    /***********************************************************/
  1784.     /* Notices!!!                                              */
  1785.     /* Change the X,Y offset should change the buffer size of  */
  1786.     /* gbuffer_millitime[] and gbuffer_maintime[] as well      */
  1787.    /***********************************************************/
  1788.     memset(gbuffer_millitime, 0, sizeof(gbuffer_millitime));
  1789.     gdata_millitimer.data = gbuffer_millitime;
  1790. #if defined (__MMI_MAINLCD_240X320__)
  1791.     _get_bitmap(
  1792.         wtch_pos.typ_milsec.x,
  1793.         wtch_pos.typ_milsec.y,
  1794.         (wtch_pos.typ_milsec.x + 24) /* 70 */ ,
  1795.         (wtch_pos.typ_milsec.y + 22) /* 120 */ ,
  1796.         &gdata_millitimer);
  1797. #else /* defined (__MMI_MAINLCD_240X320__) */ 
  1798.     _get_bitmap(
  1799.         wtch_pos.typ_milsec.x,
  1800.         wtch_pos.typ_milsec.y,
  1801.         (wtch_pos.typ_milsec.x + 15) /* 70 */ ,
  1802.         (wtch_pos.typ_milsec.y + 15) /* 120 */ ,
  1803.         &gdata_millitimer);
  1804. #endif /* defined (__MMI_MAINLCD_240X320__) */ 
  1805.     /* gMainTimeUpdatedFlag=1; */
  1806.     print_center_time();
  1807.     gui_unlock_double_buffer();
  1808.     gui_BLT_double_buffer(0, 0, UI_device_width - 1, (UI_device_height - MMI_button_bar_height));
  1809.     gui_start_timer(STOP_WATCH_ANIMATION_DELAY, stop_watch_animation_processor);
  1810.     if (timer_flag_stop_start == TIMER_START)
  1811.     {
  1812.         gui_start_timer(STPWACH_UI_UPDATE_PERIOD, show_center_time);
  1813.     }
  1814. }
  1815. /*****************************************************************************
  1816.  * FUNCTION
  1817.  *  ShowCategory307Screen
  1818.  * DESCRIPTION
  1819.  *  Redraws the Idle screen
  1820.  * PARAMETERS
  1821.  *  left_softkey            [IN]        
  1822.  *  left_softkey_icon       [IN]        
  1823.  *  right_softkey           [IN]        
  1824.  *  right_softkey_icon      [IN]        
  1825.  *  number_of_items         [IN]        
  1826.  *  list_watch              [?]         
  1827.  *  highlighted_item        [IN]        
  1828.  *  history_buffer          [?]         
  1829.  *  bkg_image               [IN]        
  1830.  *  start_continue_flag     [IN]        
  1831.  * RETURNS
  1832.  *  void
  1833.  *****************************************************************************/
  1834. void ShowCategory307Screen(
  1835.         U16 left_softkey,
  1836.         U16 left_softkey_icon,
  1837.         U16 right_softkey,
  1838.         U16 right_softkey_icon,
  1839.         S32 number_of_items,
  1840.         UI_stop_watch *list_watch,
  1841.         S32 highlighted_item,
  1842.         U8 *history_buffer,
  1843.         U16 bkg_image,
  1844.         S32 start_continue_flag)
  1845. {
  1846.     /*----------------------------------------------------------------*/
  1847.     /* Local Variables                                                */
  1848.     /*----------------------------------------------------------------*/
  1849.     dm_data_struct dm_data;
  1850.     S32 i;
  1851.     U8 h_flag;
  1852.     PU8 img_bkg_stop;
  1853.     /*----------------------------------------------------------------*/
  1854.     /* Code Body                                                      */
  1855.     /*----------------------------------------------------------------*/
  1856.     g_current_screen = TYPICAL_TIMER_SCR;
  1857.     gui_lock_double_buffer();
  1858.     start_timer_again = start_continue_flag;
  1859.     MMI_menu_shortcut_number = -1;
  1860.     clear_category_screen_key_handlers();
  1861.     change_left_softkey(left_softkey, left_softkey_icon);
  1862.     change_right_softkey(right_softkey, right_softkey_icon);
  1863.     clear_left_softkey();
  1864.     clear_right_softkey();
  1865.     register_left_softkey_handler();
  1866.     register_right_softkey_handler();
  1867.     register_default_hide_softkeys();
  1868. #if !defined (__MMI_MAINLCD_240X320__)
  1869.     entry_full_screen();
  1870. #endif 
  1871.     create_fixed_icontext_list_menuitems(2, 0);
  1872.     MMI_current_menu_type = LIST_MENU;
  1873.     GUI_current_fixed_icontext_list_menuitem_column = 1;
  1874.     resize_fixed_list(MMI_content_width, wtch_pos.typ_history_height + 2);
  1875. #if defined (__MMI_WALLPAPER_ON_BOTTOM__)
  1876.     dm_get_scr_bg_image(
  1877.         &stopwatch_scr_bg_ID,
  1878.         &stopwatch_scr_bg_filename,
  1879.         &stopwatch_scr_bg_x,
  1880.         &stopwatch_scr_bg_y,
  1881.         &stopwatch_scr_bg_opacity);
  1882.     dm_set_scr_bg_image(IMG_TYPICALSW_LIST_BACKGROUND, NULL, 0, 0, current_MMI_theme->bg_opacity_medium);
  1883. #endif /* defined (__MMI_WALLPAPER_ON_BOTTOM__) */ 
  1884.     set_fixed_icontext_list_text_coordinates(0, 1, 0, 30, MMI_MENUITEM_HEIGHT);
  1885.     set_fixed_icontext_list_text_coordinates(
  1886.         1,
  1887.         30,
  1888.         0,
  1889.         UI_device_width - 30 - 4 - MMI_fixed_list_menu.vbar.width,
  1890.         MMI_MENUITEM_HEIGHT);
  1891.     associate_fixed_icontext_list_list();
  1892.     for (i = 0; i < number_of_items; i++)
  1893.     {
  1894.         fixed_icontext_list_item_insert(i);
  1895.         gui_itoa(i + 1, (UI_string_type) category89_string_list[i], 10);
  1896.         gui_strcat((UI_string_type) category89_string_list[i], (UI_string_type) ".");
  1897.         add_fixed_icontext_list_item_text(i, 0, (UI_string_type) category89_string_list[i]);
  1898.         change_stopwatchtime_to_string(
  1899.             list_watch[i].mili_sec,
  1900.             list_watch[i].hour,
  1901.             list_watch[i].min,
  1902.             list_watch[i].sec,
  1903.             list_watch[i].watch_string,
  1904.             DISPLAY_MILISEC_TRUE);
  1905.         add_fixed_icontext_list_item_text(i, 1, (UI_string_type) list_watch[i].watch_string);
  1906.     }
  1907.     register_fixed_list_keys();
  1908.     resize_fixed_icontext_list_menuitems(0, MMI_menuitem_height);
  1909.     set_fixed_icontext_positions(0, 0, 1, 0);
  1910.     register_fixed_list_highlight_handler(standard_stop_watch_list_highlight_handler);
  1911.     MMI_current_menu_type = LIST_MENU;
  1912.     h_flag = set_list_menu_category_history(MMI_CATEGORY307_ID, history_buffer);
  1913.     if (h_flag)
  1914.     {
  1915.         fixed_list_goto_item_no_redraw(MMI_fixed_list_menu.highlighted_item);
  1916.     }
  1917.     else
  1918.     {
  1919.         fixed_list_goto_item_no_redraw(highlighted_item);
  1920.     }
  1921.     MMI_title_string = 0;
  1922.     MMI_title_icon = 0;
  1923.     stop_watch_bkg_img = bkg_image;
  1924.     img_bkg_stop = (PU8) GetImage(bkg_image);
  1925.     gui_measure_image(img_bkg_stop, &stop_watch_width, &stop_watch_height);
  1926.     stop_watch_total_frames = gui_image_n_frames(img_bkg_stop);
  1927.     gui_unlock_double_buffer();
  1928.     /* Not to execute LSK function when pen down on list menuitem */
  1929. #ifdef __MMI_TOUCH_SCREEN__
  1930.     wgui_register_list_item_selected_callback_all(UI_dummy_function);
  1931. #endif 
  1932.     ExitCategoryFunction = ExitCategory307Screen;
  1933.     dm_setup_category_functions(dm_redraw_category_screen, dm_get_category_history, dm_get_category_history_size);
  1934.     dm_data.s32ScrId = (S32) GetActiveScreenId();
  1935.     dm_data.s32CatId = MMI_CATEGORY307_ID;
  1936.     dm_data.s32flags = DM_CLEAR_SCREEN_BACKGROUND;
  1937.     dm_setup_data(&dm_data);
  1938.     dm_redraw_category_screen();
  1939. }
  1940. #ifdef __MMI_TOUCH_SCREEN__
  1941. /*****************************************************************************
  1942.  * FUNCTION
  1943.  *  gui_stopwatch_translate_penevent
  1944.  * DESCRIPTION
  1945.  *  Finds the index of Stopwatch Timer
  1946.  * PARAMETERS
  1947.  *  x           [IN]        Pen's x position
  1948.  *  y           [IN]        Pen's y position
  1949.  *  index       [?]         Index of Timer
  1950.  * RETURNS
  1951.  *  MMI_BOOL True/False
  1952.  *****************************************************************************/
  1953. MMI_BOOL gui_stopwatch_translate_penevent(S32 x, S32 y, S32 *index)
  1954. {
  1955.     /*----------------------------------------------------------------*/
  1956.     /* Local Variables                                                */
  1957.     /*----------------------------------------------------------------*/
  1958.     MMI_BOOL ret = MMI_FALSE;
  1959.     /*----------------------------------------------------------------*/
  1960.     /* Code Body                                                      */
  1961.     /*----------------------------------------------------------------*/
  1962.     if (g_current_screen == MP_TIMER_SCR)
  1963.     {
  1964.         S32 y1, y2, i;
  1965.         S32 img_y, text_y;
  1966.         for (i = 0; i < MAX_MULTIPURPOSE_TIMER; i++)
  1967.         {
  1968.             img_y = category306_get_img_y_offset(i);
  1969.             text_y = category306_get_text_y_offset(i);
  1970.             y1 = (img_y < text_y) ? img_y : text_y;
  1971.             y2 = (y1 + category306_text_height >
  1972.                   y1 + category306_img_height) ? (y1 + category306_text_height) : (y1 + category306_img_height);
  1973.             if (y >= y1 && y <= y2)
  1974.             {
  1975.                 *index = i;
  1976.                 ret = MMI_TRUE;
  1977.                 break;
  1978.             }
  1979.         }
  1980.     }
  1981.     return ret;
  1982. }
  1983. /*****************************************************************************
  1984.  * FUNCTION
  1985.  *  wgui_stopwatch_pen_down_hdlr
  1986.  * DESCRIPTION
  1987.  *  Handles Pen Down Event on Stopwatch
  1988.  * PARAMETERS
  1989.  *  point       [IN]        Pen's position
  1990.  *  index       [OUT]       Index of Timer
  1991.  *  IN [IN](?)
  1992.  *  OUT [OUT](?)
  1993.  * RETURNS
  1994.  *  MMI_BOOL True/False
  1995.  *****************************************************************************/
  1996. MMI_BOOL wgui_stopwatch_pen_down_hdlr(mmi_pen_point_struct point, S32 *index)
  1997. {
  1998.     /*----------------------------------------------------------------*/
  1999.     /* Local Variables                                                */
  2000.     /*----------------------------------------------------------------*/
  2001.     S32 x1 = 0, y1 = 0, x2 = 0, y2 = 0;
  2002.     S32 posx = point.x, posy = point.y;
  2003.     S32 img_y, text_y;
  2004.     MMI_BOOL ret = MMI_FALSE;
  2005.     /*----------------------------------------------------------------*/
  2006.     /* Code Body                                                      */
  2007.     /*----------------------------------------------------------------*/
  2008.     if (g_current_screen == NOT_STOPWATCH_SCREEN)
  2009.     {
  2010.         return ret;
  2011.     }
  2012.     if (g_current_screen == MP_TIMER_SCR)
  2013.     {
  2014.         img_y = category306_get_img_y_offset(0);
  2015.         text_y = category306_get_text_y_offset(0);
  2016.         x1 = category306_img_x_offset;
  2017.         y1 = (img_y < text_y) ? img_y : text_y;
  2018.         if (y1 < wtch_pos.nWay_dialog_start.y + wtch_pos.separator_height + STPWACH_NW_FRAM_BORDER)
  2019.         {
  2020.             y1 = wtch_pos.nWay_dialog_start.y + wtch_pos.separator_height + STPWACH_NW_FRAM_BORDER;
  2021.         }
  2022.         x2 = category306_text_x_offset + category306_text_width;
  2023.         img_y = category306_get_img_y_offset(MAX_MULTIPURPOSE_TIMER - 1);
  2024.         text_y = category306_get_text_y_offset(MAX_MULTIPURPOSE_TIMER - 1);
  2025.         y2 = (img_y + category306_img_height) >
  2026.             (text_y + category306_text_height) ? (img_y + category306_img_height) : (text_y + category306_text_height);
  2027.         if (y2 > wtch_pos.nWay_dialog_end.y - STPWACH_NW_FRAM_BORDER)
  2028.         {
  2029.             y2 = wtch_pos.nWay_dialog_end.y - STPWACH_NW_FRAM_BORDER;
  2030.         }
  2031.     }
  2032.     if (posx >= x1 && posx <= x2 && posy >= y1 && posy <= y2)
  2033.     {
  2034.         ret = gui_stopwatch_translate_penevent(point.x, point.y, index);
  2035.     }
  2036.     return ret;
  2037. }
  2038. #endif /* __MMI_TOUCH_SCREEN__ */ 
  2039. /*****************************************************************************/
  2040. /***  Utility Function                                                     ***/
  2041. /*****************************************************************************/
  2042. /*****************************************************************************
  2043.  * FUNCTION
  2044.  *  change_stopwatchtime_to_string
  2045.  * DESCRIPTION
  2046.  *  This function is to make stopwatch timer value to string
  2047.  * PARAMETERS
  2048.  *  milisec                     [IN]        
  2049.  *  hour                        [IN]        
  2050.  *  min                         [IN]        
  2051.  *  sec                         [IN]        
  2052.  *  str_val                     [?]         
  2053.  *  display_milisec_flag        [IN]        
  2054.  * RETURNS
  2055.  *  void
  2056.  *****************************************************************************/
  2057. void change_stopwatchtime_to_string(S32 milisec, S32 hour, S32 min, S32 sec, U8 *str_val, U8 display_milisec_flag)
  2058. {
  2059.     /*----------------------------------------------------------------*/
  2060.     /* Local Variables                                                */
  2061.     /*----------------------------------------------------------------*/
  2062.     S8 temp_str[40];
  2063.     /*----------------------------------------------------------------*/
  2064.     /* Code Body                                                      */
  2065.     /*----------------------------------------------------------------*/
  2066.     if (display_milisec_flag)
  2067.     {
  2068.         sprintf((S8*) temp_str, "%02d:%02d:%02d:%02d", hour, min, sec, milisec);
  2069.     }
  2070.     else
  2071.     {
  2072.         sprintf((S8*) temp_str, "%02d:%02d:%02d", hour, min, sec);
  2073.     }
  2074.     AnsiiToUnicodeString((PS8) str_val, (PS8) temp_str);
  2075.     return;
  2076. }
  2077. /*****************************************************************************
  2078.  * FUNCTION
  2079.  *  show_typical_stop_watch
  2080.  * DESCRIPTION
  2081.  *  
  2082.  * PARAMETERS
  2083.  *  void
  2084.  * RETURNS
  2085.  *  void
  2086.  *****************************************************************************/
  2087. void show_typical_stop_watch(void)
  2088. {
  2089.     /*----------------------------------------------------------------*/
  2090.     /* Local Variables                                                */
  2091.     /*----------------------------------------------------------------*/
  2092.     U8 time_string[40];
  2093.     U8 mili_string[20], uni_mili_string[40];
  2094.     S32 width, height;
  2095.     PU8 stop_watch_img = (PU8) GetImage(stop_watch_bkg_img);
  2096.     /*----------------------------------------------------------------*/
  2097.     /* Code Body                                                      */
  2098.     /*----------------------------------------------------------------*/
  2099.     gui_cancel_timer(stop_watch_animation_processor);
  2100.     gui_cancel_timer(show_center_time);
  2101.     gui_reset_clip();
  2102.     gui_reset_text_clip();
  2103.     /* 053005 Calvin switch the order of these 2 fucntions */
  2104.     gui_set_clip(0, MMI_status_bar_height, UI_device_width - 1, UI_device_height - MMI_button_bar_height);
  2105.     gui_draw_filled_area(0, 0, UI_device_width - 1, UI_device_height - 1, current_MMI_theme->general_background_filler);
  2106.     /* Calvin end */
  2107.     if (stop_watch_total_frames > 1)
  2108.     {
  2109.         gui_show_animated_image_frame(stop_watch_x, stop_watch_y, stop_watch_img, (S16) stop_watch_n_frame);
  2110.     }
  2111.     else
  2112.     {
  2113.         gui_show_image(stop_watch_x, stop_watch_y, stop_watch_img);
  2114.     }
  2115.    /***********************************************************/
  2116.     /* Notices!!!                                              */
  2117.     /* Change the X,Y offset should change the buffer size of  */
  2118.     /* gbuffer_millitime[] and gbuffer_maintime[] as well      */
  2119.    /***********************************************************/
  2120.     memset(gbuffer_maintime, 0, sizeof(gbuffer_maintime));
  2121.     gdata_maintimer.data = gbuffer_maintime;
  2122.     change_stopwatchtime_to_string(0, center_hr, center_min, center_sec, time_string, DISPLAY_MILISEC_FALSE);
  2123.     sprintf((S8*) mili_string, "%02d", center_mili);
  2124.     AnsiiToUnicodeString((PS8) uni_mili_string, (PS8) mili_string);
  2125.     /* 102605 time position Calvin modified */
  2126. #if defined (__MMI_MAINLCD_240X320__)
  2127.     gui_set_font(&MMI_large_font);
  2128. #else 
  2129.     gui_set_font(&MMI_small_font);
  2130. #endif 
  2131.     /* Calvin end */
  2132.     gui_measure_string((UI_string_type) time_string, &width, &height);
  2133.     wtch_pos.typ_timer.x -= (width >> 1);
  2134. #if defined (__MMI_MAINLCD_240X320__)
  2135.     _get_bitmap(wtch_pos.typ_timer.x, wtch_pos.typ_timer.y, (wtch_pos.typ_timer.x + 79), (wtch_pos.typ_timer.y + 22), &gdata_maintimer);        /* 100405 stopwatch Calvin */
  2136. #else /* defined (__MMI_MAINLCD_240X320__) */ 
  2137.     _get_bitmap(
  2138.         wtch_pos.typ_timer.x,
  2139.         wtch_pos.typ_timer.y,
  2140.         (wtch_pos.typ_timer.x + 50),
  2141.         (wtch_pos.typ_timer.y + 10),
  2142.         &gdata_maintimer);
  2143. #endif /* defined (__MMI_MAINLCD_240X320__) */ 
  2144.    /***********************************************************/
  2145.     /* Notices!!!                                              */
  2146.     /* Change the X,Y offset should change the buffer size of  */
  2147.     /* gbuffer_millitime[] and gbuffer_maintime[] as well      */
  2148.    /***********************************************************/
  2149.     memset(gbuffer_millitime, 0, sizeof(gbuffer_millitime));
  2150.     gdata_millitimer.data = gbuffer_millitime;
  2151.     gui_measure_string((UI_string_type) uni_mili_string, &width, &height);
  2152.     wtch_pos.typ_milsec.x -= (width >> 1);
  2153. #if defined (__MMI_MAINLCD_240X320__)
  2154.     _get_bitmap(wtch_pos.typ_milsec.x, wtch_pos.typ_milsec.y, (wtch_pos.typ_milsec.x + 24) /* 70 */ , (wtch_pos.typ_milsec.y + 22) /* 120 */ , &gdata_millitimer);      /* 100405 stopwatch Calvin */
  2155. #else /* defined (__MMI_MAINLCD_240X320__) */ 
  2156.     _get_bitmap(
  2157.         wtch_pos.typ_milsec.x,
  2158.         wtch_pos.typ_milsec.y,
  2159.         (wtch_pos.typ_milsec.x + 15) /* 70 */ ,
  2160.         (wtch_pos.typ_milsec.y + 15) /* 120 */ ,
  2161.         &gdata_millitimer);
  2162. #endif /* defined (__MMI_MAINLCD_240X320__) */ 
  2163.     print_center_time();
  2164.     show_fixed_list();
  2165.     if (stop_watch_total_frames > 1)
  2166.     {
  2167.         gui_start_timer(STOP_WATCH_ANIMATION_DELAY, stop_watch_animation_processor);
  2168.     }
  2169.     if (timer_flag_stop_start == TIMER_START)
  2170.     {
  2171.         gui_start_timer(STPWACH_UI_UPDATE_PERIOD, show_center_time);
  2172.     }
  2173. }
  2174. /*****************************************************************************
  2175.  * FUNCTION
  2176.  *  show_nway_stop_watch
  2177.  * DESCRIPTION
  2178.  *  
  2179.  * PARAMETERS
  2180.  *  void
  2181.  * RETURNS
  2182.  *  void
  2183.  *****************************************************************************/
  2184. void show_nway_stop_watch(void)
  2185. {
  2186.     /*----------------------------------------------------------------*/
  2187.     /* Local Variables                                                */
  2188.     /*----------------------------------------------------------------*/
  2189.     /*----------------------------------------------------------------*/
  2190.     /* Code Body                                                      */
  2191.     /*----------------------------------------------------------------*/
  2192.     gui_reset_clip();
  2193.     gui_reset_text_clip();
  2194.     /* Reassign y coordinate according to current highlight timer */
  2195.     category306_area_height =
  2196.         ((wtch_pos.nWay_dialog_end.y - wtch_pos.nWay_dialog_start.y -
  2197.           wtch_pos.separator_height) / MAX_MULTIPURPOSE_TIMER);
  2198.     /* Text start position */
  2199.     category306_text_y_offset = category306_get_text_y_offset(current_stop_watch_highlight);
  2200.     category306_text_x_offset = wtch_pos.nWay_dialog_start.x + STPWACH_NW_FRAM_BORDER
  2201.         +
  2202.         ((wtch_pos.nWay_dialog_end.x - wtch_pos.nWay_dialog_start.x - category306_img_width - category306_text_width -
  2203.           (STPWACH_NW_FRAM_BORDER << 1)) >> 1) + category306_img_width + STPWACH_NW_FRAM_BORDER * 2;
  2204.     category306_img_x_offset = category306_text_x_offset - category306_img_width - STPWACH_NW_FRAM_BORDER * 2;
  2205.     category306_img_y_offset = category306_get_img_y_offset(current_stop_watch_highlight);
  2206.     /* Draw main timer */
  2207.     draw_stopwatch_title();
  2208.     /* Draw individual timer */
  2209.     redraw_stop_watch_list();
  2210.     /* Draw Separator */
  2211.     display_stop_watch_list_header(
  2212.         wtch_pos.nWay_dialog_start.x,
  2213.         wtch_pos.nWay_dialog_start.y,
  2214.         wtch_pos.nWay_dialog_end.x,
  2215.         wtch_pos.nWay_dialog_start.y + wtch_pos.separator_height);
  2216. }
  2217. #endif /* __MMI_STOPWATCH__ */