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

MTK

开发平台:

C/C++

  1. static S32 cat83_popup_y;
  2. static color cat83_title_fg = {0, 0, 0, 255};
  3. static color cat83_horizontal_select_fg = {8, 93, 189, 255};
  4. static color cat83_horizontal_select_border = {255, 255, 255, 255};
  5. static color cat83_vertical_select_fg = {255, 255, 255, 255};
  6. static color cat83_horizontal_string_fg = {0, 0, 0, 255};
  7. static color cat83_cell_bg[CAT83_COLOR_TOTAL] = {   {0, 0, 0, 255},
  8.                                                     {79, 249, 155, 255},
  9.                                                     {30, 49, 131, 255},
  10.                                                     {255, 70, 144, 255},
  11.                                                     {255, 126, 0, 255},
  12.                                                     {255, 234, 0, 255},
  13.                                                     {200, 200, 200, 255}  };
  14. static color cat83_cell_valid_fg = {30, 49, 131, 255};
  15. static color cat83_cell_invalid_fg = {192, 192, 192, 255};
  16. static color cat83_cell_highlight = {255, 0, 0, 255};
  17. static stFontAttribute *cat83_horizontal_string_font;
  18. static stFontAttribute *cat83_cell_font;
  19. static U32 cat83_row_num;
  20. static U32 cat83_column_num;
  21. static U32 cat83_current_row;
  22. static U32 cat83_current_column;
  23. static U32 cat83_highlighted_row;
  24. static U32 cat83_highlighted_column;
  25. static U32 cat83_highlighted_row_old;
  26. static U32 cat83_highlighted_column_old;
  27. static UI_image_ID_type cat83_bg_id;
  28. static U8 cat83_bg_updated = TRUE;
  29. static U8* cat83_cell_cache_buf = NULL;
  30. static U8* cat83_popup_cache_buf = NULL;
  31. #ifdef __MMI_UI_CALENDAR_WITH_INFO_BOX__
  32. typedef struct
  33. {
  34.     UI_image_ID_type *icon_list;
  35.     U8 **string_list;
  36.     U8 num_of_entry;
  37.     U8 is_updated;
  38. } wgui_cat83_infobox_struct;
  39. void wgui_cat83_set_infobox(UI_image_ID_type *icon_list, U8 **string_list, U8 entry_num);
  40. static void wgui_cat83_redraw_infobox(void);
  41. static wgui_cat83_infobox_struct cat83_infobox;
  42. static S32 cat83_infobox_x;
  43. static S32 cat83_infobox_y;
  44. static S32 cat83_infobox_width;
  45. static S32 cat83_infobox_height;
  46. static color cat83_infobox_bg = {218, 229, 245, 255};
  47. static color cat83_infobox_entry_bg = {184, 207, 240, 255};
  48. static color cat83_infobox_fg = {166, 27, 50, 255};
  49. static stFontAttribute *cat83_infobox_font;
  50. #endif
  51. #ifdef __GDI_MEMORY_PROFILE_2__
  52. GDI_HANDLE cat83_layer = GDI_LAYER_EMPTY_HANDLE;
  53. #endif
  54. /*****************************************************************************
  55.  * FUNCTION
  56.  *  wgui_cat83_init
  57.  * DESCRIPTION
  58.  *  initialize the settings of calendar
  59.  * PARAMETERS
  60.  *  calendar_type           [IN]        calendar type <- CAT83_INIT_TYPE 
  61.  *  row_num                 [IN]        number of row 
  62.  *  column_num              [IN]        number of column 
  63.  *  cell_buf                [IN]        buffer for cache 1 cell 
  64.  *  popup_buf               [IN]        buffer for cache 1 popup 
  65.  * RETURNS
  66.  *  void
  67.  *****************************************************************************/
  68. void wgui_calendar_init(U32 calendar_type, U32 row_num, U32 column_num, U8* cell_buf, U8* popup_buf)
  69. {
  70.     switch (calendar_type)
  71.     {
  72.         case CAT83_CALENDAR_NORMAL:
  73.             cat83_vertical_select_display = MMI_TRUE;
  74.             cat83_content_x = 0;
  75.             cat83_content_y = 0;
  76.             cat83_content_width = UI_device_width;
  77.             cat83_content_height = UI_device_height;
  78.             cat83_frame_line_pixel = CAT83_FRAME_LINE_PIXEL;
  79.             cat83_horizontal_select_x = CAT83_FRAME_START_X;
  80.             cat83_horizontal_select_y = MMI_status_bar_height;
  81.             cat83_horizontal_select_width = CAT83_FRAME_WIDTH;
  82.             cat83_horizontal_select_height = CAT83_FRAME_START_Y - cat83_horizontal_select_y;
  83.             cat83_title_x = CAT83_FRAME_START_X + cat83_frame_line_pixel;
  84.             cat83_title_y = CAT83_FRAME_START_Y + cat83_frame_line_pixel;
  85.             cat83_title_width = CAT83_FRAME_WIDTH - cat83_frame_line_pixel * 2;
  86.             cat83_title_height = CAT83_TITLE_HEIGHT;
  87.             cat83_vertical_select_x = CAT83_FRAME_START_X + cat83_frame_line_pixel;
  88.             cat83_vertical_select_y = cat83_title_y + cat83_title_height + cat83_frame_line_pixel;
  89.             cat83_vertical_select_width = CAT83_VERTICAL_SELECT_WIDTH;
  90.             cat83_vertical_select_height = CAT83_FRAME_HEIGHT - cat83_title_height - cat83_frame_line_pixel * 3;
  91.             cat83_horizontal_string_x = cat83_vertical_select_x + cat83_vertical_select_width + cat83_frame_line_pixel;
  92.             cat83_horizontal_string_y = cat83_vertical_select_y;
  93.             cat83_horizontal_string_width = CAT83_FRAME_WIDTH - cat83_vertical_select_width - cat83_frame_line_pixel * 3;
  94.             cat83_horizontal_string_height = CAT83_HORIZONTAL_STRING_HEIGHT;
  95.             cat83_cell_array_x = cat83_horizontal_string_x;
  96.             cat83_cell_array_y = cat83_horizontal_string_y + cat83_horizontal_string_height + cat83_frame_line_pixel;
  97.             cat83_cell_array_width = cat83_horizontal_string_width;
  98.             cat83_cell_array_height = cat83_vertical_select_height - cat83_horizontal_string_height - cat83_frame_line_pixel;
  99.         #ifdef __MMI_UI_CALENDAR_WITH_INFO_BOX__
  100.             cat83_infobox_x = CAT83_INFOBOX_START_X;
  101.             cat83_infobox_y = CAT83_INFOBOX_START_Y;
  102.             cat83_infobox_width = CAT83_INFOBOX_WIDTH;
  103.             cat83_infobox_height = CAT83_INFOBOX_HEIGHT;
  104.             #ifdef __MMI_MAINLCD_240X320__
  105.                 cat83_infobox_font = &MMI_medium_font;
  106.             #else
  107.                 cat83_infobox_font = &MMI_small_font;
  108.             #endif
  109.         #endif
  110.         #ifdef __MMI_MAINLCD_240X320__
  111.             cat83_horizontal_string_font = &MMI_sublcd_font;
  112.             cat83_cell_font = &MMI_sublcd_font;
  113.         #else
  114.             cat83_horizontal_string_font = &MMI_small_font;
  115.             cat83_cell_font = &MMI_small_font;
  116.         #endif
  117.             break;
  118.             
  119.         case CAT83_CALENDAR_SMALL:
  120.             cat83_vertical_select_display = MMI_FALSE;
  121.             cat83_content_x = 0;
  122.             cat83_content_y = 0;
  123.             cat83_content_width = UI_device_width;
  124.             cat83_content_height = UI_device_height - MMI_button_bar_height;
  125.             cat83_frame_line_pixel = CAT83_FRAME_LINE_PIXEL;
  126.             cat83_horizontal_select_x = CAT83_FRAME_START_X;
  127.             cat83_horizontal_select_y = 0;
  128.             cat83_horizontal_select_width = CAT83_FRAME_WIDTH;
  129.             cat83_horizontal_select_height = CAT83_FRAME_START_Y - cat83_horizontal_select_y;
  130.             cat83_title_x = CAT83_FRAME_START_X + cat83_frame_line_pixel;
  131.             cat83_title_y = CAT83_FRAME_START_Y + cat83_frame_line_pixel;
  132.             cat83_title_width = CAT83_FRAME_WIDTH - cat83_frame_line_pixel * 2;
  133.             cat83_title_height = CAT83_TITLE_HEIGHT;
  134.             //cat83_vertical_select_x = CAT83_FRAME_START_X + cat83_frame_line_pixel;
  135.             //cat83_vertical_select_y = cat83_title_y + cat83_title_height + cat83_frame_line_pixel;
  136.             //cat83_vertical_select_width = CAT83_VERTICAL_SELECT_WIDTH;
  137.             //cat83_vertical_select_height = CAT83_FRAME_HEIGHT - cat83_title_height - cat83_frame_line_pixel * 3;
  138.             cat83_horizontal_string_x = CAT83_FRAME_START_X + cat83_frame_line_pixel;
  139.             cat83_horizontal_string_y = cat83_title_y + cat83_title_height + cat83_frame_line_pixel;
  140.             cat83_horizontal_string_width = CAT83_FRAME_WIDTH - cat83_frame_line_pixel * 2;
  141.             cat83_horizontal_string_height = CAT83_HORIZONTAL_STRING_HEIGHT;
  142.             cat83_cell_array_x = cat83_horizontal_string_x;
  143.             cat83_cell_array_y = cat83_horizontal_string_y + cat83_horizontal_string_height + cat83_frame_line_pixel;
  144.             cat83_cell_array_width = cat83_horizontal_string_width;
  145.             cat83_cell_array_height = cat83_vertical_select_height - cat83_horizontal_string_height - cat83_frame_line_pixel;
  146.             cat83_horizontal_string_font = &MMI_small_font;
  147.             cat83_cell_font = &MMI_small_font;
  148.             break;
  149.         case IDLE_NORMAL:
  150.             break;
  151.         default:
  152.             MMI_ASSERT(0);
  153.             break;
  154.     }
  155.     
  156.     cat83_row_num = row_num;
  157.     cat83_column_num = column_num;
  158.     cat83_cell_width = (cat83_cell_array_width-(cat83_column_num-1)*cat83_frame_line_pixel)/cat83_column_num;
  159.     cat83_cell_height = (cat83_cell_array_height-(cat83_row_num-1)*cat83_frame_line_pixel)/cat83_row_num;
  160.     cat83_cell_cache.buf_ptr = cell_buf;
  161.     cat83_popup_cache.buf_ptr = popup_buf;
  162.     cat83_cell_bg[CAT83_COLOR_CURRENT] = current_UI_theme->fixed_text_menuitem_theme->selected_filler->c;
  163.     cat83_highlighted_row = 0xffffffff;
  164.     cat83_highlighted_column = 0xffffffff;
  165.     cat83_highlighted_row_old = 0xffffffff;
  166.     cat83_highlighted_column_old = 0xffffffff;
  167. }
  168. /*****************************************************************************
  169.  * FUNCTION
  170.  *  wgui_cat83_bg
  171.  * DESCRIPTION
  172.  *  set the background image id
  173.  * PARAMETERS
  174.  *  bg_id                   [IN]        background image id
  175.  * RETURNS
  176.  *  void
  177.  *****************************************************************************/
  178. void wgui_cat83_set_bg(UI_image_ID_type bg_id)
  179. {
  180.     cat83_bg_id = bg_id;
  181.     cat83_bg_updated = TRUE;
  182. }
  183. /*****************************************************************************
  184.  * FUNCTION
  185.  *  wgui_cat83_set_select_horizontal1
  186.  * DESCRIPTION
  187.  *  set the horizontal select 1
  188.  * PARAMETERS
  189.  *  left_up                 [IN]        left image during up state
  190.  *  left_up                 [IN]        left image during down state
  191.  *  left_up                 [IN]        right image during up state
  192.  *  left_up                 [IN]        right image during down state
  193.  *  string                  [IN]        text string
  194.  *  align_type              [IN]        alignment type: CAT83_SELECT_ALIGN_CENTER | CAT83_SELECT_ALIGN_LEFT
  195.  * RETURNS
  196.  *  void
  197.  *****************************************************************************/
  198. void wgui_cat83_set_select_horizontal1(UI_image_ID_type left_up, UI_image_ID_type left_down, UI_image_ID_type right_up, UI_image_ID_type right_down, U8 *string, U32 align_type)
  199. {
  200.     cat83_horizontal_select[0].left_up = left_up;
  201.     cat83_horizontal_select[0].left_down = left_down;
  202.     cat83_horizontal_select[0].right_up = right_up;
  203.     cat83_horizontal_select[0].right_down = right_down;
  204.     cat83_horizontal_select[0].string = string;
  205.     cat83_horizontal_select[0].align_type = align_type;
  206.     cat83_horizontal_select[0].left_pressed = 0;
  207.     cat83_horizontal_select[0].right_pressed = 0;
  208.     cat83_horizontal_select[0].is_updated = TRUE;   
  209.     if (left_up != 0)
  210.     {
  211.         gdi_image_get_dimension_id((U16)left_up, &cat83_horizontal_select[0].left_width, &cat83_horizontal_select[0].left_height);
  212.     }
  213.     else
  214.     {
  215.         cat83_horizontal_select[0].left_width = cat83_horizontal_select[0].left_height = 0;
  216.     }
  217.     if (right_up != 0)
  218.     {
  219.         gdi_image_get_dimension_id((U16)right_up, &cat83_horizontal_select[0].right_width, &cat83_horizontal_select[0].right_height);
  220.     }
  221.     else
  222.     {
  223.         cat83_horizontal_select[0].right_width = cat83_horizontal_select[0].right_height = 0;
  224.     } 
  225. }
  226. void wgui_cat83_set_select_horizontal1_string(U8 *string)
  227. {
  228.     cat83_horizontal_select[0].string = string;
  229.     cat83_horizontal_select[0].is_updated = TRUE;    
  230. }
  231. void wgui_cat83_set_select_horizontal1_handler(Cat83EventFuncPtr left_handler, Cat83EventFuncPtr right_handler)
  232. {
  233.     cat83_horizontal_select[0].left_handler = left_handler;
  234.     cat83_horizontal_select[0].right_handler = right_handler;
  235. }
  236. /*****************************************************************************
  237.  * FUNCTION
  238.  *  wgui_cat83_set_select_horizontal2
  239.  * DESCRIPTION
  240.  *  set the horizontal select 2
  241.  * PARAMETERS
  242.  *  left_up                 [IN]        left image during up state
  243.  *  left_up                 [IN]        left image during down state
  244.  *  left_up                 [IN]        right image during up state
  245.  *  left_up                 [IN]        right image during down state
  246.  *  string                  [IN]        text string
  247.  *  align_type              [IN]        alignment type: CAT83_SELECT_ALIGN_CENTER | CAT83_SELECT_ALIGN_LEFT
  248.  * RETURNS
  249.  *  void
  250.  *****************************************************************************/
  251. void wgui_cat83_set_select_horizontal2(UI_image_ID_type left_up, UI_image_ID_type left_down, UI_image_ID_type right_up, UI_image_ID_type right_down, U8 *string, U32 align_type)
  252. {
  253.     cat83_horizontal_select[1].left_up = left_up;
  254.     cat83_horizontal_select[1].left_down = left_down;
  255.     cat83_horizontal_select[1].right_up = right_up;
  256.     cat83_horizontal_select[1].right_down = right_down;
  257.     cat83_horizontal_select[1].string = string;
  258.     cat83_horizontal_select[1].align_type = align_type;
  259.     cat83_horizontal_select[1].left_pressed = 0;
  260.     cat83_horizontal_select[1].right_pressed = 0;
  261.     cat83_horizontal_select[1].is_updated = TRUE;     
  262.     if (left_up != 0)
  263.     {
  264.         gdi_image_get_dimension_id((U16)left_up, &cat83_horizontal_select[1].left_width, &cat83_horizontal_select[1].left_height);
  265.     }
  266.     else
  267.     {
  268.         cat83_horizontal_select[1].left_width = cat83_horizontal_select[1].left_height = 0;
  269.     }
  270.     if (right_up != 0)
  271.     {
  272.         gdi_image_get_dimension_id((U16)right_up, &cat83_horizontal_select[1].right_width, &cat83_horizontal_select[1].right_height);
  273.     }
  274.     else
  275.     {
  276.         cat83_horizontal_select[1].right_width = cat83_horizontal_select[1].right_height = 0;
  277.     } 
  278. }
  279. void wgui_cat83_set_select_horizontal2_string(U8 *string)
  280. {
  281.     cat83_horizontal_select[1].string = string;
  282.     cat83_horizontal_select[1].is_updated = TRUE; 
  283. }  
  284. void wgui_cat83_set_select_horizontal2_handler(Cat83EventFuncPtr left_handler, Cat83EventFuncPtr right_handler)
  285. {
  286.     cat83_horizontal_select[1].left_handler = left_handler;
  287.     cat83_horizontal_select[1].right_handler = right_handler;
  288. }
  289. /*****************************************************************************
  290.  * FUNCTION
  291.  *  wgui_cat83_set_select_vertical
  292.  * DESCRIPTION
  293.  *  set the vertical select 
  294.  * PARAMETERS
  295.  *  top_up                  [IN]        top image during up state
  296.  *  top_down                [IN]        top image during down state
  297.  *  bottom_up               [IN]        bottom image during up state
  298.  *  bottom_down             [IN]        bottom image during down state
  299.  *  string_list             [IN]        text string list
  300.  *  align_type              [IN]        alignment type: CAT83_SELECT_ALIGN_LINE | CAT83_SELECT_ALIGN_CELL
  301.  * RETURNS
  302.  *  void
  303.  *****************************************************************************/
  304. void wgui_cat83_set_select_vertical(UI_image_ID_type top_up, UI_image_ID_type top_down, UI_image_ID_type bottom_up, UI_image_ID_type bottom_down, U8 **string_list, U32 align_type)
  305. {
  306.     cat83_vertical_select.top_up = top_up;
  307.     cat83_vertical_select.top_down = top_down;
  308.     cat83_vertical_select.bottom_up = bottom_up;
  309.     cat83_vertical_select.bottom_down = bottom_down;
  310.     cat83_vertical_select.string_list = string_list;
  311.     cat83_vertical_select.align_type = align_type;
  312.     cat83_vertical_select.top_pressed = 0;
  313.     cat83_vertical_select.bottom_pressed = 0;
  314.     cat83_vertical_select.is_updated = TRUE;
  315.     if (top_up != 0)
  316.     {
  317.         gdi_image_get_dimension_id((U16)top_up, &cat83_vertical_select.top_width, &cat83_vertical_select.top_height);
  318.     }
  319.     else
  320.     {
  321.         cat83_vertical_select.top_width = cat83_vertical_select.top_height = 0;
  322.     }
  323.     if (bottom_up != 0)
  324.     {
  325.         gdi_image_get_dimension_id((U16)top_up, &cat83_vertical_select.bottom_width, &cat83_vertical_select.bottom_height);
  326.     }
  327.     else
  328.     {
  329.         cat83_vertical_select.bottom_width = cat83_vertical_select.bottom_height = 0;
  330.     }
  331. }
  332. void wgui_cat83_set_select_vertical_string(U8 **string_list)
  333. {
  334.     cat83_vertical_select.string_list = string_list;
  335.     cat83_vertical_select.is_updated = TRUE;
  336. }  
  337. void wgui_cat83_set_select_vertical_handler(Cat83EventFuncPtr top_handler, Cat83EventFuncPtr bottom_handler)
  338. {
  339.     cat83_vertical_select.top_handler = top_handler;
  340.     cat83_vertical_select.bottom_handler = bottom_handler;
  341. }
  342. void wgui_cat83_set_normal_title(U8 *string)
  343. {
  344.     cat83_title.string1 = string;
  345.     cat83_title.show_title= wgui_cat83_redraw_normal_title;
  346.     cat83_title.is_updated = TRUE;
  347. }
  348. void wgui_cat83_set_menstrual_title(U8 color_index1, U8 *string1, U8 color_index2, U8 *string2)
  349. {
  350.     cat83_title.color_index1 = color_index1;
  351.     cat83_title.string1 = string1;
  352.     cat83_title.color_index2 = color_index2;
  353.     cat83_title.string2 = string2;
  354.     cat83_title.show_title= wgui_cat83_redraw_menstrual_title;
  355.     cat83_title.is_updated = TRUE;
  356. }
  357. void wgui_cat83_set_horizontal_string(U8 **string_list)
  358. {
  359.     cat83_horizontal_string.string_list = string_list;
  360.     cat83_horizontal_string.is_updated = TRUE;
  361. }
  362. void wgui_cat83_set_cell_array(wgui_cat83_cell_struct *cell, U8 cell_bg_fill_type, U8 cell_text_display_type, U8 cell_icon_display_type)
  363. {
  364.     cat83_cell_array.cell = cell;
  365.     cat83_cell_array.bg_fill_type= cell_bg_fill_type;
  366.     cat83_cell_array.text_display_type = cell_text_display_type;
  367.     cat83_cell_array.icon_display_type = cell_icon_display_type;
  368.     cat83_cell_array.is_updated = TRUE;
  369. #ifdef __MMI_TOUCH_SCREEN__
  370.     cat83_cell_array.pen_on_highlighted = FALSE;
  371. #endif
  372. }
  373. void wgui_cat83_set_current(U32 current_row, U32 current_column)
  374. {
  375.     cat83_current_row = current_row;
  376.     cat83_current_column = current_column;
  377.     cat83_cell_array.is_updated = TRUE;
  378. }
  379. void wgui_cat83_set_highlight(U32 highlighted_row, U32 highlighted_column)
  380. {
  381.     cat83_highlighted_row_old = cat83_highlighted_row;
  382.     cat83_highlighted_column_old = cat83_highlighted_column;
  383.     cat83_highlighted_row = highlighted_row;
  384.     cat83_highlighted_column = highlighted_column;
  385. }
  386. void wgui_cat83_set_popup(U8 *message1, U8 *message2, U8 *message3)
  387. {
  388.     cat83_popup.message1 = message1;
  389.     cat83_popup.message2 = message2;
  390.     cat83_popup.message3 = message3;
  391.     cat83_popup.need_popup = TRUE;
  392. }
  393. #ifdef __MMI_UI_CALENDAR_WITH_INFO_BOX__
  394. void wgui_cat83_set_infobox(UI_image_ID_type *icon_list, U8 **string_list, U8 entry_num)
  395. {
  396.     cat83_infobox.icon_list = icon_list;
  397.     cat83_infobox.string_list = string_list;
  398.     MMI_ASSERT(entry_num <= CAT83_MAX_INFOBOX);
  399.     cat83_infobox.num_of_entry = entry_num;
  400.     cat83_infobox.is_updated = TRUE;
  401. }
  402. #endif
  403. void wgui_cat83_register_cell_highlight_handler(MMI_BOOL (*app_cell_highlight_handler)(U32 highlighted_row, U32 highlighted_column))
  404. {
  405.     Cat83AppCellHighlightHanlder = app_cell_highlight_handler;
  406. }
  407. void wgui_cat83_register_left_arrow_key_handler(MMI_BOOL (*app_left_arrow_key_handler)(U32 highlighted_row, U32 highlighted_column))
  408. {
  409.     Cat83AppLeftArrowKeyHanlder = app_left_arrow_key_handler;
  410. }
  411. void wgui_cat83_register_right_arrow_key_handler(MMI_BOOL (*app_right_arrow_key_handler)(U32 highlighted_row, U32 highlighted_column))
  412. {
  413.     Cat83AppRightArrowKeyHanlder = app_right_arrow_key_handler;
  414. }
  415. void wgui_cat83_register_up_arrow_key_handler(MMI_BOOL (*app_up_arrow_key_handler)(U32 highlighted_row, U32 highlighted_column))
  416. {
  417.     Cat83AppUpArrowKeyHanlder = app_up_arrow_key_handler;
  418. }
  419. void wgui_cat83_register_down_arrow_key_handler(MMI_BOOL (*app_down_arrow_key_handler)(U32 highlighted_row, U32 highlighted_column))
  420. {
  421.     Cat83AppDownArrowKeyHanlder = app_down_arrow_key_handler;
  422. }
  423. void wgui_cat83_register_up_side_key_handler(MMI_BOOL (*app_up_side_key_handler)(U32 highlighted_row, U32 highlighted_column))
  424. {
  425.     Cat83AppUpSideKeyHanlder = app_up_side_key_handler;
  426. }
  427. void wgui_cat83_register_down_side_key_handler(MMI_BOOL (*app_down_side_key_handler)(U32 highlighted_row, U32 highlighted_column))
  428. {
  429.     Cat83AppDownSideKeyHanlder = app_down_side_key_handler;
  430. }
  431. /*****************************************************************************
  432.  * FUNCTION
  433.  *  Cat83HandleKeyRight
  434.  * DESCRIPTION
  435.  *  Right arrow key handler of Cat83.
  436.  * PARAMETERS
  437.  *  void
  438.  * RETURNS
  439.  *  void
  440.  *****************************************************************************/
  441. static void Cat83HandleKeyRight(void)
  442. {
  443.     U32 temp_row = cat83_highlighted_row;
  444.     U32 temp_column = cat83_highlighted_column + 1;
  445.     //if(temp_column == cat83_column_num)
  446.     //{
  447.     //    temp_column = 0;
  448.     //    temp_row++;
  449.     //}
  450.     
  451.     if ((temp_row < cat83_row_num) && (temp_column < cat83_column_num) && 
  452.         (wgui_cat83_cell_struct*)(cat83_cell_array.cell+temp_row*cat83_column_num+temp_column)->valid)
  453.     {        
  454.         cat83_highlighted_row_old = cat83_highlighted_row;
  455.         cat83_highlighted_column_old = cat83_highlighted_column;
  456.         cat83_highlighted_row = temp_row;
  457.         cat83_highlighted_column = temp_column;
  458.         wgui_calendar_unhighlight_cell(cat83_highlighted_row_old, cat83_highlighted_column_old);
  459.         wgui_calendar_highlight_cell(cat83_highlighted_row, cat83_highlighted_column);
  460.         /* Infobox */
  461.         
  462.     }
  463.     else
  464.     {
  465.         if (Cat83AppRightArrowKeyHanlder)
  466.         {
  467.             if (Cat83AppRightArrowKeyHanlder(cat83_highlighted_row, cat83_highlighted_column))
  468.             {
  469.                 RedrawCategory83Screen();
  470.             }
  471.         }
  472.     }
  473.     gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  474. }
  475. /*****************************************************************************
  476.  * FUNCTION
  477.  *  Cat83HandleKeyLeft
  478.  * DESCRIPTION
  479.  *  Left arrow key handler of Cat83.
  480.  * PARAMETERS
  481.  *  void
  482.  * RETURNS
  483.  *  void
  484.  *****************************************************************************/
  485. static void Cat83HandleKeyLeft(void)
  486. {
  487.     U32 temp_row = cat83_highlighted_row;
  488.     U32 temp_column = cat83_highlighted_column - 1;
  489.     //if(temp_column >= cat83_column_num)
  490.     //{
  491.     //    temp_column = cat83_column_num - 1;
  492.     //    temp_row--;
  493.     //}
  494.     
  495.     if ((temp_row < cat83_row_num) && (temp_column < cat83_column_num) && 
  496.         (wgui_cat83_cell_struct*)(cat83_cell_array.cell+temp_row*cat83_column_num+temp_column)->valid)
  497.     {        
  498.         cat83_highlighted_row_old = cat83_highlighted_row;
  499.         cat83_highlighted_column_old = cat83_highlighted_column;
  500.         cat83_highlighted_row = temp_row;
  501.         cat83_highlighted_column = temp_column;
  502.         wgui_calendar_unhighlight_cell(cat83_highlighted_row_old, cat83_highlighted_column_old);
  503.         wgui_calendar_highlight_cell(cat83_highlighted_row, cat83_highlighted_column);
  504.         /* Infobox */
  505.         
  506.     }
  507.     else
  508.     {
  509.         if (Cat83AppLeftArrowKeyHanlder)
  510.         {
  511.             if (Cat83AppLeftArrowKeyHanlder(cat83_highlighted_row, cat83_highlighted_column))
  512.             {
  513.                 RedrawCategory83Screen();
  514.             }
  515.         }
  516.     }
  517.     gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  518. }
  519. /*****************************************************************************
  520.  * FUNCTION
  521.  *  Cat83HandleKeyUp
  522.  * DESCRIPTION
  523.  *  Up arrow key handler of Cat83.
  524.  * PARAMETERS
  525.  *  void
  526.  * RETURNS
  527.  *  void
  528.  *****************************************************************************/
  529. static void Cat83HandleKeyUp(void)
  530. {
  531.     U32 temp_row = cat83_highlighted_row - 1;
  532.     U32 temp_column = cat83_highlighted_column;
  533.     //if(temp_row >= cat83_row_num)
  534.     //{
  535.     //    temp_row = cat83_row_num - 1;
  536.     //}
  537.     
  538.     if ((temp_row < cat83_row_num) && (temp_column < cat83_column_num) && 
  539.         (wgui_cat83_cell_struct*)(cat83_cell_array.cell+temp_row*cat83_column_num+temp_column)->valid)
  540.     {        
  541.         cat83_highlighted_row_old = cat83_highlighted_row;
  542.         cat83_highlighted_column_old = cat83_highlighted_column;
  543.         cat83_highlighted_row = temp_row;
  544.         cat83_highlighted_column = temp_column;
  545.         wgui_calendar_unhighlight_cell(cat83_highlighted_row_old, cat83_highlighted_column_old);
  546.         wgui_calendar_highlight_cell(cat83_highlighted_row, cat83_highlighted_column);
  547.         /* Infobox */
  548.         
  549.     }
  550.     else
  551.     {
  552.         if (Cat83AppUpArrowKeyHanlder)
  553.         {
  554.             if (Cat83AppUpArrowKeyHanlder(cat83_highlighted_row, cat83_highlighted_column))
  555.             {
  556.                 RedrawCategory83Screen();
  557.             }
  558.         }
  559.     }
  560.     gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  561. }
  562. /*****************************************************************************
  563.  * FUNCTION
  564.  *  Cat83HandleKeyDown
  565.  * DESCRIPTION
  566.  *  Down arrow key handler of Cat83.
  567.  * PARAMETERS
  568.  *  void
  569.  * RETURNS
  570.  *  void
  571.  *****************************************************************************/
  572. static void Cat83HandleKeyDown(void)
  573. {
  574.     U32 temp_row = cat83_highlighted_row + 1;
  575.     U32 temp_column = cat83_highlighted_column;
  576.     //if(temp_row == cat83_row_num)
  577.     //{
  578.     //    temp_row = 0;
  579.     //}
  580.     
  581.     if ((temp_row < cat83_row_num) && (temp_column < cat83_column_num) && 
  582.         (wgui_cat83_cell_struct*)(cat83_cell_array.cell+temp_row*cat83_column_num+temp_column)->valid)
  583.     {        
  584.         cat83_highlighted_row_old = cat83_highlighted_row;
  585.         cat83_highlighted_column_old = cat83_highlighted_column;
  586.         cat83_highlighted_row = temp_row;
  587.         cat83_highlighted_column = temp_column;
  588.         wgui_calendar_unhighlight_cell(cat83_highlighted_row_old, cat83_highlighted_column_old);
  589.         wgui_calendar_highlight_cell(cat83_highlighted_row, cat83_highlighted_column);
  590.         /* Infobox */
  591.         
  592.     }
  593.     else
  594.     {
  595.         if (Cat83AppDownArrowKeyHanlder)
  596.         {
  597.             if (Cat83AppDownArrowKeyHanlder(cat83_highlighted_row, cat83_highlighted_column))
  598.             {
  599.                 RedrawCategory83Screen();
  600.             }
  601.         }
  602.     }
  603.     gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  604. }
  605. /*****************************************************************************
  606.  * FUNCTION
  607.  *  Cat83HandleSideKeyUp
  608.  * DESCRIPTION
  609.  *  Up side key handler of Cat83.
  610.  * PARAMETERS
  611.  *  void
  612.  * RETURNS
  613.  *  void
  614.  *****************************************************************************/
  615. static void Cat83HandleSideKeyUp(void)
  616. {
  617.     if (Cat83AppUpSideKeyHanlder)
  618.     {
  619.         if (Cat83AppUpSideKeyHanlder(cat83_highlighted_row, cat83_highlighted_column))
  620.         {
  621.             RedrawCategory83Screen();
  622.             gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  623.         }
  624.     }
  625. }
  626. /*****************************************************************************
  627.  * FUNCTION
  628.  *  Cat83HandleSideKeyDown
  629.  * DESCRIPTION
  630.  *  Down side key handler of Cat83.
  631.  * PARAMETERS
  632.  *  void
  633.  * RETURNS
  634.  *  void
  635.  *****************************************************************************/
  636. static void Cat83HandleSideKeyDown(void)
  637. {
  638.     if (Cat83AppDownSideKeyHanlder)
  639.     {
  640.         if (Cat83AppDownSideKeyHanlder(cat83_highlighted_row, cat83_highlighted_column))
  641.         {
  642.             RedrawCategory83Screen();
  643.             gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  644.         }
  645.     }
  646. }
  647. #ifdef __MMI_TOUCH_SCREEN__
  648. static void wgui_calendar_translate_pen_position(S32 x, S32 y, U32* pen_row, U32* pen_column)
  649. {
  650.     if ((x-cat83_cell_array_x+1) % (cat83_cell_width+cat83_frame_line_pixel) != 0)
  651.     {
  652.         *pen_column = (x-cat83_cell_array_x+1) / (cat83_cell_width+cat83_frame_line_pixel);
  653.     }
  654.     
  655.     if ((y-cat83_cell_array_y+1) % (cat83_cell_height+cat83_frame_line_pixel) != 0)
  656.     {
  657.         *pen_row = (y-cat83_cell_array_y+1) / (cat83_cell_height+cat83_frame_line_pixel);
  658.     }
  659. }
  660. static MMI_BOOL Cat83PenDownHandler(mmi_pen_point_struct pos)
  661. {
  662.     /*----------------------------------------------------------------*/
  663.     /* Local Variables                                                */
  664.     /*----------------------------------------------------------------*/
  665.     /*----------------------------------------------------------------*/
  666.     /* Code Body                                                      */
  667.     /*----------------------------------------------------------------*/
  668.     /* horizontal select 1 */
  669.     if (PEN_CHECK_BOUND(pos.x, pos.y, cat83_horizontal_select_x, cat83_horizontal_select_y, cat83_horizontal_select_width>>1, cat83_horizontal_select_height))
  670.     {
  671.         /* left arrow */
  672.         if (PEN_CHECK_BOUND(pos.x, pos.y, cat83_horizontal_select_x+CAT83_HORIZONTAL_SELECT_GAP_BORDER, cat83_horizontal_select_y+((cat83_horizontal_select_height-cat83_horizontal_select[0].left_height)>>1), cat83_horizontal_select[0].left_width, cat83_horizontal_select[0].left_height))
  673.         {
  674.             gdi_layer_lock_frame_buffer();
  675.             cat83_horizontal_select[0].left_pressed = 1;
  676.             wgui_cat83_redraw_select_horizontal1();
  677.             gdi_layer_unlock_frame_buffer();
  678.             gdi_layer_blt_previous(cat83_horizontal_select_x, cat83_horizontal_select_y, cat83_horizontal_select_x+(cat83_horizontal_select_width>>1)-1, cat83_horizontal_select_y+cat83_horizontal_select_height-1);
  679.             cat83_horizontal_select[0].left_pressed = 0;
  680.             cat83_horizontal_select[0].is_updated = 1;
  681.             if(cat83_horizontal_select[0].left_handler)
  682.             {
  683.                 if(cat83_horizontal_select[0].left_handler(cat83_highlighted_row, cat83_highlighted_column))
  684.                 {
  685.                     RedrawCategory83Screen();
  686.                     gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  687.                 }
  688.             }
  689.         }
  690.         /* right arrow */
  691.         if (PEN_CHECK_BOUND(pos.x, pos.y, cat83_horizontal_select_x+(cat83_horizontal_select_width>>1)-cat83_horizontal_select[0].right_width-CAT83_HORIZONTAL_SELECT_GAP_OTHER, cat83_horizontal_select_y+((cat83_horizontal_select_height-cat83_horizontal_select[0].right_height)>>1), cat83_horizontal_select[0].right_width, cat83_horizontal_select[0].right_height))
  692.         {
  693.             gdi_layer_lock_frame_buffer();
  694.             cat83_horizontal_select[0].right_pressed = 1;
  695.             wgui_cat83_redraw_select_horizontal1();
  696.             gdi_layer_unlock_frame_buffer();
  697.             gdi_layer_blt_previous(cat83_horizontal_select_x, cat83_horizontal_select_y, cat83_horizontal_select_x+(cat83_horizontal_select_width>>1)-1, cat83_horizontal_select_y+cat83_horizontal_select_height-1);
  698.             cat83_horizontal_select[0].right_pressed = 0;
  699.             cat83_horizontal_select[0].is_updated = 1;
  700.             if(cat83_horizontal_select[0].right_handler)
  701.             {
  702.                 if(cat83_horizontal_select[0].right_handler(cat83_highlighted_row, cat83_highlighted_column))
  703.                 {
  704.                     RedrawCategory83Screen();
  705.                     gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  706.                 }
  707.             }
  708.         }
  709.     }
  710.     /* horizontal select 2 */
  711.     if (PEN_CHECK_BOUND(pos.x, pos.y, cat83_horizontal_select_x+(cat83_horizontal_select_width>>1), cat83_horizontal_select_y, cat83_horizontal_select_width>>1, cat83_horizontal_select_height))
  712.     {
  713.         /* left arrow */
  714.         if (PEN_CHECK_BOUND(pos.x, pos.y, cat83_horizontal_select_x+(cat83_horizontal_select_width>>1)+CAT83_HORIZONTAL_SELECT_GAP_OTHER, cat83_horizontal_select_y+((cat83_horizontal_select_height-cat83_horizontal_select[1].left_height)>>1), cat83_horizontal_select[1].left_width, cat83_horizontal_select[1].left_height))
  715.         {
  716.             gdi_layer_lock_frame_buffer();
  717.             cat83_horizontal_select[1].left_pressed = 1;
  718.             wgui_cat83_redraw_select_horizontal2();
  719.             gdi_layer_unlock_frame_buffer();
  720.             gdi_layer_blt_previous(cat83_horizontal_select_x+(cat83_horizontal_select_width>>1), cat83_horizontal_select_y, cat83_horizontal_select_x+cat83_horizontal_select_width-1, cat83_horizontal_select_y+cat83_horizontal_select_height-1);
  721.             cat83_horizontal_select[1].left_pressed = 0;
  722.             cat83_horizontal_select[1].is_updated = 1;
  723.             if(cat83_horizontal_select[1].left_handler)
  724.             {
  725.                 if(cat83_horizontal_select[1].left_handler(cat83_highlighted_row, cat83_highlighted_column))
  726.                 {
  727.                     RedrawCategory83Screen();
  728.                     gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  729.                 }
  730.             }
  731.         }
  732.         /* right arrow */
  733.         if (PEN_CHECK_BOUND(pos.x, pos.y, cat83_horizontal_select_x+cat83_horizontal_select_width-cat83_horizontal_select[0].right_width-CAT83_HORIZONTAL_SELECT_GAP_BORDER, cat83_horizontal_select_y+((cat83_horizontal_select_height-cat83_horizontal_select[1].right_height)>>1), cat83_horizontal_select[1].right_width, cat83_horizontal_select[1].right_height))
  734.         {
  735.             gdi_layer_lock_frame_buffer();
  736.             cat83_horizontal_select[1].right_pressed = 1;
  737.             wgui_cat83_redraw_select_horizontal2();
  738.             gdi_layer_unlock_frame_buffer();
  739.             gdi_layer_blt_previous(cat83_horizontal_select_x+(cat83_horizontal_select_width>>1), cat83_horizontal_select_y, cat83_horizontal_select_x+cat83_horizontal_select_width-1, cat83_horizontal_select_y+cat83_horizontal_select_height-1);
  740.             cat83_horizontal_select[1].right_pressed = 0;
  741.             cat83_horizontal_select[1].is_updated = 1;
  742.             if(cat83_horizontal_select[1].right_handler)
  743.             {
  744.                 if(cat83_horizontal_select[1].right_handler(cat83_highlighted_row, cat83_highlighted_column))
  745.                 {
  746.                     RedrawCategory83Screen();
  747.                     gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  748.                 }
  749.             }
  750.         }
  751.     }
  752.     /* vertical select */
  753.     if (PEN_CHECK_BOUND(pos.x, pos.y, cat83_vertical_select_x, cat83_vertical_select_y, cat83_vertical_select_width, cat83_vertical_select_height))
  754.     {
  755.         /* top arrow */
  756.         if (PEN_CHECK_BOUND(pos.x, pos.y, cat83_vertical_select_x+((cat83_vertical_select_width-cat83_vertical_select.top_width)>>1), cat83_vertical_select_y + 1, cat83_vertical_select.top_width, cat83_vertical_select.top_height))
  757.         {
  758.             gdi_layer_lock_frame_buffer();
  759.             cat83_vertical_select.top_pressed = 1;
  760.             wgui_cat83_redraw_select_vertical();
  761.             gdi_layer_unlock_frame_buffer();
  762.             gdi_layer_blt_previous(cat83_vertical_select_x, cat83_vertical_select_y, cat83_vertical_select_x+cat83_vertical_select_width-1, cat83_vertical_select_y+cat83_vertical_select_height-1);
  763.             cat83_vertical_select.top_pressed = 0;
  764.             cat83_vertical_select.is_updated = 1;
  765.             if(cat83_vertical_select.top_handler)
  766.             {
  767.                 cat83_vertical_select.top_handler(cat83_highlighted_row, cat83_highlighted_column);
  768.             }
  769.             RedrawCategory83Screen();
  770.             gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  771.         }
  772.         /* bottom arrow */
  773.         if (PEN_CHECK_BOUND(pos.x, pos.y, cat83_vertical_select_x+((cat83_vertical_select_width-cat83_vertical_select.top_width)>>1), cat83_vertical_select_y+cat83_vertical_select_height-cat83_vertical_select.bottom_height-1, cat83_vertical_select.bottom_width, cat83_vertical_select.bottom_height))
  774.         {
  775.             gdi_layer_lock_frame_buffer();
  776.             cat83_vertical_select.bottom_pressed = 1;
  777.             wgui_cat83_redraw_select_vertical();
  778.             gdi_layer_unlock_frame_buffer();
  779.             gdi_layer_blt_previous(cat83_vertical_select_x, cat83_vertical_select_y, cat83_vertical_select_x+cat83_vertical_select_width-1, cat83_vertical_select_y+cat83_vertical_select_height-1);
  780.             cat83_vertical_select.bottom_pressed = 0;
  781.             cat83_vertical_select.is_updated = 1;
  782.             if(cat83_vertical_select.bottom_handler)
  783.             {
  784.                 cat83_vertical_select.bottom_handler(cat83_highlighted_row, cat83_highlighted_column);
  785.             }
  786.             RedrawCategory83Screen();
  787.             gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  788.         }
  789.     }
  790.     /* cell array */
  791.     if (PEN_CHECK_BOUND(pos.x, pos.y, cat83_cell_array_x, cat83_cell_array_y, cat83_cell_array_width, cat83_cell_array_height))
  792.     {
  793.         U32 pen_row = 0xffffffff;
  794.         U32 pen_column = 0xffffffff;
  795.         
  796.         wgui_calendar_translate_pen_position(pos.x, pos.y, &pen_row, &pen_column);
  797.         if ((pen_row != 0xffffffff) && (pen_column != 0xffffffff))
  798.         {
  799.             if ((cat83_highlighted_row == pen_row) && (cat83_highlighted_column == pen_column))
  800.             {
  801.                 cat83_cell_array.pen_on_highlighted = TRUE;
  802.             }
  803.             else if((wgui_cat83_cell_struct*)(cat83_cell_array.cell+pen_row*cat83_column_num+pen_column)->valid)
  804.             {
  805.                 cat83_highlighted_row_old = cat83_highlighted_row;
  806.                 cat83_highlighted_column_old = cat83_highlighted_column;
  807.                 cat83_highlighted_row = pen_row;
  808.                 cat83_highlighted_column = pen_column;
  809.                 wgui_calendar_unhighlight_cell(cat83_highlighted_row_old, cat83_highlighted_column_old);
  810.                 wgui_calendar_highlight_cell(cat83_highlighted_row, cat83_highlighted_column);
  811.                 gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  812.             }
  813.         }
  814.     }
  815.     return MMI_TRUE;
  816. }
  817. static MMI_BOOL Cat83PenUpHandler(mmi_pen_point_struct pos)
  818. {
  819.     /*----------------------------------------------------------------*/
  820.     /* Local Variables                                                */
  821.     /*----------------------------------------------------------------*/
  822.     /*----------------------------------------------------------------*/
  823.     /* Code Body                                                      */
  824.     /*----------------------------------------------------------------*/
  825.     /* cell array */
  826.     if (PEN_CHECK_BOUND(pos.x, pos.y, cat83_cell_array_x, cat83_cell_array_y, cat83_cell_array_width, cat83_cell_array_height))
  827.     {
  828.         U32 pen_row = 0xffffffff;
  829.         U32 pen_column = 0xffffffff;
  830.         
  831.         wgui_calendar_translate_pen_position(pos.x, pos.y, &pen_row, &pen_column);
  832.         if ((pen_row != 0xffffffff) && (pen_column != 0xffffffff))
  833.         {
  834.             if ((cat83_highlighted_row == pen_row) && (cat83_highlighted_column == pen_column))
  835.             {
  836.                 if (cat83_cell_array.pen_on_highlighted == TRUE)
  837.                 {
  838.                     cat83_cell_array.pen_on_highlighted = FALSE;
  839.                     if (GetKeyHandler(KEY_LSK, KEY_EVENT_UP))
  840.                     {
  841.                         /* Some softkey handlers use GetkeyInfo() */
  842.                         SetkeyInfo(KEY_LSK, KEY_EVENT_UP);
  843.                         execute_softkey_function(KEY_EVENT_UP, MMI_LEFT_SOFTKEY);
  844.                     }
  845.                 }
  846.             }
  847.         }
  848.     }
  849.     return MMI_TRUE;
  850. }
  851. static MMI_BOOL Cat83PenMoveHandler(mmi_pen_point_struct pos)
  852. {
  853.     /*----------------------------------------------------------------*/
  854.     /* Local Variables                                                */
  855.     /*----------------------------------------------------------------*/
  856.     /*----------------------------------------------------------------*/
  857.     /* Code Body                                                      */
  858.     /*----------------------------------------------------------------*/
  859.     if (PEN_CHECK_BOUND(pos.x, pos.y, cat83_cell_array_x, cat83_cell_array_y, cat83_cell_array_width, cat83_cell_array_height))
  860.     {
  861.         U32 pen_row = 0xffffffff;
  862.         U32 pen_column = 0xffffffff;
  863.         wgui_calendar_translate_pen_position(pos.x, pos.y, &pen_row, &pen_column);
  864.         if ((cat83_highlighted_row == pen_row) && (cat83_highlighted_column == pen_column) && (cat83_cell_array.pen_on_highlighted == TRUE))
  865.         {
  866.             cat83_cell_array.pen_on_highlighted = TRUE;
  867.         }
  868.         else
  869.         {
  870.             if ((pen_row != 0xffffffff) && (pen_column != 0xffffffff))
  871.             {
  872.                 if ((cat83_highlighted_row != pen_row) || (cat83_highlighted_column != pen_column))
  873.                 {
  874.                     if((wgui_cat83_cell_struct*)(cat83_cell_array.cell+pen_row*cat83_column_num+pen_column)->valid)
  875.                     {
  876.                         cat83_highlighted_row_old = cat83_highlighted_row;
  877.                         cat83_highlighted_column_old = cat83_highlighted_column;
  878.                         cat83_highlighted_row = pen_row;
  879.                         cat83_highlighted_column = pen_column;
  880.                         wgui_calendar_unhighlight_cell(cat83_highlighted_row_old, cat83_highlighted_column_old);
  881.                         wgui_calendar_highlight_cell(cat83_highlighted_row, cat83_highlighted_column);
  882.                         gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  883.                     }
  884.                 }
  885.             }   
  886.             cat83_cell_array.pen_on_highlighted = FALSE;
  887.         }
  888.     }
  889.     else
  890.     {
  891.         
  892.     }
  893.     
  894.     return MMI_TRUE;
  895. }
  896. #if 0
  897. /* under construction !*/
  898. /* under construction !*/
  899. /* under construction !*/
  900. /* under construction !*/
  901. /* under construction !*/
  902. /* under construction !*/
  903. /* under construction !*/
  904. /* under construction !*/
  905. /* under construction !*/
  906. /* under construction !*/
  907. /* under construction !*/
  908. /* under construction !*/
  909. #endif
  910. #endif /* __MMI_TOUCH_SCREEN__ */ 
  911. /*****************************************************************************
  912.  * FUNCTION
  913.  *  ExitCategory83Screen
  914.  * DESCRIPTION
  915.  *  exit function of category83
  916.  * PARAMETERS
  917.  *  void
  918.  * RETURNS
  919.  *  void
  920.  *****************************************************************************/
  921. void ExitCategory83Screen(void)
  922. {
  923.     /*----------------------------------------------------------------*/
  924.     /* Local Variables                                                */
  925.     /*----------------------------------------------------------------*/
  926.     /*----------------------------------------------------------------*/
  927.     /* Code Body                                                      */
  928.     /*----------------------------------------------------------------*/
  929.     reset_softkeys();
  930.     if (cat83_cell_cache_buf != NULL)
  931.     {
  932.         mmi_frm_scrmem_free(cat83_cell_cache_buf);
  933.         cat83_cell_cache_buf = NULL;
  934.     }
  935.     if (cat83_popup_cache_buf != NULL)
  936.     {
  937.         mmi_frm_scrmem_free(cat83_popup_cache_buf);
  938.         cat83_popup_cache_buf = NULL;
  939.     }
  940.     
  941.     if (cat83_popup.need_popup)
  942.     {
  943.         gui_cancel_timer(wgui_calendar_redraw_popup); /* stop the timer */
  944.     }
  945.     /* ToDo: clean up selector */
  946.     memset((U8*) &cat83_horizontal_select[0], 0, sizeof(cat83_horizontal_select[0]));
  947.     memset((U8*) &cat83_horizontal_select[1], 0, sizeof(cat83_horizontal_select[1]));
  948.     memset((U8*) &cat83_vertical_select, 0, sizeof(cat83_vertical_select));
  949.     memset((U8*) &cat83_popup, 0, sizeof(cat83_popup));
  950.     
  951.     Cat83AppCellHighlightHanlder = NULL;
  952.     Cat83AppLeftArrowKeyHanlder = NULL;
  953.     Cat83AppRightArrowKeyHanlder = NULL;
  954.     Cat83AppUpArrowKeyHanlder = NULL;
  955.     Cat83AppDownArrowKeyHanlder = NULL;
  956.     Cat83AppUpSideKeyHanlder = NULL;
  957.     Cat83AppDownSideKeyHanlder = NULL;
  958.     
  959. #ifdef __MMI_UI_CALENDAR_WITH_INFO_BOX__
  960.     cat83_infobox.icon_list = NULL;
  961.     cat83_infobox.string_list = NULL;
  962.     cat83_infobox.num_of_entry = 0;
  963.     cat83_infobox.is_updated = FALSE;
  964. #endif
  965. #ifdef __GDI_MEMORY_PROFILE_2__
  966.     gdi_layer_multi_layer_disable();
  967.     cat83_layer = GDI_LAYER_EMPTY_HANDLE;
  968. #endif
  969. }
  970. /*****************************************************************************
  971.  * FUNCTION
  972.  *  GetCategory83HistorySize
  973.  * DESCRIPTION
  974.  *  Gets the history buffer size of category 83
  975.  * PARAMETERS
  976.  *  void
  977.  * RETURNS
  978.  *  size in U8s of the history buffer
  979.  *****************************************************************************/
  980. S32 GetCategory83HistorySize(void)
  981. {
  982.     /*----------------------------------------------------------------*/
  983.     /* Local Variables                                                */
  984.     /*----------------------------------------------------------------*/
  985.     /*----------------------------------------------------------------*/
  986.     /* Code Body                                                      */
  987.     /*----------------------------------------------------------------*/
  988.     return 0;
  989. }
  990. /*****************************************************************************
  991.  * FUNCTION
  992.  *  GetCategory83History
  993.  * DESCRIPTION
  994.  *  Gets the history buffer of category 83
  995.  * PARAMETERS
  996.  *  history_buffer      [?]     
  997.  * RETURNS
  998.  *  return history buffer
  999.  *****************************************************************************/
  1000. U8 *GetCategory83History(U8 *history_buffer)
  1001. {
  1002.     /*----------------------------------------------------------------*/
  1003.     /* Local Variables                                                */
  1004.     /*----------------------------------------------------------------*/
  1005.     /*----------------------------------------------------------------*/
  1006.     /* Code Body                                                      */
  1007.     /*----------------------------------------------------------------*/
  1008.     return history_buffer;
  1009. }
  1010. static void wgui_cat83_redraw_bg(void)
  1011. {
  1012. #ifdef __GDI_MEMORY_PROFILE_2__
  1013.     gdi_layer_multi_layer_enable();
  1014.     if (cat83_layer == GDI_LAYER_EMPTY_HANDLE)
  1015.     {
  1016.         dm_create_layer(cat83_content_x, cat83_content_y, cat83_content_width, cat83_content_height, &cat83_layer, DM_LAYER_BOTTOM);
  1017.         gdi_layer_push_and_set_active(cat83_layer);
  1018.         gdi_layer_set_source_key(FALSE, GDI_COLOR_TRANSPARENT);
  1019.         gdi_layer_clear(GDI_COLOR_TRANSPARENT);
  1020.         gdi_layer_pop_and_restore_active();
  1021.     }
  1022. #endif
  1023.     if(cat83_bg_updated)
  1024.     {
  1025. #ifdef __GDI_MEMORY_PROFILE_2__
  1026.         gdi_layer_push_and_set_active(cat83_layer);
  1027. #endif
  1028.         gdi_layer_push_clip();
  1029.         gdi_layer_set_clip(cat83_content_x, cat83_content_y, cat83_content_x+cat83_content_width-1, cat83_content_y+cat83_content_height-1);
  1030.         gdi_image_draw_id(cat83_content_x, cat83_content_y, cat83_bg_id);
  1031.         gdi_layer_pop_clip();
  1032. #ifdef __GDI_MEMORY_PROFILE_2__
  1033.         gdi_layer_pop_and_restore_active();
  1034. #endif
  1035.         cat83_bg_updated = FALSE;
  1036.     
  1037.     #ifndef __GDI_MEMORY_PROFILE_2__
  1038.         cat83_horizontal_select[0].is_updated = TRUE;
  1039.         cat83_horizontal_select[1].is_updated = TRUE;
  1040.         cat83_vertical_select.is_updated = TRUE;
  1041.         cat83_title.is_updated = TRUE;
  1042.         cat83_horizontal_string.is_updated = TRUE;
  1043.         cat83_cell_array.is_updated = TRUE;
  1044.         cat83_highlighted_row_old = 0xffffffff;
  1045.         cat83_highlighted_column_old = 0xffffffff;
  1046.     #endif
  1047.     }
  1048. }
  1049. static void wgui_cat83_redraw_select_horizontal1(void)
  1050. {
  1051.     S32 cell_x, cell_width;
  1052.     S32 string_width, string_height;
  1053.     UI_image_ID_type icon_id;
  1054.     gdi_layer_push_clip();
  1055.     gdi_layer_set_clip(cat83_horizontal_select_x, cat83_horizontal_select_y, cat83_horizontal_select_x+(cat83_horizontal_select_width>>1)-1, cat83_horizontal_select_y+cat83_horizontal_select_height-1);
  1056. #ifdef __GDI_MEMORY_PROFILE_2__
  1057.     gdi_draw_solid_rect(cat83_horizontal_select_x, cat83_horizontal_select_y, cat83_horizontal_select_x+(cat83_horizontal_select_width>>1)-1, cat83_horizontal_select_y+cat83_horizontal_select_height-1, GDI_COLOR_TRANSPARENT);
  1058. #endif
  1059.     /* left arrow */
  1060.     if (cat83_horizontal_select[0].left_pressed == 0)
  1061.     {
  1062.         icon_id = cat83_horizontal_select[0].left_up;
  1063.     }
  1064.     else
  1065.     {
  1066.         icon_id = cat83_horizontal_select[0].left_down;
  1067.     }
  1068.     if(icon_id != 0)
  1069.     {
  1070.         gdi_image_draw_id(cat83_horizontal_select_x+CAT83_HORIZONTAL_SELECT_GAP_BORDER, cat83_horizontal_select_y+((cat83_horizontal_select_height-cat83_horizontal_select[0].left_height)>>1), (U16)icon_id);
  1071.     }
  1072.     /* right arrow */
  1073.     if (cat83_horizontal_select[0].right_pressed == 0)
  1074.     {
  1075.         icon_id = cat83_horizontal_select[0].right_up;
  1076.     }
  1077.     else
  1078.     {
  1079.         icon_id = cat83_horizontal_select[0].right_down;
  1080.     }
  1081.     if(icon_id != 0)
  1082.     {
  1083.         gdi_image_draw_id(cat83_horizontal_select_x+(cat83_horizontal_select_width>>1)-cat83_horizontal_select[0].right_width-CAT83_HORIZONTAL_SELECT_GAP_OTHER, cat83_horizontal_select_y+((cat83_horizontal_select_height-cat83_horizontal_select[0].right_height)>>1), (U16)icon_id);
  1084.     }
  1085.  
  1086.     /* text */
  1087.     cell_x = cat83_horizontal_select_x+CAT83_HORIZONTAL_SELECT_GAP_BORDER+cat83_horizontal_select[0].left_width+1;
  1088.     cell_width = (cat83_horizontal_select_width>>1)-CAT83_HORIZONTAL_SELECT_GAP_BORDER-cat83_horizontal_select[0].left_width-cat83_horizontal_select[0].right_width-CAT83_HORIZONTAL_SELECT_GAP_OTHER-2;
  1089.     gdi_layer_set_clip(cell_x, cat83_horizontal_select_y, cell_x+cell_width-1, cat83_horizontal_select_y+cat83_horizontal_select_height-1);
  1090.     
  1091.     gui_set_font(&MMI_medium_font);
  1092.     gui_set_text_color(cat83_horizontal_select_fg);
  1093.     gui_set_text_border_color(cat83_horizontal_select_border);
  1094.     gui_measure_string((UI_string_type)cat83_horizontal_select[0].string, &string_width, &string_height);
  1095.     if (cat83_horizontal_select[0].align_type == CAT83_SELECT_ALIGN_CENTER)
  1096.     {
  1097.         gui_move_text_cursor(cell_x+((cell_width-string_width)>>1), cat83_horizontal_select_y+((cat83_horizontal_select_height-string_height)>>1));
  1098.     }
  1099.     else if (cat83_horizontal_select[0].align_type == CAT83_SELECT_ALIGN_LEFT)
  1100.     {
  1101.         gui_move_text_cursor(cell_x, cat83_horizontal_select_y+((cat83_horizontal_select_height-string_height)>>1));
  1102.     }
  1103.     else
  1104.     {
  1105.         MMI_ASSERT(0);
  1106.     }
  1107.     gui_print_bordered_text((UI_string_type)cat83_horizontal_select[0].string);
  1108.     cat83_horizontal_select[0].is_updated = FALSE;
  1109.     gdi_layer_pop_clip();
  1110. }
  1111. static void wgui_cat83_redraw_select_horizontal2(void)
  1112. {
  1113.     S32 cell_x, cell_width;
  1114.     S32 string_width, string_height;
  1115.     UI_image_ID_type icon_id;
  1116.     gdi_layer_push_clip();
  1117.     gdi_layer_set_clip(cat83_horizontal_select_x+(cat83_horizontal_select_width>>1), cat83_horizontal_select_y, cat83_horizontal_select_x+cat83_horizontal_select_width-1, cat83_horizontal_select_y+cat83_horizontal_select_height-1);
  1118. #ifdef __GDI_MEMORY_PROFILE_2__
  1119.     gdi_draw_solid_rect(cat83_horizontal_select_x+(cat83_horizontal_select_width>>1), cat83_horizontal_select_y, cat83_horizontal_select_x+cat83_horizontal_select_width-1, cat83_horizontal_select_y+cat83_horizontal_select_height-1, GDI_COLOR_TRANSPARENT);
  1120. #endif
  1121.     /* left arrow */
  1122.     if (cat83_horizontal_select[1].left_pressed == 0)
  1123.     {
  1124.         icon_id = cat83_horizontal_select[1].left_up;
  1125.     }
  1126.     else
  1127.     {
  1128.         icon_id = cat83_horizontal_select[1].left_down;
  1129.     }
  1130.     if(icon_id != 0)
  1131.     {
  1132.         gdi_image_draw_id(cat83_horizontal_select_x+(cat83_horizontal_select_width>>1)+CAT83_HORIZONTAL_SELECT_GAP_OTHER, cat83_horizontal_select_y+((cat83_horizontal_select_height-cat83_horizontal_select[1].left_height)>>1), (U16)icon_id);
  1133.     }
  1134.     /* right arrow */
  1135.     if (cat83_horizontal_select[1].right_pressed == 0)
  1136.     {
  1137.         icon_id = cat83_horizontal_select[1].right_up;
  1138.     }
  1139.     else
  1140.     {
  1141.         icon_id = cat83_horizontal_select[1].right_down;
  1142.     }
  1143.     if(icon_id != 0)
  1144.     {
  1145.         gdi_image_draw_id(cat83_horizontal_select_x+cat83_horizontal_select_width-cat83_horizontal_select[0].right_width-CAT83_HORIZONTAL_SELECT_GAP_BORDER, cat83_horizontal_select_y+((cat83_horizontal_select_height-cat83_horizontal_select[1].right_height)>>1), (U16)icon_id);
  1146.     }
  1147.  
  1148.     /* text */
  1149.     cell_x = cat83_horizontal_select_x+(cat83_horizontal_select_width>>1)+CAT83_HORIZONTAL_SELECT_GAP_OTHER+cat83_horizontal_select[1].left_width+1;
  1150.     cell_width = (cat83_horizontal_select_width>>1)-CAT83_HORIZONTAL_SELECT_GAP_BORDER-cat83_horizontal_select[1].left_width-cat83_horizontal_select[1].right_width-CAT83_HORIZONTAL_SELECT_GAP_OTHER-2;
  1151.     gdi_layer_set_clip(cell_x, cat83_horizontal_select_y, cell_x+cell_width-1, cat83_horizontal_select_y+cat83_horizontal_select_height-1);
  1152.     
  1153.     gui_set_font(&MMI_medium_font);
  1154.     gui_set_text_color(cat83_horizontal_select_fg);
  1155.     gui_set_text_border_color(cat83_horizontal_select_border);
  1156.     gui_measure_string((UI_string_type)cat83_horizontal_select[1].string, &string_width, &string_height);
  1157.     gui_move_text_cursor(cell_x+((cell_width-string_width)>>1), cat83_horizontal_select_y+((cat83_horizontal_select_height-string_height)>>1));
  1158.     gui_print_bordered_text((UI_string_type)cat83_horizontal_select[1].string);
  1159.     cat83_horizontal_select[1].is_updated = FALSE;
  1160.     gdi_layer_pop_clip();
  1161. }
  1162. static void wgui_cat83_redraw_horizontal_string(void)
  1163. {
  1164.     S32 cell_x, cell_y, cell_width, cell_height;
  1165.     S32 string_width, string_height;
  1166.     U32 i;
  1167.     gdi_layer_push_clip();
  1168.     gdi_layer_set_clip(cat83_horizontal_string_x, cat83_horizontal_string_y, cat83_horizontal_string_x+cat83_horizontal_string_width-1, cat83_horizontal_string_y+cat83_horizontal_string_height-1);
  1169. #ifdef __GDI_MEMORY_PROFILE_2__
  1170.     gdi_draw_solid_rect(cat83_horizontal_string_x, cat83_horizontal_string_y, cat83_horizontal_string_x+cat83_horizontal_string_width-1, cat83_horizontal_string_y+cat83_horizontal_string_height-1, GDI_COLOR_TRANSPARENT);
  1171. #endif
  1172.     cell_x = cat83_horizontal_string_x;
  1173.     cell_y = cat83_horizontal_string_y;
  1174.     cell_width = (cat83_horizontal_string_width-(cat83_column_num-1)*cat83_frame_line_pixel)/cat83_column_num;
  1175.     cell_height = cat83_horizontal_string_height;
  1176.     gui_set_font(cat83_horizontal_string_font);
  1177.     gui_set_text_color(cat83_horizontal_string_fg);
  1178.     for(i = 0; i < cat83_column_num; i++)
  1179.     {
  1180.         gui_measure_string((UI_string_type)cat83_horizontal_string.string_list[i], &string_width, &string_height);
  1181.         gui_move_text_cursor(cell_x+((cell_width-string_width)>>1), cell_y+((cell_height-string_height)>>1));
  1182.         gui_print_text((UI_string_type)cat83_horizontal_string.string_list[i]);
  1183.         cell_x += (cell_width+cat83_frame_line_pixel);
  1184.     }
  1185.     cat83_horizontal_string.is_updated = FALSE;
  1186.     gdi_layer_pop_clip();
  1187. }
  1188. static void wgui_cat83_redraw_select_vertical(void)
  1189. {
  1190.     S32 cell_x, cell_y = 0, cell_width, cell_height;//120406 warning remove
  1191.     S32 string_width, string_height;
  1192.     U32 i;
  1193.     UI_image_ID_type icon_id;
  1194.     gdi_layer_push_clip();
  1195.     gdi_layer_set_clip(cat83_vertical_select_x, cat83_vertical_select_y, cat83_vertical_select_x+cat83_vertical_select_width-1, cat83_vertical_select_y+cat83_vertical_select_height-1);
  1196. #ifdef __GDI_MEMORY_PROFILE_2__
  1197.     gdi_draw_solid_rect(cat83_vertical_select_x, cat83_vertical_select_y, cat83_vertical_select_x+cat83_vertical_select_width-1, cat83_vertical_select_y+cat83_vertical_select_height-1, GDI_COLOR_TRANSPARENT);
  1198. #endif
  1199.     /* top arrow */
  1200.     if (cat83_vertical_select.top_pressed == 0)
  1201.     {
  1202.         icon_id = cat83_vertical_select.top_up;
  1203.     }
  1204.     else
  1205.     {
  1206.         icon_id = cat83_vertical_select.top_down;
  1207.     }
  1208.     if(icon_id != 0)
  1209.     {
  1210.         gdi_image_draw_id(cat83_vertical_select_x+((cat83_vertical_select_width-cat83_vertical_select.top_width)>>1), cat83_vertical_select_y + 1, (U16)icon_id);
  1211.     }
  1212.     /* bottom arrow */
  1213.     if (cat83_vertical_select.bottom_pressed == 0)
  1214.     {
  1215.         icon_id = cat83_vertical_select.bottom_up;
  1216.     }
  1217.     else
  1218.     {
  1219.         icon_id = cat83_vertical_select.bottom_down;
  1220.     }
  1221.     if(icon_id != 0)
  1222.     {
  1223.         gdi_image_draw_id(cat83_vertical_select_x+((cat83_vertical_select_width-cat83_vertical_select.top_width)>>1), cat83_vertical_select_y+cat83_vertical_select_height-cat83_vertical_select.bottom_height-1, (U16)icon_id);
  1224.     }
  1225.     
  1226.     /* text */
  1227.     cell_x = cat83_vertical_select_x;
  1228.     cell_width = cat83_vertical_select_width;
  1229.     cell_height = (cat83_cell_array_height-(cat83_row_num-1)*cat83_frame_line_pixel)/cat83_row_num;
  1230.     if(cat83_vertical_select.align_type == CAT83_SELECT_ALIGN_CELL)
  1231.     {
  1232.         cell_y = cat83_cell_array_y;        
  1233.     }
  1234.     else if(cat83_vertical_select.align_type == CAT83_SELECT_ALIGN_LINE)
  1235.     {
  1236.         cell_y = cat83_cell_array_y - (cell_height>>1);
  1237.     }
  1238.     else
  1239.     {
  1240.         MMI_ASSERT(0);
  1241.     }
  1242.     gui_set_font(cat83_cell_font);
  1243.     gui_set_text_color(cat83_vertical_select_fg);
  1244.     for(i = 0; i < cat83_row_num; i++)
  1245.     {
  1246.         gui_measure_string((UI_string_type)cat83_vertical_select.string_list[i], &string_width, &string_height);
  1247.         gui_move_text_cursor(cell_x+((cell_width-string_width)>>1), cell_y+((cell_height-string_height)>>1));
  1248.         gui_print_text((UI_string_type)cat83_vertical_select.string_list[i]);
  1249.         cell_y += (cell_height+cat83_frame_line_pixel);
  1250.     }
  1251.     cat83_vertical_select.is_updated = FALSE;
  1252.     gdi_layer_pop_clip();
  1253. }
  1254. static void wgui_cat83_redraw_normal_title(void)
  1255. {
  1256.     S32 string_width, string_height;
  1257.     gdi_layer_push_clip();
  1258.     gdi_layer_set_clip(cat83_title_x, cat83_title_y, cat83_title_x+cat83_title_width-1, cat83_title_y+cat83_title_height-1);
  1259. #ifdef __GDI_MEMORY_PROFILE_2__
  1260.     gdi_draw_solid_rect(cat83_title_x, cat83_title_y, cat83_title_x+cat83_title_width-1, cat83_title_y+cat83_title_height-1, GDI_COLOR_TRANSPARENT);
  1261. #endif
  1262.     gui_set_font(&MMI_medium_font);
  1263.     gui_set_text_color(cat83_title_fg);
  1264.     
  1265.     gui_measure_string((UI_string_type)cat83_title.string1, &string_width, &string_height);
  1266.     gui_move_text_cursor(cat83_title_x+((cat83_title_width-string_width)>>1), cat83_title_y+((cat83_title_height-string_height)>>1));
  1267.     gui_print_text((UI_string_type)cat83_title.string1);
  1268.     cat83_title.is_updated = FALSE;
  1269.     gdi_layer_pop_clip();
  1270. }
  1271. static void wgui_cat83_redraw_menstrual_title(void)
  1272. {
  1273. }
  1274. void wgui_calendar_redraw_cell_array(void)
  1275. {
  1276.     S32 cell_x, cell_y, cell_width, cell_height;
  1277.     S32 current_cell_x, current_cell_y;
  1278.     //S32 highlighted_cell_x, highlighted_cell_y;
  1279.     U32 i, j;
  1280.     gdi_layer_push_clip();
  1281.     gdi_layer_set_clip(cat83_cell_array_x, cat83_cell_array_y, cat83_cell_array_x+cat83_cell_array_width-1, cat83_cell_array_y+cat83_cell_array_height-1);
  1282. #ifdef __GDI_MEMORY_PROFILE_2__
  1283.     gdi_draw_solid_rect(cat83_cell_array_x, cat83_cell_array_y, cat83_cell_array_x+cat83_cell_array_width-1, cat83_cell_array_y+cat83_cell_array_height-1, GDI_COLOR_TRANSPARENT);
  1284. #endif
  1285.     cell_x = cat83_cell_array_x;
  1286.     cell_y = cat83_cell_array_y;
  1287.     cell_width = cat83_cell_width;
  1288.     cell_height = cat83_cell_height;
  1289.     /* current cell bg */
  1290.     if ((cat83_current_row<cat83_row_num) && (cat83_current_column<cat83_column_num))
  1291.     {
  1292.         current_cell_x = cell_x + (cell_width+cat83_frame_line_pixel)*cat83_current_column;
  1293.         current_cell_y = cell_y + (cell_height+cat83_frame_line_pixel)*cat83_current_row;
  1294.         gdi_draw_solid_rect(current_cell_x, current_cell_y, current_cell_x+cell_width-1, current_cell_y+cell_height-1, gdi_act_color_from_rgb(cat83_cell_bg[CAT83_COLOR_CURRENT].alpha, cat83_cell_bg[CAT83_COLOR_CURRENT].r, cat83_cell_bg[CAT83_COLOR_CURRENT].g, cat83_cell_bg[CAT83_COLOR_CURRENT].b));
  1295.     }
  1296.     /* each cell */
  1297.     for(i = 0; i < cat83_row_num; i ++)
  1298.     {
  1299.         cell_x = cat83_cell_array_x;
  1300.         for(j = 0; j < cat83_column_num; j++)
  1301.         {
  1302.             wgui_calendar_redraw_cell(cell_x, cell_y, cell_width, cell_height, cat83_cell_array.cell+i*cat83_column_num+j);
  1303.             cell_x += (cell_width+cat83_frame_line_pixel);
  1304.         }
  1305.         cell_y += (cell_height+cat83_frame_line_pixel);
  1306.     }    
  1307.     cat83_cell_array.is_updated = FALSE;
  1308.     gdi_layer_pop_clip();
  1309. }
  1310. static void wgui_calendar_redraw_cell(S32 cell_x, S32 cell_y, S32 cell_width, S32 cell_height, wgui_cat83_cell_struct *cell)
  1311. {
  1312.     S32 fill_bg_x = 0, fill_bg_y = 0, fill_bg_width = 0, fill_bg_height = 0;//120406 warning remove
  1313.     S32 text_x = 0, text_y = 0, text_width, text_height;
  1314.     S32 icon_x = 0, icon_y = 0, icon_width, icon_height;
  1315.     /* fill bg */
  1316.     if (cat83_cell_array.bg_fill_type == CAT83_CELL_BG_FILL_HORIZONTAL)
  1317.     {
  1318.         fill_bg_x = cell_x;
  1319.         fill_bg_y = cell_y + cell_height - (cell_height>>1);
  1320.         fill_bg_width = cell_width;
  1321.         fill_bg_height = cell_height>>1;
  1322.     }
  1323.     else if(cat83_cell_array.bg_fill_type == CAT83_CELL_BG_FILL_VERTICAL)
  1324.     {
  1325.         fill_bg_x = cell_x + (cell_width>>2);
  1326.         fill_bg_y = cell_y;
  1327.         fill_bg_width = cell_width>>1;
  1328.         fill_bg_height = cell_height;
  1329.     }
  1330.     else
  1331.     {
  1332.         MMI_ASSERT(0);
  1333.     }
  1334.     if (cell->bg_index != CAT83_COLOR_NONE)
  1335.     {
  1336.         gdi_draw_solid_rect(fill_bg_x, fill_bg_y, fill_bg_x+fill_bg_width-1, fill_bg_y+fill_bg_height-1, gdi_act_color_from_rgb(cat83_cell_bg[cell->bg_index].alpha, cat83_cell_bg[cell->bg_index].r, cat83_cell_bg[cell->bg_index].g, cat83_cell_bg[cell->bg_index].b));
  1337.     }
  1338.     /* draw icon */
  1339.     if ((cat83_cell_array.icon_display_type != CAT83_CELL_ICON_DISPLAY_DISABLE) && (cell->icon_id != 0))
  1340.     {
  1341.         gdi_image_get_dimension_id((U16)cell->icon_id, &icon_width, &icon_height);
  1342.         if (cat83_cell_array.icon_display_type == CAT83_CELL_ICON_DISPLAY_RIGHT_TOP)
  1343.         {
  1344.             icon_x = cell_x + cell_width - icon_width - 1;
  1345.             icon_y = cell_y + 1;
  1346.         }
  1347.         else if (cat83_cell_array.icon_display_type == CAT83_CELL_ICON_DISPLAY_CENTER)
  1348.         {
  1349.             icon_x = cell_x + ((cell_width-icon_width)>>1);
  1350.             icon_y = cell_y + ((cell_height-icon_height)>>1);
  1351.         }
  1352.         else
  1353.         {
  1354.             MMI_ASSERT(0);
  1355.         }
  1356.         gdi_image_draw_id(icon_x, icon_y, (U16) cell->icon_id);
  1357.     }
  1358.     /* draw text */
  1359.     if (cat83_cell_array.text_display_type != CAT83_CELL_TEXT_DISPLAY_DISABLE)
  1360.     {
  1361.         gui_measure_string(cell->text, &text_width, &text_height);
  1362.         if (cat83_cell_array.text_display_type == CAT83_CELL_TEXT_DISPLAY_LEFT_BOTTOM)
  1363.         {
  1364.             text_x = cell_x;
  1365.             text_y = cell_y + cell_height - text_height + 1;
  1366.         }
  1367.         else if(cat83_cell_array.text_display_type == CAT83_CELL_TEXT_DISPLAY_CENTER)
  1368.         {
  1369.             text_x = cell_x + ((cell_width-text_width)>>1);
  1370.             text_y = cell_y + ((cell_height-text_height)>>1);
  1371.         }
  1372.         else
  1373.         {
  1374.             MMI_ASSERT(0);
  1375.         }
  1376.         gui_set_font(cat83_cell_font);
  1377.         if (cell->valid)
  1378.         {
  1379.             gui_set_text_color(cat83_cell_valid_fg);
  1380.         }
  1381.         else
  1382.         {
  1383.             gui_set_text_color(cat83_cell_invalid_fg);
  1384.         }
  1385.         gui_move_text_cursor(text_x, text_y);
  1386.         gui_print_text((UI_string_type)cell->text);
  1387.     }
  1388.     
  1389. }
  1390. static void wgui_calendar_redraw_popup(void)
  1391. {
  1392. #if 0
  1393. /* under construction !*/
  1394. /* under construction !*/
  1395. /* under construction !*/
  1396. /* under construction !*/
  1397. /* under construction !*/
  1398. /* under construction !*/
  1399. /* under construction !*/
  1400. /* under construction !*/
  1401. /* under construction !*/
  1402. /* under construction !*/
  1403. /* under construction !*/
  1404. /* under construction !*/
  1405. /* under construction !*/
  1406. /* under construction !*/
  1407. /* under construction !*/
  1408. /* under construction !*/
  1409. /* under construction !*/
  1410. /* under construction !*/
  1411. /* under construction !*/
  1412. #else
  1413.     /* These can be obtained from theme data  */
  1414.     const UI_filled_area popup_filler = {UI_FILLED_AREA_TYPE_COLOR | UI_FILLED_AREA_SINGLE_BORDER,
  1415.         UI_NULL_IMAGE,
  1416.         NULL,
  1417.         {47, 55, 143, 80},
  1418.         {0, 0, 0, 0},
  1419.         {0, 0, 0, 100},
  1420.         {0, 0, 0, 0},
  1421.         0
  1422.     };
  1423.     color tc = *(current_MMI_theme->UI_white_color);
  1424.     UI_font_type text_font = &MMI_medium_font;
  1425.     S32 x1 = cat83_cell_array_x + (cat83_cell_width+cat83_frame_line_pixel)*cat83_highlighted_column;
  1426.     S32 y1 = cat83_cell_array_y + (cat83_cell_height+cat83_frame_line_pixel)*cat83_highlighted_row;
  1427.     S32 x2 = x1 + cat83_cell_width - 1;
  1428.     //S32 y2 = y1 + cat83_cell_height - 1;
  1429.     S32 px1, py1, px2, py2;
  1430.     S32 width, height, y;
  1431.     S32 w1, w2, w3, h1, h2, h3;
  1432.     /* set message 1 of popup */
  1433.     UI_string_type msg1 = (UI_string_type) cat83_popup.message1;
  1434.     /* set message 2 of popup */
  1435.     UI_string_type msg2 = (UI_string_type) cat83_popup.message2;
  1436.     /* set message 3 of popup */
  1437.     UI_string_type msg3 = (UI_string_type) cat83_popup.message3;
  1438.     /*----------------------------------------------------------------*/
  1439.     /* Code Body                                                      */
  1440.     /*----------------------------------------------------------------*/
  1441.     /* set font of popup */
  1442.     gui_set_font(text_font);
  1443.     if ((msg1 == NULL) && (msg2 == NULL) && (msg3 == NULL))
  1444.     {
  1445.         cat83_popup.is_drawed = FALSE;
  1446.         return;
  1447.     }
  1448.     if (msg1 == NULL)
  1449.     {
  1450.         h1 = 0;
  1451.         w1 = 0;
  1452.     }
  1453.     else
  1454.     {
  1455.         gui_measure_string(msg1, &w1, &h1); /* measue width and height of msg1 */
  1456.     }
  1457.     if (msg2 == NULL)
  1458.     {
  1459.         h2 = 0;
  1460.         w2 = 0;
  1461.     }
  1462.     else
  1463.     {
  1464.         gui_measure_string(msg2, &w2, &h2); /* measue width and height of msg1 */
  1465.     }
  1466.     if (msg3 == NULL)
  1467.     {
  1468.         h3 = 0;
  1469.         w3 = 0;
  1470.     }
  1471.     else
  1472.     {
  1473.         gui_measure_string(msg3, &w3, &h3); /* measue width and height of msg1 */
  1474.     }
  1475.     height = h1 + h2 + h3 + 8;
  1476.     width = w1;
  1477.     if (w2 > width)
  1478.     {
  1479.         width = w2;
  1480.     }
  1481.     if (w3 > width)
  1482.     {
  1483.         width = w3;
  1484.     }
  1485.     width += 8;
  1486.     if (width > (CAT83_FRAME_WIDTH>>1))
  1487.     {
  1488.         width = (CAT83_FRAME_WIDTH>>1);
  1489.     }
  1490.     if (height > (CAT83_FRAME_HEIGHT>>1))
  1491.     {
  1492.         height = (CAT83_FRAME_HEIGHT>>1);
  1493.     }
  1494.     px1 = x2 + cat83_frame_line_pixel;
  1495.     py1 = y1;// + cat83_frame_line_pixel;
  1496.     if ((px1 + width - 1) > cat83_cell_array_x + cat83_cell_array_width - 1)
  1497.     {
  1498.         px1 = x1 - width - cat83_frame_line_pixel;
  1499.         if (px1 < cat83_cell_array_x)
  1500.         {
  1501.             px1 = cat83_cell_array_x;
  1502.         }
  1503.     }
  1504.     if ((py1 + height - 1) > cat83_cell_array_y + cat83_cell_array_height - 1)
  1505.     {
  1506.         py1 = cat83_cell_array_y + cat83_cell_array_height - height;
  1507.         if (py1 < cat83_cell_array_y)
  1508.         {
  1509.             py1 = cat83_cell_array_y;
  1510.         }
  1511.     }
  1512.     px2 = px1 + width - 1;
  1513.     py2 = py1 + height - 1;
  1514.     gdi_layer_push_clip();
  1515.     gdi_layer_set_clip(px1, py1, px2, py2);
  1516.     gdi_image_cache_bmp_get(px1, py1, px2, py2, &cat83_popup_cache);
  1517.     cat83_popup.is_drawed = TRUE;
  1518.     cat83_popup_x = px1;
  1519.     cat83_popup_y = py1;
  1520.     /* fill the color of popup */
  1521.     gui_draw_filled_area(px1, py1, px2, py2, (UI_filled_area*)&popup_filler);
  1522.     /* set text color */
  1523.     gui_set_text_color(tc);
  1524.     y = py1 + 4;
  1525.     if (msg1 != NULL)
  1526.     {
  1527.         if (r2lMMIFlag)
  1528.         {
  1529.             gui_move_text_cursor(px1 + 4 + w1, y);
  1530.         }
  1531.         else
  1532.         {
  1533.             gui_move_text_cursor(px1 + 4, y);
  1534.         }
  1535.         gui_print_text(msg1);
  1536.         y += h1;
  1537.     }
  1538.     if (msg2 != NULL)
  1539.     {
  1540.         if (r2lMMIFlag)
  1541.         {
  1542.             gui_move_text_cursor(px1 + 4 + w2, y);
  1543.         }
  1544.         else
  1545.         {
  1546.             gui_move_text_cursor(px1 + 4, y);
  1547.         }
  1548.         gui_print_text(msg2);
  1549.         y += h2;
  1550.     }
  1551.     if (msg3 != NULL)
  1552.     {
  1553.         if (r2lMMIFlag)
  1554.         {
  1555.             gui_move_text_cursor(px1 + 4 + w3, y);
  1556.         }
  1557.         else
  1558.         {
  1559.             gui_move_text_cursor(px1 + 4, y);
  1560.         }
  1561.         gui_print_text(msg3);
  1562.         y += h3;
  1563.     }
  1564.     gdi_layer_pop_clip();
  1565.     gdi_layer_blt_previous(px1, py1, px2, py2);  
  1566. #endif
  1567. }
  1568. #ifdef __MMI_UI_CALENDAR_WITH_INFO_BOX__
  1569. static void wgui_cat83_redraw_infobox(void)
  1570. {
  1571.     S32 entry_x, entry_y, entry_width, entry_height;
  1572.     S32 icon_x, icon_width, icon_height;
  1573.     S32 string_x, string_width, string_height;
  1574.     S32 i;
  1575.     entry_width = CAT83_INFOBOX_WIDTH - CAT83_INFOBOX_GAP*2;
  1576.     entry_height = CAT83_INFOBOX_ENTRY_HEIGHT;
  1577.     entry_x = cat83_infobox_x + CAT83_INFOBOX_GAP;
  1578.     entry_y = cat83_infobox_y + CAT83_INFOBOX_GAP;
  1579.     icon_x = entry_x;
  1580.     if(cat83_infobox.icon_list)
  1581.     {
  1582.         string_x = entry_x + CAT83_INFOBOX_ENTRY_HEIGHT;
  1583.     }
  1584.     else
  1585.     {
  1586.         string_x = entry_x;
  1587.     }
  1588.     
  1589.     gui_set_font(cat83_infobox_font);
  1590.     gui_set_text_color(cat83_infobox_fg);
  1591.     
  1592.     gdi_layer_push_clip();
  1593.     gdi_layer_set_clip(cat83_infobox_x, cat83_infobox_y, cat83_infobox_x+cat83_infobox_width-1, cat83_infobox_y+cat83_infobox_height-1);
  1594.     gdi_draw_solid_rect(cat83_infobox_x, cat83_infobox_y, cat83_infobox_x+cat83_infobox_width-1, cat83_infobox_y+cat83_infobox_height-1, gdi_act_color_from_rgb(cat83_infobox_bg.alpha, cat83_infobox_bg.r, cat83_infobox_bg.g, cat83_infobox_bg.b));
  1595.     for (i = 0; i < cat83_infobox.num_of_entry; i++)
  1596.     {
  1597.         gdi_layer_push_clip();
  1598.         gdi_layer_set_clip(entry_x, entry_y, entry_x+entry_width-1, entry_y+entry_height-1);
  1599.         gdi_draw_solid_rect(entry_x, entry_y, entry_x+entry_width-1, entry_y+entry_height-1, gdi_act_color_from_rgb(cat83_infobox_entry_bg.alpha, cat83_infobox_entry_bg.r, cat83_infobox_entry_bg.g, cat83_infobox_entry_bg.b));
  1600.         if(cat83_infobox.icon_list)
  1601.         {
  1602.             if(cat83_infobox.icon_list[i] != 0)
  1603.             {
  1604.                 gdi_image_get_dimension_id((U16)cat83_infobox.icon_list[i], &icon_width, &icon_height);
  1605.                 gdi_image_draw_id(icon_x+((CAT83_INFOBOX_ENTRY_HEIGHT-icon_width)>>1), entry_y+((CAT83_INFOBOX_ENTRY_HEIGHT-icon_width)>>1), (U16)cat83_infobox.icon_list[i]);
  1606.             }
  1607.         }
  1608.         
  1609.         if(cat83_infobox.string_list)
  1610.         {
  1611.             if(cat83_infobox.string_list[i] != NULL)
  1612.             {
  1613.                 gui_measure_string((UI_string_type)cat83_infobox.string_list[i], &string_width, &string_height);
  1614.                 //gui_move_text_cursor(string_x, entry_y+((CAT83_INFOBOX_ENTRY_HEIGHT-string_height)>>1));
  1615.                 //gui_print_text((UI_string_type)cat83_infobox.string_list[i]);
  1616.                 gui_print_truncated_text(
  1617.                     string_x,
  1618.                     entry_y + ((CAT83_INFOBOX_ENTRY_HEIGHT - string_height) >> 1),
  1619.                     entry_x + entry_width - string_x,
  1620.                     (UI_string_type)cat83_infobox.string_list[i]);
  1621.             }
  1622.         }
  1623.         
  1624.         entry_y += entry_height + CAT83_INFOBOX_GAP;
  1625.         gdi_layer_pop_clip();
  1626.     }
  1627.     gdi_layer_pop_clip();
  1628. }
  1629. #endif
  1630. static void wgui_calendar_highlight_cell(U32 highlighted_row, U32 highlighted_column)
  1631. {
  1632.     S32 cell_x, cell_y, cell_width, cell_height;
  1633.     S32 highlighted_cell_x, highlighted_cell_y;
  1634.     cell_x = cat83_cell_array_x;
  1635.     cell_y = cat83_cell_array_y;
  1636.     cell_width = cat83_cell_width;
  1637.     cell_height = cat83_cell_height;
  1638.     highlighted_cell_x = cell_x + (cell_width+cat83_frame_line_pixel)*cat83_highlighted_column;
  1639.     highlighted_cell_y = cell_y + (cell_height+cat83_frame_line_pixel)*cat83_highlighted_row;
  1640.     gdi_layer_push_clip();
  1641.     gdi_layer_set_clip(highlighted_cell_x, highlighted_cell_y, highlighted_cell_x+cell_width-1, highlighted_cell_y+cell_height-1);
  1642.     if ((cat83_highlighted_row_old != cat83_highlighted_row) || (cat83_highlighted_column_old != cat83_highlighted_column))
  1643.     {
  1644.         gdi_image_cache_bmp_get(highlighted_cell_x, highlighted_cell_y, highlighted_cell_x+cell_width-1, highlighted_cell_y+cell_height-1, &cat83_cell_cache);
  1645.     }
  1646.     gdi_draw_rect(highlighted_cell_x, highlighted_cell_y, highlighted_cell_x+cell_width-1, highlighted_cell_y+cell_height-1, gdi_act_color_from_rgb(cat83_cell_highlight.alpha, cat83_cell_highlight.r, cat83_cell_highlight.g, cat83_cell_highlight.b));
  1647.     gdi_layer_pop_clip();
  1648.     if (Cat83AppCellHighlightHanlder)
  1649.     {
  1650.         Cat83AppCellHighlightHanlder(highlighted_row, highlighted_column);
  1651.     }
  1652.     cat83_highlighted_row_old = cat83_highlighted_row;
  1653.     cat83_highlighted_column_old = cat83_highlighted_column;
  1654.     /* draw left horizontal select */
  1655.     if(cat83_horizontal_select[0].is_updated)
  1656.     {
  1657.         wgui_cat83_redraw_select_horizontal1();
  1658.     }
  1659.     /* draw right horizontal select */
  1660.     if(cat83_horizontal_select[1].is_updated)
  1661.     {
  1662.         wgui_cat83_redraw_select_horizontal2();
  1663.     }
  1664.     if(cat83_title.is_updated)
  1665.     {
  1666.         cat83_title.show_title();
  1667.     }
  1668.     
  1669. #ifdef __MMI_UI_CALENDAR_WITH_INFO_BOX__
  1670.     if (cat83_infobox.is_updated)
  1671.     {
  1672.         wgui_cat83_redraw_infobox();
  1673.     }
  1674. #endif
  1675.     if (cat83_popup.need_popup)
  1676.     {
  1677.         gui_cancel_timer(wgui_calendar_redraw_popup);
  1678.         gui_start_timer(CAT83_POPUP_WAIT_TIME, wgui_calendar_redraw_popup);
  1679.     }
  1680. }
  1681. static void wgui_calendar_unhighlight_cell(U32 highlighted_row, U32 highlighted_column)
  1682. {
  1683.     S32 cell_x, cell_y, cell_width, cell_height;
  1684.     S32 highlighted_cell_x, highlighted_cell_y;
  1685.     cell_x = cat83_cell_array_x;
  1686.     cell_y = cat83_cell_array_y;
  1687.     cell_width = cat83_cell_width;
  1688.     cell_height = cat83_cell_height;
  1689.     highlighted_cell_x = cell_x + (cell_width+cat83_frame_line_pixel)*highlighted_column;
  1690.     highlighted_cell_y = cell_y + (cell_height+cat83_frame_line_pixel)*highlighted_row;
  1691.     
  1692.     if (cat83_popup.need_popup && cat83_popup.is_drawed)
  1693.     {
  1694.         gdi_image_cache_bmp_draw(cat83_popup_x, cat83_popup_y, &cat83_popup_cache);
  1695.         cat83_popup.is_drawed = FALSE;
  1696.     }
  1697.     gdi_layer_push_clip();
  1698.     gdi_layer_set_clip(highlighted_cell_x, highlighted_cell_y, highlighted_cell_x+cell_width-1, highlighted_cell_y+cell_height-1);
  1699.     gdi_image_cache_bmp_draw(highlighted_cell_x, highlighted_cell_y, &cat83_cell_cache);
  1700.     gdi_layer_pop_clip();
  1701.     
  1702.     if (cat83_popup.need_popup)
  1703.     {
  1704.         gui_cancel_timer(wgui_calendar_redraw_popup); /* stop the timer */
  1705.     }
  1706. }
  1707. static void RedrawCategory83Screen(void)
  1708. {
  1709.     /* draw calendar background image */
  1710.     wgui_cat83_redraw_bg();
  1711.     /* draw left horizontal select */
  1712.     if(cat83_horizontal_select[0].is_updated)
  1713.     {
  1714.         wgui_cat83_redraw_select_horizontal1();
  1715.     }
  1716.     /* draw right horizontal select */
  1717.     if(cat83_horizontal_select[1].is_updated)
  1718.     {
  1719.         wgui_cat83_redraw_select_horizontal2();
  1720.     }
  1721.     /* draw title */
  1722.     if(cat83_title.is_updated)
  1723.     {
  1724.         cat83_title.show_title();
  1725.     }
  1726.     /* draw horizontal string */
  1727.     if(cat83_horizontal_string.is_updated)
  1728.     {
  1729.         wgui_cat83_redraw_horizontal_string();
  1730.     }
  1731.     /* draw vertical select */
  1732.     if(cat83_vertical_select_display)
  1733.     {
  1734.         if(cat83_vertical_select.is_updated)
  1735.         {
  1736.             wgui_cat83_redraw_select_vertical();
  1737.         }
  1738.     }
  1739.     /* draw calendar cells */
  1740.     if(cat83_cell_array.is_updated)
  1741.     {
  1742.         wgui_calendar_redraw_cell_array();
  1743.         cat83_highlighted_row_old = 0xffffffff;
  1744.         cat83_highlighted_column_old = 0xffffffff;
  1745.     }
  1746.     /* unhighlighted and highlighted cell */
  1747.     if ((cat83_highlighted_row_old<cat83_row_num) && (cat83_highlighted_column<cat83_column_num))
  1748.     {
  1749.         if ((cat83_highlighted_row_old!=cat83_highlighted_row) || (cat83_highlighted_column_old<cat83_highlighted_column))
  1750.         {
  1751.             wgui_calendar_unhighlight_cell(cat83_highlighted_row_old, cat83_highlighted_column_old);
  1752.         }
  1753.     }
  1754.     if ((cat83_highlighted_row<cat83_row_num) && (cat83_highlighted_column<cat83_column_num))
  1755.     {
  1756.         wgui_calendar_highlight_cell(cat83_highlighted_row, cat83_highlighted_column);
  1757.     }
  1758.     /* Infobox */
  1759. }
  1760. /*****************************************************************************
  1761.  * FUNCTION
  1762.  *  RedrawCategoryControlledArea83Screen
  1763.  * DESCRIPTION
  1764.  *  redraw category83
  1765.  * PARAMETERS
  1766.  *  coordinate      [?]     
  1767.  * RETURNS
  1768.  *  void
  1769.  *****************************************************************************/
  1770. void RedrawCategoryControlledArea83Screen(dm_coordinates *coordinate)
  1771. {
  1772.     RedrawCategory83Screen();
  1773. }
  1774. /*****************************************************************************
  1775.  * FUNCTION
  1776.  *  ShowCategory83Screen
  1777.  * DESCRIPTION
  1778.  *  category screen of integrated calendar (monthly/weekly and menstral)
  1779.  * PARAMETERS
  1780.  *  title                   [IN]        Title string
  1781.  *  horizon_string_list     [IN]        horizontal string list
  1782.  *  cell                    [IN]        2 dimension cell array
  1783.  *  num_of_row              [IN]        number of row
  1784.  *  num_of_column           [IN]        number of column
  1785.  *  current_row             [IN]        row of current time
  1786.  *  current_column          [IN]        column of current time
  1787.  *  highlighted_row         [IN]        highlighted row
  1788.  *  highlighted_column      [IN]        highlighted column
  1789.  *  cell_fill_type          [IN]        cell bg color fill type
  1790.  * RETURNS
  1791.  *  void
  1792.  *****************************************************************************/
  1793. void ShowCategory83Screen(
  1794.                     UI_image_ID_type bg_id,
  1795.                     U8 **horizon_string_list,
  1796.                     wgui_cat83_cell_struct *cell,
  1797.                     U32 num_of_row,
  1798.                     U32 num_of_column,
  1799.                     U32 current_row,
  1800.                     U32 current_column,
  1801.                     U32 highlighted_row,
  1802.                     U32 highlighted_column,
  1803.                     U8 cell_bg_fill_type,
  1804.                     U8 cell_text_display_type,
  1805.                     U8 cell_icon_display_type)
  1806. {
  1807.     /*----------------------------------------------------------------*/
  1808.     /* Local Variables                                                */
  1809.     /*----------------------------------------------------------------*/
  1810.     dm_data_struct dm_data;
  1811.     /*----------------------------------------------------------------*/
  1812.     /* Code Body                                                      */
  1813.     /*----------------------------------------------------------------*/
  1814.    
  1815.     SetupCategoryKeyHandlers();
  1816.     
  1817.     cat83_cell_cache_buf = (U8*)mmi_frm_scrmem_alloc(CALENDAR_CACHE_CELL_SIZE);
  1818.     cat83_popup_cache_buf = (U8*)mmi_frm_scrmem_alloc(CALENDAR_CACHE_POPUP_SIZE);
  1819. #if defined(__MMI_MAINLCD_176X220__) || defined(__MMI_MAINLCD_240X320__)
  1820.     wgui_calendar_init(CAT83_CALENDAR_NORMAL, num_of_row, num_of_column, cat83_cell_cache_buf, cat83_popup_cache_buf);
  1821.     wgui_set_wallpaper_on_bottom(MMI_TRUE);
  1822. #else
  1823.     wgui_calendar_init(CAT83_CALENDAR_SMALL, num_of_row, num_of_column, cat83_cell_cache_buf, cat83_popup_cache_buf);
  1824. #endif
  1825.     wgui_cat83_set_bg(bg_id);
  1826.     wgui_cat83_set_horizontal_string(horizon_string_list);
  1827.     wgui_cat83_set_cell_array(cell, cell_bg_fill_type, cell_text_display_type, cell_icon_display_type);
  1828.     cat83_current_row = current_row;
  1829.     cat83_current_column = current_column;
  1830.     cat83_highlighted_row = highlighted_row;
  1831.     cat83_highlighted_column = highlighted_column;
  1832.     
  1833.     dm_register_category_controlled_callback(RedrawCategoryControlledArea83Screen);
  1834.     SetKeyHandler(Cat83HandleKeyLeft, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1835.     SetKeyHandler(Cat83HandleKeyLeft, KEY_LEFT_ARROW, KEY_LONG_PRESS);
  1836.     SetKeyHandler(Cat83HandleKeyRight, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1837.     SetKeyHandler(Cat83HandleKeyRight, KEY_RIGHT_ARROW, KEY_LONG_PRESS);
  1838.     SetKeyHandler(Cat83HandleKeyUp, KEY_UP_ARROW, KEY_EVENT_DOWN);
  1839.     SetKeyHandler(Cat83HandleKeyUp, KEY_UP_ARROW, KEY_LONG_PRESS);
  1840.     SetKeyHandler(Cat83HandleKeyDown, KEY_DOWN_ARROW, KEY_EVENT_DOWN);
  1841.     SetKeyHandler(Cat83HandleKeyDown, KEY_DOWN_ARROW, KEY_LONG_PRESS);
  1842.     SetKeyHandler(Cat83HandleSideKeyUp, KEY_VOL_UP, KEY_EVENT_DOWN);
  1843.     SetKeyHandler(Cat83HandleSideKeyUp, KEY_VOL_UP, KEY_LONG_PRESS);
  1844.     SetKeyHandler(Cat83HandleSideKeyDown, KEY_VOL_DOWN, KEY_EVENT_DOWN);
  1845.     SetKeyHandler(Cat83HandleSideKeyDown, KEY_VOL_DOWN, KEY_LONG_PRESS);
  1846.     
  1847. #ifdef __MMI_TOUCH_SCREEN__
  1848.     wgui_register_category_screen_control_area_pen_handlers(Cat83PenDownHandler, MMI_PEN_EVENT_DOWN);
  1849.     wgui_register_category_screen_control_area_pen_handlers(Cat83PenUpHandler, MMI_PEN_EVENT_UP);
  1850.     wgui_register_category_screen_control_area_pen_handlers(Cat83PenMoveHandler, MMI_PEN_EVENT_MOVE);
  1851.     //wgui_register_category_screen_control_area_pen_handlers(Cat83PenRepeatHandler, MMI_PEN_EVENT_REPEAT);
  1852. #endif /* __MMI_TOUCH_SCREEN__ */ 
  1853.     ExitCategoryFunction = ExitCategory83Screen;
  1854.     RedrawCategoryFunction = dm_redraw_category_screen;
  1855.     GetCategoryHistory = GetCategory83History;
  1856.     GetCategoryHistorySize = GetCategory83HistorySize;
  1857.     dm_data.s32CatId = MMI_CATEGORY83_ID;
  1858.     dm_data.s32ScrId = GetActiveScreenId();
  1859.     dm_data.s32flags = DM_CLEAR_SCREEN_BACKGROUND;
  1860.     dm_setup_data(&dm_data);
  1861.     dm_redraw_category_screen();
  1862. }
  1863. /*----------------------------Async Dynamic Multi Row List-----------------------------*/
  1864. // *************************************************************************************//
  1865. extern S32 gui_asyncdynamic_list_error;
  1866. extern U16 title_bg_id;
  1867. /*****************************************************************************
  1868.  * FUNCTION
  1869.  *  cat85_clear_icon_bg
  1870.  * DESCRIPTION
  1871.  *  Clear button background function
  1872.  * PARAMETERS
  1873.  *  button      [IN]        Button pointer
  1874.  * RETURNS
  1875.  *  void
  1876.  *****************************************************************************/
  1877. void cat85_clear_icon_bg(void *button)
  1878. {
  1879.     /*----------------------------------------------------------------*/
  1880.     /* Local Variables                                                */
  1881.     /*----------------------------------------------------------------*/
  1882.     icontext_button *b = (icontext_button*) button;
  1883.     S32 x1 = b->x;
  1884.     S32 y1 = b->y;
  1885.     S32 x2 = b->x + b->width - 1;
  1886.     S32 y2 = b->y + b->height - 1;
  1887.     /*----------------------------------------------------------------*/
  1888.     /* Code Body                                                      */
  1889.     /*----------------------------------------------------------------*/
  1890.     gdi_layer_push_clip();
  1891.     //gdi_layer_set_clip(x1, y1, x2, y2);
  1892.     //gdi_draw_solid_rect(x1, y1, x2, y2, GDI_COLOR_TRANSPARENT);
  1893.     //gdi_layer_pop_clip();
  1894.     gdi_layer_set_clip(x1, y1, x2 + 1, y2 + 1);
  1895.     gdi_draw_solid_rect(MMI_title_x, MMI_title_y, MMI_title_x + MMI_title_width - 1, MMI_title_y + MMI_title_height - 1, GDI_COLOR_TRANSPARENT);    /* 061705 Calvin added */
  1896.     if (title_bg_id != 0)
  1897.     {
  1898.         gdi_image_draw_id(MMI_title_x, MMI_title_y, title_bg_id);
  1899.     }
  1900.     else
  1901.     {
  1902.         gui_draw_filled_area(
  1903.             MMI_title_x,
  1904.             MMI_title_y,
  1905.             MMI_title_x + MMI_title_width - 1,
  1906.             MMI_title_y + MMI_title_height - 1,
  1907.             current_UI_theme->window_title_theme->active_filler);
  1908.     }
  1909.     gdi_layer_pop_clip();
  1910. }
  1911. /*****************************************************************************
  1912.  * FUNCTION
  1913.  *  ExitCategory85Screen
  1914.  * DESCRIPTION
  1915.  *  
  1916.  * PARAMETERS
  1917.  *  void
  1918.  * RETURNS
  1919.  *  void
  1920.  *****************************************************************************/
  1921. void ExitCategory85Screen(void)
  1922. {
  1923.     /*----------------------------------------------------------------*/
  1924.     /* Local Variables                                                */
  1925.     /*----------------------------------------------------------------*/
  1926.     /*----------------------------------------------------------------*/
  1927.     /* Code Body                                                      */
  1928.     /*----------------------------------------------------------------*/
  1929.     title_bg_id = 0;
  1930.     MMI_disable_title_shortcut_display = 0;
  1931.     disable_menu_shortcut_box_display = 0;
  1932.     wgui_reset_touch_title_bar_buttons();
  1933.     ClearHighlightHandler();
  1934.     reset_softkeys();
  1935.     reset_menu_shortcut_handler();
  1936.     reset_asyncdynamic_list();
  1937.     reset_pop_up_descriptions();
  1938. }
  1939. // *************************************************************************************//
  1940. /*****************************************************************************
  1941.  * FUNCTION
  1942.  *  ShowCategory85Screen
  1943.  * DESCRIPTION
  1944.  *  category screen of integrated calendar (daily)
  1945.  * PARAMETERS
  1946.  *  title                   [IN]         
  1947.  *  title_icon              [IN]          
  1948.  *  left_softkey            [IN]        
  1949.  *  left_softkey_icon       [IN]        
  1950.  *  right_softkey           [IN]        
  1951.  *  right_softkey_icon      [IN]        
  1952.  *  number_of_items         [IN]        
  1953.  *  get_item_func           [IN]        
  1954.  *  get_hint_func           [IN]        
  1955.  *  highlighted_item        [IN]        
  1956.  *  main_icon               [IN]        
  1957.  *  sub_icon              [IN]        
  1958.  *  history_buffer          [IN]         
  1959.  * RETURNS
  1960.  *  void
  1961.  *****************************************************************************/
  1962. void ShowCategory85Screen(
  1963.         U8 *title,
  1964.         U16 title_icon,
  1965.         U16 left_softkey,
  1966.         U16 left_softkey_icon,
  1967.         U16 right_softkey,
  1968.         U16 right_softkey_icon,
  1969.         S32 number_of_items,
  1970.         GetAsyncItemFuncPtr get_item_func,
  1971.         GetAsyncHintFuncPtr get_hint_func,
  1972.         S32 highlighted_item,
  1973.         U16 main_icon,
  1974.         U16 sub_icon,
  1975.         U8 *history_buffer)
  1976. {
  1977.     /*----------------------------------------------------------------*/
  1978.     /* Local Variables                                                */
  1979.     /*----------------------------------------------------------------*/
  1980.     dm_data_struct dm_data;
  1981.     S32 shortcut_width;
  1982.     U8 h_flag;
  1983.     PU8 img;
  1984.     S32 h, w, h1, w1, text_width, text_width1;
  1985.     S32 font_height_m;
  1986.     //S32 font_height_s;
  1987.     UI_fixed_icontext_list_menuitem_theme theme;
  1988.     U16 btn_prev_item_id = 0, btn_next_item_id = 0;
  1989.     /*----------------------------------------------------------------*/
  1990.     /* Code Body                                                      */
  1991.     /*----------------------------------------------------------------*/
  1992.     /* Reset The Error Variable */
  1993.     gui_asyncdynamic_list_error = 0;
  1994.     /* Set The Application Side Variable To True */
  1995.     gdi_layer_lock_frame_buffer();
  1996.     MMI_menu_shortcut_number = -1;
  1997.     change_left_softkey(left_softkey, left_softkey_icon);
  1998.     change_right_softkey(right_softkey, right_softkey_icon);
  1999.     SetupCategoryKeyHandlers();
  2000.     create_fixed_icontext_list_menuitems(2, 2);
  2001.     img = (U8*) GetImage(main_icon);
  2002.     gui_measure_image(img, &w, &h);
  2003.     if (w == 0)
  2004.     {
  2005.         w = CAT85_MAIN_IMAGE_WIDTH;
  2006.     }
  2007.     if (h == 0)
  2008.     {
  2009.         h = CAT85_MAIN_IMAGE_HEIGHT;
  2010.     }
  2011.     img = (U8*) GetImage(sub_icon);
  2012.     gui_measure_image(img, &w1, &h1);
  2013.     if (w1 == 0)
  2014.     {
  2015.         w1 = CAT85_SUB_IMAGE_WIDTH;
  2016.     }
  2017.     if (h1 == 0)
  2018.     {
  2019.         h1 = CAT85_SUB_IMAGE_HEIGHT;
  2020.     }
  2021.     text_width = UI_device_width - MMI_fixed_list_menu.vbar.width - w1 - CAT85_MENUITEM_OFFSET*3 - 3;
  2022.     text_width1 = UI_device_width - MMI_fixed_list_menu.vbar.width - w - CAT85_MENUITEM_OFFSET*3 - 3;
  2023.     //gui_set_font(&MMI_small_font);
  2024.     //font_height_s = gui_get_character_height();
  2025.     gui_set_font(&MMI_medium_font);
  2026.     /* It may contain non-alphanumeric characters like Chinese */
  2027. font_height_m = Get_CharHeightOfAllLang(MEDIUM_FONT);
  2028.     set_fixed_icontext_list_text_coordinates(0, CAT85_MENUITEM_OFFSET, CAT85_MENUITEM_OFFSET, text_width, font_height_m);
  2029.     set_fixed_icontext_list_icon_coordinates(0, UI_device_width-MMI_fixed_list_menu.vbar.width-CAT85_MENUITEM_OFFSET-w1-3, CAT85_MENUITEM_OFFSET, w1, h1);
  2030.     set_fixed_icontext_list_icon_coordinates(1, CAT85_MENUITEM_OFFSET, MMI_MULTIROW_MENUITEM_HEIGHT-CAT85_MENUITEM_OFFSET-h, w, h);
  2031.     set_fixed_icontext_list_text_coordinates(1, CAT85_MENUITEM_OFFSET+w+CAT85_MENUITEM_OFFSET, MMI_MULTIROW_MENUITEM_HEIGHT-CAT85_MENUITEM_OFFSET-font_height_m, text_width1, font_height_m);
  2032.     associate_fixed_multirow_list_list(MMI_MULTIROW_MENUITEM_HEIGHT);
  2033.     memcpy((U8*)&theme, (U8*)current_fixed_icontext_list_menuitem_theme, sizeof(UI_fixed_icontext_list_menuitem_theme));
  2034.     theme.text_fonts[0] = &MMI_small_font;
  2035.     theme.text_fonts[1] = &MMI_default_font;
  2036.     fixed_icontext_list_menuitem_apply_theme(&theme);
  2037.     MMI_fixed_icontext_list_menuitem.flags |= UI_MENUITEM_AUTO_CHOOSE_MARQUEE;//111306 scrolling
  2038.     MMI_current_menu_type = LIST_MENU;
  2039.     MMI_fixed_list_menu.n_items = number_of_items;
  2040.     if (!init_asyncdynamic_item_buffer(number_of_items, get_item_func, get_hint_func))
  2041.     {
  2042.         gdi_layer_unlock_frame_buffer();
  2043.         return;
  2044.     }
  2045.     register_asyncdynamic_list_keys();
  2046.     register_fixed_list_highlight_handler(asyncdynamic_list_highlight_handler);
  2047.     
  2048.     if (wgui_is_touch_title_bar_buttons())
  2049.     {
  2050.         dm_data.s32CatId = MMI_CATEGORY85_ID;
  2051.     }
  2052.     else
  2053.     {
  2054.         dm_data.s32CatId = MMI_CATEGORY85_NO_BUTTON_ID;
  2055.     }
  2056.     
  2057.     h_flag = set_list_menu_category_history(dm_data.s32CatId, history_buffer);
  2058.     asyncdynamic_list_goto_item_no_redraw(h_flag ? MMI_fixed_list_menu.highlighted_item : highlighted_item);
  2059.     if (gui_asyncdynamic_list_error)
  2060.     {
  2061.         gdi_layer_unlock_frame_buffer();
  2062.         return;
  2063.     }
  2064.     MMI_fixed_icontext_list_menuitem.flags |= UI_MENUITEM_RIGHT_JUSTIFY;
  2065.     MMI_title_string = (UI_string_type) title;
  2066.     MMI_title_icon = (PU8) get_image(title_icon);
  2067.     if (wgui_is_touch_title_bar_buttons())
  2068.     {
  2069.         MMI_disable_title_shortcut_display = 1;
  2070.         disable_menu_shortcut_box_display = 1;
  2071.         btn_prev_item_id = dm_add_button(
  2072.                             NULL,
  2073.                             get_image(LEFT_RED_ARROW),
  2074.                             get_image(LEFT_RED_ARROW),
  2075.                             cat85_clear_icon_bg);
  2076.         btn_next_item_id = dm_add_button(
  2077.                             NULL,
  2078.                             get_image(RIGHT_RED_ARROW),
  2079.                             get_image(RIGHT_RED_ARROW),
  2080.                             cat85_clear_icon_bg);
  2081.         title_bg_id = IMAGE_VIEW_TITLEBAR_BG;   /* for showing different title bar. */
  2082.     }
  2083.     else
  2084.     {
  2085.         register_asyncdynamic_list_shortcut_handler();
  2086.         shortcut_width = set_menu_item_count(number_of_items) + 7;
  2087.         resize_menu_shortcut_handler(shortcut_width, MMI_title_height);
  2088.         move_menu_shortcut_handler(UI_device_width - MMI_menu_shortcut_box.width, MMI_title_y);
  2089.         register_hide_menu_shortcut(draw_title);
  2090.     }
  2091. #if defined(__MMI_TOUCH_SCREEN__)
  2092.     if (wgui_is_touch_title_bar_buttons())
  2093.     {
  2094.         /* register the handler for pen event down istead of pen event up */
  2095.         dm_register_button_functions(btn_prev_item_id, KEY_EVENT_UP, gMMI_touch_title_button1_up_handler);
  2096.         dm_register_button_functions(btn_next_item_id, KEY_EVENT_UP, gMMI_touch_title_button2_up_handler);
  2097.     }
  2098. #endif /* defined(__MMI_TOUCH_SCREEN__) */ 
  2099.     resize_asyncdynamic_icontext_menuitems_to_list_width();
  2100.     set_asyncdynamic_pop_up_descriptions(h_flag ? MMI_fixed_list_menu.highlighted_item : highlighted_item);
  2101.     gdi_layer_unlock_frame_buffer();
  2102.     ExitCategoryFunction = ExitCategory85Screen;
  2103.     dm_setup_category_functions(dm_redraw_category_screen, dm_get_category_history, dm_get_category_history_size);
  2104.     dm_data.s32ScrId = (S32) GetActiveScreenId();
  2105.     dm_data.s32flags = 0;
  2106.     dm_setup_data(&dm_data);
  2107.     dm_redraw_category_screen();
  2108. }
  2109. #endif
  2110. /* 072406 new calendar End */