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

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.  * Worldclock.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  * MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  * This file implements world clock application.
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * removed!
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * removed!
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * removed!
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * removed!
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * removed!
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * removed!
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * removed!
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * removed!
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * removed!
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * removed!
  114.  *
  115.  * removed!
  116.  * removed!
  117.  * removed!
  118.  *
  119.  * removed!
  120.  * removed!
  121.  * removed!
  122.  *
  123.  * removed!
  124.  * removed!
  125.  * removed!
  126.  *
  127.  * removed!
  128.  * removed!
  129.  * removed!
  130.  *
  131.  * removed!
  132.  * removed!
  133.  * removed!
  134.  *
  135.  * removed!
  136.  * removed!
  137.  * removed!
  138.  *
  139.  * removed!
  140.  * removed!
  141.  * removed!
  142.  *
  143.  * removed!
  144.  * removed!
  145.  * removed!
  146.  *
  147.  * removed!
  148.  * removed!
  149.  * removed!
  150.  *
  151.  *------------------------------------------------------------------------------
  152.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  153.  *============================================================================
  154.  ****************************************************************************/
  155.  /**
  156.  * Copyright Notice
  157.  * (c) 2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  158.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  159.  *  (It is illegal to remove this copyright notice from this software or any
  160.  *  portion of it)
  161.  */
  162. /**********************************************************************************
  163.    Filename:      Worldclock.c
  164.    Author:        Vandana M
  165.    Date Created:  June-14-2003
  166.    Contains:      World Clock
  167. **********************************************************************************/
  168. #ifndef _MMI_WORLDCLOCK_C
  169. #define _MMI_WORLDCLOCK_C
  170. /*  Include: MMI header file */
  171. #include "MMI_features.h"
  172. #include "DebugInitDef.h"
  173. #include "OrganizerDef.h"
  174. #include "PixtelDataTypes.h"
  175. #include "NVRAMType.h"
  176. #include "NVRAMProt.h"
  177. #include "NVRAMEnum.h"
  178. #include "worldclock.h"
  179. #include "KeyBrd.h"
  180. #include "IdleAppProt.h"
  181. #include "CustMenuRes.h"
  182. #include "CustDataProts.h"
  183. #include "DebugInitDef.h"
  184. #include "worldclock.h"
  185. #include "HistoryGprot.h"
  186. #include "GlobalDefs.h"
  187. #include "Unicodexdcl.h"
  188. #include "GlobalMenuItems.h"
  189. #include "OrganizerDef.h"
  190. #include "CommonScreens.h"
  191. #include "wgui_categories.h"
  192. #include "CommonScreens.h"
  193. #include "DateTimeGprot.h"
  194. #include "Gdi_include.h"
  195. #ifdef __MMI_WORLDCLOCK_DST__
  196. #include "WallpaperDefs.h"
  197. #include "DownloadDefs.h"
  198. #include "PhoneSetup.h"
  199. #include "Calculator.h"
  200. #endif /* __MMI_WORLDCLOCK_DST__ */ 
  201. /* ... Add More MMI header */
  202. /*  Include: PS header file */
  203. /* ... Add More PS header */
  204. /* 
  205.  * Define
  206.  */
  207. #ifdef __MMI_MAINLCD_128X160__
  208. #define  WC_CITY_NAME_HEIGHT  MMI_TITLE_HEIGHT
  209. #define  WC_HEIGHT_160
  210. #else /* __MMI_MAINLCD_128X160__ */ 
  211. #define WC_CITY_NAME_HEIGHT   0
  212. #endif /* __MMI_MAINLCD_128X160__ */ 
  213. #define WC_V_LINE_Y     (MMI_TITLE_Y+MMI_TITLE_HEIGHT+WC_CITY_NAME_HEIGHT)      /* y-coordinate of vertical line */
  214. #define WC_H_LINE_X     0       /* x-coordinate of horizontal line */
  215. #define WC_LINE_WIDTH   (gdi_layer_get_bit_per_pixel()>>3)
  216. #define WC_NUM_CITY STR_TOTAL_NUM_CITY - STR_WCLOCK_CITY_NONE
  217. // #ifdef __MMI_TOUCH_SCREEN__//061705 Calvin marked
  218. #if defined(__MMI_MAINLCD_240X320__)    /* 041205 Calvin modifed */
  219. #define  WC_TITLE_HEIGHT   40
  220. #define  WC_DATE_HEIGHT 35
  221. #define  WC_TIME_HEIGHT 35
  222. #else /* defined(__MMI_MAINLCD_240X320__) */ 
  223. #define  WC_TITLE_HEIGHT   24
  224. #define  WC_DATE_HEIGHT 22
  225. #define  WC_TIME_HEIGHT 23
  226. #endif /* defined(__MMI_MAINLCD_240X320__) */ 
  227. #ifdef __MMI_WC_TZ_SUPPORT__
  228. #define WC_INDEX_NUM 2
  229. #define WC_MAX_INDEX_INFO_LEN 40
  230. #define WC_TZ_INDEX 0
  231. #define WC_CITY_INDEX 1
  232. #define WC_TZ_SIGN_POS 3
  233. #define WC_GMT_LEN  (WC_TZ_SIGN_POS * sizeof(UI_character_type))
  234. #define WC_MAX_TZ_STR_LEN   5
  235. #define WC_SYM_COMMA    (UI_character_type)','
  236. #define WC_SYM_POSITIVE    (UI_character_type)'+'
  237. #define WC_SYM_NEGATIVE    (UI_character_type)'-'
  238. #define WC_SYM_SPACE    (UI_character_type)' '
  239. #endif /* __MMI_WC_TZ_SUPPORT__ */ 
  240. #ifdef __MMI_NITZ_TZ_SUPPORT__
  241. #define WC_DEFAULT_TZ_NUM   37
  242. #endif 
  243. /* 
  244.  * Typedef 
  245.  */
  246. #ifdef __MMI_TOUCH_SCREEN__
  247. typedef enum
  248. {
  249.     WC_TOUCH_NONE,
  250.     WC_TOUCH_ON_LEFT_ARROW_UP,
  251.     WC_TOUCH_ON_LEFT_ARROW_DOWN,
  252.     WC_TOUCH_ON_RIGHT_ARROW_UP,
  253.     WC_TOUCH_ON_RIGHT_ARROW_DOWN,
  254.     WC_TOUCH_ON_MAP,
  255.     WC_TOUCH_ON_RSK
  256. } WORLD_CLOCK_PEN_EVENTS;
  257. #endif /* __MMI_TOUCH_SCREEN__ */ 
  258. /* 
  259.  * Local Variable
  260.  */
  261. static U8 gWcTimeZoneIndex[WC_NUM_CITY];
  262. #ifdef __MMI_WC_TZ_SUPPORT__
  263. U8 *homeTime, *foreTime;
  264. #endif /* __MMI_WC_TZ_SUPPORT__ */ 
  265. /*
  266.  * Local Function
  267.  */
  268. /*
  269.  * Global Variable
  270.  */
  271. #ifdef __MMI_WORLD_CLOCK__
  272. wc_context_struct g_wc_cntx;
  273. #endif 
  274. #ifdef __MMI_WC_TZ_SUPPORT__
  275. U8 *gIndexInfo[WC_INDEX_NUM];
  276. #endif
  277. #if defined (__MMI_NITZ_TZ_SUPPORT__) || defined (__MMI_WC_TZ_SUPPORT__)
  278. const S16 validTZ[WC_DEFAULT_TZ_NUM] =
  279.     { -48, -44, -40, -38, -36, -34, -32, -28, -24, -20, -16, -14, -12, -8, -4, 0, 4, 8, 12, 14, 16, 18, 20, 22, 23, 24,
  280. 26, 28, 32, 36, 38, 40, 42, 44, 46, 48, 49};
  281. U8 gWcDefaultCityForTZ[WC_DEFAULT_TZ_NUM];
  282. #endif
  283. U8 g_dst;
  284. /* 
  285.  * Global Function
  286.  */
  287. extern void _show_bitmap(S32 x1, S32 y1, bitmap *b);
  288. extern void _get_bitmap(S32 x1, S32 y1, S32 x2, S32 y2, bitmap *b);
  289. extern U8 PhnsetGetHomeCity(void);
  290. #ifdef __MMI_WC_TZ_SUPPORT__
  291. BOOL ATSetHomeCity(U8 CityIndex);
  292. #endif
  293. /* MTK Elvis for R2L character */
  294. extern BOOL r2lMMIFlag;
  295. /* MTK end */
  296. #define WC_INITIALIZE
  297. /*****************************************************************************
  298.  * FUNCTION
  299.  *  WcInit
  300.  * DESCRIPTION
  301.  *  Initailze world clock
  302.  * PARAMETERS
  303.  *  void
  304.  * RETURNS
  305.  *  void
  306.  *****************************************************************************/
  307. void WcInit(void)
  308. {
  309. #ifdef __MMI_WORLD_CLOCK__
  310.     /*----------------------------------------------------------------*/
  311.     /* Local Variables                                                */
  312.     /*----------------------------------------------------------------*/
  313. #ifdef __MMI_WC_TZ_SUPPORT__
  314.     U8 currentHomeCity;
  315.     S16 currentTimeZone, error;
  316. #endif /* __MMI_WC_TZ_SUPPORT__ */    
  317.     /*----------------------------------------------------------------*/
  318.     /* Code Body                                                      */
  319.     /*----------------------------------------------------------------*/
  320.     memset(&g_wc_cntx, 0, sizeof(wc_context_struct));
  321.     g_wc_cntx.CurrCityIndex = 0xff;
  322. #if defined(__MMI_MAINLCD_176X220__) || defined (__MMI_MAINLCD_240X320__)       /* 041205 Calvin modieid */
  323.     gui_measure_image(get_image(WORLD_CLOCK_LEFT_ARROW_UP), &(g_wc_cntx.arrow_width), &(g_wc_cntx.arrow_height));
  324. #endif 
  325. #ifdef __MMI_TOUCH_SCREEN__
  326.     g_wc_cntx.event_on_object = WC_TOUCH_NONE;
  327. #endif 
  328.     SetHiliteHandler(ORGANIZER_WORLDCLOCK_MENU, HighlightWCMenu);
  329.     SetHiliteHandler(MITEM_WORLDCLOCK_BROWSECITY, HighlightWcBrowseCity);
  330. #if defined(__MMI_WORLD_CLOCK_SUBLCD_SETTING__)
  331.     SetHiliteHandler(MITEM_WORLDCLOCK_SUBLCDDISPLAY, HighlightWcSubLcd);
  332.     SetHintHandler(MITEM_WORLDCLOCK_SUBLCDDISPLAY_CITY1, WcHintCity1);
  333.     SetHintHandler(MITEM_WORLDCLOCK_SUBLCDDISPLAY_CITY2, WcHintCity2);
  334. #endif /* defined(__MMI_WORLD_CLOCK_SUBLCD_SETTING__) */ 
  335. #endif /* __MMI_WORLD_CLOCK__ */ 
  336.     WcGenerateTimeZoneIndex();
  337. mmi_wc_is_dst();
  338. #ifdef __MMI_NITZ_TZ_SUPPORT__
  339.     mmi_wc_set_default_city_for_tz();
  340. #endif 
  341. #ifdef __MMI_WC_TZ_SUPPORT__
  342.     currentHomeCity = PhnsetGetHomeCity() + 1;    
  343.     currentTimeZone = (S16)(TimeZoneData[currentHomeCity].CityTimeZone * 4);
  344.     WriteValue(NVRAM_TIMEZONE, &currentTimeZone, DS_SHORT, &error);
  345. #endif /* __MMI_WC_TZ_SUPPORT__ */
  346. }
  347. #define WC_UTILITY_FUNCTION
  348. /*****************************************************************************
  349.  * FUNCTION
  350.  *  GetTimeZone
  351.  * DESCRIPTION
  352.  *  Return the time zone of a city
  353.  * PARAMETERS
  354.  *  cityIndex       [IN]        Index of city
  355.  * RETURNS
  356.  *  Time zone
  357.  *****************************************************************************/
  358. FLOAT GetTimeZone(U8 cityIndex)
  359. {
  360.     /*----------------------------------------------------------------*/
  361.     /* Local Variables                                                */
  362.     /*----------------------------------------------------------------*/
  363.     /*----------------------------------------------------------------*/
  364.     /* Code Body                                                      */
  365.     /*----------------------------------------------------------------*/
  366.     return TimeZoneData[cityIndex + 1].CityTimeZone;
  367. }
  368. /*****************************************************************************
  369.  * FUNCTION
  370.  *  WcGenerateTimeZoneIndex
  371.  * DESCRIPTION
  372.  *  Generate indexing table of world clock. The table is sorted by time zone and x/y-coordinate.
  373.  * PARAMETERS
  374.  *  void
  375.  *  nIndex(?)       [IN]        Index of item.(?)
  376.  * RETURNS
  377.  *  void
  378.  *****************************************************************************/
  379. void WcGenerateTimeZoneIndex(void)
  380. {
  381.     /*----------------------------------------------------------------*/
  382.     /* Local Variables                                                */
  383.     /*----------------------------------------------------------------*/
  384.     S32 i, j;
  385.     U8 tmp;
  386.     U8 swap = FALSE;
  387.     U8 index1, index2;
  388.     U8 num_city = NUMBER_OF_CITY;
  389.     /*----------------------------------------------------------------*/
  390.     /* Code Body                                                      */
  391.     /*----------------------------------------------------------------*/
  392.     for (i = 0; i < num_city - 1; i++)
  393.     {
  394.         gWcTimeZoneIndex[i] = i + 1;
  395.     }
  396.     for (i = 0; i < num_city - 1; i++)
  397.     {
  398.         for (j = 0; j < (num_city - 1) - i - 1; j++)
  399.         {
  400.             index1 = gWcTimeZoneIndex[j + 1];
  401.             index2 = gWcTimeZoneIndex[j];
  402.             if (TimeZoneData[index1].CityTimeZone < TimeZoneData[index2].CityTimeZone)
  403.             {
  404.                 swap = TRUE;
  405.             }
  406.             else if (TimeZoneData[index1].CityTimeZone == TimeZoneData[index2].CityTimeZone)
  407.             {
  408.                 if (TimeZoneData[index1].CityX < TimeZoneData[index2].CityX)
  409.                 {
  410.                     swap = TRUE;
  411.                 }
  412.                 else if (TimeZoneData[index1].CityX == TimeZoneData[index2].CityX)
  413.                     if (TimeZoneData[index1].CityY < TimeZoneData[index2].CityY)
  414.                     {
  415.                         swap = TRUE;
  416.                     }
  417.             }
  418.             if (swap)
  419.             {
  420.                 tmp = gWcTimeZoneIndex[j];  /* swap a[j] and a[j+1]      */
  421.                 gWcTimeZoneIndex[j] = gWcTimeZoneIndex[j + 1];
  422.                 gWcTimeZoneIndex[j + 1] = tmp;
  423.                 swap = FALSE;
  424.             }
  425.         }
  426.     }
  427. }
  428. #ifdef __MMI_NITZ_TZ_SUPPORT__
  429. /*****************************************************************************
  430.  * FUNCTION
  431.  *  mmi_wc_set_default_city_for_tz
  432.  * DESCRIPTION
  433.  *  
  434.  * PARAMETERS
  435.  *  void
  436.  * RETURNS
  437.  *  void
  438.  *****************************************************************************/
  439. void mmi_wc_set_default_city_for_tz(void)
  440. {
  441.     /*----------------------------------------------------------------*/
  442.     /* Local Variables                                                */
  443.     /*----------------------------------------------------------------*/
  444.     S32 i;
  445.     U32 count = 0;
  446.     FLOAT tz;
  447.     /*----------------------------------------------------------------*/
  448.     /* Code Body                                                      */
  449.     /*----------------------------------------------------------------*/
  450.     for (i = 0; i < NUMBER_OF_CITY; i++)
  451.     {
  452.         tz = (FLOAT) validTZ[count] / (FLOAT) 4;
  453.         if (TimeZoneData[gWcTimeZoneIndex[i]].CityTimeZone == tz)
  454.         {
  455.             gWcDefaultCityForTZ[count] = gWcTimeZoneIndex[i];
  456.             count++;
  457.         }
  458.         else if (TimeZoneData[gWcTimeZoneIndex[i]].CityTimeZone > tz)
  459.         {
  460.             count++;
  461.             /* find the matched timezone for this city, therefore decrease first to balence i++ */
  462.             i--;
  463.         }
  464.     }
  465. }
  466. /*****************************************************************************
  467.  * FUNCTION
  468.  *  mmi_wc_set_home_city_from_nitz
  469.  * DESCRIPTION
  470.  *  
  471.  * PARAMETERS
  472.  *  nitz_tz     [IN]        
  473.  * RETURNS
  474.  *  
  475.  *****************************************************************************/
  476. S16 mmi_wc_set_home_city_from_nitz(S16 nitz_tz)
  477. {
  478.     /*----------------------------------------------------------------*/
  479.     /* Local Variables                                                */
  480.     /*----------------------------------------------------------------*/
  481.     U32 count;
  482.     /*----------------------------------------------------------------*/
  483.     /* Code Body                                                      */
  484.     /*----------------------------------------------------------------*/
  485.     for (count = 0; count < WC_DEFAULT_TZ_NUM; count++)
  486.     {
  487.         if (nitz_tz == validTZ[count])
  488.         {
  489.             ATSetHomeCity(gWcDefaultCityForTZ[count]);
  490.             break;
  491.         }
  492.     }
  493.     /* There's no matched city */
  494.     if (count == WC_DEFAULT_TZ_NUM)
  495.     {
  496.         return -1;
  497.     }
  498.     else
  499.     {
  500.         return (S32) gWcDefaultCityForTZ[count];
  501.     }
  502. }
  503. #endif /* __MMI_NITZ_TZ_SUPPORT__ */ 
  504. /*****************************************************************************
  505.  * FUNCTION
  506.  *  mmi_wc_get_home_city
  507.  * DESCRIPTION
  508.  *  Return string of home city
  509.  * PARAMETERS
  510.  *  void
  511.  * RETURNS
  512.  *  String pointer to home city name
  513.  *****************************************************************************/
  514. S8 *mmi_wc_get_home_city(void)
  515. {
  516.     /*----------------------------------------------------------------*/
  517.     /* Local Variables                                                */
  518.     /*----------------------------------------------------------------*/
  519.     /*----------------------------------------------------------------*/
  520.     /* Code Body                                                      */
  521.     /*----------------------------------------------------------------*/
  522.     return GetString(TimeZoneData[PhnsetGetHomeCity() + 1].CityName);
  523. }
  524. /*****************************************************************************
  525.  * FUNCTION
  526.  *  WcSetCityIndex
  527.  * DESCRIPTION
  528.  *  Set current city.
  529.  * PARAMETERS
  530.  *  index       [IN]        
  531.  * RETURNS
  532.  *  void
  533.  *****************************************************************************/
  534. void WcSetCityIndex(U16 index)
  535. {
  536.     /*----------------------------------------------------------------*/
  537.     /* Local Variables                                                */
  538.     /*----------------------------------------------------------------*/
  539.     /*----------------------------------------------------------------*/
  540.     /* Code Body                                                      */
  541.     /*----------------------------------------------------------------*/
  542. #if defined(__MMI_WORLD_CLOCK__)
  543.     g_wc_cntx.CurrCityIndex = (U8) index;
  544. #endif 
  545. }
  546. #ifdef __MMI_WORLD_CLOCK__
  547. #define WC_BROWSE_CITY
  548. /*****************************************************************************
  549.  * FUNCTION
  550.  *  HighlightWCMenu
  551.  * DESCRIPTION
  552.  *  Highlight handler of World Clock menu item.
  553.  *  Register key handlers.
  554.  * PARAMETERS
  555.  *  void
  556.  * RETURNS
  557.  *  void
  558.  *****************************************************************************/
  559. void HighlightWCMenu(void)
  560. {
  561.     /*----------------------------------------------------------------*/
  562.     /* Local Variables                                                */
  563.     /*----------------------------------------------------------------*/
  564.     /*----------------------------------------------------------------*/
  565.     /* Code Body                                                      */
  566.     /*----------------------------------------------------------------*/
  567.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  568.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  569. #if defined(__MMI_WORLD_CLOCK_SUBLCD_SETTING__)
  570.     SetKeyHandler(EntryWcApp, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  571.     SetLeftSoftkeyFunction(EntryWcApp, KEY_EVENT_UP);
  572. #else /* defined(__MMI_WORLD_CLOCK_SUBLCD_SETTING__) */ 
  573.     SetLeftSoftkeyFunction(EntryWcBrowseCity, KEY_EVENT_UP);
  574.     SetKeyHandler(EntryWcBrowseCity, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  575. #endif /* defined(__MMI_WORLD_CLOCK_SUBLCD_SETTING__) */ 
  576.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  577.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  578. }
  579. /*****************************************************************************
  580.  * FUNCTION
  581.  *  HighlightWcBrowseCity
  582.  * DESCRIPTION
  583.  *  Highlight handler of browse city menu
  584.  * PARAMETERS
  585.  *  void
  586.  * RETURNS
  587.  *  void
  588.  *****************************************************************************/
  589. void HighlightWcBrowseCity(void)
  590. {
  591.     /*----------------------------------------------------------------*/
  592.     /* Local Variables                                                */
  593.     /*----------------------------------------------------------------*/
  594.     /*----------------------------------------------------------------*/
  595.     /* Code Body                                                      */
  596.     /*----------------------------------------------------------------*/
  597.     SetLeftSoftkeyFunction(EntryWcBrowseCity, KEY_EVENT_UP);
  598. }
  599. /*****************************************************************************
  600.  * FUNCTION
  601.  *  EntryWcBrowseCity
  602.  * DESCRIPTION
  603.  *  Display browse city screen.
  604.  * PARAMETERS
  605.  *  void
  606.  * RETURNS
  607.  *  void
  608.  *****************************************************************************/
  609. #ifdef __MMI_DRAW_MANAGER__
  610. void WcShowCategory(void);
  611. #endif 
  612. void EntryWcBrowseCity(void)
  613. {
  614. #ifdef __MMI_WORLDCLOCK_DST__
  615.     /*----------------------------------------------------------------*/
  616.     /* Local Variables                                                */
  617.     /*----------------------------------------------------------------*/
  618.     S16 error;
  619.     /*----------------------------------------------------------------*/
  620.     /* Code Body                                                      */
  621.     /*----------------------------------------------------------------*/
  622.     ReadValue(NVRAM_WC_DST, &g_wc_cntx.DSTForeign, DS_BYTE, &error);
  623.     if (g_wc_cntx.DSTForeign == 0xff)
  624.     {
  625.         g_wc_cntx.DSTForeign = 0;
  626.     }
  627. #endif /* __MMI_WORLDCLOCK_DST__ */ 
  628.     EntryWcBrowseCityEx(EntryWcBrowseCity, ExitWcBrowseCity);
  629. }
  630. /*****************************************************************************
  631.  * FUNCTION
  632.  *  EntryWcBrowseCityEx
  633.  * DESCRIPTION
  634.  *  Display browse city screen
  635.  * PARAMETERS
  636.  *  entry_func      [IN]        
  637.  *  exit_func       [IN]        
  638.  * RETURNS
  639.  *  void
  640.  *****************************************************************************/
  641. void EntryWcBrowseCityEx(void (*entry_func) (void), void (*exit_func) (void))
  642. {
  643.     /*----------------------------------------------------------------*/
  644.     /* Local Variables                                                */
  645.     /*----------------------------------------------------------------*/
  646. #ifdef __MMI_WC_TZ_SUPPORT__
  647.     S16 error;
  648.     S16 tmpTimeZone;
  649.     U8 *guiBuffer;
  650. #endif /* __MMI_WC_TZ_SUPPORT__ */ 
  651.     /*----------------------------------------------------------------*/
  652.     /* Code Body                                                      */
  653.     /*----------------------------------------------------------------*/
  654.     /* initialize UI related variables */
  655.     EntryNewScreen(SCR_ID_WC_BROWSE_CITY, exit_func, entry_func, NULL);
  656.     g_wc_cntx.CurrMap = 0xff;
  657.     MMI_title_icon = NULL;
  658.     MMI_menu_shortcut_number = -1;
  659.     if (g_wc_cntx.CurrCityIndex == 0xff)
  660.     {
  661. if (PhnsetGetHomeCity() != 0xff)
  662. {
  663. g_wc_cntx.CurrCityIndex = PhnsetGetHomeCity() + 1;
  664. }
  665. else
  666. {
  667. g_wc_cntx.CurrCityIndex = 0;
  668. }
  669.     }
  670. #ifndef __MMI_WC_TZ_SUPPORT__
  671.     if (g_wc_cntx.VLine == NULL)
  672.     {
  673.         g_wc_cntx.VLine = OslMalloc(sizeof(bitmap));
  674.         g_wc_cntx.VLine->data = OslMalloc(UI_device_height * WC_LINE_WIDTH);
  675.     }
  676.     if (g_wc_cntx.HLine == NULL)
  677.     {
  678.         g_wc_cntx.HLine = OslMalloc(sizeof(bitmap));
  679.         g_wc_cntx.HLine->data = OslMalloc(UI_device_width * WC_LINE_WIDTH);
  680.     }
  681.     /* draw UI */
  682. #ifdef __MMI_DRAW_MANAGER__
  683.     WcShowCategory();
  684. #else 
  685.     WcRedrawWorldClock(0, UI_device_height);
  686. #endif 
  687.     SetKeyHandler(WcHandleKeyLeft, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  688.     SetKeyHandler(WcHandleKeyLeft, KEY_LEFT_ARROW, KEY_LONG_PRESS);
  689.     SetKeyHandler(WcHandleKeyRight, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  690.     SetKeyHandler(WcHandleKeyRight, KEY_RIGHT_ARROW, KEY_LONG_PRESS);
  691.     RedrawCategoryFunction = WcRedrawCategory;
  692. #ifdef __MMI_WORLDCLOCK_DST__
  693.     SetLeftSoftkeyFunction(WcEntryDST, KEY_EVENT_UP);
  694. #endif 
  695. #else /*#ifndef  __MMI_WC_TZ_SUPPORT__*/
  696.     gIndexInfo[WC_TZ_INDEX] = OslMalloc(WC_MAX_INDEX_INFO_LEN);
  697.     gIndexInfo[1] = OslMalloc(WC_MAX_INDEX_INFO_LEN);
  698.     memcpy(gIndexInfo[WC_TZ_INDEX], (S8*) GetString(STR_WORLD_CLOCK_GMT), WC_GMT_LEN);
  699.     homeTime = OslMalloc(WC_MAX_INDEX_INFO_LEN);
  700.     foreTime = OslMalloc(WC_MAX_INDEX_INFO_LEN);
  701.     guiBuffer = GetCurrGuiBuffer(SCR_ID_WC_BROWSE_CITY);
  702.     if (guiBuffer == NULL)  /* not goback from history */
  703.     {
  704.         ReadValue(NVRAM_TIMEZONE, &tmpTimeZone, DS_SHORT, &error);
  705.         g_wc_cntx.CurrTZ = (FLOAT)tmpTimeZone / 4;
  706.     }    
  707.     /* Check if the time zone and city are matched */
  708.     if (g_wc_cntx.CurrTZ != TimeZoneData[g_wc_cntx.CurrCityIndex].CityTimeZone && g_wc_cntx.CurrCityIndex != 0)
  709.     {
  710.         g_wc_cntx.CurrCityIndex = mmi_wc_default_city_of_tz(g_wc_cntx.CurrTZ);
  711.         ATSetHomeCity((U8) (g_wc_cntx.CurrCityIndex));
  712. g_wc_cntx.CurrTZ = TimeZoneData[g_wc_cntx.CurrCityIndex].CityTimeZone;
  713.     }
  714.     /* get time zone string */
  715.     mmi_wc_get_tz_string(g_wc_cntx.CurrTZ, (S8*) & gIndexInfo[WC_TZ_INDEX][WC_GMT_LEN]);
  716.     /* get Home city */
  717.     mmi_wc_get_city_string(g_wc_cntx.CurrCityIndex);
  718.     
  719.     
  720. #ifdef __MMI_TOUCH_SCREEN__
  721.     RegisterCat230PaintPenEventHandler(mmi_wc_paint_pen_handler);
  722. #endif
  723.     ShowCategory230Screen(
  724.         (U8*) GetString(STR_WORLD_CLOCK_TITLE),
  725.         2,
  726.         gIndexInfo,
  727.         0,
  728.         CAT230_WC_DT,
  729.         mmi_wc_leftkey_handler,
  730.         mmi_wc_rightkey_handler,    /* Cat230RedrawPaint_WC, */
  731.         mmi_wc_get_index_info);
  732. #endif /* __MMI_WC_TZ_SUPPORT__ */ 
  733.     SetRightSoftkeyFunction(WcHandleRSK, KEY_EVENT_UP);
  734. #ifdef __MMI_WC_TZ_SUPPORT__
  735.     if (mmi_wc_entry_from_phnset())
  736.     {
  737.         ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  738.         SetLeftSoftkeyFunction(PhnsetSetHomeCity, KEY_EVENT_UP);        /* set home city */
  739.     }
  740.     else
  741. #endif /* __MMI_WC_TZ_SUPPORT__ */ 
  742.     {
  743.     #ifdef __MMI_WORLDCLOCK_DST__
  744.         ChangeLeftSoftkey(STR_GLOBAL_OPTIONS, IMG_GLOBAL_OPTIONS);
  745.         SetLeftSoftkeyFunction(WcEntryDST, KEY_EVENT_UP);
  746.     #else /* __MMI_WORLDCLOCK_DST__ */ 
  747.         ChangeLeftSoftkey(0, 0);
  748.     #endif /* __MMI_WORLDCLOCK_DST__ */ 
  749.     }
  750.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  751.     
  752.     SetKeyHandler(WcHandleKeyEnd, KEY_END, KEY_EVENT_DOWN);
  753. }
  754. #ifdef __MMI_WC_TZ_SUPPORT__
  755. /*****************************************************************************
  756.  * FUNCTION
  757.  *  mmi_wc_get_index_info
  758.  * DESCRIPTION
  759.  *  This function is used to get the index information.
  760.  * PARAMETERS
  761.  *  index_info      [?]     
  762.  * RETURNS
  763.  *  void
  764.  *****************************************************************************/
  765. void mmi_wc_get_index_info(void *index_info)
  766. {
  767.     /*----------------------------------------------------------------*/
  768.     /* Local Variables                                                */
  769.     /*----------------------------------------------------------------*/
  770.     MYTIME currTime, foreignTime;
  771.     cat230_paint_wc_info_struct *index_infomation = (cat230_paint_wc_info_struct*) index_info;
  772.     U8 homeCity = PhnsetGetHomeCity() + 1;
  773.     /*----------------------------------------------------------------*/
  774.     /* Code Body                                                      */
  775.     /*----------------------------------------------------------------*/
  776.     memset(&currTime, 0, sizeof(MYTIME));
  777.     memset(&foreignTime, 0, sizeof(MYTIME));
  778.     index_infomation->static_x = TimeZoneData[homeCity].CityX;
  779.     index_infomation->static_y = TimeZoneData[homeCity].CityY;
  780.     if (g_wc_cntx.CurrCityIndex == 0)
  781.     {
  782.         index_infomation->dynamic_x = -1;
  783.         index_infomation->dynamic_y = -1;
  784.     }
  785.     else
  786.     {
  787.         index_infomation->dynamic_x = TimeZoneData[g_wc_cntx.CurrCityIndex].CityX;
  788.         index_infomation->dynamic_y = TimeZoneData[g_wc_cntx.CurrCityIndex].CityY;
  789.     }
  790.     index_infomation->hint_string = (U8*) GetString(STR_WORLD_CLOCK_LOCAL);
  791.     index_infomation->city_string = (U8*) GetString(TimeZoneData[homeCity].CityName);
  792.     /* get date/time of home city */
  793.     DTGetRTCTime(&currTime);
  794.     mmi_wc_dt_format(&currTime, homeTime);
  795.     index_infomation->static_string = homeTime;
  796.     /* index_infomation->static_string = (U8*)GetString(STR_WORLD_CLOCK_LOCAL); */
  797.     mmi_wc_get_foreign_city_dt(&foreignTime);
  798.     mmi_wc_dt_format(&foreignTime, foreTime);
  799.     index_infomation->dynamic_string = foreTime;
  800.     /* index_infomation->dynamic_string = (U8*)GetString(STR_WORLD_CLOCK_LOCAL); */
  801. }
  802. /*****************************************************************************
  803.  * FUNCTION
  804.  *  mmi_wc_dt_format
  805.  * DESCRIPTION
  806.  *  
  807.  * PARAMETERS
  808.  *  dt              [?]     
  809.  *  dtString        [?]     
  810.  * RETURNS
  811.  *  void
  812.  *****************************************************************************/
  813. void mmi_wc_dt_format(MYTIME *dt, U8 *dtString)
  814. {
  815.     /*----------------------------------------------------------------*/
  816.     /* Local Variables                                                */
  817.     /*----------------------------------------------------------------*/
  818.     U8 ascii[WC_MAX_INDEX_INFO_LEN], UniStr[WC_MAX_INDEX_INFO_LEN];
  819.     U8 sizeT = 0, sizeD = 0;
  820.     UI_character_type separate = WC_SYM_COMMA;
  821.     /*----------------------------------------------------------------*/
  822.     /* Code Body                                                      */
  823.     /*----------------------------------------------------------------*/
  824.     memset(dtString, 0, WC_MAX_INDEX_INFO_LEN);
  825.     memset(UniStr, 0, WC_MAX_INDEX_INFO_LEN);
  826.     memset(ascii, 0, WC_MAX_INDEX_INFO_LEN);
  827.     date_string(dt, (UI_string_type) dtString, DT_IDLE_SCREEN_2);
  828.     //UnicodeToAnsii((S8*) ascii, (S8*) dtString);
  829.     //sizeD = strlen((S8*) ascii);
  830.     sizeD = pfnUnicodeStrlen((S8*) dtString);
  831.     memcpy(&(dtString[sizeD * 2]), &separate, sizeof(UI_character_type));
  832.     sizeD++;
  833.     memset(ascii, 0, WC_MAX_INDEX_INFO_LEN);
  834.     time_string(dt, (UI_string_type) UniStr, DT_IDLE_SCREEN_2);
  835.     //UnicodeToAnsii((S8*) ascii, (S8*) UniStr);
  836.     //sizeT = strlen((S8*) ascii);
  837.     sizeT = pfnUnicodeStrlen((S8*) UniStr);
  838.     memcpy(&(dtString[sizeD * 2]), UniStr, sizeT * 2);
  839.     /* UnicodeToAnsii((S8*) &(dtString[size]), (S8*) UniStr); */
  840.     /*
  841.      * time_string(&dt, (UI_string_type) UniStr, DT_IDLE_SCREEN);
  842.      * UnicodeToAnsii((S8*) dtString, (S8*) UniStr);
  843.      * size = strlen(dtString);
  844.      * date_string(&dt, (UI_string_type)UniStr, DT_IDLE_SCREEN);
  845.      * UnicodeToAnsii((S8*) &(dtString[size]), (S8*) UniStr);
  846.      * AnsiiToUnicodeString(out_buffer, ansii_str);
  847.      */
  848. }
  849. /*****************************************************************************
  850.  * FUNCTION
  851.  *  mmi_wc_get_foreign_city_dt
  852.  * DESCRIPTION
  853.  *  
  854.  * PARAMETERS
  855.  *  dt      [?]     
  856.  * RETURNS
  857.  *  void
  858.  *****************************************************************************/
  859. void mmi_wc_get_foreign_city_dt(MYTIME *dt)
  860. {
  861.     /*----------------------------------------------------------------*/
  862.     /* Local Variables                                                */
  863.     /*----------------------------------------------------------------*/
  864.     MYTIME incTime;
  865.     U8 HomeCity;
  866.     FLOAT TimeDiff;
  867.     U8 TimeFlag = 0;
  868.     S32 temp;
  869. #ifdef __MMI_WORLDCLOCK_DST__
  870.     MYTIME dstTime;
  871. #endif 
  872.     /*----------------------------------------------------------------*/
  873.     /* Code Body                                                      */
  874.     /*----------------------------------------------------------------*/
  875.     /* get time zone difference */
  876.     HomeCity = PhnsetGetHomeCity() + 1;
  877.     /* TimeDiff = WcTimeZoneDiff(g_wc_cntx.CurrCityIndex, HomeCity); */
  878.     TimeDiff = g_wc_cntx.CurrTZ - TimeZoneData[HomeCity].CityTimeZone;
  879.     memset(&incTime, 0, sizeof(MYTIME));
  880.     DTGetRTCTime(dt);
  881.     if (TimeDiff < 0)
  882.     {
  883.         TimeDiff = TimeDiff * (-1);
  884.         TimeFlag = 1;
  885.     }
  886.     temp = (S32) (TimeDiff * 60);
  887.     incTime.nDay = (U8) (TimeDiff / 24);
  888.     incTime.nHour = ((S32) TimeDiff) % 24;
  889.     incTime.nMin = temp % 60;
  890.     if (TimeFlag)   /* decrement */
  891.     {
  892.         DecrementTime(*dt, incTime, dt);
  893.     }
  894.     else
  895.     {
  896.         IncrementTime(*dt, incTime, dt);
  897.     }
  898. #ifdef __MMI_WORLDCLOCK_DST__
  899.     if (HomeCity != g_wc_cntx.CurrCityIndex)    /* not home city */
  900.     {
  901.         memset(&dstTime, 0, sizeof(MYTIME));
  902.         dstTime.nHour = 1;
  903.         if (g_wc_cntx.DSTForeign && g_phnset_cntx_p->currentDST)        /* both date light saving is on */
  904.         {
  905.             /* do nothing */
  906.         }
  907.         else if (g_phnset_cntx_p->currentDST)   /* only home city turns on DST */
  908.         {
  909.             DecrementTime(*dt, dstTime, dt);
  910.         }
  911.         else if (g_wc_cntx.DSTForeign)  /* only foreign city turns on DST */
  912.         {
  913.             IncrementTime(*dt, dstTime, dt);
  914.         }
  915.     }
  916. #endif /* __MMI_WORLDCLOCK_DST__ */ 
  917. }
  918. /*****************************************************************************
  919.  * FUNCTION
  920.  *  mmi_wc_leftkey_handler
  921.  * DESCRIPTION
  922.  *  
  923.  * PARAMETERS
  924.  *  index_num       [IN]        
  925.  * RETURNS
  926.  *  void
  927.  *****************************************************************************/
  928. void mmi_wc_leftkey_handler(U8 index_num)
  929. {
  930.     /*----------------------------------------------------------------*/
  931.     /* Local Variables                                                */
  932.     /*----------------------------------------------------------------*/
  933.     U8 curr_index;
  934.     /*----------------------------------------------------------------*/
  935.     /* Code Body                                                      */
  936.     /*----------------------------------------------------------------*/
  937.     switch (index_num)
  938.     {
  939.         case WC_TZ_INDEX:
  940.             if (g_wc_cntx.CurrTZ <= -12)
  941.             {
  942.                 g_wc_cntx.CurrTZ = 12;
  943.             }
  944.             else
  945.             {
  946.                 g_wc_cntx.CurrTZ--;
  947.             }
  948.             g_wc_cntx.CurrCityIndex = mmi_wc_default_city_of_tz(g_wc_cntx.CurrTZ);
  949.             /* Modify the current time zone to the default city's time zone, ex: GMT 5.5 */
  950.             if (g_wc_cntx.CurrTZ != TimeZoneData[g_wc_cntx.CurrCityIndex].CityTimeZone && g_wc_cntx.CurrCityIndex != 0)
  951.             {
  952.                 g_wc_cntx.CurrTZ = TimeZoneData[g_wc_cntx.CurrCityIndex].CityTimeZone;
  953.             }
  954.             break;
  955.         case WC_CITY_INDEX:
  956.             /* a time zone without default city is selected as home city */
  957.             if (g_wc_cntx.CurrCityIndex == 0)
  958.             {
  959.                 while (g_wc_cntx.CurrCityIndex == 0)
  960.                 {
  961.                     if (g_wc_cntx.CurrTZ <= -12)
  962.                     {
  963.                         g_wc_cntx.CurrTZ = 12;
  964.                     }
  965.                     else
  966.                     {
  967.                         g_wc_cntx.CurrTZ--;
  968.                     }
  969.                     g_wc_cntx.CurrCityIndex = mmi_wc_default_city_of_tz(g_wc_cntx.CurrTZ);
  970.                 }
  971.                 break;
  972.             }
  973.             curr_index = WcGetCityPosition(g_wc_cntx.CurrCityIndex);
  974.             if (curr_index == 0)
  975.             {
  976.                 curr_index = (NUMBER_OF_CITY - 2);
  977.             }
  978.             else
  979.             {
  980.                 curr_index--;
  981.             }
  982.             g_wc_cntx.CurrCityIndex = gWcTimeZoneIndex[curr_index];
  983.             g_wc_cntx.CurrTZ = TimeZoneData[g_wc_cntx.CurrCityIndex].CityTimeZone;
  984.             break;
  985.     }
  986.     /* get time zone string */
  987.     mmi_wc_get_tz_string(g_wc_cntx.CurrTZ, (S8*) & gIndexInfo[WC_TZ_INDEX][WC_GMT_LEN]);
  988.     mmi_wc_get_city_string(g_wc_cntx.CurrCityIndex);
  989.  
  990.     SetCat230IndexInfo(WC_TZ_INDEX, (U8*) gIndexInfo[WC_TZ_INDEX]);
  991.     SetCat230IndexInfo(WC_CITY_INDEX, (U8*) gIndexInfo[WC_CITY_INDEX]);
  992. }
  993. /*****************************************************************************
  994.  * FUNCTION
  995.  *  mmi_wc_rightkey_handler
  996.  * DESCRIPTION
  997.  *  
  998.  * PARAMETERS
  999.  *  index_num       [IN]        
  1000.  * RETURNS
  1001.  *  void
  1002.  *****************************************************************************/
  1003. void mmi_wc_rightkey_handler(U8 index_num)
  1004. {
  1005.     /*----------------------------------------------------------------*/
  1006.     /* Local Variables                                                */
  1007.     /*----------------------------------------------------------------*/
  1008.     U8 curr_index;
  1009.     /*----------------------------------------------------------------*/
  1010.     /* Code Body                                                      */
  1011.     /*----------------------------------------------------------------*/
  1012.     switch (index_num)
  1013.     {
  1014.         case WC_TZ_INDEX:
  1015.             if (g_wc_cntx.CurrTZ >= 12)
  1016.             {
  1017.                 g_wc_cntx.CurrTZ = -12;
  1018.             }
  1019.             else
  1020.             {
  1021.                 g_wc_cntx.CurrTZ++;
  1022.             }
  1023.             g_wc_cntx.CurrCityIndex = mmi_wc_default_city_of_tz(g_wc_cntx.CurrTZ);
  1024.             /* Modify the current time zone to the default city's time zone, ex: GMT 5.5 */
  1025.             if (g_wc_cntx.CurrTZ != TimeZoneData[g_wc_cntx.CurrCityIndex].CityTimeZone && g_wc_cntx.CurrCityIndex != 0)
  1026.             {
  1027.                 g_wc_cntx.CurrTZ = TimeZoneData[g_wc_cntx.CurrCityIndex].CityTimeZone;
  1028.             }
  1029.             break;
  1030.         case WC_CITY_INDEX:
  1031.             if (g_wc_cntx.CurrCityIndex == 0)
  1032.             {
  1033.                 while (g_wc_cntx.CurrCityIndex == 0)
  1034.                 {
  1035.                     if (g_wc_cntx.CurrTZ == 12)
  1036.                     {
  1037.                         g_wc_cntx.CurrTZ = -12;
  1038.                     }
  1039.                     else
  1040.                     {
  1041.                         g_wc_cntx.CurrTZ++;
  1042.                     }
  1043.                     g_wc_cntx.CurrCityIndex = mmi_wc_default_city_of_tz(g_wc_cntx.CurrTZ);
  1044.                 }
  1045.                 break;
  1046.             }
  1047.             curr_index = WcGetCityPosition(g_wc_cntx.CurrCityIndex);
  1048.             if (curr_index == (NUMBER_OF_CITY - 2))
  1049.             {
  1050.                 curr_index = 0;
  1051.             }
  1052.             else
  1053.             {
  1054.                 curr_index++;
  1055.             }
  1056.             g_wc_cntx.CurrCityIndex = gWcTimeZoneIndex[curr_index];
  1057.             g_wc_cntx.CurrTZ = TimeZoneData[g_wc_cntx.CurrCityIndex].CityTimeZone;
  1058.             break;
  1059.     }
  1060.     /* get time zone string */
  1061.     mmi_wc_get_tz_string(g_wc_cntx.CurrTZ, (S8*) & gIndexInfo[WC_TZ_INDEX][WC_GMT_LEN]);
  1062.     mmi_wc_get_city_string(g_wc_cntx.CurrCityIndex);
  1063.      
  1064.     SetCat230IndexInfo(WC_TZ_INDEX, (U8*) gIndexInfo[WC_TZ_INDEX]);
  1065.     SetCat230IndexInfo(WC_CITY_INDEX, (U8*) gIndexInfo[WC_CITY_INDEX]);
  1066. }
  1067. /*****************************************************************************
  1068.  * FUNCTION
  1069.  *  mmi_wc_default_city_of_tz
  1070.  * DESCRIPTION
  1071.  *  
  1072.  * PARAMETERS
  1073.  *  tz      [IN]        
  1074.  * RETURNS
  1075.  *  
  1076.  *****************************************************************************/
  1077. U8 mmi_wc_default_city_of_tz(FLOAT tz)
  1078. {
  1079.     /*----------------------------------------------------------------*/
  1080.     /* Local Variables                                                */
  1081.     /*----------------------------------------------------------------*/
  1082. U32 i;
  1083.     S16 TZmap = (S16) tz * 4;
  1084.     /*----------------------------------------------------------------*/
  1085.     /* Code Body                                                      */
  1086.     /*----------------------------------------------------------------*/
  1087. for (i = 0; i < WC_DEFAULT_TZ_NUM; i++)
  1088. {
  1089. if (validTZ[i] == TZmap)
  1090. {
  1091. return gWcDefaultCityForTZ[i];
  1092. }
  1093. }
  1094.     return 0xFF;
  1095. }
  1096. /*****************************************************************************
  1097.  * FUNCTION
  1098.  *  mmi_wc_get_tz_string
  1099.  * DESCRIPTION
  1100.  *  
  1101.  * PARAMETERS
  1102.  *  tz          [IN]        
  1103.  *  outStr      [?]         
  1104.  * RETURNS
  1105.  *  void
  1106.  *****************************************************************************/
  1107. void mmi_wc_get_tz_string(FLOAT tz, S8 *outStr)
  1108. {
  1109.     /*----------------------------------------------------------------*/
  1110.     /* Local Variables                                                */
  1111.     /*----------------------------------------------------------------*/
  1112.     UI_character_type sym;
  1113.     /*----------------------------------------------------------------*/
  1114.     /* Code Body                                                      */
  1115.     /*----------------------------------------------------------------*/
  1116.     /* U8* tmpStr; */
  1117.     if (g_wc_cntx.CurrTZ >= 0)
  1118.     {
  1119.         if (g_wc_cntx.CurrTZ == 0)
  1120.         {
  1121.             sym = WC_SYM_SPACE;
  1122.         }
  1123.         else
  1124.         {
  1125.             sym = WC_SYM_POSITIVE;
  1126.         }
  1127.         memcpy(outStr, &sym, sizeof(UI_character_type));
  1128.         tz = g_wc_cntx.CurrTZ;
  1129.     }
  1130.     else
  1131.     {
  1132.         sym = WC_SYM_NEGATIVE;
  1133.         memcpy(outStr, &sym, sizeof(UI_character_type));
  1134.         tz = -(g_wc_cntx.CurrTZ);
  1135.     }
  1136.     CalcDouble2String(tz, (S8*) & outStr[sizeof(UI_character_type)], WC_MAX_TZ_STR_LEN);
  1137.     //tmpStr = outStr;
  1138.     //CalcDouble2String(tz, (S8*) tmpStr, 1);
  1139. }
  1140. /*****************************************************************************
  1141.  * FUNCTION
  1142.  *  mmi_wc_get_city_string
  1143.  * DESCRIPTION
  1144.  *  
  1145.  * PARAMETERS
  1146.  *  tz          [IN]        
  1147.  *  outStr      [?]         
  1148.  * RETURNS
  1149.  *  void
  1150.  *****************************************************************************/
  1151. void mmi_wc_get_city_string(U8 cityIndex)
  1152. {
  1153.     /*----------------------------------------------------------------*/
  1154.     /* Local Variables                                                */
  1155.     /*----------------------------------------------------------------*/
  1156.     U8 *cityName;
  1157.     /*----------------------------------------------------------------*/
  1158.     /* Code Body                                                      */
  1159.     /*----------------------------------------------------------------*/
  1160.     cityName = (U8*) GetString(TimeZoneData[g_wc_cntx.CurrCityIndex].CityName);
  1161.     /* if home city length to large */
  1162.     if (pfnUnicodeStrlen((S8*) cityName) >= WC_MAX_INDEX_INFO_LEN / ENCODING_LENGTH)
  1163.     {
  1164.         memcpy(gIndexInfo[WC_CITY_INDEX], cityName, WC_MAX_INDEX_INFO_LEN - ENCODING_LENGTH);
  1165.         pfnUnicodeStrcat((S8*)gIndexInfo[WC_CITY_INDEX], (S8*)L"");
  1166.     }
  1167.     else
  1168.     {
  1169.         memcpy(gIndexInfo[WC_CITY_INDEX], cityName, WC_MAX_INDEX_INFO_LEN);
  1170.     }
  1171. }
  1172. #endif /* __MMI_WC_TZ_SUPPORT__ */ 
  1173. /*****************************************************************************
  1174.  * FUNCTION
  1175.  *  ExitWcBrowseCity
  1176.  * DESCRIPTION
  1177.  *  Exit function of browse city screen. Free allocated data.
  1178.  * PARAMETERS
  1179.  *  void
  1180.  * RETURNS
  1181.  *  void
  1182.  *****************************************************************************/
  1183. void ExitWcBrowseCity(void)
  1184. {
  1185.     /*----------------------------------------------------------------*/
  1186.     /* Local Variables                                                */
  1187.     /*----------------------------------------------------------------*/
  1188.     /*----------------------------------------------------------------*/
  1189.     /* Code Body                                                      */
  1190.     /*----------------------------------------------------------------*/
  1191. #ifndef __MMI_WC_TZ_SUPPORT__
  1192.     if (g_wc_cntx.VLine != NULL)
  1193.     {
  1194.         OslMfree(g_wc_cntx.VLine->data);
  1195.         OslMfree(g_wc_cntx.VLine);
  1196.         g_wc_cntx.VLine = NULL;
  1197.     }
  1198.     if (g_wc_cntx.HLine != NULL)
  1199.     {
  1200.         OslMfree(g_wc_cntx.HLine->data);
  1201.         OslMfree(g_wc_cntx.HLine);
  1202.         g_wc_cntx.HLine = NULL;
  1203.     }
  1204. #ifdef __MMI_TOUCH_SCREEN__
  1205.     g_wc_cntx.event_on_object = WC_TOUCH_NONE;
  1206. #endif     
  1207. #else /* __MMI_WC_TZ_SUPPORT__ */ 
  1208.     OslMfree(gIndexInfo[0]);
  1209.     OslMfree(gIndexInfo[1]);
  1210.     OslMfree(homeTime);
  1211.     OslMfree(foreTime);
  1212. #endif /* __MMI_WC_TZ_SUPPORT__ */ 
  1213. }
  1214. /*****************************************************************************
  1215.  * FUNCTION
  1216.  *  WcHandleRSK
  1217.  * DESCRIPTION
  1218.  *  LSK handler of browse city screen.
  1219.  * PARAMETERS
  1220.  *  void
  1221.  * RETURNS
  1222.  *  void
  1223.  *****************************************************************************/
  1224. void WcHandleRSK(void)
  1225. {
  1226.     /*----------------------------------------------------------------*/
  1227.     /* Local Variables                                                */
  1228.     /*----------------------------------------------------------------*/
  1229.     /*----------------------------------------------------------------*/
  1230.     /* Code Body                                                      */
  1231.     /*----------------------------------------------------------------*/
  1232.     GoBackHistory();
  1233.     g_wc_cntx.CurrCityIndex = 0xff;
  1234. }
  1235. #ifdef __MMI_WORLDCLOCK_DST__
  1236. /*****************************************************************************
  1237.  * FUNCTION
  1238.  *  WcChangeDST
  1239.  * DESCRIPTION
  1240.  *  
  1241.  * PARAMETERS
  1242.  *  void
  1243.  * RETURNS
  1244.  *  void
  1245.  *****************************************************************************/
  1246. void WcChangeDST(void)
  1247. {
  1248.     /*----------------------------------------------------------------*/
  1249.     /* Local Variables                                                */
  1250.     /*----------------------------------------------------------------*/
  1251.     /*----------------------------------------------------------------*/
  1252.     /* Code Body                                                      */
  1253.     /*----------------------------------------------------------------*/
  1254.     if (g_wc_cntx.DSTForeign)
  1255.     {
  1256.         g_wc_cntx.DSTForeign = FALSE;
  1257.     }
  1258.     else
  1259.     {
  1260.         g_wc_cntx.DSTForeign = TRUE;
  1261.     }
  1262.     if (g_wc_cntx.DSTForeign)
  1263.     {
  1264.         pfnUnicodeStrcpy((PS8) hintData[0], (PS8) GetString(STR_GLOBAL_ON));
  1265.         Category52ChangeItemDescription(0, hintData[0]);
  1266.         ChangeLeftSoftkey(STR_GLOBAL_OFF, 0);
  1267.     }
  1268.     else
  1269.     {
  1270.         pfnUnicodeStrcpy((PS8) hintData[0], (PS8) GetString(STR_GLOBAL_OFF));
  1271.         Category52ChangeItemDescription(0, hintData[0]);
  1272.         ChangeLeftSoftkey(STR_GLOBAL_ON, 0);
  1273.     }
  1274.     RedrawCategoryFunction();
  1275. }
  1276. /*****************************************************************************
  1277.  * FUNCTION
  1278.  *  WcDSTBackAndSave
  1279.  * DESCRIPTION
  1280.  *  
  1281.  * PARAMETERS
  1282.  *  void
  1283.  * RETURNS
  1284.  *  void
  1285.  *****************************************************************************/
  1286. void WcDSTBackAndSave(void)
  1287. {
  1288.     /*----------------------------------------------------------------*/
  1289.     /* Local Variables                                                */
  1290.     /*----------------------------------------------------------------*/
  1291.     S16 error;
  1292.     /*----------------------------------------------------------------*/
  1293.     /* Code Body                                                      */
  1294.     /*----------------------------------------------------------------*/
  1295.     WriteValue(NVRAM_WC_DST, &g_wc_cntx.DSTForeign, DS_BYTE, &error);
  1296.     GoBackHistory();
  1297. }
  1298. /*****************************************************************************
  1299.  * FUNCTION
  1300.  *  WcDSTEndKeyHandler
  1301.  * DESCRIPTION
  1302.  *  End key handler of DST screen
  1303.  * PARAMETERS
  1304.  *  void
  1305.  * RETURNS
  1306.  *  void
  1307.  *****************************************************************************/
  1308. void WcDSTEndKeyHandler(void)
  1309. {
  1310. S16 error;
  1311.     g_wc_cntx.CurrCityIndex = 0xff;
  1312.     WriteValue(NVRAM_WC_DST, &g_wc_cntx.DSTForeign, DS_BYTE, &error);
  1313.     DisplayIdleScreen();
  1314. }
  1315. /*****************************************************************************
  1316.  * FUNCTION
  1317.  *  WcEntryDST
  1318.  * DESCRIPTION
  1319.  *  
  1320.  * PARAMETERS
  1321.  *  void
  1322.  * RETURNS
  1323.  *  void
  1324.  *****************************************************************************/
  1325. void WcEntryDST(void)
  1326. {
  1327.     /*----------------------------------------------------------------*/
  1328.     /* Local Variables                                                */
  1329.     /*----------------------------------------------------------------*/
  1330.     S32 num_of_items;
  1331.     U16 cityarray[1];
  1332.     U8 *guiBuffer;
  1333.     /*----------------------------------------------------------------*/
  1334.     /* Code Body                                                      */
  1335.     /*----------------------------------------------------------------*/
  1336.     EntryNewScreen(SCR_ID_WC_DST, NULL, WcEntryDST, NULL);
  1337.     guiBuffer = GetCurrGuiBuffer(SCR_ID_WC_DST);
  1338.     num_of_items = GetNumOfChild(MENU_ID_WC_DST_OPT);
  1339.     GetSequenceStringIds(MENU_ID_WC_DST_OPT, cityarray);
  1340.     subMenuDataPtrs[0] = (U8*) GetString(cityarray[0]);
  1341.     SetParentHandler(MENU_ID_WC_DST_OPT);
  1342.     if (g_wc_cntx.DSTForeign)
  1343.     {
  1344.         hintDataPtrs[0] = (U8*) GetString(STR_GLOBAL_ON);
  1345.     }
  1346.     else
  1347.     {
  1348.         hintDataPtrs[0] = (U8*) GetString(STR_GLOBAL_OFF);
  1349.     }
  1350.     ShowCategory53Screen(
  1351.         STR_WORLD_CLOCL_DST_TITLE,
  1352.         GetRootTitleIcon(ORGANIZER_WORLDCLOCK_MENU),
  1353.         STR_GLOBAL_ON,
  1354.         0,
  1355.         STR_GLOBAL_BACK,
  1356.         0,
  1357.         num_of_items,
  1358.         subMenuDataPtrs,
  1359.         (U16*) gIndexIconsImageList,
  1360.         hintDataPtrs,
  1361.         0,
  1362.         0,
  1363.         guiBuffer);
  1364.     if (g_wc_cntx.DSTForeign)
  1365.     {
  1366.         ChangeLeftSoftkey(STR_GLOBAL_OFF, IMG_GLOBAL_BACK);
  1367.     }
  1368.     SetLeftSoftkeyFunction(WcChangeDST, KEY_EVENT_UP);
  1369.     SetRightSoftkeyFunction(WcDSTBackAndSave, KEY_EVENT_UP);
  1370.     SetKeyHandler(WcDSTEndKeyHandler, KEY_END, KEY_EVENT_DOWN);
  1371. }
  1372. #endif /* __MMI_WORLDCLOCK_DST__ */ 
  1373. /*****************************************************************************
  1374.  * FUNCTION
  1375.  *  WcTimeZoneDiff
  1376.  * DESCRIPTION
  1377.  *  Calculate the time zone difference between 2 cities.
  1378.  * PARAMETERS
  1379.  *  City1       [IN]        Index of city 1.
  1380.  *  City2       [IN]        Index of city 2.
  1381.  * RETURNS
  1382.  *  time tone of city 1 - time zone of city 2.
  1383.  *****************************************************************************/
  1384. FLOAT WcTimeZoneDiff(U8 City1, U8 City2)
  1385. {
  1386.     /*----------------------------------------------------------------*/
  1387.     /* Local Variables                                                */
  1388.     /*----------------------------------------------------------------*/
  1389.     /*----------------------------------------------------------------*/
  1390.     /* Code Body                                                      */
  1391.     /*----------------------------------------------------------------*/
  1392.     if (City1 == 0 || City2 == 0)   /* of one the cities is "None" */
  1393.     {
  1394.         return 25;
  1395.     }
  1396.     else
  1397.     {
  1398.         return (TimeZoneData[City1].CityTimeZone - TimeZoneData[City2].CityTimeZone);
  1399.     }
  1400. }
  1401. /*****************************************************************************
  1402.  * FUNCTION
  1403.  *  WcGetCityPosition
  1404.  * DESCRIPTION
  1405.  *  Calculate the position of city in timezone order.
  1406.  * PARAMETERS
  1407.  *  index       [IN]        Index of city.
  1408.  * RETURNS
  1409.  *  Position on gWcTimeZoneIndex array.
  1410.  *****************************************************************************/
  1411. U8 WcGetCityPosition(U8 index)
  1412. {
  1413.     /*----------------------------------------------------------------*/
  1414.     /* Local Variables                                                */
  1415.     /*----------------------------------------------------------------*/
  1416.     U8 i, num_city;
  1417.     /*----------------------------------------------------------------*/
  1418.     /* Code Body                                                      */
  1419.     /*----------------------------------------------------------------*/
  1420.     num_city = NUMBER_OF_CITY;
  1421.     for (i = 0; i < num_city; i++)
  1422.         if (gWcTimeZoneIndex[i] == index)
  1423.         {
  1424.             break;
  1425.         }
  1426.     return i;
  1427. }
  1428. #ifndef __MMI_WC_TZ_SUPPORT__
  1429. /*****************************************************************************
  1430.  * FUNCTION
  1431.  *  WcShowDateTime
  1432.  * DESCRIPTION
  1433.  *  Display date/time in world map
  1434.  * PARAMETERS
  1435.  *  void
  1436.  *  timediff(?)     [IN]        Time difference between current city and home city.
  1437.  * RETURNS
  1438.  *  Position on gWcTimeZoneIndex array.(?)
  1439.  *****************************************************************************/
  1440. void WcShowDateTime(void)
  1441. {
  1442.     /*----------------------------------------------------------------*/
  1443.     /* Local Variables                                                */
  1444.     /*----------------------------------------------------------------*/
  1445.     MYTIME currTime, incTime;
  1446. #ifdef __MMI_WORLDCLOCK_DST__
  1447.     MYTIME dstTime;
  1448. #endif 
  1449.     U8 Ucs2Date[30];
  1450.     U8 Ucs2Time[30];
  1451. #if !defined(__MMI_MAINLCD_176X220__) && !defined (__MMI_MAINLCD_240X320__)     /* 041205 Calvin modieid */
  1452.     U8 AsciiDate[30];
  1453. #endif 
  1454.     PU8 imageday;
  1455.     color c;
  1456.     U8 HomeCity;
  1457.     FLOAT TimeDiff;
  1458.     S32 temp;
  1459.     U8 TimeFlag = 0;
  1460. #ifndef __MMI_TOUCH_SCREEN__
  1461.     color cblue = {160, 205, 250, 100};
  1462. #endif 
  1463.     /*----------------------------------------------------------------*/
  1464.     /* Code Body                                                      */
  1465.     /*----------------------------------------------------------------*/
  1466.     gui_lock_double_buffer();
  1467.     gui_reset_clip();
  1468.     gui_reset_text_clip();
  1469.     GetDateTime(&currTime);
  1470.     /* get time zone difference */
  1471.     HomeCity = PhnsetGetHomeCity() + 1;
  1472.     TimeDiff = WcTimeZoneDiff(g_wc_cntx.CurrCityIndex, HomeCity);
  1473.     memset(&incTime, 0, sizeof(MYTIME));
  1474.     if (TimeDiff < 0)
  1475.     {
  1476.         TimeDiff = TimeDiff * (-1);
  1477.         TimeFlag = 1;
  1478.     }
  1479.     temp = (S32) (TimeDiff * 60);
  1480.     incTime.nDay = (U8) (TimeDiff / 24);
  1481.     incTime.nHour = ((S32) TimeDiff) % 24;
  1482.     incTime.nMin = temp % 60;
  1483.     if (TimeFlag)   /* decrement */
  1484.     {
  1485.         DecrementTime(currTime, incTime, &currTime);
  1486.     }
  1487.     else
  1488.     {
  1489.         IncrementTime(currTime, incTime, &currTime);
  1490.     }
  1491. #ifdef __MMI_WORLDCLOCK_DST__
  1492.     if (HomeCity != g_wc_cntx.CurrCityIndex)    /* not home city */
  1493.     {
  1494.         memset(&dstTime, 0, sizeof(MYTIME));
  1495.         dstTime.nHour = 1;
  1496.         if (g_wc_cntx.DSTForeign && g_phnset_cntx_p->currentDST)        /* both date light saving is on */
  1497.         {
  1498.             /* do nothing */
  1499.         }
  1500.         else if (g_phnset_cntx_p->currentDST)   /* only home city turns on DST */
  1501.         {
  1502.             DecrementTime(currTime, dstTime, &currTime);
  1503.         }
  1504.         else if (g_wc_cntx.DSTForeign)  /* only foreign city turns on DST */
  1505.         {
  1506.             IncrementTime(currTime, dstTime, &currTime);
  1507.         }
  1508.     }
  1509. #endif /* __MMI_WORLDCLOCK_DST__ */ 
  1510.     time_string(&currTime, (UI_string_type) Ucs2Time, DT_IDLE_SCREEN);
  1511. #if defined(__MMI_MAINLCD_176X220__) || defined (__MMI_MAINLCD_240X320__)       /* 041205 Calvin modieid */
  1512.     date_string(&currTime, (UI_string_type) Ucs2Date, DT_IDLE_SCREEN);
  1513. #else /* defined(__MMI_MAINLCD_176X220__) || defined (__MMI_MAINLCD_240X320__) */ 
  1514.     sprintf((S8*) (AsciiDate), "%02d/%02d", currTime.nMonth, currTime.nDay);
  1515.     AnsiiToUnicodeString((S8*) Ucs2Date, (S8*) AsciiDate);
  1516. #endif /* defined(__MMI_MAINLCD_176X220__) || defined (__MMI_MAINLCD_240X320__) */ 
  1517.     if ((currTime.nHour >= 6) && (currTime.nHour < 18))
  1518.     {
  1519.         imageday = get_image(SUN_ICON);
  1520.     }
  1521.     else
  1522.     {
  1523.         imageday = get_image(MOON_ICON);
  1524.     }
  1525. #ifndef __MMI_TOUCH_SCREEN__
  1526.     gui_fill_rectangle(0, MMI_content_height - 7, UI_device_width - 1, MMI_content_height + WC_V_LINE_Y, cblue);
  1527. #endif /* __MMI_TOUCH_SCREEN__ */ 
  1528.     c = gui_color(0, 0, 0);
  1529.     gui_set_text_color(c);
  1530.     gui_set_font(&MMI_medium_font);
  1531. #if defined(__MMI_MAINLCD_176X220__) || defined (__MMI_MAINLCD_240X320__)
  1532.     {
  1533.     #ifdef __MMI_TOUCH_SCREEN__
  1534.         S32 str_w, str_h, str_h1, img_w, img_h, pos_x, pos_y;
  1535.     #if defined (__MMI_MAINLCD_240X320__)
  1536.         color date_bg = gui_color(106, 133, 98);
  1537.     #else 
  1538.         color date_bg = gui_color(80, 103, 75);
  1539.     #endif 
  1540.         color time_bg = gui_color(0, 0, 0);
  1541.         color date_time_text_color = gui_color(255, 255, 255);
  1542.         gui_set_text_color(date_time_text_color);
  1543.         gui_measure_string((UI_string_type) Ucs2Date, &str_w, &str_h1);
  1544.         gui_measure_image(imageday, &img_w, &img_h);
  1545.         /* show date */
  1546.         gui_fill_rectangle(
  1547.             0,
  1548.             UI_device_height - MMI_button_bar_height - WC_DATE_HEIGHT - WC_TIME_HEIGHT,
  1549.             UI_device_width,
  1550.             UI_device_height - MMI_button_bar_height - WC_TIME_HEIGHT,
  1551.             date_bg);
  1552.         if (r2lMMIFlag)
  1553.         {
  1554.             gui_move_text_cursor(
  1555.                 ((UI_device_width + str_w) >> 1),
  1556.                 UI_device_height - MMI_button_bar_height - WC_DATE_HEIGHT - WC_TIME_HEIGHT + ((WC_DATE_HEIGHT - str_h1) >> 1));
  1557.         }
  1558.         else
  1559.         {
  1560.             gui_move_text_cursor(
  1561.                 ((UI_device_width - str_w) >> 1),
  1562.                 UI_device_height - MMI_button_bar_height - WC_DATE_HEIGHT - WC_TIME_HEIGHT + ((WC_DATE_HEIGHT - str_h1) >> 1));
  1563.         }
  1564.         gui_print_text((U16*) Ucs2Date);
  1565.         /* show time */
  1566.         gui_measure_string((UI_string_type) Ucs2Time, &str_w, &str_h);
  1567.         pos_x = ((UI_device_width - str_w - img_w - 4) >> 1);
  1568.         pos_y = UI_device_height - MMI_button_bar_height - WC_TIME_HEIGHT;
  1569.         gui_fill_rectangle(0, pos_y, UI_device_width, pos_y + WC_TIME_HEIGHT, time_bg);
  1570.         if (r2lMMIFlag)
  1571.         {
  1572.             gui_move_text_cursor(pos_x + str_w, pos_y + ((WC_TIME_HEIGHT - str_h) >> 1));
  1573.         }
  1574.         else
  1575.         {
  1576.             gui_move_text_cursor(pos_x, pos_y + ((WC_TIME_HEIGHT - str_h) >> 1));
  1577.         }
  1578.         gui_print_text((U16*) Ucs2Time);
  1579.         /* show day/night image */
  1580.         gui_show_transparent_image(pos_x + str_w + 2, pos_y + ((WC_TIME_HEIGHT - img_h) >> 1), imageday, 0);
  1581.     #else /* __MMI_TOUCH_SCREEN__ */ 
  1582.         S32 str_w, str_h, str_h1;
  1583.         gui_measure_string((UI_string_type) Ucs2Date, &str_w, &str_h1);
  1584.         /* show date */
  1585.         if (r2lMMIFlag)
  1586.         {
  1587.             gui_move_text_cursor(2 + str_w, MMI_content_height);
  1588.         }
  1589.         else
  1590.         {
  1591.             gui_move_text_cursor(2, MMI_content_height);
  1592.         }
  1593.         gui_print_text((U16*) Ucs2Date);
  1594.         str_h1 += MMI_content_height;
  1595.         if (r2lMMIFlag)
  1596.         {
  1597.             gui_move_text_cursor(2 + gui_get_string_width((UI_string_type) Ucs2Time), str_h1 + 2);
  1598.         }
  1599.         else
  1600.         {
  1601.             gui_move_text_cursor(2, str_h1 + 2);
  1602.         }
  1603.         gui_print_text((U16*) Ucs2Time);
  1604.         gui_measure_string((UI_string_type) Ucs2Time, &str_w, &str_h);
  1605.         gui_show_transparent_image(str_w + 15, str_h1 + 2, imageday, 0);
  1606.     #endif /* __MMI_TOUCH_SCREEN__ */ 
  1607.     }
  1608. #else /* defined(__MMI_MAINLCD_176X220__) || defined (__MMI_MAINLCD_240X320__) */ 
  1609.     {
  1610.         if (r2lMMIFlag)
  1611.         {
  1612.             gui_move_text_cursor(2 + gui_get_string_width((UI_string_type) Ucs2Date), MMI_content_height);
  1613.         }
  1614.         else
  1615.         {
  1616.             gui_move_text_cursor(2, MMI_content_height);
  1617.         }
  1618.         gui_print_text((U16*) Ucs2Date);
  1619.         if (r2lMMIFlag)
  1620.         {
  1621.             gui_move_text_cursor(48 + gui_get_string_width((UI_string_type) Ucs2Time), MMI_content_height);
  1622.         }
  1623.         else
  1624.         {
  1625.             gui_move_text_cursor(48, MMI_content_height);
  1626.         }
  1627.         gui_print_text((U16*) Ucs2Time);
  1628.         gui_show_transparent_image(110, MMI_content_height, imageday, 0);
  1629.     }
  1630. #endif /* defined(__MMI_MAINLCD_176X220__) || defined (__MMI_MAINLCD_240X320__) */ 
  1631. #if(UI_DOUBLE_BUFFER_SUPPORT)
  1632.     gui_unlock_double_buffer();
  1633.     gui_BLT_double_buffer(0, MMI_content_height - 5, UI_device_width - 1, MMI_content_height + WC_V_LINE_Y);
  1634. #endif /* (UI_DOUBLE_BUFFER_SUPPORT) */ 
  1635. }
  1636. /*****************************************************************************
  1637.  * FUNCTION
  1638.  *  WcDrawTitle
  1639.  * DESCRIPTION
  1640.  *  Draw title bar and city name of browse city screen
  1641.  * PARAMETERS
  1642.  *  void
  1643.  * RETURNS
  1644.  *  void
  1645.  *****************************************************************************/
  1646. void WcDrawTitle(void)
  1647. {
  1648.     /*----------------------------------------------------------------*/
  1649.     /* Local Variables                                                */
  1650.     /*----------------------------------------------------------------*/
  1651.     U8 i = g_wc_cntx.CurrCityIndex;
  1652.     color cblack = {0, 0, 0, 100};
  1653.     color cwhite = {255, 255, 255, 100};
  1654. #if defined(__MMI_MAINLCD_176X220__) || defined (__MMI_MAINLCD_240X320__)       /* 041205 Calvin modieid */
  1655.     S32 str_w = 0, str_h = 0;
  1656. #endif 
  1657. #ifdef WC_HEIGHT_160
  1658.     S32 width, height;
  1659.     UI_string_type CityName;
  1660.     /*----------------------------------------------------------------*/
  1661.     /* Code Body                                                      */
  1662.     /*----------------------------------------------------------------*/
  1663.     MMI_title_string = (UI_string_type) GetString(STR_WORLD_CLOCK_TITLE);
  1664.     CityName = (UI_string_type) GetString(TimeZoneData[i].CityName);
  1665.     gui_measure_string(CityName, &width, &height);
  1666.     gui_fill_rectangle(0, (MMI_title_y + MMI_title_height), UI_device_width - 1, WC_V_LINE_Y, cwhite);
  1667.     /* MTK Elvis for R2L characters */
  1668.     if (r2lMMIFlag)
  1669.     {
  1670.         gui_move_text_cursor(((UI_device_width - width) >> 1) + width, WC_V_LINE_Y - height);
  1671.     }
  1672.     else
  1673.     {
  1674.         gui_move_text_cursor((UI_device_width - width) >> 1, WC_V_LINE_Y - height);
  1675.     }
  1676.     /* MTk end */
  1677.     gui_set_text_color(cblack);
  1678.     gui_print_text(CityName);
  1679. #else /* WC_HEIGHT_160 */ 
  1680.     MMI_title_string = (UI_string_type) GetString(TimeZoneData[i].CityName);
  1681. #endif /* WC_HEIGHT_160 */ 
  1682.     show_title_status_icon();
  1683. #if defined(__MMI_MAINLCD_176X220__) || defined (__MMI_MAINLCD_240X320__)       /* 041205 Calvin modieid */
  1684.     /* show title string */
  1685.     gui_measure_string(MMI_title_string, &str_w, &str_h);
  1686.     gui_fill_rectangle(
  1687.         0,
  1688.         MMI_status_bar_height,
  1689.         UI_device_width - 1,
  1690.         MMI_status_bar_height - 1 + WC_TITLE_HEIGHT,
  1691.         cblack);
  1692.     if (r2lMMIFlag)
  1693.     {
  1694.         gui_move_text_cursor(
  1695.             ((UI_device_width - str_w) >> 1) + str_w,
  1696.             MMI_status_bar_height + ((WC_TITLE_HEIGHT - str_h) >> 1));
  1697.     }
  1698.     else
  1699.     {
  1700.         gui_move_text_cursor((UI_device_width - str_w) >> 1, MMI_status_bar_height + ((WC_TITLE_HEIGHT - str_h) >> 1));
  1701.     }
  1702.     gui_set_text_color(cwhite);
  1703.     gui_print_text(MMI_title_string);
  1704. #ifdef __MMI_TOUCH_SCREEN__
  1705.     /* show arrows */
  1706.     if (g_wc_cntx.event_on_object == WC_TOUCH_ON_LEFT_ARROW_DOWN)
  1707.     {
  1708.         gui_show_transparent_image(
  1709.             0,
  1710.             MMI_status_bar_height + ((WC_TITLE_HEIGHT - g_wc_cntx.arrow_height) >> 1) - 1,
  1711.             get_image(WORLD_CLOCK_LEFT_ARROW_DOWN),
  1712.             0);
  1713.     }
  1714.     else
  1715.     {
  1716.         gui_show_transparent_image(
  1717.             0,
  1718.             MMI_status_bar_height + ((WC_TITLE_HEIGHT - g_wc_cntx.arrow_height) >> 1) - 1,
  1719.             get_image(WORLD_CLOCK_LEFT_ARROW_UP),
  1720.             0);
  1721.     }
  1722.     if (g_wc_cntx.event_on_object == WC_TOUCH_ON_RIGHT_ARROW_DOWN)
  1723.     {
  1724.         gui_show_transparent_image(
  1725.             UI_device_width - g_wc_cntx.arrow_width - 1,
  1726.             MMI_status_bar_height + ((WC_TITLE_HEIGHT - g_wc_cntx.arrow_height) >> 1) - 1,
  1727.             get_image(WORLD_CLOCK_RIGHT_ARROW_DOWN),
  1728.             0);
  1729.     }
  1730.     else
  1731.     {
  1732.         gui_show_transparent_image(
  1733.             UI_device_width - g_wc_cntx.arrow_width - 1,
  1734.             MMI_status_bar_height + ((WC_TITLE_HEIGHT - g_wc_cntx.arrow_height) >> 1) - 1,
  1735.             get_image(WORLD_CLOCK_RIGHT_ARROW_UP),
  1736.             0);
  1737.     }
  1738. #endif /* __MMI_TOUCH_SCREEN__ */ 
  1739. #else /* defined(__MMI_MAINLCD_176X220__) || defined (__MMI_MAINLCD_240X320__) */ 
  1740.     draw_title();
  1741. #endif /* defined(__MMI_MAINLCD_176X220__) || defined (__MMI_MAINLCD_240X320__) */ 
  1742. }
  1743. /*****************************************************************************
  1744.  * FUNCTION
  1745.  *  WcRedrawCategory
  1746.  * DESCRIPTION
  1747.  *  Redraw category function when theme update
  1748.  * PARAMETERS
  1749.  *  void
  1750.  * RETURNS
  1751.  *  void
  1752.  *****************************************************************************/
  1753. void WcRedrawCategory(void)
  1754. {
  1755.     /*----------------------------------------------------------------*/
  1756.     /* Local Variables                                                */
  1757.     /*----------------------------------------------------------------*/
  1758.     /*----------------------------------------------------------------*/
  1759.     /* Code Body                                                      */
  1760.     /*----------------------------------------------------------------*/
  1761.     /* WcRedrawWorldClock(0,UI_DEVICE_HEIGHT); */
  1762.     /* date and time information */
  1763.     WcShowDateTime();
  1764.     WcDrawTitle();
  1765.     show_softkey_background();
  1766.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  1767.     ChangeRightSoftkey(0, 0);
  1768. }
  1769. /*****************************************************************************
  1770.  * FUNCTION
  1771.  *  WcRedrawWorldClock
  1772.  * DESCRIPTION
  1773.  *  Redraw world clock screen
  1774.  * PARAMETERS
  1775.  *  old_x_vertical          [IN]        Coordinate of previous X.
  1776.  *  old_y_horizontal        [IN]        
  1777.  *  old_y_vertical(?)       [IN]        Coordinate of previous Y.(?)
  1778.  * RETURNS
  1779.  *  void
  1780.  *****************************************************************************/
  1781. void WcRedrawWorldClock(S32 old_x_vertical, S32 old_y_horizontal)
  1782. {
  1783.     /*----------------------------------------------------------------*/
  1784.     /* Local Variables                                                */
  1785.     /*----------------------------------------------------------------*/
  1786.     U8 i;
  1787.     color cred = {255, 0, 0, 100};
  1788.     color cwhite = {255, 255, 255, 100};
  1789.     /*----------------------------------------------------------------*/
  1790.     /* Code Body                                                      */
  1791.     /*----------------------------------------------------------------*/
  1792.     gui_reset_clip();
  1793.     gui_reset_text_clip();
  1794.     gui_lock_double_buffer();
  1795.     i = g_wc_cntx.CurrCityIndex;
  1796.     if (TimeZoneData[i].MapIndex != g_wc_cntx.CurrMap)
  1797.     {
  1798.         gui_fill_rectangle(0, MMI_title_y, UI_device_width - 1, UI_device_height - 1, cwhite);
  1799.         g_wc_cntx.CurrMap = TimeZoneData[i].MapIndex;
  1800.         gui_show_image(0, WC_V_LINE_Y, get_image((U16) (WORLD_CLOCK_IMAGE1 + g_wc_cntx.CurrMap - 1)));
  1801.     }
  1802.     else
  1803.     {
  1804.         _show_bitmap(old_x_vertical, WC_V_LINE_Y, g_wc_cntx.VLine);
  1805.         _show_bitmap(WC_H_LINE_X, old_y_horizontal, g_wc_cntx.HLine);
  1806.     }
  1807.     gui_reset_clip();
  1808.     /* get the bitmap of the vertical and horizontal line */
  1809.     _get_bitmap(TimeZoneData[i].CityX, WC_V_LINE_Y, TimeZoneData[i].CityX, MMI_content_height - 8, g_wc_cntx.VLine);
  1810.     _get_bitmap(
  1811.         0,
  1812.         TimeZoneData[i].CityY + WC_V_LINE_Y,
  1813.         UI_device_height,
  1814.         TimeZoneData[i].CityY + WC_V_LINE_Y,
  1815.         g_wc_cntx.HLine);
  1816.     gui_draw_vertical_line(WC_V_LINE_Y, MMI_content_height - 8, TimeZoneData[i].CityX, cred);
  1817.     gui_draw_horizontal_line(0, UI_device_height, TimeZoneData[i].CityY + WC_V_LINE_Y, cred);
  1818.     /* date and time information */
  1819.     WcShowDateTime();
  1820.     /* title */
  1821.     WcDrawTitle();
  1822.     show_softkey_background();
  1823.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  1824. #ifdef __MMI_WORLDCLOCK_DST__
  1825.     ChangeLeftSoftkey(STR_GLOBAL_OPTIONS, IMG_GLOBAL_OPTIONS);
  1826. #else 
  1827.     ChangeLeftSoftkey(0, 0);
  1828. #endif 
  1829.     gui_unlock_double_buffer();
  1830.     gui_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - 1);
  1831. }
  1832. /*****************************************************************************
  1833.  * FUNCTION
  1834.  *  WcHandleKeyRight
  1835.  * DESCRIPTION
  1836.  *  Right arrow key handler of browse city screen.
  1837.  * PARAMETERS
  1838.  *  void
  1839.  * RETURNS
  1840.  *  void
  1841.  *****************************************************************************/
  1842. void WcHandleKeyRight(void)
  1843. {
  1844.     /*----------------------------------------------------------------*/
  1845.     /* Local Variables                                                */
  1846.     /*----------------------------------------------------------------*/
  1847.     S32 old_x_vertical, old_y_horizontal;
  1848.     U8 curr_index;
  1849.     /*----------------------------------------------------------------*/
  1850.     /* Code Body                                                      */
  1851.     /*----------------------------------------------------------------*/
  1852.     curr_index = WcGetCityPosition(g_wc_cntx.CurrCityIndex);
  1853.     old_x_vertical = TimeZoneData[gWcTimeZoneIndex[curr_index]].CityX;
  1854.     old_y_horizontal = TimeZoneData[gWcTimeZoneIndex[curr_index]].CityY + WC_V_LINE_Y;
  1855.     if (curr_index == (NUMBER_OF_CITY - 2))
  1856.     {
  1857.         curr_index = 0;
  1858.     }
  1859.     else
  1860.     {
  1861.         curr_index++;
  1862.     }
  1863.     g_wc_cntx.CurrCityIndex = gWcTimeZoneIndex[curr_index];
  1864.     WcRedrawWorldClock(old_x_vertical, old_y_horizontal);
  1865. }
  1866. /*****************************************************************************
  1867.  * FUNCTION
  1868.  *  WcHandleKeyLeft
  1869.  * DESCRIPTION
  1870.  *  Left arrow key handler of browse city screen.
  1871.  * PARAMETERS
  1872.  *  void
  1873.  * RETURNS
  1874.  *  void
  1875.  *****************************************************************************/
  1876. void WcHandleKeyLeft(void)
  1877. {
  1878.     /*----------------------------------------------------------------*/
  1879.     /* Local Variables                                                */
  1880.     /*----------------------------------------------------------------*/
  1881.     S32 old_x_vertical, old_y_horizontal;
  1882.     U8 curr_index;
  1883.     /*----------------------------------------------------------------*/
  1884.     /* Code Body                                                      */
  1885.     /*----------------------------------------------------------------*/
  1886.     curr_index = WcGetCityPosition(g_wc_cntx.CurrCityIndex);
  1887.     old_x_vertical = TimeZoneData[gWcTimeZoneIndex[curr_index]].CityX;
  1888.     old_y_horizontal = TimeZoneData[gWcTimeZoneIndex[curr_index]].CityY + WC_V_LINE_Y;
  1889.     if (curr_index == 0)
  1890.     {
  1891.         curr_index = (NUMBER_OF_CITY - 2);  /* 56; */
  1892.     }
  1893.     else
  1894.     {
  1895.         curr_index--;
  1896.     }
  1897.     g_wc_cntx.CurrCityIndex = gWcTimeZoneIndex[curr_index];
  1898.     WcRedrawWorldClock(old_x_vertical, old_y_horizontal);
  1899. }
  1900. #endif /* __MMI_WC_TZ_SUPPORT__ */ 
  1901. /*****************************************************************************
  1902.  * FUNCTION
  1903.  *  WcHandleKeyEnd
  1904.  * DESCRIPTION
  1905.  *  End key handler of browse city screen.
  1906.  * PARAMETERS
  1907.  *  void
  1908.  * RETURNS
  1909.  *  void
  1910.  *****************************************************************************/
  1911. void WcHandleKeyEnd(void)
  1912. {
  1913.     /*----------------------------------------------------------------*/
  1914.     /* Local Variables                                                */
  1915.     /*----------------------------------------------------------------*/
  1916.     /*----------------------------------------------------------------*/
  1917.     /* Code Body                                                      */
  1918.     /*----------------------------------------------------------------*/
  1919.     g_wc_cntx.CurrCityIndex = 0xff;
  1920.     DisplayIdleScreen();
  1921. }
  1922. #ifdef __MMI_TOUCH_SCREEN__
  1923. #include "wgui_touch_screen.h"
  1924. #define WC_PEN_GAP   3
  1925. #ifndef __MMI_WC_TZ_SUPPORT__
  1926. /*****************************************************************************
  1927.  * FUNCTION
  1928.  *  WcPenDownHandler
  1929.  * DESCRIPTION
  1930.  *  
  1931.  * PARAMETERS
  1932.  *  point       [IN]        
  1933.  * RETURNS
  1934.  *  
  1935.  *****************************************************************************/
  1936. MMI_BOOL WcPenDownHandler(mmi_pen_point_struct point)
  1937. {
  1938.     /*----------------------------------------------------------------*/
  1939.     /* Local Variables                                                */
  1940.     /*----------------------------------------------------------------*/
  1941.     S32 number_of_city = mmi_wc_get_size();
  1942.     S32 i = 0, pos_x = point.x, pos_y = point.y;
  1943.     U8 backup_idx = g_wc_cntx.CurrCityIndex;
  1944.     wgui_component_info_struct pos;
  1945.     /*----------------------------------------------------------------*/
  1946.     /* Code Body                                                      */
  1947.     /*----------------------------------------------------------------*/
  1948.     /* left arrow */
  1949.     pos.pos_x = 0;
  1950.     pos.pos_y = MMI_status_bar_height + ((WC_TITLE_HEIGHT - g_wc_cntx.arrow_height) >> 1) - 1;
  1951.     pos.height = g_wc_cntx.arrow_height;
  1952.     pos.width = g_wc_cntx.arrow_width;
  1953.     if (wgui_test_object_position(point, pos) == MMI_TRUE)  /* LEFT ARROW */
  1954.     {
  1955.         g_wc_cntx.event_on_object = WC_TOUCH_ON_LEFT_ARROW_DOWN;
  1956.         WcHandleKeyLeft();
  1957.         return MMI_TRUE;
  1958.     }
  1959.     /* right arrow */
  1960.     pos.pos_x = UI_device_width - g_wc_cntx.arrow_width - 1;
  1961.     pos.pos_y = MMI_status_bar_height + ((WC_TITLE_HEIGHT - g_wc_cntx.arrow_height) >> 1) - 1;
  1962.     if (wgui_test_object_position(point, pos) == MMI_TRUE)  /* RIGHT ARROW */
  1963.     {
  1964.         g_wc_cntx.event_on_object = WC_TOUCH_ON_RIGHT_ARROW_DOWN;
  1965.         WcHandleKeyRight();
  1966.         return MMI_TRUE;
  1967.     }
  1968.     for (i = 0; i < number_of_city; i++)
  1969.     {
  1970.         S32 old_x_vertical = TimeZoneData[i].CityX;
  1971.         S32 old_y_horizontal = TimeZoneData[i].CityY + WC_V_LINE_Y;
  1972.         if (TimeZoneData[i].MapIndex == g_wc_cntx.CurrMap && pos_x >= old_x_vertical - WC_PEN_GAP &&
  1973.             pos_x <= old_x_vertical + WC_PEN_GAP && pos_y >= old_y_horizontal - WC_PEN_GAP &&
  1974.             pos_y <= old_y_horizontal + WC_PEN_GAP)
  1975.         {
  1976.             g_wc_cntx.CurrCityIndex = i;
  1977.             WcRedrawWorldClock(TimeZoneData[backup_idx].CityX, TimeZoneData[backup_idx].CityY + WC_V_LINE_Y);
  1978.             g_wc_cntx.event_on_object = WC_TOUCH_ON_MAP;
  1979.             return MMI_TRUE;
  1980.         }
  1981.     }
  1982.     g_wc_cntx.event_on_object = WC_TOUCH_NONE;
  1983.     return MMI_FALSE;
  1984. }
  1985. /*****************************************************************************
  1986.  * FUNCTION
  1987.  *  WcPenUpHandler
  1988.  * DESCRIPTION
  1989.  *  
  1990.  * PARAMETERS
  1991.  *  point       [IN]        
  1992.  * RETURNS
  1993.  *  
  1994.  *****************************************************************************/
  1995. MMI_BOOL WcPenUpHandler(mmi_pen_point_struct point)
  1996. {
  1997.     /*----------------------------------------------------------------*/
  1998.     /* Local Variables                                                */
  1999.     /*----------------------------------------------------------------*/
  2000.     wgui_component_info_struct pos;
  2001.     /*----------------------------------------------------------------*/
  2002.     /* Code Body                                                      */
  2003.     /*----------------------------------------------------------------*/
  2004.     /* left arrow */
  2005.     if (g_wc_cntx.event_on_object == WC_TOUCH_ON_LEFT_ARROW_DOWN)
  2006.     {
  2007.         pos.pos_x = 0;
  2008.         pos.pos_y = MMI_status_bar_height + ((WC_TITLE_HEIGHT - g_wc_cntx.arrow_height) >> 1) - 1;
  2009.         pos.height = g_wc_cntx.arrow_height;
  2010.         pos.width = g_wc_cntx.arrow_width;
  2011.         if (wgui_test_object_position(point, pos) == MMI_TRUE)  /* LEFT ARROW */
  2012.         {
  2013.             gui_show_transparent_image(pos.pos_x, pos.pos_y, get_image(WORLD_CLOCK_LEFT_ARROW_UP), 0);
  2014.             gui_BLT_double_buffer(
  2015.                 pos.pos_x,
  2016.                 pos.pos_y,
  2017.                 pos.pos_x + pos.pos_x + pos.width - 1,
  2018.                 pos.pos_y + pos.height - 1);
  2019.             g_wc_cntx.event_on_object = WC_TOUCH_NONE;
  2020.             return MMI_TRUE;
  2021.         }
  2022.     }
  2023.     /* right arrow */
  2024.     if (g_wc_cntx.event_on_object == WC_TOUCH_ON_RIGHT_ARROW_DOWN)
  2025.     {
  2026.         pos.pos_x = UI_device_width - g_wc_cntx.arrow_width - 1;
  2027.         pos.pos_y = MMI_status_bar_height + ((WC_TITLE_HEIGHT - g_wc_cntx.arrow_height) >> 1) - 1;
  2028.         pos.height = g_wc_cntx.arrow_height;
  2029.         pos.width = g_wc_cntx.arrow_width;
  2030.         if (wgui_test_object_position(point, pos) == MMI_TRUE)  /* RIGHT ARROW */
  2031.         {
  2032.             gui_show_transparent_image(pos.pos_x, pos.pos_y, get_image(WORLD_CLOCK_RIGHT_ARROW_UP), 0);
  2033.             gui_BLT_double_buffer(
  2034.                 pos.pos_x,
  2035.                 pos.pos_y,
  2036.                 pos.pos_x + pos.pos_x + pos.width - 1,
  2037.                 pos.pos_y + pos.height - 1);
  2038.             g_wc_cntx.event_on_object = WC_TOUCH_NONE;
  2039.             return MMI_TRUE;
  2040.         }
  2041.     }
  2042.     return MMI_FALSE;
  2043. }
  2044. /*****************************************************************************
  2045.  * FUNCTION
  2046.  *  WcPenRepeatHandler
  2047.  * DESCRIPTION
  2048.  *  
  2049.  * PARAMETERS
  2050.  *  point       [IN]        
  2051.  * RETURNS
  2052.  *  
  2053.  *****************************************************************************/
  2054. MMI_BOOL WcPenRepeatHandler(mmi_pen_point_struct point)
  2055. {
  2056.     /*----------------------------------------------------------------*/
  2057.     /* Local Variables                                                */
  2058.     /*----------------------------------------------------------------*/
  2059.     /*----------------------------------------------------------------*/
  2060.     /* Code Body                                                      */
  2061.     /*----------------------------------------------------------------*/
  2062.     /* left arrow */
  2063.     if (g_wc_cntx.event_on_object == WC_TOUCH_ON_LEFT_ARROW_DOWN)
  2064.     {
  2065.         WcHandleKeyLeft();
  2066.         return MMI_TRUE;
  2067.     }
  2068.     /* right arrow */
  2069.     if (g_wc_cntx.event_on_object == WC_TOUCH_ON_RIGHT_ARROW_DOWN)
  2070.     {
  2071.         WcHandleKeyRight();
  2072.         return MMI_TRUE;
  2073.     }
  2074.     return MMI_FALSE;
  2075. }
  2076. /*****************************************************************************
  2077.  * FUNCTION
  2078.  *  WcPenMoveHandler
  2079.  * DESCRIPTION
  2080.  *  
  2081.  * PARAMETERS
  2082.  *  point       [IN]        
  2083.  * RETURNS
  2084.  *  
  2085.  *****************************************************************************/
  2086. MMI_BOOL WcPenMoveHandler(mmi_pen_point_struct point)
  2087. {
  2088.     /*----------------------------------------------------------------*/
  2089.     /* Local Variables                                                */
  2090.     /*----------------------------------------------------------------*/
  2091.     S32 number_of_city = mmi_wc_get_size();
  2092.     S32 i = 0, pos_x = point.x, pos_y = point.y;
  2093.     U8 backup_idx = g_wc_cntx.CurrCityIndex;
  2094.     wgui_component_info_struct pos;
  2095.     /*----------------------------------------------------------------*/
  2096.     /* Code Body                                                      */
  2097.     /*----------------------------------------------------------------*/
  2098.     /* left arrow */
  2099.     if (g_wc_cntx.event_on_object == WC_TOUCH_ON_LEFT_ARROW_DOWN ||
  2100.         g_wc_cntx.event_on_object == WC_TOUCH_ON_LEFT_ARROW_UP)
  2101.     {
  2102.         pos.pos_x = 0;
  2103.         pos.pos_y = MMI_status_bar_height + ((WC_TITLE_HEIGHT - g_wc_cntx.arrow_height) >> 1) - 1;
  2104.         pos.height = g_wc_cntx.arrow_height;
  2105.         pos.width = g_wc_cntx.arrow_width;
  2106.         if (wgui_test_object_position(point, pos) == MMI_TRUE)  /* LEFT ARROW */
  2107.         {
  2108.             g_wc_cntx.event_on_object = WC_TOUCH_ON_LEFT_ARROW_DOWN;
  2109.             return MMI_TRUE;
  2110.         }
  2111.         else
  2112.         {
  2113.             if (g_wc_cntx.event_on_object == WC_TOUCH_ON_LEFT_ARROW_DOWN)
  2114.             {
  2115.                 g_wc_cntx.event_on_object = WC_TOUCH_ON_LEFT_ARROW_UP;
  2116.                 gui_show_transparent_image(pos.pos_x, pos.pos_y, get_image(WORLD_CLOCK_LEFT_ARROW_UP), 0);
  2117.                 gui_BLT_double_buffer(
  2118.                     pos.pos_x,
  2119.                     pos.pos_y,
  2120.                     pos.pos_x + pos.pos_x + pos.width - 1,
  2121.                     pos.pos_y + pos.height - 1);
  2122.             }
  2123.             return MMI_FALSE;
  2124.         }
  2125.     }
  2126.     /* right arrow */
  2127.     if (g_wc_cntx.event_on_object == WC_TOUCH_ON_RIGHT_ARROW_DOWN ||
  2128.         g_wc_cntx.event_on_object == WC_TOUCH_ON_RIGHT_ARROW_UP)
  2129.     {
  2130.         pos.pos_x = UI_device_width - g_wc_cntx.arrow_width - 1;
  2131.         pos.pos_y = MMI_status_bar_height + ((WC_TITLE_HEIGHT - g_wc_cntx.arrow_height) >> 1) - 1;
  2132.         pos.height = g_wc_cntx.arrow_height;
  2133.         pos.width = g_wc_cntx.arrow_width;
  2134.         if (wgui_test_object_position(point, pos) == MMI_TRUE)  /* RIGHT ARROW */
  2135.         {
  2136.             g_wc_cntx.event_on_object = WC_TOUCH_ON_RIGHT_ARROW_DOWN;
  2137.             return MMI_TRUE;
  2138.         }
  2139.         else
  2140.         {
  2141.             if (g_wc_cntx.event_on_object == WC_TOUCH_ON_RIGHT_ARROW_DOWN)
  2142.             {
  2143.                 g_wc_cntx.event_on_object = WC_TOUCH_ON_RIGHT_ARROW_UP;
  2144.                 gui_show_transparent_image(pos.pos_x, pos.pos_y, get_image(WORLD_CLOCK_RIGHT_ARROW_UP), 0);
  2145.                 gui_BLT_double_buffer(
  2146.                     pos.pos_x,
  2147.                     pos.pos_y,
  2148.                     pos.pos_x + pos.pos_x + pos.width - 1,
  2149.                     pos.pos_y + pos.height - 1);
  2150.             }
  2151.             return MMI_FALSE;
  2152.         }
  2153.     }
  2154.     for (i = 0; i < number_of_city; i++)
  2155.     {
  2156.         S32 old_x_vertical = TimeZoneData[i].CityX;
  2157.         S32 old_y_horizontal = TimeZoneData[i].CityY + WC_V_LINE_Y;
  2158.         if (TimeZoneData[i].MapIndex == g_wc_cntx.CurrMap && pos_x >= old_x_vertical - WC_PEN_GAP &&
  2159.             pos_x <= old_x_vertical + WC_PEN_GAP && pos_y >= old_y_horizontal - WC_PEN_GAP &&
  2160.             pos_y <= old_y_horizontal + WC_PEN_GAP)
  2161.         {
  2162.             g_wc_cntx.CurrCityIndex = i;
  2163.             WcRedrawWorldClock(TimeZoneData[backup_idx].CityX, TimeZoneData[backup_idx].CityY + WC_V_LINE_Y);
  2164.             g_wc_cntx.event_on_object = WC_TOUCH_ON_MAP;
  2165.             return MMI_TRUE;
  2166.         }
  2167.     }
  2168.     g_wc_cntx.event_on_object = WC_TOUCH_NONE;
  2169.     return MMI_FALSE;
  2170. }
  2171. #else /* __MMI_WC_TZ_SUPPORT__ */ 
  2172. #ifdef __MMI_TOUCH_SCREEN__
  2173. /*****************************************************************************
  2174.  * FUNCTION
  2175.  *  mmi_wc_paint_pen_handler
  2176.  * DESCRIPTION
  2177.  *  
  2178.  * PARAMETERS
  2179.  *  x               [IN]        
  2180.  *  y               [IN]        
  2181.  *  event_type      [IN]        
  2182.  * RETURNS
  2183.  *  void
  2184.  *****************************************************************************/
  2185. void mmi_wc_paint_pen_handler(S32 x, S32 y, S32 event_type)
  2186. {
  2187.     /*----------------------------------------------------------------*/
  2188.     /* Local Variables                                                */
  2189.     /*----------------------------------------------------------------*/
  2190.     S32 number_of_city = mmi_wc_get_size();
  2191.     U8 i;
  2192.     /*----------------------------------------------------------------*/
  2193.     /* Code Body                                                      */
  2194.     /*----------------------------------------------------------------*/
  2195.     for (i = 0; i < number_of_city; i++)
  2196.     {
  2197.         S32 old_x_vertical = TimeZoneData[i].CityX;
  2198.         S32 old_y_horizontal = TimeZoneData[i].CityY;   /* WC_V_LINE_Y; */
  2199.         if (x >= old_x_vertical - WC_PEN_GAP && x <= old_x_vertical + WC_PEN_GAP
  2200.             && y >= old_y_horizontal - WC_PEN_GAP && y <= old_y_horizontal + WC_PEN_GAP)
  2201.         {
  2202.             g_wc_cntx.CurrCityIndex = i;
  2203.             g_wc_cntx.event_on_object = WC_TOUCH_ON_MAP;
  2204.             g_wc_cntx.CurrTZ = TimeZoneData[g_wc_cntx.CurrCityIndex].CityTimeZone;
  2205.             break;
  2206.         }
  2207.     }
  2208.     /* get time zone string */
  2209.     mmi_wc_get_tz_string(g_wc_cntx.CurrTZ, (S8*) & gIndexInfo[WC_TZ_INDEX][WC_GMT_LEN]);
  2210.     /* get Home city */
  2211.     memcpy(gIndexInfo[WC_CITY_INDEX], GetString(TimeZoneData[g_wc_cntx.CurrCityIndex].CityName), WC_MAX_INDEX_INFO_LEN);
  2212.     SetCat230IndexInfo(WC_TZ_INDEX, (U8*) gIndexInfo[WC_TZ_INDEX]);
  2213.     SetCat230IndexInfo(WC_CITY_INDEX, (U8*) gIndexInfo[WC_CITY_INDEX]);
  2214. }
  2215. #endif /* __MMI_TOUCH_SCREEN__ */
  2216. #endif /* __MMI_WC_TZ_SUPPORT__ */ 
  2217. #endif /* __MMI_TOUCH_SCREEN__ */ 
  2218. #ifndef __MMI_WC_TZ_SUPPORT__
  2219. #ifdef __MMI_DRAW_MANAGER__
  2220. #include "wgui_draw_manager.h"
  2221. /*****************************************************************************
  2222.  * FUNCTION
  2223.  *  WcScreenDrawCallBack
  2224.  * DESCRIPTION
  2225.  *  
  2226.  * PARAMETERS
  2227.  *  coordinate      [?]     
  2228.  * RETURNS
  2229.  *  void
  2230.  *****************************************************************************/
  2231. void WcScreenDrawCallBack(dm_coordinates *coordinate)
  2232. {
  2233.     /*----------------------------------------------------------------*/
  2234.     /* Local Variables                                                */
  2235.     /*----------------------------------------------------------------*/
  2236.     /*----------------------------------------------------------------*/
  2237.     /* Code Body                                                      */
  2238.     /*----------------------------------------------------------------*/
  2239.     WcRedrawWorldClock(0, UI_device_height);
  2240. }
  2241. /*****************************************************************************
  2242.  * FUNCTION
  2243.  *  WcShowCategory
  2244.  * DESCRIPTION
  2245.  *  
  2246.  * PARAMETERS
  2247.  *  void
  2248.  * RETURNS
  2249.  *  void
  2250.  *****************************************************************************/
  2251. void WcShowCategory(void)
  2252. {
  2253.     /*----------------------------------------------------------------*/
  2254.     /* Local Variables                                                */
  2255.     /*----------------------------------------------------------------*/
  2256.     dm_data_struct dm_data;
  2257.     /*----------------------------------------------------------------*/
  2258.     /* Code Body                                                      */
  2259.     /*----------------------------------------------------------------*/
  2260.     SetupCategoryKeyHandlers();
  2261.     dm_register_category_controlled_callback(WcScreenDrawCallBack);
  2262. #ifdef __MMI_TOUCH_SCREEN__
  2263.     wgui_register_category_screen_control_area_pen_handlers(WcPenDownHandler, MMI_PEN_EVENT_DOWN);
  2264.     wgui_register_category_screen_control_area_pen_handlers(WcPenUpHandler, MMI_PEN_EVENT_UP);
  2265.     wgui_register_category_screen_control_area_pen_handlers(WcPenRepeatHandler, MMI_PEN_EVENT_REPEAT);
  2266.     wgui_register_category_screen_control_area_pen_handlers(WcPenMoveHandler, MMI_PEN_EVENT_MOVE);
  2267. #endif /* __MMI_TOUCH_SCREEN__ */ 
  2268.     dm_data.s32CatId = MMI_CATEGORY_WCLOCK;
  2269.     dm_data.s32ScrId = GetActiveScreenId();
  2270.     dm_data.s32flags = DM_CLEAR_SCREEN_BACKGROUND;
  2271.     dm_setup_data(&dm_data);
  2272.     dm_redraw_category_screen();
  2273. }
  2274. #endif /* __MMI_DRAW_MANAGER__ */ 
  2275. #endif /* __MMI_WC_TZ_SUPPORT__ */ 
  2276. #define WC_SUBLCD_DISPLAY
  2277. #if defined(__MMI_WORLD_CLOCK_SUBLCD_SETTING__)
  2278. /*****************************************************************************
  2279.  * FUNCTION
  2280.  *  EntryWcApp
  2281.  * DESCRIPTION
  2282.  *  Entry function of world clock application.
  2283.  * PARAMETERS
  2284.  *  void
  2285.  * RETURNS
  2286.  *  void
  2287.  *****************************************************************************/
  2288. void EntryWcApp(void)
  2289. {
  2290.     /*----------------------------------------------------------------*/
  2291.     /* Local Variables                                                */
  2292.     /*----------------------------------------------------------------*/
  2293.     U16 WC_list_of_items[2];
  2294.     S32 num_of_items;
  2295.     U8 *guiBuffer;
  2296.     /*----------------------------------------------------------------*/
  2297.     /* Code Body                                                      */
  2298.     /*----------------------------------------------------------------*/
  2299.     EntryNewScreen(SCR_ID_WC_APP, NULL, EntryWcApp, NULL);
  2300.     guiBuffer = GetCurrGuiBuffer(SCR_ID_WC_APP);
  2301.     num_of_items = GetNumOfChild(ORGANIZER_WORLDCLOCK_MENU);
  2302.     GetSequenceStringIds(ORGANIZER_WORLDCLOCK_MENU, WC_list_of_items);
  2303.     SetParentHandler(ORGANIZER_WORLDCLOCK_MENU);
  2304.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  2305.     ShowCategory15Screen(
  2306.         STR_WORLD_CLOCK_TITLE,
  2307.         GetRootTitleIcon(ORGANIZER_WORLDCLOCK_MENU),
  2308.         STR_GLOBAL_OK,
  2309.         0,
  2310.         STR_GLOBAL_BACK,
  2311.         0,
  2312.         num_of_items,
  2313.         WC_list_of_items,
  2314.         (U16*) gIndexIconsImageList,
  2315.         LIST_MENU,
  2316.         0,
  2317.         guiBuffer);
  2318.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2319.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  2320. }
  2321. /*****************************************************************************
  2322.  * FUNCTION
  2323.  *  WcGetNearbyCityNameIndex
  2324.  * DESCRIPTION
  2325.  *  Get the index of near by city.
  2326.  * PARAMETERS
  2327.  *  inp     [IN]        First character of city name.
  2328.  * RETURNS
  2329.  *  index of nearest city.
  2330.  *****************************************************************************/
  2331. U8 WcGetNearbyCityNameIndex(UI_character_type inp)
  2332. {
  2333.     /*----------------------------------------------------------------*/
  2334.     /* Local Variables                                                */
  2335.     /*----------------------------------------------------------------*/
  2336.     S32 i;
  2337.     U16 n1 = 0;
  2338.     U8 num_city = NUMBER_OF_CITY;
  2339.     /*----------------------------------------------------------------*/
  2340.     /* Code Body                                                      */
  2341.     /*----------------------------------------------------------------*/
  2342.     for (i = 1; (i < (num_city)); i++)
  2343.     {
  2344.         memcpy(&n1, subMenuDataPtrs[i], ENCODING_LENGTH);
  2345.         if (n1 >= inp)
  2346.         {
  2347.             return (U8) (i - 1);
  2348.         }
  2349.     }
  2350.     return 255;
  2351. }
  2352. /*****************************************************************************
  2353.  * FUNCTION
  2354.  *  WcMultitapInputCallBack
  2355.  * DESCRIPTION
  2356.  *  Call back function when input some characters in the screen.
  2357.  * PARAMETERS
  2358.  *  inp     [IN]        Input character
  2359.  * RETURNS
  2360.  *  void
  2361.  *****************************************************************************/
  2362. void WcMultitapInputCallBack(UI_character_type inp)
  2363. {
  2364.     /*----------------------------------------------------------------*/
  2365.     /* Local Variables                                                */
  2366.     /*----------------------------------------------------------------*/
  2367.     /*----------------------------------------------------------------*/
  2368.     /* Code Body                                                      */
  2369.     /*----------------------------------------------------------------*/
  2370.     g_wc_cntx.CurrHiliteCity = WcGetNearbyCityNameIndex(inp) + 1;
  2371.     fixed_list_goto_item(g_wc_cntx.CurrHiliteCity);
  2372. }
  2373. /*****************************************************************************
  2374.  * FUNCTION
  2375.  *  WcMultitapCompleteCallBack
  2376.  * DESCRIPTION
  2377.  *  Call back function when multi-tap opeartion finished.
  2378.  * PARAMETERS
  2379.  *  void
  2380.  * RETURNS
  2381.  *  void
  2382.  *****************************************************************************/
  2383. void WcMultitapCompleteCallBack(void)
  2384. {
  2385.     /*----------------------------------------------------------------*/
  2386.     /* Local Variables                                                */
  2387.     /*----------------------------------------------------------------*/
  2388.     /*----------------------------------------------------------------*/
  2389.     /* Code Body                                                      */
  2390.     /*----------------------------------------------------------------*/
  2391.     fixed_list_goto_item(g_wc_cntx.CurrHiliteCity);
  2392. }
  2393. /*****************************************************************************
  2394.  * FUNCTION
  2395.  *  HighlightWcSubLcd
  2396.  * DESCRIPTION
  2397.  *  Highlight handler of Sub Lcd Display menu
  2398.  * PARAMETERS
  2399.  *  void
  2400.  * RETURNS
  2401.  *  void
  2402.  *****************************************************************************/
  2403. void HighlightWcSubLcd(void)
  2404. {
  2405.     /*----------------------------------------------------------------*/
  2406.     /* Local Variables                                                */
  2407.     /*----------------------------------------------------------------*/
  2408.     /*----------------------------------------------------------------*/
  2409.     /* Code Body                                                      */
  2410.     /*----------------------------------------------------------------*/
  2411.     SetLeftSoftkeyFunction(EntryWcSubLcd, KEY_EVENT_UP);
  2412. }
  2413. /*****************************************************************************
  2414.  * FUNCTION
  2415.  *  WcSaveSubLcdSetting
  2416.  * DESCRIPTION
  2417.  *  Save selected city to cache.
  2418.  * PARAMETERS
  2419.  *  void
  2420.  * RETURNS
  2421.  *  void
  2422.  *****************************************************************************/
  2423. void WcSaveSubLcdSetting(void)
  2424. {
  2425.     /*----------------------------------------------------------------*/
  2426.     /* Local Variables                                                */
  2427.     /*----------------------------------------------------------------*/
  2428.     S16 error;
  2429.     /*----------------------------------------------------------------*/
  2430.     /* Code Body                                                      */
  2431.     /*----------------------------------------------------------------*/
  2432.     if (g_wc_cntx.CurrHiliteSublcd == 0)
  2433.     {
  2434.         WriteValue(NVRAM_DOWNLOAD_CITY1, &g_wc_cntx.CurrHiliteCity, DS_BYTE, &error);   /* homecity */
  2435.     }
  2436.     else
  2437.     {
  2438.         WriteValue(NVRAM_DOWNLOAD_CITY2, &g_wc_cntx.CurrHiliteCity, DS_BYTE, &error);
  2439.     }
  2440.     SubLCDIdleScreen();
  2441.     DisplayPopup((U8*) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 0, UI_POPUP_NOTIFYDURATION_TIME, SAVE_TONE);
  2442. }
  2443. /*****************************************************************************
  2444.  * FUNCTION
  2445.  *  HighlightWcSubLcdCity
  2446.  * DESCRIPTION
  2447.  *  Highlight handler of sub-lcd display city list.
  2448.  * PARAMETERS
  2449.  *  index       [IN]        Index of selected item.
  2450.  * RETURNS
  2451.  *  void
  2452.  *****************************************************************************/
  2453. void HighlightWcSubLcdCity(S32 index)
  2454. {
  2455.     /*----------------------------------------------------------------*/
  2456.     /* Local Variables                                                */
  2457.     /*----------------------------------------------------------------*/
  2458.     /*----------------------------------------------------------------*/
  2459.     /* Code Body                                                      */
  2460.     /*----------------------------------------------------------------*/
  2461.     g_wc_cntx.CurrHiliteCity = (U8) index;
  2462. }
  2463. /*****************************************************************************
  2464.  * FUNCTION
  2465.  *  EntryWcSelectCity
  2466.  * DESCRIPTION
  2467.  *  Display list of cities
  2468.  * PARAMETERS
  2469.  *  void
  2470.  * RETURNS
  2471.  *  void
  2472.  *****************************************************************************/
  2473. void EntryWcSelectCity(void)
  2474. {
  2475.     /*----------------------------------------------------------------*/
  2476.     /* Local Variables                                                */
  2477.     /*----------------------------------------------------------------*/
  2478.     S32 i;
  2479.     U8 index;
  2480.     U8 num_city = NUMBER_OF_CITY;
  2481.     /*----------------------------------------------------------------*/
  2482.     /* Code Body                                                      */
  2483.     /*----------------------------------------------------------------*/
  2484.     EntryNewScreen(SCR_ID_WC_OPTIONS, NULL, EntryWcSelectCity, NULL);
  2485.     for (i = 0; i < num_city; i++)
  2486.     {
  2487.         pfnUnicodeStrcpy((S8*) subMenuDataPtrs[i], (S8*) GetString(TimeZoneData[i].CityName));
  2488.     }
  2489.     if (g_wc_cntx.CurrHiliteSublcd == 0)
  2490.     {
  2491.         index = g_wc_cntx.City1;
  2492.     }
  2493.     else
  2494.     {
  2495.         index = g_wc_cntx.City2;
  2496.     }
  2497.     RegisterHighlightHandler(HighlightWcSubLcdCity);
  2498.     ShowCategory6Screen(
  2499.         STR_WORLD_SELECT_CITY,
  2500.         GetRootTitleIcon(ORGANIZER_WORLDCLOCK_MENU),
  2501.         STR_GLOBAL_OK,
  2502.         IMG_GLOBAL_OK,
  2503.         STR_GLOBAL_BACK,
  2504.         IMG_GLOBAL_BACK,
  2505.         num_city,
  2506.         subMenuDataPtrs,
  2507.         index,
  2508.         NULL);
  2509.     if (!IsChineseSet())
  2510.     {
  2511.         set_numberless_multitap();
  2512.         register_multitap_no_draw_key_handlers();
  2513.         set_multitap_functions(WcMultitapInputCallBack, WcMultitapCompleteCallBack);
  2514.         change_multitap_mode(0);
  2515.     }
  2516.     SetLeftSoftkeyFunction(WcSaveSubLcdSetting, KEY_EVENT_UP);
  2517.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2518.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  2519. }
  2520. /*****************************************************************************
  2521.  * FUNCTION
  2522.  *  WcHintCity1
  2523.  * DESCRIPTION
  2524.  *  Hint handler of city 1.
  2525.  * PARAMETERS
  2526.  *  index       [IN]        
  2527.  * RETURNS
  2528.  *  void
  2529.  *****************************************************************************/
  2530. void WcHintCity1(U16 index)
  2531. {
  2532.     /*----------------------------------------------------------------*/
  2533.     /* Local Variables                                                */
  2534.     /*----------------------------------------------------------------*/
  2535.     S16 error;
  2536.     /*----------------------------------------------------------------*/
  2537.     /* Code Body                                                      */
  2538.     /*----------------------------------------------------------------*/
  2539.     ReadValue(NVRAM_DOWNLOAD_CITY1, &g_wc_cntx.City1, DS_BYTE, &error); /* homecity */
  2540.     if (g_wc_cntx.City1 == 0xff)    /* not written anything in NVRAM */
  2541.     {
  2542.         g_wc_cntx.City1 = PhnsetGetHomeCity() + 1;
  2543.         WriteValue(NVRAM_DOWNLOAD_CITY1, &g_wc_cntx.City1, DS_BYTE, &error);    /* homecity */
  2544.     }
  2545.     pfnUnicodeStrncpy(
  2546.         (S8*) hintData[index],
  2547.         (S8*) GetString(TimeZoneData[g_wc_cntx.City1].CityName),
  2548.         MAX_SUBMENU_CHARACTERS);
  2549. }
  2550. /*****************************************************************************
  2551.  * FUNCTION
  2552.  *  WcHintCity2
  2553.  * DESCRIPTION
  2554.  *  Hint handler of city 2.
  2555.  * PARAMETERS
  2556.  *  index       [IN]        
  2557.  * RETURNS
  2558.  *  void
  2559.  *****************************************************************************/
  2560. void WcHintCity2(U16 index)
  2561. {
  2562.     /*----------------------------------------------------------------*/
  2563.     /* Local Variables                                                */
  2564.     /*----------------------------------------------------------------*/
  2565.     S16 error;
  2566.     /*----------------------------------------------------------------*/
  2567.     /* Code Body                                                      */
  2568.     /*----------------------------------------------------------------*/
  2569.     ReadValue(NVRAM_DOWNLOAD_CITY2, &g_wc_cntx.City2, DS_BYTE, &error);
  2570.     if (g_wc_cntx.City2 == 0xff)
  2571.     {
  2572.         g_wc_cntx.City2 = 0;
  2573.         WriteValue(NVRAM_DOWNLOAD_CITY2, &g_wc_cntx.City2, DS_BYTE, &error);    /* none */
  2574.     }
  2575.     pfnUnicodeStrncpy(
  2576.         (S8*) hintData[index],
  2577.         (S8*) GetString(TimeZoneData[g_wc_cntx.City2].CityName),
  2578.         MAX_SUBMENU_CHARACTERS);
  2579. }
  2580. /*****************************************************************************
  2581.  * FUNCTION
  2582.  *  HighlightWcSubLcdMenu
  2583.  * DESCRIPTION
  2584.  *  Highlight handler of Sub-Lcd menu.
  2585.  * PARAMETERS
  2586.  *  nIndex      [IN]        Index of item.
  2587.  * RETURNS
  2588.  *  void
  2589.  *****************************************************************************/
  2590. void HighlightWcSubLcdMenu(S32 nIndex)
  2591. {
  2592.     /*----------------------------------------------------------------*/
  2593.     /* Local Variables                                                */
  2594.     /*----------------------------------------------------------------*/
  2595.     /*----------------------------------------------------------------*/
  2596.     /* Code Body                                                      */
  2597.     /*----------------------------------------------------------------*/
  2598.     g_wc_cntx.CurrHiliteSublcd = (U8) nIndex;
  2599. }
  2600. /*****************************************************************************
  2601.  * FUNCTION
  2602.  *  EntryWcSubLcd
  2603.  * DESCRIPTION
  2604.  *  Entry function of Sub-LCD display
  2605.  * PARAMETERS
  2606.  *  void
  2607.  *  nIndex(?)       [IN]        Index of item.
  2608.  * RETURNS
  2609.  *  void
  2610.  *****************************************************************************/
  2611. void EntryWcSubLcd(void)
  2612. {
  2613.     /*----------------------------------------------------------------*/
  2614.     /* Local Variables                                                */
  2615.     /*----------------------------------------------------------------*/
  2616.     S32 num_of_items;
  2617.     U16 cityarray[2];
  2618.     U8 *guiBuffer;
  2619.     U8 *u8WorldClockPop[2];
  2620.     /*----------------------------------------------------------------*/
  2621.     /* Code Body                                                      */
  2622.     /*----------------------------------------------------------------*/
  2623.     EntryNewScreen(SCR_ID_WC_SUBLCD, NULL, EntryWcSubLcd, NULL);
  2624.     guiBuffer = GetCurrGuiBuffer(SCR_ID_WC_SUBLCD);
  2625.     num_of_items = GetNumOfChild(MITEM_WORLDCLOCK_SUBLCDDISPLAY);
  2626.     GetSequenceStringIds(MITEM_WORLDCLOCK_SUBLCDDISPLAY, cityarray);
  2627.     SetParentHandler(MITEM_WORLDCLOCK_SUBLCDDISPLAY);
  2628.     RegisterHighlightHandler(HighlightWcSubLcdMenu);
  2629.     ConstructHintsList(MITEM_WORLDCLOCK_SUBLCDDISPLAY, u8WorldClockPop);
  2630.     ShowCategory52Screen(
  2631.         STR_WORLD_CLOCK_MENU2,
  2632.         GetRootTitleIcon(ORGANIZER_WORLDCLOCK_MENU),
  2633.         STR_GLOBAL_OPTIONS,
  2634.         0,
  2635.         STR_GLOBAL_BACK,
  2636.         0,
  2637.         num_of_items,
  2638.         cityarray,
  2639.         (U16*) gIndexIconsImageList,
  2640.         u8WorldClockPop,
  2641.         0,
  2642.         0,
  2643.         guiBuffer);
  2644.     SetLeftSoftkeyFunction(EntryWcSelectCity, KEY_EVENT_UP);
  2645.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2646. }
  2647. #endif /* defined(__MMI_WORLD_CLOCK_SUBLCD_SETTING__) */ // #if defined(__MMI_WORLD_CLOCK_SUBLCD_SETTING__)
  2648. #endif /* __MMI_WORLD_CLOCK__ */ // #ifdef __MMI_WORLD_CLOCK__
  2649. /* MTK end */
  2650. /*****************************************************************************
  2651. * FUNCTION
  2652. * mmi_wc_is_dst
  2653. * DESCRIPTION
  2654. *   function to get if daylight saving is enabled in MMI
  2655. * PARAMETERS
  2656. * None.
  2657. * RETURNS
  2658. * None
  2659. * GLOBALS AFFECTED
  2660. * None.
  2661. *****************************************************************************/
  2662. void mmi_wc_is_dst(void)
  2663. {
  2664. S16 error;
  2665. ReadValue(NVRAM_SETTING_DT_DST, &g_dst, DS_BYTE, &error);
  2666. }
  2667. #endif /* _MMI_WORLDCLOCK_C */ // #ifndef _MMI_WORLDCLOCK_C