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

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*******************************************************************************
  36. * Filename:
  37. * ---------
  38. *  wgui_asyncdynamic_menus.c
  39. *
  40. * Project:
  41. * --------
  42. *   PlutoMMI
  43. *
  44. * Description:
  45. * ------------
  46. *   In order to use limited memory (size decided in compile-time) to load unlimited items (size decide in run-time) 
  47. *   to a category screen, a modification in MMI for dynamic item loading is required as the following.
  48. *
  49. * Author:
  50. * -------
  51. *  Tim Chen
  52. *
  53. *******************************************************************************/
  54. #include "CustMenuRes.h"
  55. #include "CustDataRes.h"
  56. #include "wgui_fixed_menus.h"
  57. #include "wgui_asyncdynamic_menus.h"
  58. #include "gui_asyncdynamic_menus.h"
  59. #include "wgui_categories.h"
  60. #include "gui_custom_menus.h"
  61. extern void dummy_highlight_handler(S32 item_index);
  62. extern void (*_MMI_hide_fixed_list_menu) (void);
  63. extern void wgui_display_fixed_text_list_pop_up_description(void);
  64. extern void wgui_display_asyncdynamic_text_list_pop_up_description(void);
  65. /* Extern For Error Variable - 21/5/2004 */
  66. extern S32 gui_asyncdynamic_list_error;
  67. #if( UI_ENABLE_FRAME_SKIPPING )
  68. extern S32 wgui_fixed_list_menu_frame_counter;
  69. #endif 
  70. /*****************************************************************************
  71.  * FUNCTION
  72.  *  reset_asyncdynamic_list
  73.  * DESCRIPTION
  74.  *  
  75.  * PARAMETERS
  76.  *  void
  77.  * RETURNS
  78.  *  void
  79.  *****************************************************************************/
  80. void reset_asyncdynamic_list(void)
  81. {
  82.     /*----------------------------------------------------------------*/
  83.     /* Local Variables                                                */
  84.     /*----------------------------------------------------------------*/
  85.     /*----------------------------------------------------------------*/
  86.     /* Code Body                                                      */
  87.     /*----------------------------------------------------------------*/
  88. #ifdef __MMI_UI_LIST_HIGHLIGHT_EFFECTS__
  89.     gui_stop_list_highlight_effect();
  90. #endif 
  91. #if( UI_ENABLE_FRAME_SKIPPING )
  92.     gui_cancel_timer(wgui_asyncdynamic_list_menu_end_frame);
  93.     wgui_fixed_list_menu_frame_counter = 0;
  94. #endif /* ( UI_ENABLE_FRAME_SKIPPING ) */ 
  95.     normal_fixed_list();
  96. #if defined (__MMI_UI_TRANSPARENT_EFFECT__) || defined (__MMI_UI_LIST_HIGHLIGHT_EFFECTS__)      /* 072505 Calvin modified */
  97.     gui_reset_transparent_source_layer();
  98. #endif 
  99.     clear_keyboard_key_handler();
  100.     ClearKeyHandler(KEY_UP_ARROW, KEY_EVENT_DOWN);
  101.     ClearKeyHandler(KEY_DOWN_ARROW, KEY_EVENT_DOWN);
  102.     ClearKeyHandler(KEY_VOL_UP, KEY_EVENT_DOWN);
  103.     ClearKeyHandler(KEY_VOL_DOWN, KEY_EVENT_DOWN);
  104.     MMI_fixed_list_menu.item_highlighted = dummy_highlight_handler;
  105.     wgui_text_menuitem_reset_scrolling();
  106.     /* PMT NEERAJ START 20050825 */
  107. #ifdef __MMI_UI_TWO_LINE_MENUITEM_STYLES__
  108.     reset_fixed_icontext_menuitem_type();
  109. #endif 
  110.     /* PMT NEERAJ END 20050825 */
  111. }
  112. /*****************************************************************************
  113.  * FUNCTION
  114.  *  show_asyncdynamic_list
  115.  * DESCRIPTION
  116.  *  
  117.  * PARAMETERS
  118.  *  void
  119.  * RETURNS
  120.  *  void
  121.  *****************************************************************************/
  122. void show_asyncdynamic_list(void)
  123. {
  124.     /*----------------------------------------------------------------*/
  125.     /* Local Variables                                                */
  126.     /*----------------------------------------------------------------*/
  127.     /*----------------------------------------------------------------*/
  128.     /* Code Body                                                      */
  129.     /*----------------------------------------------------------------*/
  130. #ifdef __MMI_UI_LIST_HIGHLIGHT_EFFECTS__
  131.     gui_stop_list_highlight_effect();
  132. #endif 
  133.     if (MMI_fixed_list_menu.flags & UI_LIST_MENU_DISABLE_BACKGROUND)
  134.     {
  135.         _MMI_hide_fixed_list_menu();
  136.     }
  137.     gui_hide_animations();
  138.     gui_show_asyncdynamic_list_menu(&MMI_fixed_list_menu);
  139.     wgui_display_asyncdynamic_text_list_pop_up_description();
  140.     wgui_list_menu_show_empty_label_if_needed();
  141.     
  142. #if(UI_DOUBLE_BUFFER_SUPPORT)
  143.     gui_BLT_double_buffer(MMI_fixed_list_menu.x, MMI_fixed_list_menu.y - 1, MMI_fixed_list_menu.x + MMI_fixed_list_menu.width - 1, MMI_fixed_list_menu.y + MMI_fixed_list_menu.height - 1);     /* 052305 Calvin modified */
  144. #endif 
  145. }
  146. /*****************************************************************************
  147.  * FUNCTION
  148.  *  redraw_asyncdynamic_list
  149.  * DESCRIPTION
  150.  *  
  151.  * PARAMETERS
  152.  *  void
  153.  * RETURNS
  154.  *  void
  155.  *****************************************************************************/
  156. void redraw_asyncdynamic_list(void)
  157. {
  158.     /*----------------------------------------------------------------*/
  159.     /* Local Variables                                                */
  160.     /*----------------------------------------------------------------*/
  161.     /*----------------------------------------------------------------*/
  162.     /* Code Body                                                      */
  163.     /*----------------------------------------------------------------*/
  164.     if (MMI_current_menu_type == ANI_BG_LIST_MENU)
  165.     {
  166.         return;
  167.     }
  168. #if( UI_ENABLE_FRAME_SKIPPING )
  169.     if (wgui_fixed_list_menu_frame_counter > 0)
  170.     {
  171.         wgui_fixed_list_menu_frame_counter++;
  172.         gui_show_asyncdynamic_list_menu_no_draw(&MMI_fixed_list_menu);
  173.     }
  174.     else
  175.     {
  176.         wgui_fixed_list_menu_frame_counter = 1;
  177.         gui_show_asyncdynamic_list_menu_no_draw(&MMI_fixed_list_menu);
  178.         gui_start_timer(UI_FRAME_START_TIMEOUT, wgui_asyncdynamic_list_menu_end_frame);
  179.     }
  180. #else /* ( UI_ENABLE_FRAME_SKIPPING ) */ 
  181.     show_asyncdynamic_list();
  182. #endif /* ( UI_ENABLE_FRAME_SKIPPING ) */ 
  183. }
  184. /*****************************************************************************
  185.  * FUNCTION
  186.  *  asyncdynamic_list_goto_previous_item
  187.  * DESCRIPTION
  188.  *  
  189.  * PARAMETERS
  190.  *  void
  191.  * RETURNS
  192.  *  void
  193.  *****************************************************************************/
  194. void asyncdynamic_list_goto_previous_item(void)
  195. {
  196.     /*----------------------------------------------------------------*/
  197.     /* Local Variables                                                */
  198.     /*----------------------------------------------------------------*/
  199.     /*----------------------------------------------------------------*/
  200.     /* Code Body                                                      */
  201.     /*----------------------------------------------------------------*/
  202.     if (MMI_fixed_list_menu.n_items <= 0)
  203.     {
  204.         return;
  205.     }
  206.     if ((MMI_fixed_list_menu.n_items == 1) && (MMI_fixed_list_menu.highlighted_item == 0))
  207.     {
  208.         return;
  209.     }
  210. #ifdef __MMI_UI_LIST_HIGHLIGHT_EFFECTS__
  211.     gui_stop_list_highlight_effect();
  212. #endif 
  213.     gui_asyncdynamic_list_menu_goto_previous_item(&MMI_fixed_list_menu);
  214.     /* Return In Case Of Error - 21/5/2004 */
  215.     if (gui_asyncdynamic_list_error)
  216.     {
  217.         return;
  218.     }
  219.     redraw_asyncdynamic_list();
  220. }
  221. /*****************************************************************************
  222.  * FUNCTION
  223.  *  asyncdynamic_list_goto_next_item
  224.  * DESCRIPTION
  225.  *  
  226.  * PARAMETERS
  227.  *  void
  228.  * RETURNS
  229.  *  void
  230.  *****************************************************************************/
  231. void asyncdynamic_list_goto_next_item(void)
  232. {
  233.     /*----------------------------------------------------------------*/
  234.     /* Local Variables                                                */
  235.     /*----------------------------------------------------------------*/
  236.     /*----------------------------------------------------------------*/
  237.     /* Code Body                                                      */
  238.     /*----------------------------------------------------------------*/
  239.     if (MMI_fixed_list_menu.n_items <= 0)
  240.     {
  241.         return;
  242.     }
  243.     if ((MMI_fixed_list_menu.n_items == 1) && (MMI_fixed_list_menu.highlighted_item == 0))
  244.     {
  245.         return;
  246.     }
  247. #ifdef __MMI_UI_LIST_HIGHLIGHT_EFFECTS__
  248.     gui_stop_list_highlight_effect();
  249. #endif 
  250.     gui_asyncdynamic_list_menu_goto_next_item(&MMI_fixed_list_menu);
  251.     /* Return In Case Of Error - 21/5/2004 */
  252.     if (gui_asyncdynamic_list_error)
  253.     {
  254.         return;
  255.     }
  256.     redraw_asyncdynamic_list();
  257. }
  258. /*****************************************************************************
  259.  * FUNCTION
  260.  *  asyncdynamic_list_goto_item
  261.  * DESCRIPTION
  262.  *  
  263.  * PARAMETERS
  264.  *  item_index      [IN]        
  265.  * RETURNS
  266.  *  void
  267.  *****************************************************************************/
  268. void asyncdynamic_list_goto_item(S32 item_index)
  269. {
  270.     /*----------------------------------------------------------------*/
  271.     /* Local Variables                                                */
  272.     /*----------------------------------------------------------------*/
  273.     /*----------------------------------------------------------------*/
  274.     /* Code Body                                                      */
  275.     /*----------------------------------------------------------------*/
  276.     if (MMI_fixed_list_menu.n_items <= 0)
  277.     {
  278.         return;
  279.     }
  280.     if (item_index == MMI_fixed_list_menu.highlighted_item)
  281.     {
  282.         return;
  283.     }
  284. #ifdef __MMI_UI_LIST_HIGHLIGHT_EFFECTS__
  285.     /* To avoid highlight effect when user jump to wrong menu index */
  286.     if (item_index >= MMI_fixed_list_menu.n_items)
  287.     {
  288.         return;
  289.     }
  290.     gui_stop_list_highlight_effect();
  291. #endif /* __MMI_UI_LIST_HIGHLIGHT_EFFECTS__ */ 
  292.     gui_asyncdynamic_list_menu_goto_item(&MMI_fixed_list_menu, item_index);
  293.     /* Return In Case Of Error - 21/5/2004 */
  294.     if (gui_asyncdynamic_list_error)
  295.     {
  296.         return;
  297.     }
  298.     redraw_asyncdynamic_list();
  299. }
  300. /*****************************************************************************
  301.  * FUNCTION
  302.  *  asyncdynamic_list_goto_item_no_redraw
  303.  * DESCRIPTION
  304.  *  
  305.  * PARAMETERS
  306.  *  item_index      [IN]        
  307.  * RETURNS
  308.  *  void
  309.  *****************************************************************************/
  310. void asyncdynamic_list_goto_item_no_redraw(S32 item_index)
  311. {
  312.     /*----------------------------------------------------------------*/
  313.     /* Local Variables                                                */
  314.     /*----------------------------------------------------------------*/
  315.     /*----------------------------------------------------------------*/
  316.     /* Code Body                                                      */
  317.     /*----------------------------------------------------------------*/
  318.     if (MMI_fixed_list_menu.n_items <= 0)
  319.     {
  320.         return;
  321.     }
  322.     if (item_index < 0)
  323.     {
  324.         item_index = 0;
  325.     }
  326.     if (item_index > (MMI_fixed_list_menu.n_items - 1))
  327.     {
  328.         item_index = MMI_fixed_list_menu.n_items - 1;
  329.     }
  330.     /* 
  331.      * This is used in menu setup. Highlighted item is set to -1 at first because
  332.      * 1. gui_asyncdynamic_list_menu_goto_item() might return directly if (highlighted_item==m->highlighted_item)
  333.      * 2. m->item_remove_highlight_function wont be invoked on the previous highlighted item.
  334.      */
  335.     MMI_fixed_list_menu.highlighted_item = -1;
  336.     gui_asyncdynamic_list_menu_goto_item(&MMI_fixed_list_menu, item_index);
  337. }
  338. /*****************************************************************************
  339.  * FUNCTION
  340.  *  register_asyncdynamic_list_shortcut_handler
  341.  * DESCRIPTION
  342.  *  
  343.  * PARAMETERS
  344.  *  void
  345.  * RETURNS
  346.  *  void
  347.  *****************************************************************************/
  348. void register_asyncdynamic_list_shortcut_handler(void)
  349. {
  350.     /*----------------------------------------------------------------*/
  351.     /* Local Variables                                                */
  352.     /*----------------------------------------------------------------*/
  353.     /*----------------------------------------------------------------*/
  354.     /* Code Body                                                      */
  355.     /*----------------------------------------------------------------*/
  356.     register_menu_shortcut_keys();
  357.     register_menu_shortcut_selected_only(asyncdynamic_list_goto_item);
  358. }
  359. /*****************************************************************************
  360.  * FUNCTION
  361.  *  register_asyncdynamic_list_keys
  362.  * DESCRIPTION
  363.  *  
  364.  * PARAMETERS
  365.  *  void
  366.  * RETURNS
  367.  *  void
  368.  *****************************************************************************/
  369. void register_asyncdynamic_list_keys(void)
  370. {
  371.     /*----------------------------------------------------------------*/
  372.     /* Local Variables                                                */
  373.     /*----------------------------------------------------------------*/
  374.     /*----------------------------------------------------------------*/
  375.     /* Code Body                                                      */
  376.     /*----------------------------------------------------------------*/
  377.     clear_keyboard_key_handler();
  378.     SetKeyHandler(asyncdynamic_list_goto_previous_item, KEY_UP_ARROW, KEY_EVENT_DOWN);
  379.     SetKeyHandler(asyncdynamic_list_goto_next_item, KEY_DOWN_ARROW, KEY_EVENT_DOWN);
  380.     SetKeyHandler(asyncdynamic_list_goto_previous_item, KEY_VOL_UP, KEY_EVENT_DOWN);
  381.     SetKeyHandler(asyncdynamic_list_goto_next_item, KEY_VOL_DOWN, KEY_EVENT_DOWN);
  382. }
  383. #if( UI_ENABLE_FRAME_SKIPPING )
  384. /*****************************************************************************
  385.  * FUNCTION
  386.  *  wgui_asyncdynamic_list_menu_end_frame
  387.  * DESCRIPTION
  388.  *  
  389.  * PARAMETERS
  390.  *  void
  391.  * RETURNS
  392.  *  void
  393.  *****************************************************************************/
  394. void wgui_asyncdynamic_list_menu_end_frame(void)
  395. {
  396.     /*----------------------------------------------------------------*/
  397.     /* Local Variables                                                */
  398.     /*----------------------------------------------------------------*/
  399.     /*----------------------------------------------------------------*/
  400.     /* Code Body                                                      */
  401.     /*----------------------------------------------------------------*/
  402.     if (wgui_fixed_list_menu_frame_counter >= 1)
  403.     {
  404.         if (MMI_fixed_list_menu.flags & UI_LIST_MENU_DISABLE_BACKGROUND)
  405.         {
  406.             _MMI_hide_fixed_list_menu();
  407.         }
  408.         gui_hide_animations();
  409.     #if(UI_DOUBLE_BUFFER_SUPPORT)
  410.         gui_lock_double_buffer();
  411.     #endif 
  412.         gui_show_asyncdynamic_list_menu(&MMI_fixed_list_menu);
  413.     #if(UI_DOUBLE_BUFFER_SUPPORT)
  414.         gui_unlock_double_buffer();
  415.     #endif 
  416.         wgui_display_asyncdynamic_text_list_pop_up_description();
  417.     #if(UI_DOUBLE_BUFFER_SUPPORT)
  418.         gui_BLT_double_buffer(
  419.             MMI_fixed_list_menu.x,
  420.             MMI_fixed_list_menu.y,
  421.             MMI_fixed_list_menu.x + MMI_fixed_list_menu.width,
  422.             MMI_fixed_list_menu.y + MMI_fixed_list_menu.height);
  423.     #endif /* (UI_DOUBLE_BUFFER_SUPPORT) */ 
  424.         wgui_fixed_list_menu_frame_counter = 0;
  425.         gui_start_timer(UI_FRAME_SKIP_TIMEOUT, wgui_asyncdynamic_list_menu_end_frame);
  426.     }
  427. }
  428. #endif /* ( UI_ENABLE_FRAME_SKIPPING ) */