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

MTK

开发平台:

C/C++

  1. /*******************************************************************************
  2. *  Modification Notice:
  3. *  --------------------------
  4. *  This software is modified by MediaTek Inc. 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.  * Filename:
  37.  * ---------
  38.  *   wgui_calendar.c
  39.  *
  40.  * Project:
  41.  * --------
  42.  *   Maui_Software
  43.  *
  44.  * Description:
  45.  * ------------
  46.  *  calendar related funtions
  47.  *
  48.  * Author:
  49.  * -------
  50.  * -------
  51.  *
  52.  *------------------------------------------------------------------------------
  53.  * $Log$
  54.  *
  55.  * removed!
  56.  * removed!
  57.  * 
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * 
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * 
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * 
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * 
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * 
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * 
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * 
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * 
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * 
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * 
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * 
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * 
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * 
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * 
  114.  *
  115.  * removed!
  116.  * removed!
  117.  * 
  118.  *
  119.  * removed!
  120.  * removed!
  121.  * 
  122.  *
  123.  * removed!
  124.  * removed!
  125.  * 
  126.  *
  127.  * removed!
  128.  * removed!
  129.  * Go to 1970/1/1 or 2030/12/31 when highlighted date is out of the boundary.
  130.  *
  131.  * removed!
  132.  * removed!
  133.  * 
  134.  *
  135.  * removed!
  136.  * removed!
  137.  * 
  138.  *
  139.  * removed!
  140.  * removed!
  141.  * 
  142.  *
  143.  * removed!
  144.  * removed!
  145.  * 
  146.  *
  147.  * removed!
  148.  * removed!
  149.  * 
  150.  *
  151.  * removed!
  152.  * removed!
  153.  * 
  154.  *
  155.  * removed!
  156.  * removed!
  157.  * 
  158.  *
  159.  * removed!
  160.  * removed!
  161.  * Modified right arrow key blt region
  162.  *
  163.  * removed!
  164.  * removed!
  165.  * 
  166.  *
  167.  * removed!
  168.  * removed!
  169.  * 
  170.  *
  171.  * removed!
  172.  * removed!
  173.  * 
  174.  *
  175.  * removed!
  176.  * removed!
  177.  * 
  178.  *
  179.  */
  180. /**********************************************************************************
  181.    Filename:      wgui_calendar.c
  182.    Author:        manju
  183.    Date Created:  July-07-2003
  184.    Contains:      Contains the calendar control wrappers and category screens
  185. **********************************************************************************/
  186. /* Wrappers functions for use by category screens and applications   */
  187. #include "GlobalDefs.h"
  188. #include "CustDataRes.h"
  189. #include "CustDataProts.h"
  190. #include "gui_themes.h"
  191. #include "wgui_categories.h"
  192. #include "wgui_status_icons.h"
  193. #include "wgui_softkeys.h"
  194. #include "wgui_calendar.h"
  195. #include "MMI_features.h"
  196. #include "DebugInitDef.h"
  197. #include "wgui_draw_manager.h"
  198. #include "DateTimeGprot.h"
  199. #include "DateTimeType.h"
  200. #include "wgui_categories_defs.h"
  201. #include "wgui_softkeys.h"
  202. #include "wgui_categories_defs.h"
  203. #include "CalendarDef.h"        /* Calendar image */
  204. #include "CalendarProt.h"
  205. #if(ENABLE_CALENDAR_CONTROL)
  206. #ifdef __MMI_TOUCH_SCREEN__
  207. static S32 calendar_arrow_width, calendar_arrow_height;
  208. #endif 
  209. #define CALENDAR_FULL_SCREEN_BACKGROUND      1
  210. #define CALENDAR_BORDERED_TITLES       1
  211. /* Calendar popup widht */
  212. #define CALENDAR_POPUP_WIDTH           100      /* Maximum width allowed for calendar pop up                            */
  213. /* Calendar popup height */
  214. #define CALENDAR_POPUP_HEIGHT          100      /* Maximum height allowed for calendar pop up                              */
  215. /* start x position of calendar popup */
  216. #define CALENDAR_POPUP_X               1        /* If using Fixed position, (x,y) are relative / absolute values to screen corners  */
  217. /* start y position of calendar popup */
  218. #define CALENDAR_POPUP_Y               0        /* Otherwise, (x,y) are relative to the highlighted day on calendar           */
  219. #define CALENDAR_POPUP_FIXED_POSITION     0     /* 1:Show at fixed location (fixed with respect to screen corners)               */
  220. #define CALENDAR_POPUP_FIXED_RIGHT        0     /* 1:Show to right side of screen, 0:Show to left side                        */
  221. #define CALENDAR_POPUP_FIXED_BOTTOM       0     /* 1:Show to bottom of screen, 0:Show from top of screen                   */
  222. /* popup time duration */
  223. #define CALENDAR_POPUP_WAIT_TIME       2000     /* Milliseconds before the pop up is displayed after highlighting a day       */
  224. /* External Global variables and funtion declaration */
  225. extern S32 UI_get_font_height(UI_font_type f);
  226. extern BOOL r2lMMIFlag;
  227. extern pBOOL IsChineseSet(void);
  228. extern U8 matrix_main_menu_highlight_bitmap_data[];
  229. extern icontext_button MMI_softkeys[];
  230. /* global variable of calendar_control */
  231. calendar_control MMI_calendar_control;
  232. /* store monthly days */
  233. U8 MMI_calendar_days[MAX_CALENDAR_DAYS];
  234. /* store hightlighted day */
  235. S32 MMI_calendar_highlighted_day = -1;
  236. /* Lunar calendar specific title display  */
  237. U8 *Cat82_title1;
  238. U8 *Cat82_title2;
  239. U8 *Cat82_title3;
  240. #ifdef __MMI_UI_CALENDAR_WITH_INFO_BOX__
  241. U8 *Cat82_title1_month;
  242. #ifdef __MMI_TOUCH_SCREEN__
  243. BOOL Cat82_title1_arrow_disable = MMI_FALSE;
  244. BOOL Cat82_title1_month_arrow_disable = MMI_FALSE;
  245. #endif /* __MMI_TOUCH_SCREEN__ */ 
  246. #endif /* __MMI_UI_CALENDAR_WITH_INFO_BOX__ */ 
  247. U8 MMI_calendar_title_string[CLNDR_TITLE_LEN];
  248. #ifdef __MMI_UI_CALENDAR_WITH_INFO_BOX__
  249. U8 MMI_calendar_title_string_month[CLNDR_TITLE_LEN];    /* get from getstring() so don't need buffer */
  250. #endif 
  251. S16 MMI_calendar_current_month = -1;
  252. S16 MMI_calendar_current_year = -1;
  253. BOOL lunar_calendar_present = MMI_FALSE;
  254. static void UI_dummy_function_s32s32s32(S32 day, S32 month, S32 year);
  255. static void (*MMI_calendar_control_update_handler) (S32 day, S32 month, S32 year) = UI_dummy_function_s32s32s32;
  256. /* a func pointer of calendar control highhlight handler */
  257. void (*MMI_calendar_control_highlight_handler) (S32 day) = UI_dummy_function_s32;
  258. /* global varibales of mesage for lunar calendar */
  259. U8 *MMI_calendar_messages1 = NULL;
  260. U8 *MMI_calendar_messages2 = NULL;
  261. U8 *MMI_calendar_messages3 = NULL;
  262. pBOOL calendar_show_title2 = 1;
  263. pBOOL calendar_show_title3 = 1;
  264. #ifdef __MMI_UI_CALENDAR_WITH_INFO_BOX__
  265. pBOOL calendar_show_title_month = 1;
  266. #endif 
  267. UI_font_type calendar_title_font;
  268. void SetCategory82Title1(U8 *title);
  269. #ifdef __MMI_UI_CALENDAR_WITH_INFO_BOX__
  270. void SetCategory82Title1Month(U8 *title);
  271. #endif 
  272. /* Category functions for calendar related screens    */
  273. S32 cat82_title1_x1;    /* start x position of lunar calendar title1 */
  274. S32 cat82_title1_y1;    /* start y position of lunar calendar title1 */
  275. S32 cat82_title1_x2;    /* end x position of lunar calendar title1 */
  276. S32 cat82_title1_y2;    /* end y  position of lunar calendar title1 */
  277. #ifdef __MMI_UI_CALENDAR_WITH_INFO_BOX__
  278. S32 cat82_title1_month_x1;  /* start x position of lunar calendar title1 month */
  279. S32 cat82_title1_month_y1;  /* start y position of lunar calendar title1 month */
  280. S32 cat82_title1_month_x2;  /* end x position of lunar calendar title1 month */
  281. S32 cat82_title1_month_y2;  /* end y  position of lunar calendar title1 month */
  282. UI_font_type calendar_title_month_font;
  283. #endif /* __MMI_UI_CALENDAR_WITH_INFO_BOX__ */ 
  284. S32 cat82_title2_x1;    /* start x position of lunar calendar title2 */
  285. S32 cat82_title2_y1;    /* start y position of lunar calendar title2 */
  286. S32 cat82_title2_x2;    /* end x position of lunar calendar title2 */
  287. S32 cat82_title2_y2;    /* end y position of lunar calendar title2 */
  288. S32 cat82_title3_x1;    /* start x position of lunar calendar title3 */
  289. S32 cat82_title3_y1;    /* start y position of lunar calendar title3 */
  290. S32 cat82_title3_x2;    /* end x position of lunar calendar title3 */
  291. S32 cat82_title3_y2;    /* end y  position of lunar calendar title 3 */
  292. /* global variable store the calendar bkg image */
  293. PU8 calendar_control_background_image = NULL;
  294. /* global variable store the calendar title image */
  295. PU8 calendar_control_title_image = NULL;
  296. /* global variable store strat y position of calndar bkg */
  297. S32 calendar_control_background_y1 = 0;
  298. /* global variable store end y position of calndar bkg */
  299. S32 calendar_control_background_y2 = 0;
  300. /* store calendar popup start x position */
  301. S32 *wgui_calendar_ppx1 = NULL;
  302. /* store calendar popup end x position */
  303. S32 *wgui_calendar_ppx2 = NULL;
  304. /* store calendar popup start y position */
  305. S32 *wgui_calendar_ppy1 = NULL;
  306. /* store calendar popup end y  position */
  307. S32 *wgui_calendar_ppy2 = NULL;
  308. /* current day */
  309. S32 wgui_calendar_pp_day = -1;
  310. /* Health calendar message1 */
  311. UI_string_type cat81_message1 = NULL;
  312. /* Health calendar message2 */
  313. UI_string_type cat81_message2 = NULL;
  314. /* Functions to setup the background image and display theme for the calendar */
  315. /* theme colr of calendar normal day */
  316. const UI_filled_area _calendar_normal_day_filler = {UI_FILLED_AREA_TYPE_NO_BACKGROUND,
  317.     NULL,
  318.     NULL,
  319.     {0, 0, 0, 0},
  320.     {0, 0, 0, 0},
  321.     {0, 0, 0, 0},
  322.     {0, 0, 0, 0},
  323.     0
  324. };
  325. /* theme color of calendar task day */
  326. const UI_filled_area _calendar_task_day_filler = {UI_FILLED_AREA_TYPE_NO_BACKGROUND | UI_FILLED_AREA_SINGLE_BORDER,
  327.     NULL,
  328.     NULL,
  329.     {0, 0, 0, 0},
  330.     {0, 0, 0, 0},
  331.     {255, 0, 0, 100},
  332.     {0, 0, 0, 0},
  333.     0
  334. };
  335. /* theme color of calendar selected  day */
  336. const UI_filled_area _calendar_selected_day_filler = {UI_FILLED_AREA_TYPE_COLOR,
  337.     NULL,
  338.     NULL,
  339.     {20, 124, 86, 100},
  340.     {0, 0, 0, 0},
  341.     {255, 0, 0, 100},
  342.     {0, 0, 0, 0},
  343.     0
  344. };
  345. /* theme color of calendar current  day */
  346. const UI_filled_area _calendar_current_day_filler = {UI_FILLED_AREA_TYPE_NO_BACKGROUND | UI_FILLED_AREA_SINGLE_BORDER,
  347.     NULL,
  348.     NULL,
  349.     {20, 124, 86, 100},
  350.     {0, 0, 0, 0},
  351.     {0, 192, 0, 100},
  352.     {0, 0, 0, 0},
  353.     0
  354. };
  355. /* special day theme color , Move to wgui_calendar.c */
  356. const UI_filled_area _calendar_special1_day_filler = {UI_FILLED_AREA_TYPE_COLOR | UI_FILLED_AREA_SINGLE_BORDER,
  357.     NULL,
  358.     NULL,
  359.     {255, 100, 100, 100},
  360.     {0, 0, 0, 0},
  361.     {255, 100, 100, 100},
  362.     {0, 0, 0, 0},
  363.     0
  364. };
  365. const UI_filled_area _calendar_special2_day_filler = {UI_FILLED_AREA_TYPE_COLOR | UI_FILLED_AREA_SINGLE_BORDER,
  366.     NULL,
  367.     NULL,
  368.     {255, 200, 100, 100},
  369.     {0, 0, 0, 0},
  370.     {255, 200, 100, 100},
  371.     {0, 0, 0, 0},
  372.     0
  373. };
  374. const UI_filled_area _calendar_special3_day_filler = {UI_FILLED_AREA_TYPE_COLOR | UI_FILLED_AREA_SINGLE_BORDER,
  375.     NULL,
  376.     NULL,
  377.     {255, 255, 100, 100},
  378.     {0, 0, 0, 0},
  379.     {255, 255, 100, 100},
  380.     {0, 0, 0, 0},
  381.     0
  382. };
  383. const UI_filled_area _calendar_special4_day_filler = {UI_FILLED_AREA_TYPE_COLOR | UI_FILLED_AREA_SINGLE_BORDER,
  384.     NULL,
  385.     NULL,
  386.     {205, 234, 180, 100},
  387.     {0, 0, 0, 0},
  388.     {151, 171, 160, 100},
  389.     {0, 0, 0, 0},
  390.     0
  391. };
  392. /* theme color of calendar  */
  393. calendar_theme _calendar_control_theme_data = 
  394. {
  395.     &MMI_small_font,
  396.     {0, 0, 0, 100},
  397.     {0, 0, 0, 100},
  398.     {0, 0, 0, 100},
  399.     {255, 255, 255, 100},
  400.     {200, 0, 0, 100},
  401.     {0, 128, 0, 100},
  402.     {0, 0, 0, 100},
  403.     {0, 0, 0, 100},
  404.     {0, 0, 0, 100},
  405.     {0, 0, 0, 100},
  406.     (UI_filled_area *)&_calendar_normal_day_filler,
  407.     (UI_filled_area *)&_calendar_normal_day_filler,
  408.     (UI_filled_area *)&_calendar_task_day_filler,
  409.     (UI_filled_area *)&_calendar_current_day_filler,
  410.     (UI_filled_area *)&_calendar_selected_day_filler,
  411.     (UI_filled_area *)&_calendar_normal_day_filler,
  412.     (UI_filled_area *)&_calendar_normal_day_filler,
  413.     (UI_filled_area *)&_calendar_special1_day_filler,
  414.     (UI_filled_area *)&_calendar_special2_day_filler,
  415.     (UI_filled_area *)&_calendar_special3_day_filler,
  416.     (UI_filled_area *)&_calendar_special4_day_filler,
  417. };
  418. /*****************************************************************************
  419.  * FUNCTION
  420.  *  UI_dummy_function_s32s32s32
  421.  * DESCRIPTION
  422.  *  
  423.  * PARAMETERS
  424.  *  day         [IN]        
  425.  *  month       [IN]        
  426.  *  year        [IN]        
  427.  * RETURNS
  428.  *  void
  429.  *****************************************************************************/
  430. void UI_dummy_function_s32s32s32(S32 day, S32 month, S32 year)
  431. {
  432.     /*----------------------------------------------------------------*/
  433.     /* Local Variables                                                */
  434.     /*----------------------------------------------------------------*/
  435.     /*----------------------------------------------------------------*/
  436.     /* Code Body                                                      */
  437.     /*----------------------------------------------------------------*/
  438.     UI_UNUSED_PARAMETER(day);
  439.     UI_UNUSED_PARAMETER(month);
  440.     UI_UNUSED_PARAMETER(year);
  441. }
  442. #ifdef __MMI_UI_DALMATIAN_CALENDAR__
  443. /* PMT VIKAS START 20051217 */
  444. #if ( defined (__MMI_MAINLCD_128X128__) || defined (__MMI_MAINLCD_128X160__) )
  445. #define DALMATIAN_CALENDAR_WEEK_IMAGE_START 2
  446. #elif defined( __MMI_MAINLCD_176X220__) || defined(__MMI_MAINLCD_240X320__)
  447. #define DALMATIAN_CALENDAR_WEEK_IMAGE_START 4
  448. #endif 
  449. /* PMT VIKAS END 20051217 */
  450. static S32 gdalmatian_current_month = 0;
  451. static S32 gdalmatian_current_year = 0;
  452. static S32 gdalmatian_current_day = 0;
  453. static S32 gdalmatian_week_num = 1;
  454. static S32 gdalmatian_calendar_highlighter = 1;
  455. wgui_dalmatian_calendar_highlighter_styles dalmatian_calendar_highlighter_style =
  456.     DALMATIAN_CALENDAR_HIGHLIGHTER_MOVE_WITH_SELECT;
  457. UI_filled_area *backup_selected_day_filler;
  458. UI_filled_area image_box_selected_day_filler;
  459. typedef struct _calendar_highlighter
  460. {
  461.     color horizontal;
  462.     color vertical;
  463. } calendar_highlighter;
  464. typedef struct _calendar_highlighter_box
  465. {
  466.     color box_color;
  467. } calendar_highlighter_box;
  468. /* Use diff structure for make seperation easy if required i.e. if border is not required */
  469. typedef struct _calendar_highlighter_box_border
  470. {
  471.     color box_border_color;
  472. } calendar_highlighter_box_border;
  473. calendar_highlighter color_opacity_lookup_Table_calendar_highlighter[] = 
  474. {
  475.     {{51, 126, 184, 50}, {141, 165, 186, 60}},
  476.     {{253, 72, 53, 50}, {253, 113, 113, 60}},
  477.     {{253, 146, 60, 50}, {251, 209, 82, 60}},
  478.     {{156, 93, 51, 50}, {253, 212, 143, 60}},
  479.     {{251, 216, 51, 50}, {248, 183, 8, 60}},
  480.     {{153, 209, 56, 50}, {220, 252, 2, 60}},
  481.     {{95, 184, 51, 50}, {171, 249, 36, 60}},
  482.     {{54, 233, 253, 50}, {80, 198, 247, 60}},
  483.     {{251, 154, 184, 50}, {253, 52, 114, 60}},
  484.     {{160, 125, 204, 50}, {177, 78, 188, 60}},
  485.     {{160, 56, 81, 50}, {215, 65, 100, 60}},
  486.     {{51, 126, 184, 50}, {141, 165, 186, 60}}
  487. };
  488. calendar_highlighter_box color_opacity_lookup_Table_calendar_highlighter_box[] = 
  489. {
  490.     {128, 128, 128, 100},
  491.     {214, 4, 4, 100},
  492.     {252, 154, 13, 100},
  493.     {132, 54, 3, 100},
  494.     {250, 119, 3, 100},
  495.     {92, 143, 4, 100},
  496.     {108, 174, 5, 100},
  497.     {4, 120, 169, 100},
  498.     {200, 4, 64, 100},
  499.     {173, 86, 247, 100},
  500.     {205, 25, 63, 100},
  501.     {128, 128, 128, 100}
  502. };
  503. calendar_highlighter_box_border color_opacity_lookup_Table_calendar_highlighter_box_border[] = 
  504. {
  505.     {1, 6, 0, 100},
  506.     {3, 0, 0, 100},
  507.     {168, 69, 3, 100},
  508.     {1, 6, 0, 100},
  509.     {90, 28, 1, 100},
  510.     {1, 6, 0, 100},
  511.     {11, 53, 2, 100},
  512.     {2, 46, 90, 100},
  513.     {102, 4, 50, 100},
  514.     {37, 3, 51, 100},
  515.     {90, 28, 1, 100},
  516.     {1, 6, 0, 100}
  517. };
  518. /*****************************************************************************
  519.  * FUNCTION
  520.  *  wgui_read_calendar_highlighter_horizontal_color
  521.  * DESCRIPTION
  522.  *  Returns the highlighter color of horizontal bar
  523.  * PARAMETERS
  524.  *  month       [IN]        
  525.  * RETURNS
  526.  *  color
  527.  *****************************************************************************/
  528. color wgui_read_calendar_highlighter_horizontal_color(S32 month)
  529. {
  530.     /*----------------------------------------------------------------*/
  531.     /* Local Variables                                                */
  532.     /*----------------------------------------------------------------*/
  533.     /*----------------------------------------------------------------*/
  534.     /* Code Body                                                      */
  535.     /*----------------------------------------------------------------*/
  536.     return color_opacity_lookup_Table_calendar_highlighter[month].horizontal;
  537. }
  538. /*****************************************************************************
  539.  * FUNCTION
  540.  *  wgui_read_calendar_highlighter_vertical_color
  541.  * DESCRIPTION
  542.  *  Returns the highlighter color of vertical bar
  543.  * PARAMETERS
  544.  *  month       [IN]        
  545.  * RETURNS
  546.  *  color
  547.  *****************************************************************************/
  548. color wgui_read_calendar_highlighter_vertical_color(S32 month)
  549. {
  550.     /*----------------------------------------------------------------*/
  551.     /* Local Variables                                                */
  552.     /*----------------------------------------------------------------*/
  553.     /*----------------------------------------------------------------*/
  554.     /* Code Body                                                      */
  555.     /*----------------------------------------------------------------*/
  556.     return color_opacity_lookup_Table_calendar_highlighter[month].vertical;
  557. }
  558. /*****************************************************************************
  559.  * FUNCTION
  560.  *  set_current_month_year_for_dalmatian
  561.  * DESCRIPTION
  562.  *  Set the globel values for the current date
  563.  * PARAMETERS
  564.  *  current_day         [IN]        S32 current_month S32 current_year
  565.  *  current_month       [IN]        
  566.  *  current_year        [IN]        
  567.  * RETURNS
  568.  *  void
  569.  *****************************************************************************/
  570. void set_current_month_year_for_dalmatian(S32 current_day, S32 current_month, S32 current_year)
  571. {
  572.     /*----------------------------------------------------------------*/
  573.     /* Local Variables                                                */
  574.     /*----------------------------------------------------------------*/
  575.     /*----------------------------------------------------------------*/
  576.     /* Code Body                                                      */
  577.     /*----------------------------------------------------------------*/
  578.     gdalmatian_current_day = current_day;
  579.     gdalmatian_current_month = current_month;
  580.     gdalmatian_current_year = current_year;
  581. }
  582. /*****************************************************************************
  583.  * FUNCTION
  584.  *  draw_current_week_highlighter
  585.  * DESCRIPTION
  586.  *  Draw the week highlighter for current date
  587.  * PARAMETERS
  588.  *  c       [IN]        
  589.  * RETURNS
  590.  *  void
  591.  *****************************************************************************/
  592. void draw_current_week_highlighter(calendar_control *c)
  593. {
  594.     /*----------------------------------------------------------------*/
  595.     /* Local Variables                                                */
  596.     /*----------------------------------------------------------------*/
  597.     S32 x1, x2, y1, y2;
  598.     S32 cell_width = c->cell_width;
  599.     S32 cell_height = c->cell_height;
  600.     S32 n_rows = c->n_rows;
  601.     S32 n_columns = c->n_columns;
  602.     /*----------------------------------------------------------------*/
  603.     /* Code Body                                                      */
  604.     /*----------------------------------------------------------------*/
  605.     if (MMI_calendar_current_month == gdalmatian_current_month && MMI_calendar_current_year == gdalmatian_current_year)
  606.     {
  607.         get_current_date_highlighter_coordinates(&MMI_calendar_control, &x1, &y1);
  608.         x2 = x1 + cell_width;
  609.         y2 = y1 + cell_height - 1;
  610.         /* PMT VIKAS START 20051217 */
  611.     #ifdef __MMI_UI_TRANSPARENT_EFFECT_IN_DALMATIAN_CALENDAR__
  612.         /* PMT VIKAS END 20051217 */
  613.         gui_transparent_color_filler(
  614.             x1 - 1,
  615.             c->y,
  616.             x2,
  617.             c->y2,
  618.             wgui_read_calendar_highlighter_vertical_color(MMI_calendar_current_month - 1));
  619.         gui_transparent_color_filler(
  620.             c->x + 1,
  621.             y1 + 1,
  622.             c->x + ((cell_width) * n_columns) - 1,
  623.             y2 + 1,
  624.             wgui_read_calendar_highlighter_horizontal_color(MMI_calendar_current_month - 1));
  625.     #else /* __MMI_UI_TRANSPARENT_EFFECT_IN_DALMATIAN_CALENDAR__ */ 
  626.         gui_draw_rectangle(
  627.             x1 - 1,
  628.             c->y,
  629.             x2,
  630.             c->y2,
  631.             wgui_read_calendar_highlighter_vertical_color(MMI_calendar_current_month - 1));
  632.         gui_draw_rectangle(
  633.             c->x + 1,
  634.             y1 + 1,
  635.             c->x + ((cell_width) * n_columns) - 1,
  636.             y2 + 1,
  637.             wgui_read_calendar_highlighter_horizontal_color(MMI_calendar_current_month - 1));
  638.     #endif /* __MMI_UI_TRANSPARENT_EFFECT_IN_DALMATIAN_CALENDAR__ */ 
  639.         /* For current date reselection. */
  640.         gui_draw_rectangle(x1, y1 + 1, x2 - 1, y2 + 1, MMI_calendar_control.theme->current_day_filler->c);
  641.         return;
  642.     }
  643. }
  644. /*****************************************************************************
  645.  * FUNCTION
  646.  *  get_current_date_highlighter_coordinates
  647.  * DESCRIPTION
  648.  *  Return the date highlighter coordinates
  649.  * PARAMETERS
  650.  *  c       [IN]        
  651.  *  x       [OUT]       
  652.  *  y       [OUT]       
  653.  * RETURNS
  654.  *  void
  655.  *****************************************************************************/
  656. void get_current_date_highlighter_coordinates(calendar_control *c, S32 *x, S32 *y)
  657. {
  658.     /*----------------------------------------------------------------*/
  659.     /* Local Variables                                                */
  660.     /*----------------------------------------------------------------*/
  661.     S32 i, j, x1, x2, y1, y2;
  662.     S32 cell_width = c->cell_width;
  663.     S32 cell_height = c->cell_height;
  664.     S32 ox = c->x1;
  665.     S32 oy = c->y1;
  666.     S32 n_rows = c->n_rows;
  667.     S32 n_columns = c->n_columns;
  668.     S32 index = 0;
  669.     U8 *list_of_items = c->list_of_items;
  670.     S32 current_day = 1;
  671.     /*----------------------------------------------------------------*/
  672.     /* Code Body                                                      */
  673.     /*----------------------------------------------------------------*/
  674.     y1 = oy;
  675.     for (j = 0; j < n_rows; j++)
  676.     {
  677.         x1 = ox;
  678.         for (i = 0; i < n_columns; i++)
  679.         {
  680.             x2 = x1 + cell_width - 1;
  681.             y2 = y1 + cell_height - 1;
  682.             if ((index >= c->first_item) && (index <= c->last_item))
  683.             {
  684.                 if ((list_of_items[current_day] & 0x3f) == CALENDAR_CURRENT_DAY)
  685.                 {
  686.                     *x = x1;
  687.                     *y = y1;
  688.                     return;
  689.                 }
  690.                 current_day++;
  691.             }
  692.             x1 += cell_width;
  693.             index++;
  694.         }
  695.         y1 += cell_height;
  696.     }
  697. }
  698. /*****************************************************************************
  699.  * FUNCTION
  700.  *  draw_current_day_highlighter
  701.  * DESCRIPTION
  702.  *  Draw the date highlighter for current date
  703.  * PARAMETERS
  704.  *  void
  705.  * RETURNS
  706.  *  void
  707.  *****************************************************************************/
  708. void draw_current_day_highlighter(void)
  709. {
  710.     /*----------------------------------------------------------------*/
  711.     /* Local Variables                                                */
  712.     /*----------------------------------------------------------------*/
  713.     S32 x1, y1, x2, y2;
  714.     color day_highlighter_color;
  715.     /*----------------------------------------------------------------*/
  716.     /* Code Body                                                      */
  717.     /*----------------------------------------------------------------*/
  718.     day_highlighter_color = MMI_calendar_control.theme->current_day_filler->c;
  719.     get_current_date_highlighter_coordinates(&MMI_calendar_control, &x1, &y1);
  720.     x2 = x1 + MMI_calendar_control.cell_width;
  721.     y2 = y1 + MMI_calendar_control.cell_height - 1;
  722.     if ( MMI_calendar_current_month == gdalmatian_current_month && MMI_calendar_current_year==gdalmatian_current_year )
  723.     {
  724.         gui_draw_rectangle(x1, y1 + 1, x2 - 1, y2 + 1, day_highlighter_color);
  725.     }
  726. }
  727. /*****************************************************************************
  728.  * FUNCTION
  729.  *  draw_current_week_highlighter_with_current_selection
  730.  * DESCRIPTION
  731.  *  Draw the week highlighter for current date selected
  732.  * PARAMETERS
  733.  *  void
  734.  * RETURNS
  735.  *  void
  736.  *****************************************************************************/
  737. void draw_current_week_highlighter_with_current_selection(void)
  738. {
  739.     /*----------------------------------------------------------------*/
  740.     /* Local Variables                                                */
  741.     /*----------------------------------------------------------------*/
  742.     S32 row, col;
  743.     S32 x11, y11, x21, y21;
  744.     /*----------------------------------------------------------------*/
  745.     /* Code Body                                                      */
  746.     /*----------------------------------------------------------------*/
  747.     gdi_layer_lock_frame_buffer();
  748.     gdi_layer_push_clip();
  749.     gui_reset_clip();
  750.     /* PMT VIKAS START 20051217 */
  751. #ifdef __MMI_MAINLCD_128X160__
  752.     gui_push_clip();
  753.     gui_set_clip(0, 0, MMI_calendar_control.x2, MMI_calendar_control.y2);
  754. #endif /* __MMI_MAINLCD_128X160__ */ 
  755.     /* PMT VIKAS END 20051217 */
  756.     gui_show_image(0, 0, calendar_control_background_image);
  757.     gui_show_calendar(&MMI_calendar_control);
  758.     /* PMT VIKAS START 20051217 */
  759. #ifdef __MMI_MAINLCD_128X160__
  760.     gui_pop_clip();
  761. #endif 
  762.     /* PMT VIKAS END 20051217 */
  763.     row = MMI_calendar_control.highlighted_item / MMI_calendar_control.n_columns;
  764.     col = MMI_calendar_control.highlighted_item % MMI_calendar_control.n_columns;
  765.     x11 = MMI_calendar_control.x1 + MMI_calendar_control.cell_width * col;
  766.     y11 = MMI_calendar_control.y1 + MMI_calendar_control.cell_height * row;
  767.     x21 = x11 + MMI_calendar_control.cell_width;
  768.     y21 = y11 + MMI_calendar_control.cell_height;
  769.     /* PMT VIKAS START 20051217 */
  770. #ifdef __MMI_UI_TRANSPARENT_EFFECT_IN_DALMATIAN_CALENDAR__
  771.     /* PMT VIKAS END 20051217 */
  772.     gui_transparent_color_filler(
  773.         x11,//-1
  774.         MMI_calendar_control.y+1,
  775.         x21-1,
  776.         MMI_calendar_control.y2,
  777.         wgui_read_calendar_highlighter_vertical_color(MMI_calendar_current_month - 1));
  778.     gui_transparent_color_filler(
  779.         MMI_calendar_control.x ,
  780.         y11 + 1,
  781.         MMI_calendar_control.x + ((MMI_calendar_control.cell_width) * MMI_calendar_control.n_columns) - 1,
  782.         y21,
  783.         wgui_read_calendar_highlighter_horizontal_color(MMI_calendar_current_month - 1));
  784. #else /* __MMI_UI_TRANSPARENT_EFFECT_IN_DALMATIAN_CALENDAR__ */ 
  785.     gui_draw_rectangle(
  786.         x11 - 1,
  787.         MMI_calendar_control.y,
  788.         x21,
  789.         MMI_calendar_control.y2,
  790.         wgui_read_calendar_highlighter_vertical_color(MMI_calendar_current_month - 1));
  791.     gui_draw_rectangle(
  792.         MMI_calendar_control.x + 1,
  793.         y11 + 1,
  794.         MMI_calendar_control.x + ((MMI_calendar_control.cell_width) * MMI_calendar_control.n_columns) - 1,
  795.         y21 + 1,
  796.         wgui_read_calendar_highlighter_horizontal_color(MMI_calendar_current_month - 1));
  797. #endif /* __MMI_UI_TRANSPARENT_EFFECT_IN_DALMATIAN_CALENDAR__ */ 
  798.     gui_calendar_refresh_highlight(&MMI_calendar_control, 0, MMI_calendar_control.highlighted_item);
  799.     draw_current_day_highlighter();
  800.     gdi_layer_pop_clip();
  801.     gdi_layer_unlock_frame_buffer();
  802. }
  803. /*****************************************************************************
  804.  * FUNCTION
  805.  *  set_dalmatian_calendar_highlighter_box
  806.  * DESCRIPTION
  807.  *  Draw the highlighter box for current date selected
  808.  * PARAMETERS
  809.  *  void
  810.  * RETURNS
  811.  *  void
  812.  *****************************************************************************/
  813. void set_dalmatian_calendar_highlighter_box(void)
  814. {
  815.     /*----------------------------------------------------------------*/
  816.     /* Local Variables                                                */
  817.     /*----------------------------------------------------------------*/
  818.     /*----------------------------------------------------------------*/
  819.     /* Code Body                                                      */
  820.     /*----------------------------------------------------------------*/
  821.     /* for color filler */
  822.     backup_selected_day_filler = MMI_calendar_control.theme->selected_day_filler;
  823.     image_box_selected_day_filler = *backup_selected_day_filler;
  824.     MMI_calendar_control.theme->selected_day_filler = &image_box_selected_day_filler;
  825.     MMI_calendar_control.theme->selected_day_filler->c =
  826.         color_opacity_lookup_Table_calendar_highlighter_box[MMI_calendar_current_month - 1].box_color;
  827.     MMI_calendar_control.theme->selected_day_filler->border_color =
  828.         color_opacity_lookup_Table_calendar_highlighter_box_border[MMI_calendar_current_month - 1].box_border_color;
  829.     MMI_calendar_control.theme->selected_day_filler->flags = UI_FILLED_AREA_TYPE_COLOR;
  830.     MMI_calendar_control.theme->selected_day_filler->flags =
  831.         MMI_calendar_control.theme->selected_day_filler->flags | UI_FILLED_AREA_SINGLE_BORDER;
  832. }
  833. /*****************************************************************************
  834.  * FUNCTION
  835.  *  dalmatian_calendar_current_week_image
  836.  * DESCRIPTION
  837.  *  Draw the week highlighter image for current date selected
  838.  * PARAMETERS
  839.  *  void
  840.  * RETURNS
  841.  *  void
  842.  *****************************************************************************/
  843. U16 dalmatian_calendar_current_week_image(void)
  844. {
  845.     /*----------------------------------------------------------------*/
  846.     /* Local Variables                                                */
  847.     /*----------------------------------------------------------------*/
  848.     /*----------------------------------------------------------------*/
  849.     /* Code Body                                                      */
  850.     /*----------------------------------------------------------------*/
  851.     if (IsChineseSet())
  852.     {
  853.         return CAL_CHINESE_DAYS_IMAGE;
  854.     }
  855.     else
  856.     {
  857.         return (DALMATIAN_WEEK_HIGHLIGHTER_IMAGE_ID_JAN + MMI_calendar_current_month - 1);
  858.     }
  859. }
  860. /*****************************************************************************
  861.  * FUNCTION
  862.  *  set_dalmatian_calendar_highlighter_enable
  863.  * DESCRIPTION
  864.  *  It enable the flag gdalmatian_calendar_highlighter
  865.  * PARAMETERS
  866.  *  void
  867.  * RETURNS
  868.  *  void
  869.  *****************************************************************************/
  870. void set_dalmatian_calendar_highlighter_enable(void)
  871. {
  872.     /*----------------------------------------------------------------*/
  873.     /* Local Variables                                                */
  874.     /*----------------------------------------------------------------*/
  875.     /*----------------------------------------------------------------*/
  876.     /* Code Body                                                      */
  877.     /*----------------------------------------------------------------*/
  878.     gdalmatian_calendar_highlighter = 1;
  879. }
  880. /*****************************************************************************
  881.  * FUNCTION
  882.  *  set_dalmatian_calendar_highlighter_disable
  883.  * DESCRIPTION
  884.  *  It disable the flag gdalmatian_calendar_highlighter
  885.  * PARAMETERS
  886.  *  void
  887.  * RETURNS
  888.  *  void
  889.  *****************************************************************************/
  890. void set_dalmatian_calendar_highlighter_disable(void)
  891. {
  892.     /*----------------------------------------------------------------*/
  893.     /* Local Variables                                                */
  894.     /*----------------------------------------------------------------*/
  895.     /*----------------------------------------------------------------*/
  896.     /* Code Body                                                      */
  897.     /*----------------------------------------------------------------*/
  898.     gdalmatian_calendar_highlighter = 0;
  899. }
  900. /*****************************************************************************
  901.  * FUNCTION
  902.  *  dalmatian_calendar_highlighter_status
  903.  * DESCRIPTION
  904.  *  It returns the value of flag gdalmatian_calendar_highlighter
  905.  * PARAMETERS
  906.  *  void
  907.  * RETURNS
  908.  *  S32
  909.  *****************************************************************************/
  910. S32 dalmatian_calendar_highlighter_status(void)
  911. {
  912.     /*----------------------------------------------------------------*/
  913.     /* Local Variables                                                */
  914.     /*----------------------------------------------------------------*/
  915.     /*----------------------------------------------------------------*/
  916.     /* Code Body                                                      */
  917.     /*----------------------------------------------------------------*/
  918.     return gdalmatian_calendar_highlighter;
  919. }
  920. /*****************************************************************************
  921.  * FUNCTION
  922.  *  set_dalmatian_current_week_num
  923.  * DESCRIPTION
  924.  *  It returns the value of flag gdalmatian_calendar_highlighter
  925.  * PARAMETERS
  926.  *  void
  927.  * RETURNS
  928.  *  S32(?)
  929.  *****************************************************************************/
  930. void set_dalmatian_current_week_num(void)
  931. {
  932.     /*----------------------------------------------------------------*/
  933.     /* Local Variables                                                */
  934.     /*----------------------------------------------------------------*/
  935.     S32 i, no_of_days, is_leap, week_day, numdays_inmonth, day_on_firstjan, day_on_last_day;
  936.     calendar_control *c = &MMI_calendar_control;
  937.     S32 handler_sunday_saterday = 2;
  938.     S32 no_of_days_inweek = 7;
  939.     /*----------------------------------------------------------------*/
  940.     /* Code Body                                                      */
  941.     /*----------------------------------------------------------------*/
  942.     no_of_days = 0;
  943.     is_leap = 0;
  944.     for (i = MMI_calendar_current_month - 1; i > 0; i--)
  945.     {
  946.         /* get the num of days in todays month */
  947.         numdays_inmonth = LastDayOfMonth((U8) i, (U16) MMI_calendar_current_year);
  948.         no_of_days += numdays_inmonth;
  949.     }
  950.     day_on_firstjan = DOW(MMI_calendar_current_year, 1, 1);
  951.     day_on_last_day = DOW(MMI_calendar_current_year, (U8) MMI_calendar_current_month, 1);
  952.     /* Total no of days/ weekdays */
  953.     no_of_days += (day_on_firstjan - handler_sunday_saterday + c->highlighted_item - day_on_last_day + 1);
  954.     week_day = (no_of_days) / no_of_days_inweek;
  955.     gdalmatian_week_num = week_day + 1;
  956. }
  957. #if 0
  958. /* under construction !*/
  959. /* under construction !*/
  960. /* under construction !*/
  961. /* under construction !*/
  962. /* under construction !*/
  963. /* under construction !*/
  964. /* under construction !*/
  965. /* under construction !*/
  966. /* under construction !*/
  967. /* under construction !*/
  968. /* under construction !*/
  969. /* under construction !*/
  970. /* under construction !*/
  971. /* under construction !*/
  972. /* under construction !*/
  973. /* under construction !*/
  974. /* under construction !*/
  975. /* under construction !*/
  976. /* under construction !*/
  977. /* under construction !*/
  978. /* under construction !*/
  979. /* under construction !*/
  980. /* under construction !*/
  981. /* under construction !*/
  982. /* under construction !*/
  983. /* under construction !*/
  984. /* under construction !*/
  985. /* under construction !*/
  986. /* under construction !*/
  987. /* under construction !*/
  988. /* under construction !*/
  989. /* under construction !*/
  990. /* under construction !*/
  991. /* under construction !*/
  992. /* under construction !*/
  993. /* under construction !*/
  994. /* under construction !*/
  995. /* under construction !*/
  996. /* under construction !*/
  997. /* under construction !*/
  998. /* under construction !*/
  999. /* under construction !*/
  1000. /* under construction !*/
  1001. /* under construction !*/
  1002. /* under construction !*/
  1003. /* under construction !*/
  1004. /* under construction !*/
  1005. #endif
  1006. #endif /* __MMI_UI_DALMATIAN_CALENDAR__ */ 
  1007. #ifdef __MMI_UI_DALMATIAN_SOFTKEYS__
  1008. /*****************************************************************************
  1009.  * FUNCTION
  1010.  *  shuffle_softkey_draw_dalmatian_calender_image
  1011.  * DESCRIPTION
  1012.  *  shuffle the softkey by drawing the calendar background
  1013.  * PARAMETERS
  1014.  *  void
  1015.  * RETURNS
  1016.  *  void
  1017.  *****************************************************************************/
  1018. void shuffle_softkey_draw_dalmatian_calender_image(void)
  1019. {
  1020.     /*----------------------------------------------------------------*/
  1021.     /* Local Variables                                                */
  1022.     /*----------------------------------------------------------------*/
  1023.     /*----------------------------------------------------------------*/
  1024.     /* Code Body                                                      */
  1025.     /*----------------------------------------------------------------*/
  1026.     gui_show_image(0, 0, calendar_control_background_image);
  1027. }
  1028. #endif /* __MMI_UI_DALMATIAN_SOFTKEYS__ */ 
  1029. /*****************************************************************************
  1030.  * FUNCTION
  1031.  *  ShowCalendarCommomCategoryScreen
  1032.  * DESCRIPTION
  1033.  *  key board handler of calendar
  1034.  * PARAMETERS
  1035.  *  left_softkey            [IN]        
  1036.  *  left_softkey_icon       [IN]        
  1037.  *  right_softkey           [IN]        
  1038.  *  right_softkey_icon      [IN]        
  1039.  *  history_buffer          [?]         
  1040.  *  S32(?)                  [IN]        Key_state  key state
  1041.  * RETURNS
  1042.  *  void
  1043.  *****************************************************************************/
  1044. void ShowCalendarCommomCategoryScreen(
  1045.         U16 left_softkey,
  1046.         U16 left_softkey_icon,
  1047.         U16 right_softkey,
  1048.         U16 right_softkey_icon,
  1049.         U8 *history_buffer)
  1050. {
  1051.     /*----------------------------------------------------------------*/
  1052.     /* Local Variables                                                */
  1053.     /*----------------------------------------------------------------*/
  1054.     S8 tmpString[CLNDR_TITLE_LEN];
  1055.     /*----------------------------------------------------------------*/
  1056.     /* Code Body                                                      */
  1057.     /*----------------------------------------------------------------*/
  1058.     ADD_SCREEN_STRINGS((2, left_softkey, right_softkey));
  1059.     ADD_SCREEN_IMAGES((2, left_softkey_icon, right_softkey_icon));
  1060.     entry_full_screen();
  1061.     UI_UNUSED_PARAMETER(history_buffer);
  1062.     gdi_layer_lock_frame_buffer();
  1063. #ifdef __MMI_UI_CALENDAR_WITH_INFO_BOX__
  1064.     memset(MMI_calendar_title_string, 0, sizeof(MMI_calendar_title_string));
  1065.     memset(MMI_calendar_title_string_month, 0, sizeof(MMI_calendar_title_string));
  1066.     sprintf(tmpString, "%d", MMI_calendar_current_year);
  1067.     AnsiiToUnicodeString((S8*) MMI_calendar_title_string, tmpString);
  1068.     if (IsChineseSet())
  1069.     {
  1070.         sprintf(tmpString, "%d", MMI_calendar_current_month);
  1071.         AnsiiToUnicodeString((S8*) MMI_calendar_title_string_month, tmpString);
  1072.     }
  1073.     else
  1074.     {
  1075.         pfnUnicodeStrcpy(
  1076.             (S8*) MMI_calendar_title_string_month,
  1077.             GetString((U16) (STR_GUI_MONTH_BASE + MMI_calendar_current_month)));
  1078.     }
  1079. #else /* __MMI_UI_CALENDAR_WITH_INFO_BOX__ */ 
  1080.     memset(MMI_calendar_title_string, 0, sizeof(MMI_calendar_title_string));
  1081.     if (IsChineseSet())
  1082.     {
  1083.         sprintf(tmpString, "%d %02d", MMI_calendar_current_year, MMI_calendar_current_month);
  1084.         AnsiiToUnicodeString((S8*) MMI_calendar_title_string, tmpString);
  1085.     }
  1086.     else
  1087.     {
  1088.         sprintf(tmpString, "%d ", MMI_calendar_current_year);
  1089.         AnsiiToUnicodeString((S8*) MMI_calendar_title_string, tmpString);
  1090.         pfnUnicodeStrcat(
  1091.             (S8*) MMI_calendar_title_string,
  1092.             GetString((U16) (STR_GUI_MONTH_BASE + MMI_calendar_current_month)));
  1093.     }
  1094. #endif /* __MMI_UI_CALENDAR_WITH_INFO_BOX__ */ 
  1095.     if (lunar_calendar_present)
  1096.     {
  1097.         Cat82_title2 = MMI_calendar_title_string;
  1098.     }
  1099.     else
  1100.     {
  1101.         MMI_title_string = (UI_string_type) MMI_calendar_title_string;
  1102.     }
  1103. #ifdef __MMI_SLIM_CALENDAR__
  1104.     SetCalendarBackground((U16) IMG_CALENDAR_JAN);
  1105. #else 
  1106.     SetCalendarBackground((U16) (IMG_CALENDAR_JAN + MMI_calendar_current_month - 1));
  1107. #endif 
  1108.     clear_category_screen_key_handlers();
  1109.     change_left_softkey(left_softkey, left_softkey_icon);
  1110.     change_right_softkey(right_softkey, right_softkey_icon);
  1111.     clear_left_softkey();
  1112.     clear_right_softkey();
  1113.     register_left_softkey_handler();
  1114.     register_right_softkey_handler();
  1115.     register_default_hide_softkeys();
  1116.     /* register calendat key handlers */
  1117.     wgui_register_calendar_keys();
  1118.     gdi_layer_unlock_frame_buffer();
  1119. }
  1120. /*****************************************************************************
  1121.  * FUNCTION
  1122.  *  wgui_calendar_keyboard_key_handler
  1123.  * DESCRIPTION
  1124.  *  key board handler of calendar
  1125.  * PARAMETERS
  1126.  *  vkey_code       [IN]        Key code
  1127.  *  key_state       [IN]        Key state
  1128.  * RETURNS
  1129.  *  void
  1130.  *****************************************************************************/
  1131. void wgui_calendar_keyboard_key_handler(S32 vkey_code, S32 key_state)
  1132. {
  1133. #if(MMI_BUILD_TYPE == BUILD_TYPE_X86WIN32)
  1134.     /*----------------------------------------------------------------*/
  1135.     /* Local Variables                                                */
  1136.     /*----------------------------------------------------------------*/
  1137.     /*----------------------------------------------------------------*/
  1138.     /* Code Body                                                      */
  1139.     /*----------------------------------------------------------------*/
  1140.     if (key_state)
  1141.     {
  1142.         switch (vkey_code)
  1143.         {
  1144.             case 37:
  1145.                 gui_calendar_previous_day(&MMI_calendar_control);       /* move to previous day */
  1146.                 break;
  1147.             case 39:
  1148.                 gui_calendar_next_day(&MMI_calendar_control);   /* move to next day */
  1149.                 break;
  1150.             case 38:
  1151.                 gui_calendar_previous_row(&MMI_calendar_control);       /* move to previous row */
  1152.                 break;
  1153.             case 40:
  1154.                 gui_calendar_next_row(&MMI_calendar_control);   /* move to next row */
  1155.                 break;
  1156.         }
  1157.     }
  1158. #else /* (MMI_BUILD_TYPE == BUILD_TYPE_X86WIN32) */ 
  1159.     UI_UNUSED_PARAMETER(vkey_code);
  1160.     UI_UNUSED_PARAMETER(key_state);
  1161. #endif /* (MMI_BUILD_TYPE == BUILD_TYPE_X86WIN32) */ 
  1162. }
  1163. /*****************************************************************************
  1164.  * FUNCTION
  1165.  *  wgui_calendar_control_highlight_handler
  1166.  * DESCRIPTION
  1167.  *  highlight handler of calendar
  1168.  * PARAMETERS
  1169.  *  day     [IN]        Selected day
  1170.  * RETURNS
  1171.  *  void
  1172.  *****************************************************************************/
  1173. void wgui_calendar_control_highlight_handler(S32 day)
  1174. {   /* store selected day */
  1175.     /*----------------------------------------------------------------*/
  1176.     /* Local Variables                                                */
  1177.     /*----------------------------------------------------------------*/
  1178.     /*----------------------------------------------------------------*/
  1179.     /* Code Body                                                      */
  1180.     /*----------------------------------------------------------------*/
  1181.     MMI_calendar_highlighted_day = day;
  1182. #ifdef __MMI_UI_DALMATIAN_CALENDAR__
  1183.     if (dalmatian_calendar_highlighter_status() == 1)
  1184.     {
  1185.         set_dalmatian_calendar_highlighter_box();
  1186.     }
  1187.     if (dalmatian_calendar_highlighter_style == DALMATIAN_CALENDAR_HIGHLIGHTER_MOVE_WITH_SELECT &&
  1188.         dalmatian_calendar_highlighter_status() == 1)
  1189.     {
  1190.         draw_current_week_highlighter_with_current_selection();
  1191.     }
  1192.     //set_dalmatian_current_week_num();
  1193. #endif /* __MMI_UI_DALMATIAN_CALENDAR__ */ 
  1194.     /* highlight the selected day */
  1195.     MMI_calendar_control_highlight_handler(day);
  1196. }
  1197. /*****************************************************************************
  1198.  * FUNCTION
  1199.  *  wgui_calendar_control_update_handler
  1200.  * DESCRIPTION
  1201.  *  update the content of the calendar control
  1202.  * PARAMETERS
  1203.  *  void
  1204.  * RETURNS
  1205.  *  void
  1206.  *****************************************************************************/
  1207. static void wgui_calendar_control_update_handler(void)
  1208. {
  1209.     /*----------------------------------------------------------------*/
  1210.     /* Local Variables                                                */
  1211.     /*----------------------------------------------------------------*/
  1212.     U8 DayOnFirst, NumDaysInMonth;
  1213.     S32 i;
  1214.     S8 tmpString[CLNDR_TITLE_LEN];
  1215.     /*----------------------------------------------------------------*/
  1216.     /* Code Body                                                      */
  1217.     /*----------------------------------------------------------------*/
  1218.     DayOnFirst = DOW(MMI_calendar_current_year, (U8) MMI_calendar_current_month, 1);
  1219.     /* get the num of days in todays month */
  1220.     NumDaysInMonth = LastDayOfMonth((U8) MMI_calendar_current_month, MMI_calendar_current_year);
  1221. #ifdef __MMI_UI_CALENDAR_WITH_INFO_BOX__
  1222.     memset(MMI_calendar_title_string, 0, sizeof(MMI_calendar_title_string));
  1223.     memset(MMI_calendar_title_string_month, 0, sizeof(MMI_calendar_title_string));
  1224.     sprintf(tmpString, "%d", MMI_calendar_current_year);
  1225.     AnsiiToUnicodeString((S8*) MMI_calendar_title_string, tmpString);
  1226.     if (IsChineseSet())
  1227.     {
  1228.         if (lunar_calendar_present)
  1229.         {
  1230.             Cat82_title2 = MMI_calendar_title_string;
  1231.         }
  1232.         else
  1233.         {
  1234.             MMI_title_string = (UI_string_type) MMI_calendar_title_string;
  1235.         }
  1236.         sprintf(tmpString, "%d", MMI_calendar_current_month);
  1237.         AnsiiToUnicodeString((S8*) MMI_calendar_title_string_month, tmpString);
  1238.     }
  1239.     else
  1240.     {
  1241.         MMI_title_string = (UI_string_type) MMI_calendar_title_string;
  1242.         pfnUnicodeStrcpy(
  1243.             (S8*) MMI_calendar_title_string_month,
  1244.             GetString((U16) (STR_GUI_MONTH_BASE + MMI_calendar_current_month)));
  1245.     }
  1246. #else /* __MMI_UI_CALENDAR_WITH_INFO_BOX__ */ 
  1247.     memset(MMI_calendar_title_string, 0, sizeof(MMI_calendar_title_string));
  1248.     if (IsChineseSet())
  1249.     {
  1250.         sprintf(tmpString, "%d %02d", MMI_calendar_current_year, MMI_calendar_current_month);
  1251.         AnsiiToUnicodeString((S8*) MMI_calendar_title_string, tmpString);
  1252.         if (lunar_calendar_present)
  1253.         {
  1254.             Cat82_title2 = MMI_calendar_title_string;
  1255.         }
  1256.         else
  1257.         {
  1258.             MMI_title_string = (UI_string_type) MMI_calendar_title_string;
  1259.         }
  1260.     }
  1261.     else
  1262.     {
  1263.         sprintf(tmpString, "%d ", MMI_calendar_current_year);
  1264.         AnsiiToUnicodeString((S8*) MMI_calendar_title_string, tmpString);
  1265.         pfnUnicodeStrcat(
  1266.             (S8*) MMI_calendar_title_string,
  1267.             GetString((U16) (STR_GUI_MONTH_BASE + MMI_calendar_current_month)));
  1268.         MMI_title_string = (UI_string_type) MMI_calendar_title_string;
  1269.     }
  1270. #endif /* __MMI_UI_CALENDAR_WITH_INFO_BOX__ */ 
  1271. #ifdef __MMI_SLIM_CALENDAR__
  1272.     calendar_control_background_image = get_image((U16) IMG_CALENDAR_JAN);
  1273. #else 
  1274.     calendar_control_background_image = get_image((U16) (IMG_CALENDAR_JAN + MMI_calendar_current_month - 1));
  1275. #endif 
  1276.     for (i = 0; i < MAX_CALENDAR_DAYS; i++)
  1277.     {
  1278.         MMI_calendar_days[i] = CALENDAR_NORMAL_DAY; /* Clear all flags before updating */
  1279.     }
  1280.     MMI_calendar_control_update_handler(
  1281.         MMI_calendar_highlighted_day,
  1282.         MMI_calendar_current_month,
  1283.         MMI_calendar_current_year);
  1284.     gui_set_calendar_days(&MMI_calendar_control, DayOnFirst, NumDaysInMonth, MMI_calendar_days);
  1285.     if (IsChineseSet() && lunar_calendar_present)
  1286.     {
  1287.         RedrawCategory82Screen();
  1288.     }
  1289.     else
  1290.     {
  1291.         RedrawCategory80Screen();
  1292.     }
  1293. }
  1294. /*****************************************************************************
  1295.  * FUNCTION
  1296.  *  wgui_display_calendar_pop_up
  1297.  * DESCRIPTION
  1298.  *  create popup dialog box of calendar
  1299.  * PARAMETERS
  1300.  *  void
  1301.  * RETURNS
  1302.  *  void
  1303.  *****************************************************************************/
  1304. void wgui_display_calendar_pop_up(void)
  1305. {
  1306.     /*----------------------------------------------------------------*/
  1307.     /* Local Variables                                                */
  1308.     /*----------------------------------------------------------------*/
  1309.     /* These can be obtained from theme data  */
  1310.     const UI_filled_area popup_filler = {UI_FILLED_AREA_TYPE_COLOR | UI_FILLED_AREA_SINGLE_BORDER,
  1311.         UI_NULL_IMAGE,
  1312.         NULL,
  1313.         {47, 55, 143, 80},
  1314.         {0, 0, 0, 0},
  1315.         {0, 0, 0, 100},
  1316.         {0, 0, 0, 0},
  1317.         0
  1318.     };
  1319.     color tc = *(current_MMI_theme->UI_white_color);
  1320.     UI_font_type text_font = &MMI_medium_font;
  1321.     S32 x1 = *wgui_calendar_ppx1;
  1322.     S32 y1 = *wgui_calendar_ppy1;
  1323.     S32 x2 = *wgui_calendar_ppx2;
  1324.     S32 px1, py1, px2, py2;
  1325.     S32 width, height, y;
  1326.     S32 w1, w2, w3, h1, h2, h3;
  1327.     /* set message 1 of popup */
  1328.     UI_string_type msg1 = (UI_string_type) MMI_calendar_messages1;
  1329.     /* set message 2 of popup */
  1330.     UI_string_type msg2 = (UI_string_type) MMI_calendar_messages2;
  1331.     /* set message 3 of popup */
  1332.     UI_string_type msg3 = (UI_string_type) MMI_calendar_messages3;
  1333.     /*----------------------------------------------------------------*/
  1334.     /* Code Body                                                      */
  1335.     /*----------------------------------------------------------------*/
  1336.     /* set font of popup */
  1337.     gui_set_font(text_font);
  1338.     if ((msg1 == NULL) && (msg2 == NULL) && (msg3 == NULL))
  1339.     {
  1340.         MMI_calendar_control.flags &= ~CALENDAR_POPUP_BACKUP;
  1341.         return;
  1342.     }
  1343.     if (msg1 == NULL)
  1344.     {
  1345.         h1 = 0;
  1346.         w1 = 0;
  1347.     }
  1348.     else
  1349.     {
  1350.         gui_measure_string(msg1, &w1, &h1); /* measue width and height of msg1 */
  1351.     }
  1352.     if (msg2 == NULL)
  1353.     {
  1354.         h2 = 0;
  1355.         w2 = 0;
  1356.     }
  1357.     else
  1358.     {
  1359.         gui_measure_string(msg2, &w2, &h2); /* measue width and height of msg1 */
  1360.     }
  1361.     if (msg3 == NULL)
  1362.     {
  1363.         h3 = 0;
  1364.         w3 = 0;
  1365.     }
  1366.     else
  1367.     {
  1368.         gui_measure_string(msg3, &w3, &h3); /* measue width and height of msg1 */
  1369.     }
  1370.     height = h1 + h2 + h3 + 8;
  1371.     width = w1;
  1372.     if (w2 > width)
  1373.     {
  1374.         width = w2;
  1375.     }
  1376.     if (w3 > width)
  1377.     {
  1378.         width = w3;
  1379.     }
  1380.     width += 8;
  1381.     if (width > CALENDAR_POPUP_WIDTH)
  1382.     {
  1383.         width = CALENDAR_POPUP_WIDTH;
  1384.     }
  1385.     if (height > CALENDAR_POPUP_HEIGHT)
  1386.     {
  1387.         height = CALENDAR_POPUP_HEIGHT;
  1388.     }
  1389. #if(CALENDAR_POPUP_FIXED_POSITION)
  1390.     /* Not complete: Overlaps need to be handled */
  1391. #if(CALENDAR_POPUP_FIXED_RIGHT)
  1392.     px1 = CALENDAR_POPUP_X - width;
  1393. #else 
  1394.     px1 = CALENDAR_POPUP_X;
  1395. #endif 
  1396. #if(CALENDAR_POPUP_FIXED_BOTTOM)
  1397.     py1 = CALENDAR_POPUP_Y - height;
  1398. #else 
  1399.     py1 = CALENDAR_POPUP_Y;
  1400. #endif 
  1401. #else /* (CALENDAR_POPUP_FIXED_POSITION) */ 
  1402.     px1 = x2 + CALENDAR_POPUP_X;
  1403.     py1 = y1 + CALENDAR_POPUP_Y;
  1404. #endif /* (CALENDAR_POPUP_FIXED_POSITION) */ 
  1405.     if ((px1 + width - 1) > MMI_calendar_control.x2)
  1406.     {
  1407.         px1 = x1 - width - CALENDAR_POPUP_X;
  1408.         if (px1 < MMI_calendar_control.x1)
  1409.         {
  1410.             px1 = MMI_calendar_control.x1;
  1411.         }
  1412.     }
  1413.     if ((py1 + height - 1) > MMI_calendar_control.y2)
  1414.     {
  1415.         py1 = MMI_calendar_control.y2 - height;
  1416.         if (py1 < MMI_calendar_control.y1)
  1417.         {
  1418.             py1 = MMI_calendar_control.y1;
  1419.         }
  1420.     }
  1421.     px2 = px1 + width - 1;
  1422.     py2 = py1 + height - 1;
  1423.     gui_reset_clip();
  1424.     /* Temporarily disabled pop up bitmap backup since there is no available buffer to use on hardware    */
  1425.     /* _get_bitmap(px1,py1,px2,py2,&MMI_calendar_control.popup_save_bitmap);                        */
  1426.     MMI_calendar_control.flags |= CALENDAR_POPUP_BACKUP;
  1427.     /* fill the color of popup */
  1428.     gui_draw_filled_area(px1, py1, px2, py2, (UI_filled_area*)&popup_filler);
  1429.     gdi_layer_set_text_clip(px1, py1, px2, py2);
  1430.     /* set text color */
  1431.     gui_set_text_color(tc);
  1432.     y = py1 + 4;
  1433.     if (msg1 != NULL)
  1434.     {
  1435.         if (r2lMMIFlag)
  1436.         {
  1437.             gui_move_text_cursor(px1 + 4 + w1, y);
  1438.         }
  1439.         else
  1440.         {
  1441.             gui_move_text_cursor(px1 + 4, y);
  1442.         }
  1443.         gui_print_text(msg1);
  1444.         y += h1;
  1445.     }
  1446.     if (msg2 != NULL)
  1447.     {
  1448.         if (r2lMMIFlag)
  1449.         {
  1450.             gui_move_text_cursor(px1 + 4 + w2, y);
  1451.         }
  1452.         else
  1453.         {
  1454.             gui_move_text_cursor(px1 + 4, y);
  1455.         }
  1456.         gui_print_text(msg2);
  1457.         y += h2;
  1458.     }
  1459.     if (msg3 != NULL)
  1460.     {
  1461.         if (r2lMMIFlag)
  1462.         {
  1463.             gui_move_text_cursor(px1 + 4 + w3, y);
  1464.         }
  1465.         else
  1466.         {
  1467.             gui_move_text_cursor(px1 + 4, y);
  1468.         }
  1469.         gui_print_text(msg3);
  1470.         y += h3;
  1471.     }
  1472.     *wgui_calendar_ppx1 = px1;
  1473.     *wgui_calendar_ppy1 = py1;
  1474.     *wgui_calendar_ppx2 = px2;
  1475.     *wgui_calendar_ppy2 = py2;
  1476.     gdi_layer_blt_previous(px1, py1, px2, py2);
  1477. }
  1478. /*****************************************************************************
  1479.  * FUNCTION
  1480.  *  wgui_show_calendar_pop_up
  1481.  * DESCRIPTION
  1482.  *  Show calendar popup start time of diosplay popup
  1483.  * PARAMETERS
  1484.  *  day         [IN]        Highlighted day
  1485.  *  x1_p        [IN]        Start x position of popup
  1486.  *  y1_p        [IN]        Start y position of popup
  1487.  *  x2_p        [IN]        End x position of popup
  1488.  *  y2_p        [IN]        End y position of popup
  1489.  * RETURNS
  1490.  *  void
  1491.  *****************************************************************************/
  1492. void wgui_show_calendar_pop_up(S32 day, S32 *x1_p, S32 *y1_p, S32 *x2_p, S32 *y2_p)
  1493. {
  1494.     /*----------------------------------------------------------------*/
  1495.     /* Local Variables                                                */
  1496.     /*----------------------------------------------------------------*/
  1497.     /*----------------------------------------------------------------*/
  1498.     /* Code Body                                                      */
  1499.     /*----------------------------------------------------------------*/
  1500.     wgui_calendar_ppx1 = x1_p;
  1501.     wgui_calendar_ppy1 = y1_p;
  1502.     wgui_calendar_ppx2 = x2_p;
  1503.     wgui_calendar_ppy2 = y2_p;
  1504.     wgui_calendar_pp_day = day;
  1505.     MMI_calendar_control.flags &= ~CALENDAR_POPUP_BACKUP;
  1506.     /* start timer of display popup */
  1507.     gui_start_timer(CALENDAR_POPUP_WAIT_TIME, wgui_display_calendar_pop_up);
  1508. }
  1509. /*****************************************************************************
  1510.  * FUNCTION
  1511.  *  wgui_setup_calendar
  1512.  * DESCRIPTION
  1513.  *  create calendar ..set the values of calendar control
  1514.  * PARAMETERS
  1515.  *  x                   [IN]        Start x position of calendar
  1516.  *  y                   [IN]        Start y position of calendar
  1517.  *  cell_width          [IN]        One cell width
  1518.  *  cell_height         [IN]        One cell height
  1519.  *  first_dow           [IN]        First day of month
  1520.  *  last_day            [IN]        Last day of month
  1521.  *  current_day         [IN]        Current day
  1522.  *  current_month       [IN]        Current month
  1523.  *  current_year        [IN]        Current year
  1524.  *  flags               [IN]        Flags for enable popup
  1525.  * RETURNS
  1526.  *  void
  1527.  *****************************************************************************/
  1528. void wgui_setup_calendar(
  1529.         S32 x,
  1530.         S32 y,
  1531.         S32 cell_width,
  1532.         S32 cell_height,
  1533.         S32 first_dow,
  1534.         S32 last_day,
  1535.         S32 current_day,
  1536.         S32 current_month,
  1537.         S32 current_year,
  1538.         U32 flags)
  1539. {
  1540.     /*----------------------------------------------------------------*/
  1541.     /* Local Variables                                                */
  1542.     /*----------------------------------------------------------------*/
  1543.     S32 i;
  1544.     /*----------------------------------------------------------------*/
  1545.     /* Code Body                                                      */
  1546.     /*----------------------------------------------------------------*/
  1547.     /* initilize the calendar daya */
  1548.     for (i = 0; i < MAX_CALENDAR_DAYS; i++)
  1549.     {
  1550.         MMI_calendar_days[i] = CALENDAR_NORMAL_DAY;
  1551.     }
  1552.     /* create calendar */
  1553.     gui_create_calendar(&MMI_calendar_control, x, y, CALENDAR_N_COLUMNS, CALENDAR_N_ROWS, cell_width, cell_height);
  1554.     MMI_calendar_current_month = current_month;
  1555.     MMI_calendar_current_year = current_year;
  1556.     /* set the bitmap of calndar */
  1557. #ifdef MMI_ON_HARDWARE_P
  1558.     MMI_calendar_control.cursor_save_bitmap.data = (U8*) matrix_main_menu_highlight_bitmap_data;
  1559. #else 
  1560.     MMI_calendar_control.cursor_save_bitmap.data = (U8*) gui_malloc(cell_width * 16 * (cell_height + 1));
  1561. #endif 
  1562.     gui_set_calendar_days(&MMI_calendar_control, first_dow, last_day, MMI_calendar_days);
  1563.     /* set current day */
  1564.     MMI_calendar_highlighted_day = current_day;
  1565.     if (MMI_calendar_highlighted_day < 1)
  1566.     {
  1567.         MMI_calendar_highlighted_day = 1;
  1568.     }
  1569.     if (MMI_calendar_highlighted_day > last_day)
  1570.     {
  1571.         MMI_calendar_highlighted_day = last_day;
  1572.     }
  1573.     /* set function pointer of highlight function */
  1574.     MMI_calendar_control.item_highlighted_function = wgui_calendar_control_highlight_handler;
  1575.     if (flags & CALENDAR_ENABLE_POPUP)  /* check if display popup is enable or not */
  1576.     {
  1577.         MMI_calendar_control.flags |= CALENDAR_ENABLE_POPUP;
  1578.         /* Temporarily disabled pop up bitmap backup since there is no available buffer to use on hardware                */
  1579.         MMI_calendar_control.display_popup = wgui_show_calendar_pop_up;
  1580.     }
  1581. }
  1582. /*****************************************************************************
  1583.  * FUNCTION
  1584.  *  wgui_move_calendar
  1585.  * DESCRIPTION
  1586.  *  move calendar to particular x,y position
  1587.  * PARAMETERS
  1588.  *  x       [IN]        Start x position of calendar
  1589.  *  y       [IN]        Start y position of calendar
  1590.  * RETURNS
  1591.  *  void
  1592.  *****************************************************************************/
  1593. void wgui_move_calendar(S32 x, S32 y)
  1594. {
  1595.     /*----------------------------------------------------------------*/
  1596.     /* Local Variables                                                */
  1597.     /*----------------------------------------------------------------*/
  1598.     /*----------------------------------------------------------------*/
  1599.     /* Code Body                                                      */
  1600.     /*----------------------------------------------------------------*/
  1601.     gui_move_calendar(&MMI_calendar_control, x, y);
  1602. }
  1603. /*****************************************************************************
  1604.  * FUNCTION
  1605.  *  wgui_reset_calendar_params
  1606.  * DESCRIPTION
  1607.  *  resets calendars to new parameters
  1608.  * PARAMETERS
  1609.  *  x               [IN]        Start x position of calendar
  1610.  *  y               [IN]        Start y position of calendar
  1611.  *  n_columns       [IN]        No of columns of calendar
  1612.  *  n_rows          [IN]        No of rows of calendar
  1613.  *  cell_width      [IN]        Width of each cell of calendar
  1614.  *  cell_height     [IN]        Height of each cell of calendar
  1615.  * RETURNS
  1616.  *  void
  1617.  *****************************************************************************/
  1618. void wgui_reset_calendar_params(S32 x, S32 y, S32 n_columns, S32 n_rows, S32 cell_width, S32 cell_height)
  1619. {
  1620.     /*----------------------------------------------------------------*/
  1621.     /* Local Variables                                                */
  1622.     /*----------------------------------------------------------------*/
  1623.     /*----------------------------------------------------------------*/
  1624.     /* Code Body                                                      */
  1625.     /*----------------------------------------------------------------*/
  1626.     MMI_calendar_control.n_columns = n_columns;
  1627.     MMI_calendar_control.n_rows = n_rows;
  1628.     MMI_calendar_control.cell_width = cell_width;
  1629.     MMI_calendar_control.cell_height = cell_height;
  1630.     gui_move_calendar(&MMI_calendar_control, x, y);
  1631. }
  1632. #ifdef __MMI_UI_CALENDAR_WITH_INFO_BOX__
  1633. /*****************************************************************************
  1634.  * FUNCTION
  1635.  *  wgui_set_calendar_info_box
  1636.  * DESCRIPTION
  1637.  *  set calendars info box
  1638.  * PARAMETERS
  1639.  *  InfoBoxX            [IN]        Start x position of infobox
  1640.  *  InfoBoxY            [IN]        Start y position of infobox
  1641.  *  InfoBoxWidth        [IN]        Width of info box
  1642.  *  InfoBoxHeight       [IN]        Hegiht of infobox
  1643.  *  InfoBoxMax          [IN]        Max lines of infobox
  1644.  *  InfoBoxShow         [IN]        Flag to decide if show info box or not
  1645.  * RETURNS
  1646.  *  void
  1647.  *****************************************************************************/
  1648. void wgui_set_calendar_info_box(
  1649.         S32 InfoBoxX,
  1650.         S32 InfoBoxY,
  1651.         S32 InfoBoxWidth,
  1652.         S32 InfoBoxHeight,
  1653.         S32 InfoBoxMax,
  1654.         U16 InfoBoxShow)
  1655. {
  1656.     /*----------------------------------------------------------------*/
  1657.     /* Local Variables                                                */
  1658.     /*----------------------------------------------------------------*/
  1659.     /*----------------------------------------------------------------*/
  1660.     /* Code Body                                                      */
  1661.     /*----------------------------------------------------------------*/
  1662.     MMI_calendar_control.info_x1 = InfoBoxX;
  1663.     MMI_calendar_control.info_y1 = InfoBoxY;
  1664.     MMI_calendar_control.info_x2 = InfoBoxX + InfoBoxWidth - 1;
  1665.     MMI_calendar_control.info_y2 = InfoBoxY + InfoBoxHeight - 1;
  1666.     MMI_calendar_control.max_n_info = InfoBoxMax;
  1667.     if (InfoBoxMax)
  1668.     {
  1669.         MMI_calendar_control.flags |= CALENDAR_SHOW_INFO_BOX;
  1670.     }
  1671.     else
  1672.     {
  1673.         MMI_calendar_control.flags &= ~CALENDAR_SHOW_INFO_BOX;
  1674.     }
  1675. }
  1676. #endif /* __MMI_UI_CALENDAR_WITH_INFO_BOX__ */ 
  1677. /*****************************************************************************
  1678.  * FUNCTION
  1679.  *  wgui_show_calendar
  1680.  * DESCRIPTION
  1681.  *  show calendar
  1682.  * PARAMETERS
  1683.  *  void
  1684.  * RETURNS
  1685.  *  void
  1686.  *****************************************************************************/
  1687. void wgui_show_calendar(void)
  1688. {
  1689.     /*----------------------------------------------------------------*/
  1690.     /* Local Variables                                                */
  1691.     /*----------------------------------------------------------------*/
  1692.     /*----------------------------------------------------------------*/
  1693.     /* Code Body                                                      */
  1694.     /*----------------------------------------------------------------*/
  1695.     /* show calendar */
  1696.     gui_show_calendar(&MMI_calendar_control);
  1697.     MMI_calendar_control.highlighted_item = -1;
  1698. #ifdef __MMI_UI_DALMATIAN_CALENDAR__
  1699.     if (dalmatian_calendar_highlighter_style == DALMATIAN_CALENDAR_HIGHLIGHTER_MOVE_WITH_CURRENT &&
  1700.         MMI_calendar_current_month == gdalmatian_current_month && (dalmatian_calendar_highlighter_status() == 1))
  1701.     {
  1702.         draw_current_week_highlighter(&MMI_calendar_control);
  1703.     }
  1704. #endif /* __MMI_UI_DALMATIAN_CALENDAR__ */ 
  1705.     /* highlight day of calendar */
  1706.     gui_calendar_highlight_day(&MMI_calendar_control, MMI_calendar_highlighted_day);
  1707. }
  1708. /*****************************************************************************
  1709.  * FUNCTION
  1710.  *  wgui_close_calendar
  1711.  * DESCRIPTION
  1712.  *  close calndar deallocate the memory allocated by calendar
  1713.  *  stop the popup timer
  1714.  * PARAMETERS
  1715.  *  void
  1716.  * RETURNS
  1717.  *  void
  1718.  *****************************************************************************/
  1719. void wgui_close_calendar(void)
  1720. {   /* free memory allocated by calendar bitmap */
  1721.     /*----------------------------------------------------------------*/
  1722.     /* Local Variables                                                */
  1723.     /*----------------------------------------------------------------*/
  1724.     /*----------------------------------------------------------------*/
  1725.     /* Code Body                                                      */
  1726.     /*----------------------------------------------------------------*/
  1727.     /* set the calendar highlight handler to dummy func */
  1728.     MMI_calendar_control_highlight_handler = UI_dummy_function_s32;
  1729.     MMI_calendar_control_update_handler = UI_dummy_function_s32s32s32;
  1730.     if (MMI_calendar_control.flags & CALENDAR_ENABLE_POPUP)
  1731.     {
  1732.         /* Temporarily disabled pop up bitmap backup since there is no available buffer to use on hardware                */
  1733.         gui_cancel_timer(wgui_display_calendar_pop_up); /* stop the timer */
  1734.     }
  1735.     calendar_control_background_image = NULL;
  1736.     calendar_control_title_image = NULL;
  1737. }
  1738. /*****************************************************************************
  1739.  * FUNCTION
  1740.  *  wgui_calendar_previous_day
  1741.  * DESCRIPTION
  1742.  *  Move highlight to previous day
  1743.  * PARAMETERS
  1744.  *  void
  1745.  * RETURNS
  1746.  *  void
  1747.  *****************************************************************************/
  1748. void wgui_calendar_previous_day(void)
  1749. {
  1750. #ifdef __MMI_UI_DALMATIAN_CALENDAR__
  1751.     /*----------------------------------------------------------------*/
  1752.     /* Local Variables                                                */
  1753.     /*----------------------------------------------------------------*/
  1754.     /*----------------------------------------------------------------*/
  1755.     /* Code Body                                                      */
  1756.     /*----------------------------------------------------------------*/
  1757.     gdi_layer_lock_frame_buffer();
  1758.     set_dalmatian_calendar_highlighter_box();
  1759. #endif /* __MMI_UI_DALMATIAN_CALENDAR__ */ 
  1760.     gui_calendar_previous_day(&MMI_calendar_control);
  1761. #ifdef __MMI_UI_DALMATIAN_CALENDAR__
  1762.     gdi_layer_unlock_frame_buffer();
  1763.     gdi_layer_blt_previous(0, 0, UI_device_width, UI_device_height);
  1764. #endif /* __MMI_UI_DALMATIAN_CALENDAR__ */ 
  1765. }
  1766. /*****************************************************************************
  1767.  * FUNCTION
  1768.  *  wgui_calendar_next_day
  1769.  * DESCRIPTION
  1770.  *  Move highlight to next day
  1771.  * PARAMETERS
  1772.  *  void
  1773.  * RETURNS
  1774.  *  void
  1775.  *****************************************************************************/
  1776. void wgui_calendar_next_day(void)
  1777. {
  1778. #ifdef __MMI_UI_DALMATIAN_CALENDAR__
  1779.     /*----------------------------------------------------------------*/
  1780.     /* Local Variables                                                */
  1781.     /*----------------------------------------------------------------*/
  1782.     /*----------------------------------------------------------------*/
  1783.     /* Code Body                                                      */
  1784.     /*----------------------------------------------------------------*/
  1785.     gdi_layer_lock_frame_buffer();
  1786.     set_dalmatian_calendar_highlighter_box();
  1787. #endif /* __MMI_UI_DALMATIAN_CALENDAR__ */ 
  1788.     gui_calendar_next_day(&MMI_calendar_control);
  1789. #ifdef __MMI_UI_DALMATIAN_CALENDAR__
  1790.     gdi_layer_unlock_frame_buffer();
  1791.     gdi_layer_blt_previous(0, 0, UI_device_width, UI_device_height);
  1792. #endif /* __MMI_UI_DALMATIAN_CALENDAR__ */ 
  1793. }
  1794. /*****************************************************************************
  1795.  * FUNCTION
  1796.  *  wgui_calendar_previous_row
  1797.  * DESCRIPTION
  1798.  *  Move highlight to previous row
  1799.  * PARAMETERS
  1800.  *  void
  1801.  * RETURNS
  1802.  *  void
  1803.  *****************************************************************************/
  1804. void wgui_calendar_previous_row(void)
  1805. {
  1806. #ifdef __MMI_UI_DALMATIAN_CALENDAR__
  1807.     /*----------------------------------------------------------------*/
  1808.     /* Local Variables                                                */
  1809.     /*----------------------------------------------------------------*/
  1810.     /*----------------------------------------------------------------*/
  1811.     /* Code Body                                                      */
  1812.     /*----------------------------------------------------------------*/
  1813.     gdi_layer_lock_frame_buffer();
  1814.     set_dalmatian_calendar_highlighter_box();
  1815. #endif /* __MMI_UI_DALMATIAN_CALENDAR__ */ 
  1816.     gui_calendar_previous_row(&MMI_calendar_control);
  1817. #ifdef __MMI_UI_DALMATIAN_CALENDAR__
  1818.     gdi_layer_unlock_frame_buffer();
  1819.     gdi_layer_blt_previous(0, 0, UI_device_width, UI_device_height);
  1820. #endif /* __MMI_UI_DALMATIAN_CALENDAR__ */ 
  1821. }
  1822. /*****************************************************************************
  1823.  * FUNCTION
  1824.  *  wgui_calendar_next_row
  1825.  * DESCRIPTION
  1826.  *  Move highlight to next row
  1827.  * PARAMETERS
  1828.  *  void
  1829.  * RETURNS
  1830.  *  void
  1831.  *****************************************************************************/
  1832. void wgui_calendar_next_row(void)
  1833. {
  1834. #ifdef __MMI_UI_DALMATIAN_CALENDAR__
  1835.     /*----------------------------------------------------------------*/
  1836.     /* Local Variables                                                */
  1837.     /*----------------------------------------------------------------*/
  1838.     /*----------------------------------------------------------------*/
  1839.     /* Code Body                                                      */
  1840.     /*----------------------------------------------------------------*/
  1841.     gdi_layer_lock_frame_buffer();
  1842.     set_dalmatian_calendar_highlighter_box();
  1843. #endif /* __MMI_UI_DALMATIAN_CALENDAR__ */ 
  1844.     gui_calendar_next_row(&MMI_calendar_control);
  1845. #ifdef __MMI_UI_DALMATIAN_CALENDAR__
  1846.     gdi_layer_unlock_frame_buffer();
  1847.     gdi_layer_blt_previous(0, 0, UI_device_width, UI_device_height);
  1848. #endif /* __MMI_UI_DALMATIAN_CALENDAR__ */ 
  1849. }
  1850. /*****************************************************************************
  1851.  * FUNCTION
  1852.  *  wgui_register_calendar_keys
  1853.  * DESCRIPTION
  1854.  *  register calendar key handlers
  1855.  * PARAMETERS
  1856.  *  void
  1857.  * RETURNS
  1858.  *  void
  1859.  *****************************************************************************/
  1860. void wgui_register_calendar_keys(void)
  1861. {
  1862.     /*----------------------------------------------------------------*/
  1863.     /* Local Variables                                                */
  1864.     /*----------------------------------------------------------------*/
  1865.     /*----------------------------------------------------------------*/
  1866.     /* Code Body                                                      */
  1867.     /*----------------------------------------------------------------*/
  1868.     register_keyboard_key_handler(wgui_calendar_keyboard_key_handler);
  1869.     SetKeyHandler(wgui_calendar_previous_day, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1870.     SetKeyHandler(wgui_calendar_next_day, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1871.     SetKeyHandler(wgui_calendar_previous_row, KEY_UP_ARROW, KEY_EVENT_DOWN);
  1872.     SetKeyHandler(wgui_calendar_next_row, KEY_DOWN_ARROW, KEY_EVENT_DOWN);
  1873. }
  1874. /* High level functions for use by applications */
  1875. /*****************************************************************************
  1876.  * FUNCTION
  1877.  *  SetCalendarPopupTitleLunarFunc
  1878.  * DESCRIPTION
  1879.  *  set the function pointer of popuptitle of lunar calendar
  1880.  * PARAMETERS
  1881.  *  popuptitle      [IN]        ) (U8 ,U8 ) a function pointer with 2 U* parmeters
  1882.  * RETURNS
  1883.  *  void
  1884.  *****************************************************************************/
  1885. void SetCalendarPopupTitleLunarFunc(void (*popuptitle) (U8, U8, U8, U8))
  1886. {
  1887.     /*----------------------------------------------------------------*/
  1888.     /* Local Variables                                                */
  1889.     /*----------------------------------------------------------------*/
  1890.     /*----------------------------------------------------------------*/
  1891.     /* Code Body                                                      */
  1892.     /*----------------------------------------------------------------*/
  1893.     if (popuptitle != NULL)
  1894.     {
  1895.         MMI_calendar_control.popuptitle_lunarcalendar = popuptitle;
  1896.     }
  1897. }
  1898. /*****************************************************************************
  1899.  * FUNCTION
  1900.  *  SetCalendarMonthFunctions
  1901.  * DESCRIPTION
  1902.  *  Register function pointers of months navigation ofcalendar
  1903.  * PARAMETERS
  1904.  *  month_previous_day      [IN]        )(void) a function pointer which handle navigation to months previous day
  1905.  *  month_next_day          [IN]        )(void)     a function pointer which handle navigation to months next  day
  1906.  *  month_previous_week     [IN]        )(void)   a function pointer which handle navigation to months previous week
  1907.  *  month_next_week         [IN]        )(void)    a function pointer which handle navigation to months next week
  1908.  * RETURNS
  1909.  *  void
  1910.  *****************************************************************************/
  1911. void SetCalendarMonthFunctions(
  1912.         void (*month_previous_day) (void),
  1913.         void (*month_next_day) (void),
  1914.         void (*month_previous_week) (void),
  1915.         void (*month_next_week) (void))
  1916. {
  1917.     /*----------------------------------------------------------------*/
  1918.     /* Local Variables                                                */
  1919.     /*----------------------------------------------------------------*/
  1920.     /*----------------------------------------------------------------*/
  1921.     /* Code Body                                                      */
  1922.     /*----------------------------------------------------------------*/
  1923.     if (month_previous_day != NULL)
  1924.     {
  1925.         MMI_calendar_control.month_previous_day_function = month_previous_day;
  1926.     }
  1927.     if (month_next_day != NULL)
  1928.     {
  1929.         MMI_calendar_control.month_next_day_function = month_next_day;
  1930.     }
  1931.     if (month_previous_week != NULL)
  1932.     {
  1933.         MMI_calendar_control.month_previous_week_function = month_previous_week;
  1934.     }
  1935.     if (month_next_week != NULL)
  1936.     {
  1937.         MMI_calendar_control.month_next_week_function = month_next_week;
  1938.     }
  1939. }
  1940. /*****************************************************************************
  1941.  * FUNCTION
  1942.  *  wgui_calendar_previous_month
  1943.  * DESCRIPTION
  1944.  *  Side up key handler, go to 1st day of previous month.
  1945.  * PARAMETERS
  1946.  *  void
  1947.  * RETURNS
  1948.  *  void
  1949.  *****************************************************************************/
  1950. void wgui_calendar_previous_month(void)
  1951. {
  1952.     /*----------------------------------------------------------------*/
  1953.     /* Local Variables                                                */
  1954.     /*----------------------------------------------------------------*/
  1955.     /*----------------------------------------------------------------*/
  1956.     /* Code Body                                                      */
  1957.     /*----------------------------------------------------------------*/
  1958.     if (MMI_calendar_current_year != CLNDR_FIRST_NAVI_YEAR || MMI_calendar_current_month != 1)
  1959.     {
  1960.         MYTIME myTime, incTime, resultTime;;
  1961.         memset(&myTime, 0, sizeof(MYTIME));
  1962.         memset(&incTime, 0, sizeof(MYTIME));
  1963.         myTime.nDay = 1;
  1964.         myTime.nMonth = (U8) MMI_calendar_current_month;
  1965.         myTime.nYear = MMI_calendar_current_year;
  1966.         incTime.nMonth = 1;
  1967.         DecrementTime(myTime, incTime, &resultTime);
  1968.         MMI_calendar_highlighted_day = resultTime.nDay;
  1969.         MMI_calendar_current_month = resultTime.nMonth;
  1970.         MMI_calendar_current_year = resultTime.nYear;
  1971.     }
  1972.     else
  1973.     {
  1974.         MMI_calendar_highlighted_day = 1;
  1975.         MMI_calendar_current_month = 12;
  1976.         MMI_calendar_current_year = CLNDR_LAST_NAVI_YEAR;
  1977.     }
  1978.     wgui_calendar_control_update_handler();
  1979. }
  1980. /*****************************************************************************
  1981.  * FUNCTION
  1982.  *  wgui_calendar_next_month
  1983.  * DESCRIPTION
  1984.  *  Side down key handler, go to 1st day of next month.
  1985.  * PARAMETERS
  1986.  *  void
  1987.  * RETURNS
  1988.  *  void
  1989.  *****************************************************************************/
  1990. void wgui_calendar_next_month(void)
  1991. {
  1992.     /*----------------------------------------------------------------*/
  1993.     /* Local Variables                                                */
  1994.     /*----------------------------------------------------------------*/
  1995.     /*----------------------------------------------------------------*/
  1996.     /* Code Body                                                      */
  1997.     /*----------------------------------------------------------------*/
  1998.     if (MMI_calendar_current_year != CLNDR_LAST_NAVI_YEAR || MMI_calendar_current_month != 12)
  1999.     {
  2000.         MYTIME myTime, incTime, resultTime;;
  2001.         memset(&myTime, 0, sizeof(MYTIME));
  2002.         memset(&incTime, 0, sizeof(MYTIME));
  2003.         myTime.nDay = 1;
  2004.         myTime.nMonth = (U8) MMI_calendar_current_month;
  2005.         myTime.nYear = MMI_calendar_current_year;
  2006.         incTime.nMonth = 1;
  2007.         IncrementTime(myTime, incTime, &resultTime);
  2008.         MMI_calendar_highlighted_day = resultTime.nDay;
  2009.         MMI_calendar_current_month = resultTime.nMonth;
  2010.         MMI_calendar_current_year = resultTime.nYear;
  2011.     }
  2012.     else
  2013.     {
  2014.         MMI_calendar_highlighted_day = 1;
  2015.         MMI_calendar_current_month = 1;
  2016.         MMI_calendar_current_year = CLNDR_FIRST_NAVI_YEAR;
  2017.     }
  2018.     wgui_calendar_control_update_handler();
  2019. }
  2020. #if defined (__MMI_TOUCH_SCREEN__) && defined (__MMI_UI_CALENDAR_WITH_INFO_BOX__)
  2021. /*****************************************************************************
  2022.  * FUNCTION
  2023.  *  wgui_calendar_previous_year
  2024.  * DESCRIPTION
  2025.  *  Side up key handler, go to 1st day of previous year.
  2026.  * PARAMETERS
  2027.  *  void
  2028.  * RETURNS
  2029.  *  void
  2030.  *****************************************************************************/
  2031. void wgui_calendar_previous_year(void)
  2032. {
  2033.     /*----------------------------------------------------------------*/
  2034.     /* Local Variables                                                */
  2035.     /*----------------------------------------------------------------*/
  2036.     /*----------------------------------------------------------------*/
  2037.     /* Code Body                                                      */
  2038.     /*----------------------------------------------------------------*/
  2039.     if (MMI_calendar_current_year != CLNDR_FIRST_NAVI_YEAR)
  2040.     {
  2041.         MYTIME myTime, incTime, resultTime;;
  2042.         memset(&myTime, 0, sizeof(MYTIME));
  2043.         memset(&incTime, 0, sizeof(MYTIME));
  2044.         myTime.nDay = 1;
  2045.         myTime.nMonth = (U8)MMI_calendar_current_month;
  2046.         myTime.nYear = MMI_calendar_current_year;
  2047.         incTime.nYear = 1;
  2048.         DecrementTime(myTime, incTime, &resultTime);
  2049.         MMI_calendar_highlighted_day = resultTime.nDay;
  2050.         MMI_calendar_current_month = resultTime.nMonth;
  2051.         MMI_calendar_current_year = resultTime.nYear;
  2052.     }
  2053.     else
  2054.     {
  2055.         MMI_calendar_highlighted_day = 1;
  2056.         MMI_calendar_current_year = CLNDR_LAST_NAVI_YEAR;
  2057.     }
  2058.     wgui_calendar_control_update_handler();
  2059. }
  2060. /*****************************************************************************
  2061.  * FUNCTION
  2062.  *  wgui_calendar_next_year
  2063.  * DESCRIPTION
  2064.  *  Side down key handler, go to 1st day of next year.
  2065.  * PARAMETERS
  2066.  *  void
  2067.  * RETURNS
  2068.  *  void
  2069.  *****************************************************************************/
  2070. void wgui_calendar_next_year(void)
  2071. {
  2072.     /*----------------------------------------------------------------*/
  2073.     /* Local Variables                                                */
  2074.     /*----------------------------------------------------------------*/
  2075.     /*----------------------------------------------------------------*/
  2076.     /* Code Body                                                      */
  2077.     /*----------------------------------------------------------------*/
  2078.     if (MMI_calendar_current_year != CLNDR_LAST_NAVI_YEAR)
  2079.     {
  2080.         MYTIME myTime, incTime, resultTime;;
  2081.         memset(&myTime, 0, sizeof(MYTIME));
  2082.         memset(&incTime, 0, sizeof(MYTIME));
  2083.         myTime.nDay = 1;
  2084.         myTime.nMonth = (U8)MMI_calendar_current_month;
  2085.         myTime.nYear = MMI_calendar_current_year;
  2086.         incTime.nYear = 1;
  2087.         IncrementTime(myTime, incTime, &resultTime);
  2088.         MMI_calendar_highlighted_day = resultTime.nDay;
  2089.         MMI_calendar_current_month = resultTime.nMonth;
  2090.         MMI_calendar_current_year = resultTime.nYear;
  2091.     }
  2092.     else
  2093.     {
  2094.         MMI_calendar_highlighted_day = 1;
  2095.         MMI_calendar_current_year = CLNDR_FIRST_NAVI_YEAR;
  2096.     }
  2097.     wgui_calendar_control_update_handler();
  2098. }
  2099. #endif /* defined (__MMI_TOUCH_SCREEN__) && defined (__MMI_UI_CALENDAR_WITH_INFO_BOX__) */ 
  2100. /*****************************************************************************
  2101.  * FUNCTION
  2102.  *  wgui_calendar_next_month_day
  2103.  * DESCRIPTION
  2104.  *  Side down key handler, go to 1st day of next month.
  2105.  * PARAMETERS
  2106.  *  void
  2107.  * RETURNS
  2108.  *  void
  2109.  *****************************************************************************/
  2110. void wgui_calendar_next_month_day(void)
  2111. {
  2112.     /*----------------------------------------------------------------*/
  2113.     /* Local Variables                                                */
  2114.     /*----------------------------------------------------------------*/
  2115.     /*----------------------------------------------------------------*/
  2116.     /* Code Body                                                      */
  2117.     /*----------------------------------------------------------------*/
  2118.     if (MMI_calendar_current_year != CLNDR_LAST_NAVI_YEAR || MMI_calendar_current_month != 12)
  2119.     {
  2120.         MYTIME myTime, incTime, resultTime;