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

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36. *
  37.  * Filename:
  38.  * ---------
  39.  *  wgui_categories_fmgr.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *  MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *  File Manager related categories.
  48.  *
  49.  *  [Category212]       Info Style Dynamic List Menu 
  50.  *  [Category213]       Thick Style Dynamic List Menu 
  51.  *  [Category214]       Matrix Style Dynamic Image Menu 
  52.  *
  53.  * Author:
  54.  * -------
  55.  * -------
  56.  *
  57.  *============================================================================
  58.  *             HISTORY
  59.   * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
  60.  *------------------------------------------------------------------------------
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * removed!
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * removed!
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * removed!
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * removed!
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * removed!
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * removed!
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * removed!
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * removed!
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * removed!
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * removed!
  114.  *
  115.  * removed!
  116.  * removed!
  117.  * removed!
  118.  *
  119.  * removed!
  120.  * removed!
  121.  * removed!
  122.  *
  123.  * removed!
  124.  * removed!
  125.  * removed!
  126.  *
  127.  * removed!
  128.  * removed!
  129.  * removed!
  130.  *
  131.  * removed!
  132.  * removed!
  133.  * removed!
  134.  *
  135.  * removed!
  136.  * removed!
  137.  * removed!
  138.  *
  139.  * removed!
  140.  * removed!
  141.  * removed!
  142.  *
  143.  * removed!
  144.  * removed!
  145.  * removed!
  146.  *
  147.  * removed!
  148.  * removed!
  149.  * removed!
  150.  *
  151.  * removed!
  152.  * removed!
  153.  * removed!
  154.  *
  155.  * removed!
  156.  * removed!
  157.  * removed!
  158.  *
  159.  * removed!
  160.  * removed!
  161.  * removed!
  162.  *
  163.  *------------------------------------------------------------------------------
  164.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  165.  *============================================================================
  166.  ****************************************************************************/
  167. #include "MMI_features.h"
  168. /* framework related include */
  169. #include "EventsGprot.h"
  170. #include "CustDataProts.h"
  171. #include "CustMenuRes.h"
  172. #include "GlobalDefs.h"
  173. #include "FrameworkStruct.h"
  174. #include "EventsDef.h"
  175. #include "Unicodexdcl.h"
  176. #include "DebugInitDef.h"
  177. /* gui related include */
  178. #include "gdi_include.h"        /* include for graphic lib */
  179. #include "kal_non_specific_general_types.h"     /* include this for kal data type */
  180. #include "lcd_sw_rnd.h"
  181. #include "gui_themes.h"
  182. #include "wgui.h"
  183. #include "wgui_softkeys.h"
  184. #include "wgui_fixed_menus.h"
  185. #include "wgui_fixed_menuitems.h"
  186. #include "wgui_dynamic_menus.h"
  187. #include "wgui_dynamic_menuitems.h"
  188. #include "wgui_categories.h"
  189. #include "wgui_categories_fmgr.h"
  190. #include "wgui_draw_manager.h"
  191. #ifdef __MMI_TOUCH_SCREEN__
  192. #include "wgui_touch_screen.h"
  193. #endif 
  194. #include "FileMgr.h"    /* file Utility functions */
  195. #include "FileManagerDef.h"     /* String ID define */
  196. #include "gdi_lcd_config.h"     /* include this for LCD_HEIGHT */
  197. #ifdef __MMI_UI_TAB_PANE__
  198. #include "wgui_tab.h"
  199. #endif 
  200. /***************************************************************************** 
  201. * Define
  202. *****************************************************************************/
  203. #if defined(__MMI_MAINLCD_128X128__)
  204. #define MMI_THICK_MENUITEM_HEIGHT   (30)
  205. #elif defined(__MMI_MAINLCD_128X160__)
  206. #define MMI_THICK_MENUITEM_HEIGHT   (30)
  207. #elif defined(__MMI_MAINLCD_176X220__)
  208. #ifdef __MMI_UI_DALMATIAN_FIXEDLIST__
  209. #define MMI_THICK_MENUITEM_HEIGHT   (37)        /* to set no of menu item to 7 */
  210. #else 
  211. #define MMI_THICK_MENUITEM_HEIGHT   (39)
  212. #endif 
  213. #elif defined(__MMI_MAINLCD_240X320__)
  214. #define MMI_THICK_MENUITEM_HEIGHT   (60)
  215. #else 
  216. #define MMI_THICK_MENUITEM_HEIGHT   (30)
  217. #endif 
  218. #define CAT214_INSIDE_SPACING          (4)      /* spacing include photo style frame */
  219. #define CAT214_OUTSIDE_SPACING         (4)
  220. /***************************************************************************** 
  221. * Golbal Variable
  222. *****************************************************************************/
  223. S32 MMI_thick_menuitem_height = MMI_THICK_MENUITEM_HEIGHT;  /* this shall move to other customizable place */
  224. extern gdi_handle wgui_layer_1;
  225. extern gdi_handle wgui_base_layer;
  226. extern BOOL r2lMMIFlag;
  227. /***************************************************************************** 
  228. * Golbal Function
  229. *****************************************************************************/
  230. extern S32 wgui_current_pop_up_description_index;
  231. extern void reset_pop_up_descriptions(void);
  232. extern void set_dynamic_pop_up_descriptions(S32 highlighted_item);
  233. extern void (*MMI_matrix_highlight_handler) (S32 item_index);
  234. extern void draw_wallpaper(void);
  235. /***************************************************************************** 
  236. * Local Variable
  237. *****************************************************************************/
  238. /* [Category212] */
  239. static Cat212DrawInfoFuncPtr cat212_draw_info_callback = NULL;
  240. static Cat212HideInfoFuncPtr cat212_hide_info_callback = NULL;
  241. static U16 cat212_info_box_height = 0;
  242. /* [Category213] */
  243. static Cat213DrawMenuItemFuncPtr cat213_draw_menuitem_callback = NULL;
  244. static Cat213HideMenuItemFuncPtr cat213_hide_menuitem_callback = NULL;
  245. static U16 cat213_menuitem_per_screen;
  246. static U8 cat213_arrow_flag;
  247. /* [Category214] */
  248. static Cat214DrawImageFuncPtr cat214_draw_image_callback = NULL;
  249. static Cat214HideImageFuncPtr cat214_hide_image_callback = NULL;
  250. static U8 cat214_num_per_row;
  251. static U8 cat214_num_per_col;
  252. static U16 cat214_hilighted_index;
  253. #if defined(__MMI_TOUCH_SCREEN__)
  254. static S16 cat214_pen_down_index;
  255. static U16 cat214_pen_down_on_scroll;
  256. #endif /* defined(__MMI_TOUCH_SCREEN__) */ 
  257. static U16 cat214_prev_hilighted_index;
  258. static U16 cat214_item_count;
  259. static S16 cat214_page_index;
  260. /***************************************************************************** 
  261. * Local Function
  262. *****************************************************************************/
  263. /* [Category212] */
  264. static void ExitCategory212Screen(void);
  265. void DrawCate212CategoryControlArea(dm_coordinates *coordinate);
  266. static void ShowCategory212InfoArea(S32 item_idx);
  267. /* [Category213] */
  268. static void ExitCategory213Screen(void);
  269. static pBOOL Cat213GetItemCallback(S32 item_idx, UI_string_type str_buff, PU8 *img_buff_p, U8 str_img_mask);
  270. static S32 Cat213GetHintCallback(S32 item_idx, UI_string_type *hint_array);
  271. static void Cat213RedrawDynamicList(void);
  272. static void Cat213KeyUpHdlr(void);
  273. static void Cat213KeyDownHdlr(void);
  274. static void Cat213ShortCutHdlr(S32 item_index);
  275. /* [Category214] */
  276. static void ExitCategory214Screen(void);
  277. static void Cat214KeyUpHdlr(void);
  278. static void Cat214KeyDownHdlr(void);
  279. static void Cat214KeyLeftHdlr(void);
  280. static void Cat214KeyRightHdlr(void);
  281. static void Cat214RedrawMatrix(void);
  282. static void Cat214ShortCutHdlr(S32 item_index);
  283. #if defined(__MMI_TOUCH_SCREEN__)
  284. static MMI_BOOL Cat214CategoryControlAreaPenDownHdlr(mmi_pen_point_struct pos);
  285. static MMI_BOOL Cat214CategoryControlAreaPenMoveHdlr(mmi_pen_point_struct pos);
  286. static MMI_BOOL Cat214CategoryControlAreaPenUpHdlr(mmi_pen_point_struct pos);
  287. #endif /* defined(__MMI_TOUCH_SCREEN__) */ 
  288. static void DrawCate214CategoryControlArea(dm_coordinates *coordinate);
  289. /*****************************************************************************
  290. * [Category212]
  291. *
  292. * This category is for File Manager to display drive info.
  293. *
  294. *  **********************
  295. *  *                    *
  296. *  *                  ----------- info box   
  297. *  **********************
  298. *  *  # Folder          *
  299. *  *  # File A          *
  300. *  *  # File B          *
  301. *  *                    *
  302. *  *                    *
  303. *  *                 -------------- Fix List 
  304. *  *                    *
  305. *  *                    *
  306. *  **********************
  307. *
  308. *****************************************************************************/
  309. /*****************************************************************************
  310.  * FUNCTION
  311.  *  ShowCategory211Screen
  312.  * DESCRIPTION
  313.  *  Show sategory 211 screen.
  314.  * PARAMETERS
  315.  *  title                       [IN]        Title string id
  316.  *  title_icon                  [IN]        Title image id
  317.  *  left_softkey                [IN]        Lsk string id
  318.  *  left_softkey_icon           [IN]        Lsk image id
  319.  *  right_softkey               [IN]        Rsk string id
  320.  *  right_softkey_icon          [IN]        Rsk image id
  321.  *  num_of_items                [IN]        How many items
  322.  *  get_item_func               [IN]        Callback function to get item string
  323.  *  get_hint_func               [IN]        Callback function to get item hint
  324.  *  draw_info_callback          [IN]        Callback function to draw info
  325.  *  hide_info_callback          [IN]        Callback function to hide info
  326.  *  info_box_height             [IN]        Height of info box
  327.  *  info_bg_img_id              [IN]        (unused)
  328.  *  highlighted_item            [IN]        Highlighted item
  329.  *  history_buffer              [IN]        History buffer
  330.  * RETURNS
  331.  *  void
  332.  *****************************************************************************/
  333. void ShowCategory211Screen(
  334.         U16 title,
  335.         U16 title_icon,
  336.         U16 left_softkey,
  337.         U16 left_softkey_icon,
  338.         U16 right_softkey,
  339.         U16 right_softkey_icon,
  340.         S32 num_of_items,
  341.         GetItemFuncPtr get_item_func,
  342.         GetHintFuncPtr get_hint_func,
  343.         Cat212DrawInfoFuncPtr draw_info_callback,
  344.         Cat212HideInfoFuncPtr hide_info_callback,
  345.         S32 info_box_height,
  346.         U16 info_bg_img_id,
  347.         S32 highlighted_item,
  348.         U8 *history_buffer)
  349. {
  350.     /*----------------------------------------------------------------*/
  351.     /* Local Variables                                                */
  352.     /*----------------------------------------------------------------*/
  353.     dm_data_struct dm_data;
  354.     S32 shortcut_width;
  355.     U8 h_flag,mm_bg_flags;
  356.     /*----------------------------------------------------------------*/
  357.     /* Code Body                                                      */
  358.     /*----------------------------------------------------------------*/
  359.     cat212_draw_info_callback = draw_info_callback;
  360.     cat212_hide_info_callback = hide_info_callback;
  361.     cat212_info_box_height = (U16) info_box_height;
  362.     /* lock */
  363.     gui_lock_double_buffer();
  364.     MMI_menu_shortcut_number = -1;
  365.     change_left_softkey(left_softkey, left_softkey_icon);
  366.     change_right_softkey(right_softkey, right_softkey_icon);
  367.     SetupCategoryKeyHandlers();
  368.     create_fixed_icontext_menuitems();
  369.     MMI_current_menu_type = LIST_MENU;
  370.     /* init dynamic list */
  371.     associate_fixed_icontext_list();
  372. MMI_disable_title_shortcut_display = 1;
  373. MMI_fixed_list_menu.flags |= UI_LIST_MENU_DISABLE_BACKGROUND | UI_LIST_MENU_DISABLE_BKGRND_IN_LAYER;
  374.                
  375.     init_dynamic_item_buffer(num_of_items, get_item_func, get_hint_func, UI_dummy_function);
  376.     MMI_fixed_list_menu.n_items = num_of_items;
  377.     /* register shortcut */
  378.     register_menu_shortcut_keys();
  379.     register_menu_shortcut_handler(Cat212ShortCutHdlr);
  380.     register_dynamic_list_keys();
  381.     shortcut_width = set_menu_item_count(num_of_items) + 7;
  382.     resize_menu_shortcut_handler(shortcut_width, MMI_title_height);
  383.     move_menu_shortcut_handler(UI_device_width - MMI_menu_shortcut_box.width, MMI_title_y);
  384.     register_hide_menu_shortcut(draw_title);
  385.     resize_fixed_icontext_menuitems(0, MMI_MENUITEM_HEIGHT);
  386.     set_fixed_icontext_positions(MMI_ICONTEXT_MENUITEM_HEIGHT + 2, 0, 1, 0);
  387. #ifdef __MMI_UI_TAB_PANE__
  388.     if (is_enabled_tab_pane())
  389.     {
  390.         move_fixed_list(0, (MMI_title_y + MMI_title_height) + cat212_info_box_height);  /* use two menuitem height to draw drive info */
  391.         resize_fixed_list(
  392.             MMI_content_width,
  393.             MMI_content_height - cat212_info_box_height - get_current_tab_pane_height());
  394.     }
  395.     else
  396. #endif /* __MMI_UI_TAB_PANE__ */ 
  397.     {
  398.         move_fixed_list(0, (MMI_title_y + MMI_title_height) + cat212_info_box_height);  /* use two menuitem height to draw drive info */
  399.         resize_fixed_list(MMI_content_width, MMI_content_height - cat212_info_box_height);
  400.     }
  401.     /* when hilight, will update info area */
  402.     register_fixed_list_highlight_handler(ShowCategory212InfoArea);
  403.     h_flag = set_list_menu_category_history(MMI_CATEGORY212_ID, history_buffer);
  404.     dynamic_list_goto_item_no_redraw(h_flag ? MMI_fixed_list_menu.highlighted_item : highlighted_item);
  405.     /* init title */
  406.     MMI_title_string = (UI_string_type) get_string(title);
  407.     MMI_title_icon = (PU8) get_image(title_icon);
  408.     resize_dynamic_icontext_menuitems_to_list_width();
  409.     set_dynamic_pop_up_descriptions(h_flag ? MMI_fixed_list_menu.highlighted_item : highlighted_item);  /* ????? */
  410.     gui_unlock_double_buffer();
  411. dm_set_scr_bg_image(IMG_GLOBAL_SUB_MENU_BG_2, NULL, -1, -1, current_MMI_theme->bg_opacity_full);
  412.     dm_get_scr_bg_flag(&mm_bg_flags);
  413.     dm_set_scr_bg_flag(mm_bg_flags | DM_SCR_BG_FORCE_SHOW);
  414.     ExitCategoryFunction = ExitCategory212Screen;
  415.     dm_setup_category_functions(dm_redraw_category_screen, dm_get_category_history, dm_get_category_history_size);
  416.     dm_data.s32ScrId = (S32) GetActiveScreenId();
  417.     dm_data.s32CatId = MMI_CATEGORY212_ID;
  418.     dm_data.s32flags |= DM_CLEAR_SCREEN_BACKGROUND;
  419.     dm_setup_data(&dm_data);
  420.     dm_register_category_controlled_callback(DrawCate212CategoryControlArea);
  421.     dm_redraw_category_screen();
  422. }
  423. /*****************************************************************************
  424.  * FUNCTION
  425.  *  ShowCategory212Screen
  426.  * DESCRIPTION
  427.  *  Show sategory 212 screen.
  428.  * PARAMETERS
  429.  *  title                       [IN]        Title string id
  430.  *  title_icon                  [IN]        Title image id
  431.  *  left_softkey                [IN]        Lsk string id
  432.  *  left_softkey_icon           [IN]        Lsk image id
  433.  *  right_softkey               [IN]        Rsk string id
  434.  *  right_softkey_icon          [IN]        Rsk image id
  435.  *  num_of_items                [IN]        How many items
  436.  *  get_item_func               [IN]        Callback function to get item string
  437.  *  get_hint_func               [IN]        Callback function to get item hint
  438.  *  draw_info_callback          [IN]        Callback function to draw info
  439.  *  hide_info_callback          [IN]        Callback function to hide info
  440.  *  num_of_info_box_rows        [IN]        How many row (height) for info box
  441.  *  info_bg_img_id              [IN]        (unused)
  442.  *  highlighted_item            [IN]        Highlighted item
  443.  *  history_buffer              [IN]        History buffer
  444.  * RETURNS
  445.  *  void
  446.  *****************************************************************************/
  447. void ShowCategory212Screen(
  448.         U16 title,
  449.         U16 title_icon,
  450.         U16 left_softkey,
  451.         U16 left_softkey_icon,
  452.         U16 right_softkey,
  453.         U16 right_softkey_icon,
  454.         S32 num_of_items,
  455.         GetItemFuncPtr get_item_func,
  456.         GetHintFuncPtr get_hint_func,
  457.         Cat212DrawInfoFuncPtr draw_info_callback,
  458.         Cat212HideInfoFuncPtr hide_info_callback,
  459.         U16 num_of_info_box_rows,
  460.         U16 info_bg_img_id,
  461.         S32 highlighted_item,
  462.         U8 *history_buffer)
  463. {
  464.     /*----------------------------------------------------------------*/
  465.     /* Local Variables                                                */
  466.     /*----------------------------------------------------------------*/
  467.     /*----------------------------------------------------------------*/
  468.     /* Code Body                                                      */
  469.     /*----------------------------------------------------------------*/
  470.     ShowCategory211Screen(
  471.         title, 
  472.         title_icon,
  473.         left_softkey,
  474.         left_softkey_icon,
  475.         right_softkey,
  476.         right_softkey_icon,
  477.         num_of_items,
  478.         get_item_func,
  479.         get_hint_func,
  480.         draw_info_callback,
  481.         hide_info_callback,
  482.         (S32) num_of_info_box_rows * MMI_ICONTEXT_MENUITEM_HEIGHT,
  483.         info_bg_img_id,
  484.         highlighted_item,
  485.         history_buffer);
  486. }
  487. /*****************************************************************************
  488.  * FUNCTION
  489.  *  ExitCategory212Screen
  490.  * DESCRIPTION
  491.  *  Exit category 212 screen
  492.  * PARAMETERS
  493.  *  void
  494.  * RETURNS
  495.  *  void
  496.  *****************************************************************************/
  497. static void ExitCategory212Screen(void)
  498. {
  499.     /*----------------------------------------------------------------*/
  500.     /* Local Variables                                                */
  501.     /*----------------------------------------------------------------*/
  502.     /*----------------------------------------------------------------*/
  503.     /* Code Body                                                      */
  504.     /*----------------------------------------------------------------*/
  505.     if (cat212_hide_info_callback != NULL)
  506.     {
  507.         cat212_hide_info_callback();
  508.     }
  509.     ClearHighlightHandler();
  510.     reset_softkeys();
  511.     reset_menu_shortcut_handler();
  512.     reset_dynamic_list();
  513.     reset_pop_up_descriptions();
  514.     /* reset cat212 related golbal var */
  515.     cat212_info_box_height = 0;
  516.     cat212_draw_info_callback = NULL;
  517.     cat212_hide_info_callback = NULL;
  518. }
  519. /*****************************************************************************
  520.  * FUNCTION
  521.  *  DrawCate212CategoryControlArea
  522.  * DESCRIPTION
  523.  *  This function is used to draw the category controlled area of category212 screen
  524.  * PARAMETERS
  525.  *  coordinate      [IN/OUT]        Coordinates of category controlled area.
  526.  * RETURNS
  527.  *  void
  528.  *****************************************************************************/
  529. void DrawCate212CategoryControlArea(dm_coordinates *coordinate)
  530. {
  531.     /*----------------------------------------------------------------*/
  532.     /* Local Variables                                                */
  533.     /*----------------------------------------------------------------*/
  534.     /*----------------------------------------------------------------*/
  535.     /* Code Body                                                      */
  536.     /*----------------------------------------------------------------*/
  537.     ShowCategory212InfoArea(MMI_fixed_list_menu.highlighted_item);
  538.     coordinate->s16X = 0;
  539.     coordinate->s16Y = (MMI_title_y + MMI_title_height);
  540.     coordinate->s16Height = cat212_info_box_height;
  541.     coordinate->s16Width = MMI_content_width;
  542. }
  543. /*****************************************************************************
  544.  * FUNCTION
  545.  *  ShowCategory212InfoArea
  546.  * DESCRIPTION
  547.  *  Show the info area for category212
  548.  * PARAMETERS
  549.  *  item_idx        [IN]        Item_index
  550.  * RETURNS
  551.  *  void
  552.  *****************************************************************************/
  553. static void ShowCategory212InfoArea(S32 item_idx)
  554. {
  555.     /*----------------------------------------------------------------*/
  556.     /* Local Variables                                                */
  557.     /*----------------------------------------------------------------*/
  558.     S32 offset_x;
  559.     S32 offset_y;
  560.     S32 str_width;
  561.     S32 str_height;
  562.     S8 *str_ptr;
  563.     /*----------------------------------------------------------------*/
  564.     /* Code Body                                                      */
  565.     /*----------------------------------------------------------------*/
  566.     /* call dynamic list's hilight handler */
  567.     dynamic_list_highlight_handler(item_idx);
  568.     gdi_layer_lock_frame_buffer();
  569.     /* drive info block */
  570.     gui_reset_clip();
  571.     gui_fill_rectangle(
  572.         0,
  573.         (MMI_title_y + MMI_title_height),
  574.         UI_device_width - 1,
  575.         (MMI_title_y + MMI_title_height) + cat212_info_box_height - 1,
  576.         gui_color(255, 255, 255));
  577.     gui_draw_rectangle(
  578.         0,
  579.         (MMI_title_y + MMI_title_height),
  580.         UI_device_width - 1,
  581.         (MMI_title_y + MMI_title_height) + cat212_info_box_height - 1,
  582.         gui_color(0, 0, 0));
  583.     /* stop previous action, such as gif animation, decoder, timer etc. */
  584.     if (cat212_hide_info_callback != NULL)
  585.     {
  586.         cat212_hide_info_callback();
  587.     }
  588.     /* if is emtpty folder, show a empty string */
  589.     if (MMI_fixed_list_menu.n_items == 0)
  590.     {
  591.         gui_set_font(&MMI_medium_font);
  592.         gui_set_text_color(gui_color(0, 0, 0));
  593.         str_ptr = GetString(STR_ID_FMGR_EMPTY_FOLDER);
  594.         gui_measure_string((UI_string_type) str_ptr, &str_width, &str_height);
  595.         offset_x = (UI_device_width - str_width) >> 1;
  596.         offset_y = (UI_device_height - str_height) >> 1;
  597.         if (r2lMMIFlag)
  598.         {
  599.             gui_move_text_cursor(offset_x + str_width, offset_y);
  600.         }
  601.         else
  602.         {
  603.             gui_move_text_cursor(offset_x, offset_y);
  604.         }
  605.         gui_print_text((UI_string_type) str_ptr);
  606.     }
  607.     if (cat212_draw_info_callback != NULL)
  608.     {
  609.         cat212_draw_info_callback(
  610.             MMI_fixed_list_menu.highlighted_item,   /* idx */
  611.             0,                                      /* x1 */
  612.             (MMI_title_y + MMI_title_height),       /* y1 */
  613.             UI_device_width - 1,                    /* x2 */
  614.             (MMI_title_y + MMI_title_height) + cat212_info_box_height - 1);       /* y2 */
  615.     }
  616.     /* 
  617.      * lock then blt, will not update to lcm directly, but will force next blt function 
  618.      * also update this region 
  619.      */
  620.     gdi_layer_blt_previous(0, 0, UI_device_width - 1, UI_device_height - 1);
  621.     gdi_layer_unlock_frame_buffer();
  622. }
  623. /*****************************************************************************
  624.  * FUNCTION
  625.  *  Cat212ShortCutHdlr
  626.  * DESCRIPTION
  627.  *  Category 212 short cut goto item hdlr
  628.  * PARAMETERS
  629.  *  item_index      [IN]        Goto item's index
  630.  * RETURNS
  631.  *  void
  632.  *****************************************************************************/
  633. void Cat212ShortCutHdlr(S32 item_index)
  634. {
  635.     /*----------------------------------------------------------------*/
  636.     /* Local Variables                                                */
  637.     /*----------------------------------------------------------------*/
  638.     /*----------------------------------------------------------------*/
  639.     /* Code Body                                                      */
  640.     /*----------------------------------------------------------------*/
  641.     if (MMI_fixed_list_menu.n_items <= 0)
  642.     {
  643.         return;
  644.     }
  645.     if (item_index == MMI_fixed_list_menu.highlighted_item)
  646.     {
  647.         return;
  648.     }
  649.     gui_dynamic_list_menu_goto_item(&MMI_fixed_list_menu, item_index);
  650.     RedrawCategoryFunction();
  651. }
  652. /*****************************************************************************
  653.  * FUNCTION
  654.  *  DrawCate213CategoryControlArea
  655.  * DESCRIPTION
  656.  *  draw control area
  657.  * PARAMETERS
  658.  *  coordinate      [IN]        Coordinate
  659.  * RETURNS
  660.  *  void
  661.  *****************************************************************************/
  662. void DrawCate213CategoryControlArea(dm_coordinates *coordinate)
  663. {
  664.     /*----------------------------------------------------------------*/
  665.     /* Local Variables                                                */
  666.     /*----------------------------------------------------------------*/
  667.     S32 offset_x;
  668.     S32 offset_y;
  669.     S32 str_width;
  670.     S32 str_height;
  671.     S8 *str_ptr;
  672.     /*----------------------------------------------------------------*/
  673.     /* Code Body                                                      */
  674.     /*----------------------------------------------------------------*/
  675.     if (MMI_fixed_list_menu.n_items == 0)
  676.     {
  677.         show_dynamic_list();
  678.         gui_reset_text_clip();
  679.         gui_set_font(&MMI_medium_font);
  680.         gui_set_text_color(gui_color(0, 0, 0));
  681.         str_ptr = GetString(STR_ID_FMGR_EMPTY_FOLDER);
  682.         gui_measure_string((UI_string_type) str_ptr, &str_width, &str_height);
  683.         offset_x = (UI_device_width - str_width) >> 1;
  684.         offset_y = (UI_device_height - str_height) >> 1;
  685.         if (r2lMMIFlag)
  686.         {
  687.             gui_move_text_cursor(offset_x + str_width, offset_y);
  688.         }
  689.         else
  690.         {
  691.             gui_move_text_cursor(offset_x, offset_y);
  692.         }
  693.         gui_print_text((UI_string_type) str_ptr);
  694.     }
  695.     else
  696.     {
  697.         Cat213RedrawDynamicList();
  698.     }
  699. }
  700. #ifdef __MMI_TOUCH_SCREEN__
  701. /*****************************************************************************
  702.  * FUNCTION
  703.  *  category213_control_area_pen_handler
  704.  * DESCRIPTION
  705.  *  
  706.  * PARAMETERS
  707.  *  point           [IN]        
  708.  *  pen_event       [IN]        
  709.  * RETURNS
  710.  *  
  711.  *****************************************************************************/
  712. static MMI_BOOL category213_control_area_pen_handler(mmi_pen_point_struct point, mmi_pen_event_type_enum pen_event)
  713. {
  714.     /*----------------------------------------------------------------*/
  715.     /* Local Variables                                                */
  716.     /*----------------------------------------------------------------*/
  717.     /*----------------------------------------------------------------*/
  718.     /* Code Body                                                      */
  719.     /*----------------------------------------------------------------*/
  720.     /* Display prompt string instead of menu */
  721.     if (MMI_fixed_list_menu.n_items == 0)
  722.     {
  723.         return MMI_FALSE;
  724.     }
  725.     if (pen_event == MMI_PEN_EVENT_DOWN)
  726.     {
  727.         MMI_fixed_list_menu.pen_redraw_menu_function = Cat213RedrawDynamicList;
  728.         gui_vertical_scrollbar_set_pen_self_scroll(&MMI_fixed_list_menu.vbar, MMI_TRUE);
  729.         gui_fixed_list_menu_set_pen_scroll_delay(&MMI_fixed_list_menu, GUI_DYNAMIC_LIST_PEN_SCROLL_DELAY);
  730.     }
  731.     return wgui_general_pen_dynamic_list_menu_hdlr(point, pen_event);
  732. }
  733. /*****************************************************************************
  734.  * FUNCTION
  735.  *  category213_control_area_pen_down_handler
  736.  * DESCRIPTION
  737.  *  
  738.  * PARAMETERS
  739.  *  point       [IN]        
  740.  * RETURNS
  741.  *  
  742.  *****************************************************************************/
  743. static MMI_BOOL category213_control_area_pen_down_handler(mmi_pen_point_struct point)
  744. {
  745.     /*----------------------------------------------------------------*/
  746.     /* Local Variables                                                */
  747.     /*----------------------------------------------------------------*/
  748.     /*----------------------------------------------------------------*/
  749.     /* Code Body                                                      */
  750.     /*----------------------------------------------------------------*/
  751.     return category213_control_area_pen_handler(point, MMI_PEN_EVENT_DOWN);
  752. }
  753. /*****************************************************************************
  754.  * FUNCTION
  755.  *  category213_control_area_pen_move_handler
  756.  * DESCRIPTION
  757.  *  
  758.  * PARAMETERS
  759.  *  point       [IN]        
  760.  * RETURNS
  761.  *  
  762.  *****************************************************************************/
  763. static MMI_BOOL category213_control_area_pen_move_handler(mmi_pen_point_struct point)
  764. {
  765.     /*----------------------------------------------------------------*/
  766.     /* Local Variables                                                */
  767.     /*----------------------------------------------------------------*/
  768.     /*----------------------------------------------------------------*/
  769.     /* Code Body                                                      */
  770.     /*----------------------------------------------------------------*/
  771.     return category213_control_area_pen_handler(point, MMI_PEN_EVENT_MOVE);
  772. }
  773. /*****************************************************************************
  774.  * FUNCTION
  775.  *  category213_control_area_pen_longtap_handler
  776.  * DESCRIPTION
  777.  *  
  778.  * PARAMETERS
  779.  *  point       [IN]        
  780.  * RETURNS
  781.  *  
  782.  *****************************************************************************/
  783. static MMI_BOOL category213_control_area_pen_longtap_handler(mmi_pen_point_struct point)
  784. {
  785.     /*----------------------------------------------------------------*/
  786.     /* Local Variables                                                */
  787.     /*----------------------------------------------------------------*/
  788.     /*----------------------------------------------------------------*/
  789.     /* Code Body                                                      */
  790.     /*----------------------------------------------------------------*/
  791.     return category213_control_area_pen_handler(point, MMI_PEN_EVENT_LONG_TAP);
  792. }
  793. /*****************************************************************************
  794.  * FUNCTION
  795.  *  category213_control_area_pen_repeat_handler
  796.  * DESCRIPTION
  797.  *  
  798.  * PARAMETERS
  799.  *  point       [IN]        
  800.  * RETURNS
  801.  *  
  802.  *****************************************************************************/
  803. static MMI_BOOL category213_control_area_pen_repeat_handler(mmi_pen_point_struct point)
  804. {
  805.     /*----------------------------------------------------------------*/
  806.     /* Local Variables                                                */
  807.     /*----------------------------------------------------------------*/
  808.     /*----------------------------------------------------------------*/
  809.     /* Code Body                                                      */
  810.     /*----------------------------------------------------------------*/
  811.     return category213_control_area_pen_handler(point, MMI_PEN_EVENT_REPEAT);
  812. }
  813. /*****************************************************************************
  814.  * FUNCTION
  815.  *  category213_control_area_pen_up_handler
  816.  * DESCRIPTION
  817.  *  
  818.  * PARAMETERS
  819.  *  point       [IN]        
  820.  * RETURNS
  821.  *  
  822.  *****************************************************************************/
  823. static MMI_BOOL category213_control_area_pen_up_handler(mmi_pen_point_struct point)
  824. {
  825.     /*----------------------------------------------------------------*/
  826.     /* Local Variables                                                */
  827.     /*----------------------------------------------------------------*/
  828.     /*----------------------------------------------------------------*/
  829.     /* Code Body                                                      */
  830.     /*----------------------------------------------------------------*/
  831.     return category213_control_area_pen_handler(point, MMI_PEN_EVENT_UP);
  832. }
  833. /*****************************************************************************
  834.  * FUNCTION
  835.  *  category213_control_area_pen_abort_handler
  836.  * DESCRIPTION
  837.  *  
  838.  * PARAMETERS
  839.  *  point       [IN]        
  840.  * RETURNS
  841.  *  
  842.  *****************************************************************************/
  843. static MMI_BOOL category213_control_area_pen_abort_handler(mmi_pen_point_struct point)
  844. {
  845.     /*----------------------------------------------------------------*/
  846.     /* Local Variables                                                */
  847.     /*----------------------------------------------------------------*/
  848.     /*----------------------------------------------------------------*/
  849.     /* Code Body                                                      */
  850.     /*----------------------------------------------------------------*/
  851.     return category213_control_area_pen_handler(point, MMI_PEN_EVENT_ABORT);
  852. }
  853. #endif /* __MMI_TOUCH_SCREEN__ */ 
  854. /*****************************************************************************
  855. * [Category213]
  856. *
  857. * This category is for ImageViewer to display drive info.
  858. *
  859. *  **********************
  860. *  *  ####  FileName    *
  861. *  *  ####  Res    Size *  
  862. *  **********************
  863. *  *  ####  FileName    *
  864. *  *  ####  Res    Size *  
  865. *  **********************
  866. *  *  ####  FileName    *
  867. *  *  ####  Res    Size *  
  868. *  **********************
  869. *  *  ####  FileName    *
  870. *  *  ####  Res    Size *  
  871. *  **********************
  872. *
  873. *****************************************************************************/
  874. /*****************************************************************************
  875.  * FUNCTION
  876.  *  ShowCategory213Screen
  877.  * DESCRIPTION
  878.  *  Show sategory 223 screen.
  879.  * PARAMETERS
  880.  *  title                       [IN]        Title string id
  881.  *  title_icon                  [IN]        Title image id
  882.  *  left_softkey                [IN]        Lsk string id
  883.  *  left_softkey_icon           [IN]        Lsk image id
  884.  *  right_softkey               [IN]        Rsk string id
  885.  *  right_softkey_icon          [IN]        Rsk image id
  886.  *  num_of_items                [IN]        How many items
  887.  *  draw_menuitem_callback      [IN]        Callback function to draw menuitem
  888.  *  hide_menuitem_callback      [IN]        Callback function to hide menuitem
  889.  *  highlighted_item            [IN]        Highlighted item index
  890.  *  arrow_flag                  [IN]        Arrow on buttom bar
  891.  *  history_buffer              [IN]        History buffer
  892.  * RETURNS
  893.  *  void
  894.  *****************************************************************************/
  895. void ShowCategory213Screen(
  896.         U16 title,
  897.         U16 title_icon,
  898.         U16 left_softkey,
  899.         U16 left_softkey_icon,
  900.         U16 right_softkey,
  901.         U16 right_softkey_icon,
  902.         S32 num_of_items,
  903.         Cat213DrawMenuItemFuncPtr draw_menuitem_callback,
  904.         Cat213HideMenuItemFuncPtr hide_menuitem_callback,
  905.         S32 highlighted_item,
  906.         U8 arrow_flag,
  907.         U8 *history_buffer)
  908. {
  909.     /*----------------------------------------------------------------*/
  910.     /* Local Variables                                                */
  911.     /*----------------------------------------------------------------*/
  912.     dm_data_struct dm_data;
  913.     S32 shortcut_width;
  914.     U8 h_flag,mm_bg_flags;
  915.     /*----------------------------------------------------------------*/
  916.     /* Code Body                                                      */
  917.     /*----------------------------------------------------------------*/
  918.     cat213_draw_menuitem_callback = draw_menuitem_callback;
  919.     cat213_hide_menuitem_callback = hide_menuitem_callback;
  920.     cat213_menuitem_per_screen = MMI_content_height / (MMI_thick_menuitem_height - 1);
  921.     cat213_arrow_flag = arrow_flag;
  922.     /* lock */
  923.     gui_lock_double_buffer();
  924. #ifdef __MMI_UI_LIST_HIGHLIGHT_EFFECTS__
  925.     gui_block_list_effect();
  926. #endif 
  927.     MMI_menu_shortcut_number = -1;
  928.     change_left_softkey(left_softkey, left_softkey_icon);
  929.     change_right_softkey(right_softkey, right_softkey_icon);
  930.     SetupCategoryKeyHandlers();
  931.     create_fixed_icontext_menuitems();
  932.     MMI_current_menu_type = LIST_MENU;
  933.     /* init dynamic list */
  934.     associate_fixed_icontext_list();
  935. MMI_disable_title_shortcut_display = 1;
  936. MMI_fixed_list_menu.flags |= UI_LIST_MENU_LOOP | UI_LIST_MENU_DISABLE_BACKGROUND | UI_LIST_MENU_DISABLE_BKGRND_IN_LAYER;
  937. #ifdef __MMI_UI_TRANSPARENT_EFFECT__
  938.     disable_fixed_icontext_menuitem_transparent_effect();
  939. #endif 
  940.     init_dynamic_item_buffer(num_of_items, Cat213GetItemCallback, Cat213GetHintCallback, UI_dummy_function);
  941.     MMI_fixed_list_menu.n_items = num_of_items;
  942.     /* register shortcut */
  943.     register_menu_shortcut_keys();
  944.     register_menu_shortcut_selected_only(Cat213ShortCutHdlr);
  945.     clear_keyboard_key_handler();
  946.     SetKeyHandler(Cat213KeyUpHdlr, KEY_UP_ARROW, KEY_EVENT_DOWN);
  947.     SetKeyHandler(Cat213KeyDownHdlr, KEY_DOWN_ARROW, KEY_EVENT_DOWN);
  948.     SetKeyHandler(Cat213KeyUpHdlr, KEY_VOL_UP, KEY_EVENT_DOWN);
  949.     SetKeyHandler(Cat213KeyDownHdlr, KEY_VOL_DOWN, KEY_EVENT_DOWN);
  950.     shortcut_width = set_menu_item_count(num_of_items) + 7;
  951.     resize_menu_shortcut_handler(shortcut_width, MMI_title_height);
  952.     move_menu_shortcut_handler(UI_device_width - MMI_menu_shortcut_box.width, MMI_title_y);
  953.     register_hide_menu_shortcut(draw_title);
  954.     resize_fixed_icontext_menuitems(0, MMI_thick_menuitem_height);
  955.     set_fixed_icontext_positions(MMI_ICONTEXT_MENUITEM_HEIGHT, 0, 1, 0);
  956.     /* change menuitem's height */
  957. #ifdef __MMI_UI_TAB_PANE__
  958.     if (is_enabled_tab_pane())
  959.     {
  960.         move_fixed_list(0, (MMI_title_y + MMI_title_height));
  961.         resize_fixed_list(MMI_content_width, MMI_content_height - get_current_tab_pane_height());
  962.     }
  963.     else
  964. #endif /* __MMI_UI_TAB_PANE__ */ 
  965.     {
  966.         move_fixed_list(0, (MMI_title_y + MMI_title_height));
  967.         resize_fixed_list(MMI_content_width, MMI_content_height);
  968.     }
  969.     register_fixed_list_highlight_handler(dynamic_list_highlight_handler);
  970.     /* if caller wish to use gui buffer as histoy */
  971.     h_flag = set_list_menu_category_history(MMI_CATEGORY213_ID, history_buffer);
  972.     if (h_flag)
  973.     {
  974.         highlighted_item = MMI_fixed_list_menu.highlighted_item;
  975.     }
  976.     dynamic_list_goto_item_no_redraw(highlighted_item);
  977.     /* adjust hilight - since its is thick menu and previous function will not calc correclty */
  978.     MMI_fixed_list_menu.highlighted_item = highlighted_item;
  979.     if (num_of_items < cat213_menuitem_per_screen)
  980.     {
  981.         MMI_fixed_list_menu.first_displayed_item = 0;
  982.         MMI_fixed_list_menu.last_displayed_item = num_of_items - 1;
  983.     }
  984.     else
  985.     {
  986.         if ((num_of_items - highlighted_item) < cat213_menuitem_per_screen)
  987.         {
  988.             MMI_fixed_list_menu.first_displayed_item = num_of_items - cat213_menuitem_per_screen;
  989.             MMI_fixed_list_menu.last_displayed_item = num_of_items - 1;
  990.         }
  991.         else
  992.         {
  993.             MMI_fixed_list_menu.first_displayed_item = highlighted_item;
  994.             MMI_fixed_list_menu.last_displayed_item = highlighted_item + num_of_items - 1;
  995.         }
  996.     }
  997.     /* init title */
  998.     MMI_title_string = (UI_string_type) get_string(title);
  999.     MMI_title_icon = (PU8) get_image(title_icon);
  1000.     resize_dynamic_icontext_menuitems_to_list_width();
  1001.     resize_fixed_icontext_menuitems(0, MMI_thick_menuitem_height);
  1002.     set_dynamic_pop_up_descriptions(h_flag ? MMI_fixed_list_menu.highlighted_item : highlighted_item);  /* ????? */
  1003.     gui_unlock_double_buffer();
  1004. wgui_set_title_bknd_display(MMI_FALSE);
  1005. dm_set_scr_bg_image(IMG_GLOBAL_SUB_MENU_BG_2, NULL, -1, -1, current_MMI_theme->bg_opacity_full);
  1006. dm_get_scr_bg_flag(&mm_bg_flags);
  1007. dm_set_scr_bg_flag(mm_bg_flags | DM_SCR_BG_FORCE_SHOW);
  1008.     ExitCategoryFunction = ExitCategory213Screen;
  1009.     dm_setup_category_functions(dm_redraw_category_screen, dm_get_category_history, dm_get_category_history_size);
  1010.     dm_data.s32ScrId = (S32) GetActiveScreenId();
  1011.     dm_data.s32CatId = MMI_CATEGORY213_ID;
  1012.     dm_data.s32flags = DM_CLEAR_SCREEN_BACKGROUND | DM_NO_STATUS_BAR;
  1013. #ifdef __MMI_TOUCH_SCREEN__
  1014.     wgui_register_category_screen_control_area_pen_handlers(
  1015.         category213_control_area_pen_down_handler,
  1016.         MMI_PEN_EVENT_DOWN);
  1017.     wgui_register_category_screen_control_area_pen_handlers(category213_control_area_pen_up_handler, MMI_PEN_EVENT_UP);
  1018.     wgui_register_category_screen_control_area_pen_handlers(
  1019.         category213_control_area_pen_move_handler,
  1020.         MMI_PEN_EVENT_MOVE);
  1021.     wgui_register_category_screen_control_area_pen_handlers(
  1022.         category213_control_area_pen_repeat_handler,
  1023.         MMI_PEN_EVENT_REPEAT);
  1024.     wgui_register_category_screen_control_area_pen_handlers(
  1025.         category213_control_area_pen_longtap_handler,
  1026.         MMI_PEN_EVENT_LONG_TAP);
  1027.     wgui_register_category_screen_control_area_pen_handlers(
  1028.         category213_control_area_pen_abort_handler,
  1029.         MMI_PEN_EVENT_ABORT);
  1030. #endif /* __MMI_TOUCH_SCREEN__ */ 
  1031.     dm_setup_data(&dm_data);
  1032.     dm_register_category_controlled_callback(DrawCate213CategoryControlArea);
  1033.     dm_redraw_category_screen();
  1034. }
  1035. /*****************************************************************************
  1036.  * FUNCTION
  1037.  *  ExitCategory213Screen
  1038.  * DESCRIPTION
  1039.  *  Exit category 213 screen
  1040.  * PARAMETERS
  1041.  *  void
  1042.  * RETURNS
  1043.  *  void
  1044.  *****************************************************************************/
  1045. static void ExitCategory213Screen(void)
  1046. {
  1047.     /*----------------------------------------------------------------*/
  1048.     /* Local Variables                                                */
  1049.     /*----------------------------------------------------------------*/
  1050.     /*----------------------------------------------------------------*/
  1051.     /* Code Body                                                      */
  1052.     /*----------------------------------------------------------------*/
  1053.     ClearHighlightHandler();
  1054.     reset_softkeys();
  1055.     reset_menu_shortcut_handler();
  1056.     reset_dynamic_list();
  1057.     reset_pop_up_descriptions();    /* ????? */
  1058.     /* PMT VIKAS START 20050817 */
  1059. #ifdef __MMI_UI_LIST_HIGHLIGHT_EFFECTS__
  1060.     gui_unblock_list_effect();
  1061. #endif 
  1062.     //PMT VIKAS END 20050817
  1063.     //PMT VIKAS START 20050817
  1064. #ifdef __MMI_UI_TRANSPARENT_EFFECT__
  1065.     enable_fixed_icontext_menuitem_transparent_effect();
  1066. #endif 
  1067.     /* PMT VIKAS END 20050817 */
  1068.     if (cat213_hide_menuitem_callback != NULL)
  1069.     {
  1070.         cat213_hide_menuitem_callback();
  1071.     }
  1072.     cat213_draw_menuitem_callback = NULL;
  1073.     cat213_hide_menuitem_callback = NULL;
  1074. }
  1075. /*****************************************************************************
  1076.  * FUNCTION
  1077.  *  Cat213GetItemCallback
  1078.  * DESCRIPTION
  1079.  *  Get category 213 get item callback function
  1080.  * PARAMETERS
  1081.  *  item_idx            [IN]        
  1082.  *  str_buff            [IN]        
  1083.  *  img_buff_p          [?]         
  1084.  *  str_img_mask        [IN]        
  1085.  * RETURNS
  1086.  *  void
  1087.  *****************************************************************************/
  1088. static pBOOL Cat213GetItemCallback(S32 item_idx, UI_string_type str_buff, PU8 *img_buff_p, U8 str_img_mask)
  1089. {
  1090.     /*----------------------------------------------------------------*/
  1091.     /* Local Variables                                                */
  1092.     /*----------------------------------------------------------------*/
  1093.     /*----------------------------------------------------------------*/
  1094.     /* Code Body                                                      */
  1095.     /*----------------------------------------------------------------*/
  1096.     UCS2Strcpy((PS8) str_buff, (PS8) L"");
  1097.     *img_buff_p = NULL;;
  1098.     return TRUE;
  1099. }
  1100. /*****************************************************************************
  1101.  * FUNCTION
  1102.  *  Cat213GetHintCallback
  1103.  * DESCRIPTION
  1104.  *  Get category 213 get hint callback function
  1105.  * PARAMETERS
  1106.  *  item_idx        [IN]        
  1107.  *  hint_array      [?]         
  1108.  * RETURNS
  1109.  *  void
  1110.  *****************************************************************************/
  1111. static S32 Cat213GetHintCallback(S32 item_idx, UI_string_type *hint_array)
  1112. {
  1113.     /*----------------------------------------------------------------*/
  1114.     /* Local Variables                                                */
  1115.     /*----------------------------------------------------------------*/
  1116.     /*----------------------------------------------------------------*/
  1117.     /* Code Body                                                      */
  1118.     /*----------------------------------------------------------------*/
  1119.     /* do nothing */
  1120.     return FALSE;
  1121. }
  1122. /*****************************************************************************
  1123.  * FUNCTION
  1124.  *  Cat213RedrawDynamicList
  1125.  * DESCRIPTION
  1126.  *  Redraw category 213 dynamic list
  1127.  * PARAMETERS
  1128.  *  void
  1129.  * RETURNS
  1130.  *  void
  1131.  *****************************************************************************/
  1132. static void Cat213RedrawDynamicList(void)
  1133. {
  1134.     /*----------------------------------------------------------------*/
  1135.     /* Local Variables                                                */
  1136.     /*----------------------------------------------------------------*/
  1137.     S32 i;
  1138.     BOOL is_done;
  1139.     S32 item_width, item_height;
  1140.     S32 offset_y;
  1141.     S32 total_height;
  1142.     S32 counter;
  1143.     S32 list_height;
  1144.     BOOL is_hilighted;
  1145.     /*----------------------------------------------------------------*/
  1146.     /* Code Body                                                      */
  1147.     /*----------------------------------------------------------------*/
  1148.     /* hide previous menuitems, usually stop animation and some off-line decoder */
  1149.     if (cat213_hide_menuitem_callback != NULL)
  1150.     {
  1151.         cat213_hide_menuitem_callback();
  1152.     }
  1153.     gui_lock_double_buffer();
  1154.     /* show list, only show the frame - content will be draw by callback function */
  1155.     show_dynamic_list();
  1156.     list_height = MMI_fixed_list_menu.height;
  1157.     is_done = FALSE;
  1158.     total_height = 0;
  1159.     counter = 0;
  1160.     MMI_fixed_list_menu.item_measure_function(
  1161.                             MMI_fixed_list_menu.items[0],
  1162.                             MMI_fixed_list_menu.common_item_data,
  1163.                             &item_width,
  1164.                             &item_height);
  1165.     item_height = MMI_thick_menuitem_height;
  1166.     for (i = MMI_fixed_list_menu.first_displayed_item; (i < MMI_fixed_list_menu.n_items && !is_done); i++)
  1167.     {
  1168.         if (i == MMI_fixed_list_menu.highlighted_item)
  1169.         {
  1170.         #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  1171.             g_mmi_frm_cntx.dump_screen_info.hightlight_type = MMI_SCREEN_HIGHLIGHT_FOR_CAR213_DYNAMIC_LIST;
  1172.         #endif
  1173.             is_hilighted = TRUE;
  1174.         }
  1175.         else
  1176.         {
  1177.             is_hilighted = FALSE;
  1178.         }
  1179.         if (i == MMI_fixed_list_menu.highlighted_item)
  1180.         {
  1181.             current_fixed_list_menuitem_display_index = -1;
  1182.         }
  1183.         else
  1184.         {
  1185.             current_fixed_list_menuitem_display_index = i;
  1186.         }
  1187.         offset_y = total_height;
  1188.         total_height += item_height;
  1189.         if (total_height > list_height + 1)
  1190.         {
  1191.             is_done = TRUE;
  1192.             if (counter == 0)
  1193.             {
  1194.                 if (cat213_draw_menuitem_callback != NULL)
  1195.                 {
  1196.                     if (r2lMMIFlag)
  1197.                     {
  1198.                         cat213_draw_menuitem_callback(
  1199.                             i,
  1200.                             is_hilighted,
  1201.                             MMI_fixed_list_menu.x + MMI_fixed_list_menu.vbar.width + 1,
  1202.                             MMI_fixed_list_menu.y + offset_y + MMI_fixed_list_menu.top,
  1203.                             MMI_fixed_list_menu.x + MMI_fixed_list_menu.vbar.width + item_width + 1,
  1204.                             MMI_fixed_list_menu.y + offset_y + item_height + MMI_fixed_list_menu.top);
  1205.                     }
  1206.                     else
  1207.                     {
  1208.                         cat213_draw_menuitem_callback(
  1209.                             i,
  1210.                             is_hilighted,
  1211.                             MMI_fixed_list_menu.x + 1,
  1212.                             MMI_fixed_list_menu.y + offset_y + MMI_fixed_list_menu.top,
  1213.                             MMI_fixed_list_menu.x + item_width + 1,
  1214.                             MMI_fixed_list_menu.y + offset_y + item_height + MMI_fixed_list_menu.top);
  1215.                     }
  1216.                 }
  1217.             }
  1218.         }
  1219.         else
  1220.         {
  1221.             if (cat213_draw_menuitem_callback != NULL)
  1222.             {
  1223.                 if (r2lMMIFlag)
  1224.                 {
  1225.                     cat213_draw_menuitem_callback(
  1226.                         i,
  1227.                         is_hilighted,
  1228.                         MMI_fixed_list_menu.x + MMI_fixed_list_menu.vbar.width + 1,
  1229.                         MMI_fixed_list_menu.y + offset_y + MMI_fixed_list_menu.top,
  1230.                         MMI_fixed_list_menu.x + MMI_fixed_list_menu.vbar.width + item_width + 1,
  1231.                         MMI_fixed_list_menu.y + offset_y + item_height + MMI_fixed_list_menu.top);
  1232.                 }
  1233.                 else
  1234.                 {
  1235.                     cat213_draw_menuitem_callback(
  1236.                         i,
  1237.                         is_hilighted,
  1238.                         MMI_fixed_list_menu.x + 1,
  1239.                         MMI_fixed_list_menu.y + offset_y + MMI_fixed_list_menu.top,
  1240.                         MMI_fixed_list_menu.x + item_width + 1,
  1241.                         MMI_fixed_list_menu.y + offset_y + item_height + MMI_fixed_list_menu.top);
  1242.                 }
  1243.             }
  1244.             counter++;
  1245.         }
  1246.     }
  1247.     gui_unlock_double_buffer();
  1248.     gui_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - 1);
  1249. }
  1250. /*****************************************************************************
  1251.  * FUNCTION
  1252.  *  Cat213KeyUpHdlr
  1253.  * DESCRIPTION
  1254.  *  Category 213 key up handler
  1255.  * PARAMETERS
  1256.  *  void
  1257.  * RETURNS
  1258.  *  void
  1259.  *****************************************************************************/
  1260. static void Cat213KeyUpHdlr(void)
  1261. {
  1262.     /*----------------------------------------------------------------*/
  1263.     /* Local Variables                                                */
  1264.     /*----------------------------------------------------------------*/
  1265.     S32 hilight_idx = MMI_fixed_list_menu.highlighted_item;
  1266.     /*----------------------------------------------------------------*/
  1267.     /* Code Body                                                      */
  1268.     /*----------------------------------------------------------------*/
  1269.     if (MMI_fixed_list_menu.n_items <= 0)
  1270.     {
  1271.         return;
  1272.     }
  1273.     if ((MMI_fixed_list_menu.n_items == 1) && (MMI_fixed_list_menu.highlighted_item == 0))
  1274.     {
  1275.         return;
  1276.     }
  1277.     if (hilight_idx - 1 >= 0)
  1278.     {
  1279.         hilight_idx--;
  1280.     }
  1281.     else
  1282.     {
  1283.         hilight_idx = MMI_fixed_list_menu.n_items - 1;
  1284.     }
  1285.     gui_lock_double_buffer();
  1286.     /* goto prev item */
  1287.     gui_dynamic_list_menu_goto_item(&MMI_fixed_list_menu, hilight_idx);
  1288.     /* redraw dynamic list */
  1289.     Cat213RedrawDynamicList();
  1290.     gui_unlock_double_buffer();
  1291.     gui_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - 1);
  1292. }
  1293. /*****************************************************************************
  1294.  * FUNCTION
  1295.  *  Cat213KeyDownHdlr
  1296.  * DESCRIPTION
  1297.  *  Category 213 key down handler
  1298.  * PARAMETERS
  1299.  *  void
  1300.  * RETURNS
  1301.  *  void
  1302.  *****************************************************************************/
  1303. static void Cat213KeyDownHdlr(void)
  1304. {
  1305.     /*----------------------------------------------------------------*/
  1306.     /* Local Variables                                                */
  1307.     /*----------------------------------------------------------------*/
  1308.     S32 hilight_idx = MMI_fixed_list_menu.highlighted_item;
  1309.     /*----------------------------------------------------------------*/
  1310.     /* Code Body                                                      */
  1311.     /*----------------------------------------------------------------*/
  1312.     if (MMI_fixed_list_menu.n_items <= 0)
  1313.     {
  1314.         return;
  1315.     }
  1316.     if ((MMI_fixed_list_menu.n_items == 1) && (MMI_fixed_list_menu.highlighted_item == 0))
  1317.     {
  1318.         return;
  1319.     }
  1320.     if (hilight_idx + 1 < MMI_fixed_list_menu.n_items)
  1321.     {
  1322.         hilight_idx++;
  1323.     }
  1324.     else
  1325.     {
  1326.         hilight_idx = 0;
  1327.     }
  1328.     gui_lock_double_buffer();
  1329.     /* goto next item */
  1330.     gui_dynamic_list_menu_goto_item(&MMI_fixed_list_menu, hilight_idx);
  1331.     /* redraw dynamic list */
  1332.     Cat213RedrawDynamicList();
  1333.     gui_unlock_double_buffer();
  1334.     gui_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - 1);
  1335. }
  1336. /*****************************************************************************
  1337.  * FUNCTION
  1338.  *  Cat213ShortCutHdlr
  1339.  * DESCRIPTION
  1340.  *  Category 213 shot cut key press handler
  1341.  * PARAMETERS
  1342.  *  item_index      [IN]        Item index
  1343.  * RETURNS
  1344.  *  void
  1345.  *****************************************************************************/
  1346. static void Cat213ShortCutHdlr(S32 item_index)
  1347. {
  1348.     /*----------------------------------------------------------------*/
  1349.     /* Local Variables                                                */
  1350.     /*----------------------------------------------------------------*/
  1351.     /*----------------------------------------------------------------*/
  1352.     /* Code Body                                                      */
  1353.     /*----------------------------------------------------------------*/
  1354.     if (MMI_fixed_list_menu.n_items <= 0)
  1355.     {
  1356.         return;
  1357.     }
  1358.     if (item_index == MMI_fixed_list_menu.highlighted_item)
  1359.     {
  1360.         return;
  1361.     }
  1362.     gui_dynamic_list_menu_goto_item(&MMI_fixed_list_menu, item_index);
  1363.     RedrawCategoryFunction();
  1364. }
  1365. /*****************************************************************************
  1366. * [Category214]
  1367. *
  1368. * This category is for File Manager to display drive info.
  1369. *
  1370. *  *********************
  1371. *  *                  ----------- Title
  1372. *  *********************
  1373. *  *  ******* *******  *
  1374. *  *  *     * *     *  *
  1375. *  *  *     * *     ----------- Matrix Images
  1376. *  *  ******* *******  *
  1377. *  *  ******* *******  *
  1378. *  *  *     * *     *  *
  1379. *  *  *     * *     *  *
  1380. *  *  ******* *******  *
  1381. *  *********************
  1382. *
  1383. *****************************************************************************/
  1384. /*****************************************************************************
  1385.  * FUNCTION
  1386.  *  ShowCategory214Screen
  1387.  * DESCRIPTION
  1388.  *  Show sategory 214 screen.
  1389.  * PARAMETERS
  1390.  *  title                   [IN]        Title string id
  1391.  *  title_icon              [IN]        Title image id
  1392.  *  left_softkey            [IN]        Lsk string id
  1393.  *  left_softkey_icon       [IN]        Lsk image id
  1394.  *  right_softkey           [IN]        Rsk string id
  1395.  *  right_softkey_icon      [IN]        Rsk image id
  1396.  *  num_of_items            [IN]        How many items
  1397.  *  draw_image_callback     [IN]        Callback function to draw image
  1398.  *  hide_image_callback     [IN]        Callback function to hide
  1399.  *  num_per_row             [IN]        Num of image pre row
  1400.  *  num_per_col             [IN]        Num of image pre col
  1401.  *  highlighted_item        [IN]        Highlighted item
  1402.  *  history_buffer          [IN]        History buffer
  1403.  * RETURNS
  1404.  *  void
  1405.  *****************************************************************************/
  1406. void ShowCategory214Screen(
  1407.         U16 title,
  1408.         U16 title_icon,
  1409.         U16 left_softkey,
  1410.         U16 left_softkey_icon,
  1411.         U16 right_softkey,
  1412.         U16 right_softkey_icon,
  1413.         U16 num_of_items,
  1414.         Cat214DrawImageFuncPtr draw_image_callback,
  1415.         Cat214HideImageFuncPtr hide_image_callback,
  1416.         U8 num_per_row,
  1417.         U8 num_per_col,
  1418.         S32 highlighted_item,
  1419.         U8 *history_buffer)
  1420. {
  1421.     /*----------------------------------------------------------------*/
  1422.     /* Local Variables                                                */
  1423.     /*----------------------------------------------------------------*/
  1424.     dm_data_struct dm_data;
  1425. #ifndef __MMI_WALLPAPER_ON_BOTTOM__
  1426.     GDI_HANDLE cat214_bg_layer;
  1427. #endif 
  1428.     S32 num_of_page;
  1429.     S32 item_per_page;
  1430.     /*----------------------------------------------------------------*/
  1431.     /* Code Body                                                      */
  1432.     /*----------------------------------------------------------------*/
  1433.     /* arg checking */
  1434.     MMI_ASSERT(num_per_row != 0);
  1435.     MMI_ASSERT(num_per_col != 0);
  1436.     cat214_draw_image_callback = draw_image_callback;
  1437.     cat214_hide_image_callback = hide_image_callback;
  1438.     cat214_num_per_row = num_per_row;
  1439.     cat214_num_per_col = num_per_col;
  1440.     cat214_hilighted_index = (U16) highlighted_item;
  1441.     cat214_prev_hilighted_index = (U16) highlighted_item;
  1442.     cat214_item_count = num_of_items;
  1443.     cat214_page_index = -1; /* this will force to redraw whole matrix */
  1444.     MMI_menu_shortcut_number = -1;
  1445.     /* init highligthed item idx */
  1446.     MMI_fixed_list_menu.highlighted_item = 0;
  1447.     item_per_page = num_per_row * num_per_col;
  1448.     num_of_page = num_of_items / (item_per_page);
  1449.     if (num_of_items % item_per_page != 0)
  1450.     {
  1451.         num_of_page++;
  1452.     }
  1453.     /* use MMI_fixed_list_menu's history */
  1454.     if (set_list_menu_category_history(MMI_CATEGORY214_ID, history_buffer))
  1455.     {
  1456.         cat214_hilighted_index = (U16) MMI_fixed_list_menu.highlighted_item;
  1457.     }
  1458.     /* create layer */
  1459.     gdi_layer_multi_layer_enable();
  1460.     gdi_layer_lock_frame_buffer();
  1461.     if (num_of_items != 0)
  1462.     {
  1463.         /* use fixed list menu's scroll bar to save memory */
  1464.         if (r2lMMIFlag)
  1465.         {
  1466.             gui_create_vertical_scrollbar(
  1467.                 &MMI_fixed_list_menu.vbar,
  1468.                 0,
  1469.                 (MMI_title_y + MMI_title_height),
  1470.                 current_MMI_theme->scrollbar_size,
  1471.                 MMI_content_height);
  1472.         }
  1473.         else
  1474.         {
  1475.             gui_create_vertical_scrollbar(
  1476.                 &MMI_fixed_list_menu.vbar,
  1477.                 UI_device_width - current_MMI_theme->scrollbar_size,
  1478.                 (MMI_title_y + MMI_title_height),
  1479.                 current_MMI_theme->scrollbar_size,
  1480.                 MMI_content_height);
  1481.         }
  1482.         gui_set_vertical_scrollbar_range(&MMI_fixed_list_menu.vbar, num_of_page);
  1483.         gui_set_vertical_scrollbar_scale(&MMI_fixed_list_menu.vbar, 1);
  1484.         gui_set_vertical_scrollbar_value(&MMI_fixed_list_menu.vbar, highlighted_item / item_per_page);
  1485.         gui_show_vertical_scrollbar(&MMI_fixed_list_menu.vbar);
  1486.     }
  1487.     gdi_layer_get_base_handle(&wgui_base_layer);
  1488.     gdi_layer_set_source_key(TRUE, GDI_COLOR_TRANSPARENT);
  1489.     gdi_layer_set_opacity(TRUE, UI_SUBMENU_OPACITY_BASED_LAYER);
  1490. #if !(defined(__MMI_WALLPAPER_ON_BOTTOM__))
  1491.     /* dm will draw a wallpaper bg on extra layer */
  1492.     dm_create_layer(0, 0, UI_device_width, UI_device_height, &cat214_bg_layer, DM_LAYER_BOTTOM);
  1493.     gdi_layer_push_and_set_active(cat214_bg_layer);
  1494.     gdi_layer_set_source_key(TRUE, GDI_COLOR_TRANSPARENT);
  1495.     gdi_layer_clear(GDI_COLOR_TRANSPARENT);
  1496.     gdi_layer_reset_clip();
  1497.     /* draw fix list backgroud */
  1498.     gui_draw_filled_area(
  1499.         0,
  1500.         MMI_content_y,
  1501.         UI_device_width - 1,
  1502.         MMI_content_y + MMI_content_height - 1,
  1503.         current_MMI_theme->list_background_filler);
  1504.     gdi_layer_pop_and_restore_active();
  1505. #endif /* !(defined(__MMI_WALLPAPER_ON_BOTTOM__)) */ 
  1506.     /* shortcut */
  1507.     register_menu_shortcut_keys();
  1508.     register_menu_shortcut_selected_only(Cat214ShortCutHdlr);
  1509.     resize_menu_shortcut_handler(set_menu_item_count(num_of_items) + 7, MMI_title_height);
  1510.     move_menu_shortcut_handler(UI_device_width - MMI_menu_shortcut_box.width, MMI_title_y);
  1511.     register_hide_menu_shortcut(draw_title);
  1512.     if (cat214_item_count != 0)
  1513.     {
  1514.         MMI_menu_shortcut_number = cat214_hilighted_index + 1;
  1515.     }
  1516.     MMI_disable_title_shortcut_display = FALSE;
  1517.     change_left_softkey(left_softkey, left_softkey_icon);
  1518.     change_right_softkey(right_softkey, right_softkey_icon);
  1519.     SetupCategoryKeyHandlers();
  1520.     SetKeyHandler(Cat214KeyUpHdlr, KEY_UP_ARROW, KEY_EVENT_DOWN);
  1521.     SetKeyHandler(Cat214KeyDownHdlr, KEY_DOWN_ARROW, KEY_EVENT_DOWN);
  1522.     SetKeyHandler(Cat214KeyUpHdlr, KEY_VOL_UP, KEY_EVENT_DOWN);
  1523.     SetKeyHandler(Cat214KeyDownHdlr, KEY_VOL_DOWN, KEY_EVENT_DOWN);
  1524.     SetKeyHandler(Cat214KeyLeftHdlr, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1525.     SetKeyHandler(Cat214KeyRightHdlr, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1526.     /* init title */
  1527.     MMI_title_string = (UI_string_type) get_string(title);
  1528.     MMI_title_icon = (PU8) get_image(title_icon);
  1529.     /* call highlight handler */
  1530.     if ((MMI_list_highlight_handler != NULL) && (num_of_items != 0))
  1531.     {
  1532.         MMI_list_highlight_handler(cat214_hilighted_index);
  1533.     }
  1534.     gdi_layer_unlock_frame_buffer();
  1535.     ExitCategoryFunction = ExitCategory214Screen;
  1536.     dm_setup_category_functions(dm_redraw_category_screen, dm_get_category_history, dm_get_category_history_size);
  1537. #ifdef __MMI_TOUCH_SCREEN__
  1538.     wgui_register_category_screen_control_area_pen_handlers(Cat214CategoryControlAreaPenDownHdlr, MMI_PEN_EVENT_DOWN);
  1539.     wgui_register_category_screen_control_area_pen_handlers(Cat214CategoryControlAreaPenMoveHdlr, MMI_PEN_EVENT_MOVE);
  1540.     wgui_register_category_screen_control_area_pen_handlers(Cat214CategoryControlAreaPenUpHdlr, MMI_PEN_EVENT_UP);
  1541. #endif /* __MMI_TOUCH_SCREEN__ */ 
  1542.     dm_data.s32ScrId = (S32) GetActiveScreenId();
  1543.     dm_data.s32CatId = MMI_CATEGORY214_ID;
  1544.     dm_data.s32flags = DM_CLEAR_SCREEN_BACKGROUND;
  1545.     dm_setup_data(&dm_data);
  1546.     dm_register_category_controlled_callback(DrawCate214CategoryControlArea);
  1547.     dm_redraw_category_screen();
  1548. }
  1549. /*****************************************************************************
  1550.  * FUNCTION
  1551.  *  ExitCategory214Screen
  1552.  * DESCRIPTION
  1553.  *  Exit category 214
  1554.  * PARAMETERS
  1555.  *  void
  1556.  * RETURNS
  1557.  *  void
  1558.  *****************************************************************************/
  1559. static void ExitCategory214Screen(void)
  1560. {
  1561.     /*----------------------------------------------------------------*/
  1562.     /* Local Variables                                                */
  1563.     /*----------------------------------------------------------------*/
  1564.     /*----------------------------------------------------------------*/
  1565.     /* Code Body                                                      */
  1566.     /*----------------------------------------------------------------*/
  1567.     ClearHighlightHandler();
  1568.     reset_menu_shortcut_handler();
  1569.     reset_softkeys();
  1570.     /* hide image callback */
  1571.     if (cat214_hide_image_callback != NULL)
  1572.     {
  1573.         cat214_hide_image_callback(cat214_prev_hilighted_index);
  1574.     }
  1575.     /* flatten layer */
  1576.     gdi_layer_flatten_previous_to_base();
  1577.     gdi_layer_set_blt_layer(wgui_base_layer, 0, 0, 0);
  1578.     gdi_layer_multi_layer_disable();
  1579. }
  1580. /*****************************************************************************
  1581.  * FUNCTION
  1582.  *  Cat214RedrawMatrix
  1583.  * DESCRIPTION
  1584.  *  Redraw Category 214 Matrix
  1585.  * PARAMETERS
  1586.  *  void
  1587.  * RETURNS
  1588.  *  void
  1589.  *****************************************************************************/
  1590. static void Cat214RedrawMatrix(void)
  1591. {
  1592.     /*----------------------------------------------------------------*/
  1593.     /* Local Variables                                                */
  1594.     /*----------------------------------------------------------------*/
  1595.     S32 content_offset_x;
  1596.     S32 content_offset_y;
  1597.     S32 content_width;
  1598.     S32 content_height;
  1599.     S32 box_offset_x;
  1600.     S32 box_offset_y;
  1601.     S32 box_width;
  1602.     S32 box_height;
  1603.     S32 i, j;
  1604.     S32 index;
  1605.     S32 cur_page_index;
  1606.     BOOL is_redraw_all;
  1607.     BOOL is_hilighted;
  1608.     S32 item_per_page;
  1609.     color *color_ptr;
  1610.     gdi_color box_bg_color;
  1611.     gdi_color box_frame_color;
  1612.     gdi_color box_hilight_color;
  1613.     /*----------------------------------------------------------------*/
  1614.     /* Code Body                                                      */
  1615.     /*----------------------------------------------------------------*/
  1616.     gdi_layer_lock_frame_buffer();
  1617.     gdi_layer_push_clip();
  1618.     gdi_layer_set_clip(
  1619.         0,
  1620.         MMI_title_y + MMI_title_height + 1,
  1621.         UI_device_width - 1,
  1622.         (MMI_title_y + MMI_title_height) + MMI_content_height - 1);
  1623.     box_frame_color = gdi_act_color_from_rgb(255,150, 150, 150);
  1624.     box_hilight_color = gdi_act_color_from_rgb(255,255, 0, 0);
  1625.     /* prepare parameters */
  1626.     if (r2lMMIFlag)
  1627.     {
  1628.         content_offset_x = current_MMI_theme->scrollbar_size;
  1629.     }
  1630.     else
  1631.     {
  1632.         content_offset_x = 0;
  1633.     }
  1634.     content_width = UI_device_width - current_MMI_theme->scrollbar_size;
  1635.     content_offset_y = MMI_title_y + MMI_title_height;
  1636.     content_height = MMI_content_height;
  1637.     box_width = content_width - CAT214_OUTSIDE_SPACING * 2 - CAT214_INSIDE_SPACING * (cat214_num_per_col - 1);
  1638.     box_width /= cat214_num_per_col;
  1639.     box_height = content_height - CAT214_OUTSIDE_SPACING * 2 - CAT214_INSIDE_SPACING * (cat214_num_per_row - 1);
  1640.     box_height /= cat214_num_per_row;
  1641.     item_per_page = cat214_num_per_row * cat214_num_per_col;
  1642.     cur_page_index = (cat214_hilighted_index / item_per_page) * item_per_page;
  1643.     /* page changed, redraw whole page */
  1644.     is_redraw_all = (cur_page_index != cat214_page_index) ? TRUE : FALSE;
  1645.     cat214_page_index = (U16) cur_page_index;
  1646.     /* clear whole content background */
  1647.     if (is_redraw_all)
  1648.     {
  1649.         if (r2lMMIFlag)
  1650.         {
  1651.             gdi_draw_solid_rect(
  1652.                 current_MMI_theme->scrollbar_size,
  1653.                 MMI_title_y + MMI_title_height,
  1654.                 UI_device_width - 1,
  1655.                 (MMI_title_y + MMI_title_height) + MMI_content_height - 1,
  1656.                 GDI_COLOR_TRANSPARENT);
  1657.         }
  1658.         else
  1659.         {
  1660.             gdi_draw_solid_rect(
  1661.                 0,
  1662.                 MMI_title_y + MMI_title_height,
  1663.                 UI_device_width - current_MMI_theme->scrollbar_size - 1,
  1664.                 (MMI_title_y + MMI_title_height) + MMI_content_height - 1,
  1665.                 GDI_COLOR_TRANSPARENT);
  1666.         }
  1667.         if (cat214_item_count != 0)
  1668.         {
  1669.             gui_set_vertical_scrollbar_value(&MMI_fixed_list_menu.vbar, cat214_hilighted_index / item_per_page);
  1670.             gui_show_vertical_scrollbar(&MMI_fixed_list_menu.vbar);
  1671.         }
  1672.     }
  1673.     /* empty category */
  1674.     if (cat214_item_count == 0)
  1675.     {
  1676.         gdi_layer_pop_clip();
  1677.         gdi_layer_unlock_frame_buffer();
  1678.         gdi_layer_blt_previous(0, 0, UI_device_width - 1, UI_device_height - 1);
  1679.         return;
  1680.     }
  1681.     /* draw each item */
  1682.     for (i = 0; i < cat214_num_per_row; i++)
  1683.     {
  1684.         for (j = 0; j < cat214_num_per_col; j++)
  1685.         {
  1686.             index = (cat214_page_index) + i * cat214_num_per_col + j;
  1687.             if (index < cat214_item_count)
  1688.             {
  1689.                 is_hilighted = (index == cat214_hilighted_index) ? TRUE : FALSE;
  1690.                 box_offset_x = box_width * j + CAT214_OUTSIDE_SPACING + CAT214_INSIDE_SPACING * j + content_offset_x;
  1691.                 box_offset_y = box_height * i + CAT214_OUTSIDE_SPACING + CAT214_INSIDE_SPACING * i + content_offset_y;
  1692.                 if (is_redraw_all || (index == cat214_hilighted_index) || (index == cat214_prev_hilighted_index))       /* draw all or changed */
  1693.                 {
  1694.                     /* clear item's background */
  1695.                     gdi_draw_solid_rect(
  1696.                         box_offset_x - 3,
  1697.                         box_offset_y - 3,
  1698.                         box_offset_x + box_width + 2,
  1699.                         box_offset_y + box_height + 2,
  1700.                         GDI_COLOR_TRANSPARENT);
  1701.                     if (is_hilighted)
  1702.                     {
  1703.                         color_ptr = &(current_MMI_theme->list_selected_item_filler->c);
  1704.                         box_bg_color = gdi_act_color_from_rgb(255,color_ptr->r, color_ptr->g, color_ptr->b);
  1705.                     }
  1706.                     else
  1707.                     {
  1708.                         color_ptr = &(current_MMI_theme->list_background_filler->c);
  1709.                         box_bg_color = gdi_act_color_from_rgb(255,color_ptr->r, color_ptr->g, color_ptr->b);
  1710.                     }
  1711.                     /* draw box */
  1712.                     gdi_draw_solid_rect(
  1713.                         box_offset_x,
  1714.                         box_offset_y,
  1715.                         box_offset_x + box_width - 1,
  1716.                         box_offset_y + box_height - 1,
  1717.                         box_bg_color);
  1718.                     if (index == cat214_hilighted_index)
  1719.                     {
  1720.                         /* highlight frame */
  1721.                         gdi_draw_rect(
  1722.                             box_offset_x - 1,
  1723.                             box_offset_y - 1,
  1724.                             box_offset_x + box_width,
  1725.                             box_offset_y + box_height,
  1726.                             box_hilight_color);
  1727.                     }
  1728.                     else
  1729.                     {
  1730.                         /* draw frame */
  1731.                         gdi_draw_rect(
  1732.                             box_offset_x - 1,
  1733.                             box_offset_y - 1,
  1734.                             box_offset_x + box_width,
  1735.                             box_offset_y + box_height,
  1736.                             box_frame_color);
  1737.                     }
  1738.                     /* call draw image callback function */
  1739.                     if (cat214_draw_image_callback != NULL)
  1740.                     {
  1741.                         cat214_draw_image_callback(
  1742.                             index,
  1743.                             cur_page_index,
  1744.                             cur_page_index + item_per_page - 1,
  1745.                             is_hilighted,
  1746.                             TRUE,           /* need update */
  1747.                             is_redraw_all,  /* new page */
  1748.                             box_offset_x,
  1749.                             box_offset_y,
  1750.                             box_offset_x + box_width - 1,
  1751.                             box_offset_y + box_height - 1);
  1752.                     }
  1753.                 }
  1754.                 else
  1755.                 {
  1756.                     if (index == cat214_hilighted_index)
  1757.                     {
  1758.                         /* highlight frame */
  1759.                         gdi_draw_rect(
  1760.                             box_offset_x - 1,
  1761.                             box_offset_y - 1,
  1762.                             box_offset_x + box_width,
  1763.                             box_offset_y + box_height,
  1764.                             box_hilight_color);
  1765.                     }
  1766.                     else
  1767.                     {
  1768.                         if (index == cat214_prev_hilighted_index)
  1769.                         {
  1770.                             /* clear highlight frame with transparent color */
  1771.                             gdi_draw_rect(
  1772.                                 box_offset_x - 1,
  1773.                                 box_offset_y - 1,
  1774.                                 box_offset_x + box_width,
  1775.                                 box_offset_y + box_height,
  1776.                                 box_frame_color);
  1777.                         }
  1778.                     }
  1779.                     /* call draw image callback function */
  1780.                     if (cat214_draw_image_callback != NULL)
  1781.                     {
  1782.                         cat214_draw_image_callback(
  1783.                             index,
  1784.                             cur_page_index,
  1785.                             cur_page_index + item_per_page - 1,
  1786.                             is_hilighted,
  1787.                             FALSE,  /* not need update */
  1788.                             FALSE,  /* not new page */
  1789.                             box_offset_x,
  1790.                             box_offset_y,
  1791.                             box_offset_x + box_width - 1,
  1792.                             box_offset_y + box_height - 1);
  1793.                     }
  1794.                 }
  1795.             }
  1796.         }
  1797.     }
  1798.     gdi_layer_pop_clip();
  1799.     gdi_layer_unlock_frame_buffer();
  1800.     gdi_layer_blt_previous(0, 0, UI_device_width - 1, UI_device_height - 1);
  1801. }
  1802. /*****************************************************************************
  1803.  * FUNCTION
  1804.  *  GetCategory214BoxSize
  1805.  * DESCRIPTION
  1806.  *  Get 214 box size
  1807.  * PARAMETERS
  1808.  *  num_per_row         [IN]        N     number per row
  1809.  *  num_per_col         [IN]        Number per column
  1810.  *  box_width_ptr       [OUT]       Box width ptr
  1811.  *  box_height_ptr      [OUT]       Box height ptr
  1812.  * RETURNS
  1813.  *  void
  1814.  *****************************************************************************/
  1815. void GetCategory214BoxSize(S32 num_per_row, S32 num_per_col, S32 *box_width_ptr, S32 *box_height_ptr)
  1816. {
  1817.     /*----------------------------------------------------------------*/
  1818.     /* Local Variables                                                */
  1819.     /*----------------------------------------------------------------*/
  1820.     /*----------------------------------------------------------------*/
  1821.     /* Code Body                                                      */
  1822.     /*----------------------------------------------------------------*/
  1823.     *box_width_ptr = MMI_content_height - CAT214_OUTSIDE_SPACING * 2 - CAT214_INSIDE_SPACING * (num_per_col - 1);
  1824.     *box_width_ptr /= num_per_col;
  1825.     *box_height_ptr = MMI_content_height - CAT214_OUTSIDE_SPACING * 2 - CAT214_INSIDE_SPACING * (num_per_row - 1);
  1826.     *box_height_ptr /= num_per_row;
  1827. }
  1828. /*****************************************************************************
  1829.  * FUNCTION
  1830.  *  Cat214KeyUpHdlr
  1831.  * DESCRIPTION
  1832.  *  Category 214 key up handler
  1833.  * PARAMETERS
  1834.  *  void
  1835.  * RETURNS
  1836.  *  void
  1837.  *****************************************************************************/
  1838. static void Cat214KeyUpHdlr(void)
  1839. {
  1840.     /*----------------------------------------------------------------*/
  1841.     /* Local Variables                                                */
  1842.     /*----------------------------------------------------------------*/
  1843.     S32 moved_index;
  1844.     /*----------------------------------------------------------------*/
  1845.     /* Code Body                                                      */
  1846.     /*----------------------------------------------------------------*/
  1847.     if (cat214_item_count == 0)
  1848.     {
  1849.         return;
  1850.     }
  1851.     cat214_prev_hilighted_index = cat214_hilighted_index;
  1852.     moved_index = cat214_hilighted_index - cat214_num_per_row;
  1853.     /* move to last if needed */
  1854.     if (moved_index < 0)
  1855.     {
  1856.         cat214_hilighted_index = cat214_item_count - 1;
  1857.     }
  1858.     else
  1859.     {
  1860.         cat214_hilighted_index = (U16) moved_index;
  1861.     }
  1862.     MMI_menu_shortcut_number = cat214_hilighted_index + 1;
  1863.     /* assign to fixed list menu - for history */
  1864.     MMI_fixed_list_menu.highlighted_item = cat214_hilighted_index;
  1865.     /* call hilight handler callback */
  1866.     if (MMI_list_highlight_handler != NULL)
  1867.     {
  1868.         MMI_list_highlight_handler(cat214_hilighted_index);
  1869.     }
  1870.     /* hide image callback */
  1871.     if (cat214_hide_image_callback != NULL)
  1872.     {
  1873.         cat214_hide_image_callback(cat214_prev_hilighted_index);
  1874.     }
  1875.     gdi_layer_lock_frame_buffer();
  1876.     draw_title();
  1877.     Cat214RedrawMatrix();
  1878.     gdi_layer_unlock_frame_buffer();
  1879.     gdi_layer_blt_previous(0, 0, UI_device_width - 1, UI_device_height - 1);
  1880. }
  1881. /*****************************************************************************
  1882.  * FUNCTION
  1883.  *  Cat214KeyDownHdlr
  1884.  * DESCRIPTION
  1885.  *  Category 214 key down handler
  1886.  * PARAMETERS
  1887.  *  void
  1888.  * RETURNS
  1889.  *  void
  1890.  *****************************************************************************/
  1891. static void Cat214KeyDownHdlr(void)
  1892. {
  1893.     /*----------------------------------------------------------------*/
  1894.     /* Local Variables                                                */
  1895.     /*----------------------------------------------------------------*/
  1896.     S32 moved_index;
  1897.     /*----------------------------------------------------------------*/
  1898.     /* Code Body                                                      */
  1899.     /*----------------------------------------------------------------*/
  1900.     if (cat214_item_count == 0)
  1901.     {
  1902.         return;
  1903.     }
  1904.     cat214_prev_hilighted_index = cat214_hilighted_index;
  1905.     moved_index = cat214_hilighted_index + cat214_num_per_row;
  1906.     
  1907.     /* move to first if needed */
  1908.     if (moved_index >= cat214_item_count)
  1909.     {
  1910.         cat214_hilighted_index = (cat214_prev_hilighted_index)%cat214_num_per_row;
  1911.     }
  1912.     else
  1913.     {
  1914.         cat214_hilighted_index = (U16) moved_index;
  1915.     }
  1916.     MMI_menu_shortcut_number = cat214_hilighted_index + 1;
  1917.     /* assign to fixed list menu - for history */
  1918.     MMI_fixed_list_menu.highlighted_item = cat214_hilighted_index;
  1919.     /* call hilight handler callback */
  1920.     if (MMI_list_highlight_handler != NULL)
  1921.     {
  1922.         MMI_list_highlight_handler(cat214_hilighted_index);
  1923.     }
  1924.     /* hide image callback */
  1925.     if (cat214_hide_image_callback != NULL)
  1926.     {
  1927.         cat214_hide_image_callback(cat214_prev_hilighted_index);
  1928.     }
  1929.     gdi_layer_lock_frame_buffer();
  1930.     draw_title();
  1931.     Cat214RedrawMatrix();
  1932.     gdi_layer_unlock_frame_buffer();
  1933.     gdi_layer_blt_previous(0, 0, UI_device_width - 1, UI_device_height - 1);
  1934. }
  1935. /*****************************************************************************
  1936.  * FUNCTION
  1937.  *  Cat214KeyLeftHdlr
  1938.  * DESCRIPTION
  1939.  *  Category 214 key left handler
  1940.  * PARAMETERS
  1941.  *  void
  1942.  * RETURNS
  1943.  *  void
  1944.  *****************************************************************************/
  1945. static void Cat214KeyLeftHdlr(void)
  1946. {
  1947.     /*----------------------------------------------------------------*/
  1948.     /* Local Variables                                                */
  1949.     /*----------------------------------------------------------------*/
  1950.     S32 moved_index;
  1951.     /*----------------------------------------------------------------*/
  1952.     /* Code Body                                                      */
  1953.     /*----------------------------------------------------------------*/
  1954.     if (cat214_item_count == 0)
  1955.     {
  1956.         return;
  1957.     }
  1958.     cat214_prev_hilighted_index = cat214_hilighted_index;
  1959.     moved_index = cat214_hilighted_index - 1;
  1960.     /* move to last if needed */
  1961.     if (moved_index < 0)
  1962.     {
  1963.         cat214_hilighted_index = cat214_item_count - 1;
  1964.     }
  1965.     else
  1966.     {
  1967.         cat214_hilighted_index = (U16) moved_index;
  1968.     }
  1969.     MMI_menu_shortcut_number = cat214_hilighted_index + 1;
  1970.     /* assign to fixed list menu - for history */
  1971.     MMI_fixed_list_menu.highlighted_item = cat214_hilighted_index;
  1972.     /* call hilight handler callback */
  1973.     if (MMI_list_highlight_handler != NULL)
  1974.     {
  1975.         MMI_list_highlight_handler(cat214_hilighted_index);
  1976.     }
  1977.     /* hide image callback */
  1978.     if (cat214_hide_image_callback != NULL)
  1979.     {
  1980.         cat214_hide_image_callback(cat214_prev_hilighted_index);
  1981.     }
  1982.     gdi_layer_lock_frame_buffer();
  1983.     draw_title();
  1984.     Cat214RedrawMatrix();
  1985.     gdi_layer_unlock_frame_buffer();
  1986.     gdi_layer_blt_previous(0, 0, UI_device_width - 1, UI_device_height - 1);
  1987. }
  1988. /*****************************************************************************
  1989.  * FUNCTION
  1990.  *  Cat214KeyRightHdlr
  1991.  * DESCRIPTION
  1992.  *  Category 214 key right handler
  1993.  * PARAMETERS
  1994.  *  void
  1995.  * RETURNS
  1996.  *  void
  1997.  *****************************************************************************/
  1998. static void Cat214KeyRightHdlr(void)
  1999. {
  2000.     /*----------------------------------------------------------------*/
  2001.     /* Local Variables                                                */
  2002.     /*----------------------------------------------------------------*/
  2003.     S32 moved_index;
  2004.     /*----------------------------------------------------------------*/
  2005.     /* Code Body                                                      */
  2006.     /*----------------------------------------------------------------*/
  2007.     if (cat214_item_count == 0)
  2008.     {
  2009.         return;
  2010.     }
  2011.     cat214_prev_hilighted_index = cat214_hilighted_index;
  2012.     moved_index = cat214_hilighted_index + 1;
  2013.     /* move to first if needed */
  2014.     if (moved_index >= cat214_item_count)
  2015.     {
  2016.         cat214_hilighted_index = 0;
  2017.     }
  2018.     else
  2019.     {
  2020.         cat214_hilighted_index = (U16) moved_index;
  2021.     }
  2022.     MMI_menu_shortcut_number = cat214_hilighted_index + 1;
  2023.     /* assign to fixed list menu - for history */
  2024.     MMI_fixed_list_menu.highlighted_item = cat214_hilighted_index;
  2025.     /* call hilight handler callback */
  2026.     if (MMI_list_highlight_handler != NULL)
  2027.     {
  2028.         MMI_list_highlight_handler(cat214_hilighted_index);
  2029.     }
  2030.     /* hide image callback */
  2031.     if (cat214_hide_image_callback != NULL)
  2032.     {
  2033.         cat214_hide_image_callback(cat214_prev_hilighted_index);
  2034.     }
  2035.     gdi_layer_lock_frame_buffer();
  2036.     draw_title();
  2037.     Cat214RedrawMatrix();
  2038.     gdi_layer_unlock_frame_buffer();
  2039.     gdi_layer_blt_previous(0, 0, UI_device_width - 1, UI_device_height - 1);
  2040. }
  2041. /*****************************************************************************
  2042.  * FUNCTION
  2043.  *  Cat214ShortCutHdlr
  2044.  * DESCRIPTION
  2045.  *  Category 214 shot cut key press handler
  2046.  * PARAMETERS
  2047.  *  item_index      [IN]        Item index
  2048.  * RETURNS
  2049.  *  void
  2050.  *****************************************************************************/
  2051. static void Cat214ShortCutHdlr(S32 item_index)
  2052. {
  2053.     /*----------------------------------------------------------------*/
  2054.     /* Local Variables                                                */
  2055.     /*----------------------------------------------------------------*/
  2056.     /*----------------------------------------------------------------*/
  2057.     /* Code Body                                                      */
  2058.     /*----------------------------------------------------------------*/
  2059.     if (cat214_item_count == 0)
  2060.     {
  2061.         return;
  2062.     }
  2063.     if (item_index < cat214_item_count)
  2064.     {
  2065.         cat214_prev_hilighted_index = cat214_hilighted_index;
  2066.         cat214_hilighted_index = (U16) item_index;
  2067.     }
  2068.     MMI_menu_shortcut_number = cat214_hilighted_index + 1;
  2069.     /* assign to fixed list menu - for history */
  2070.     MMI_fixed_list_menu.highlighted_item = cat214_hilighted_index;
  2071.     /* call hilight handler callback */
  2072.     if (MMI_list_highlight_handler != NULL)
  2073.     {
  2074.         MMI_list_highlight_handler(cat214_hilighted_index);
  2075.     }
  2076.     /* hide image callback */
  2077.     if (cat214_hide_image_callback != NULL)
  2078.     {
  2079.         cat214_hide_image_callback(cat214_prev_hilighted_index);
  2080.     }
  2081.     gdi_layer_lock_frame_buffer();
  2082.     draw_title();
  2083.     Cat214RedrawMatrix();
  2084.     gdi_layer_unlock_frame_buffer();
  2085.     gdi_layer_blt_previous(0, 0, UI_device_width - 1, UI_device_height - 1);
  2086. }
  2087. /*****************************************************************************
  2088.  * FUNCTION
  2089.  *  DrawCate214CategoryControlArea
  2090.  * DESCRIPTION
  2091.  *  Draw category 214 control area
  2092.  * PARAMETERS
  2093.  *  coordinate      [IN]        Cooridinate
  2094.  * RETURNS
  2095.  *  void
  2096.  *****************************************************************************/
  2097. static void DrawCate214CategoryControlArea(dm_coordinates *coordinate)
  2098. {
  2099.     /*----------------------------------------------------------------*/
  2100.     /* Local Variables                                                */
  2101.     /*----------------------------------------------------------------*/
  2102.     S32 offset_x;
  2103.     S32 offset_y;
  2104.     S32 str_width;
  2105.     S32 str_height;
  2106.     S8 *str_ptr;
  2107.     /*----------------------------------------------------------------*/
  2108.     /* Code Body                                                      */
  2109.     /*----------------------------------------------------------------*/
  2110.     /* clear background */
  2111.     if (r2lMMIFlag)
  2112.     {
  2113.         gdi_draw_solid_rect(
  2114.             current_MMI_theme->scrollbar_size,
  2115.             MMI_title_y + MMI_title_height,
  2116.             UI_device_width - 1,
  2117.             (MMI_title_y + MMI_title_height) + MMI_content_height - 1,
  2118.             GDI_COLOR_TRANSPARENT);
  2119.     }
  2120.     else
  2121.     {
  2122.         gdi_draw_solid_rect(
  2123.             0,
  2124.             MMI_title_y + MMI_title_height,
  2125.             UI_device_width - current_MMI_theme->scrollbar_size - 1,
  2126.             (MMI_title_y + MMI_title_height) + MMI_content_height - 1,
  2127.             GDI_COLOR_TRANSPARENT);
  2128.     }
  2129.     Cat214RedrawMatrix();
  2130.     /* if is emtpty folder, show a empty string */
  2131.     if (cat214_item_count == 0)
  2132.     {
  2133.         gui_reset_clip();
  2134.         gui_set_font(&MMI_medium_font);
  2135.         gui_set_text_color(gui_color(0, 0, 0));
  2136.         str_ptr = GetString(STR_ID_FMGR_EMPTY_FOLDER);
  2137.         gui_measure_string((UI_string_type) str_ptr, &str_width, &str_height);
  2138.         offset_x = (UI_device_width - str_width) >> 1;
  2139.         offset_y = (UI_device_height - str_height) >> 1;
  2140.         if (r2lMMIFlag)
  2141.         {
  2142.             gui_move_text_cursor(offset_x + str_width, offset_y);
  2143.         }
  2144.         else
  2145.         {
  2146.             gui_move_text_cursor(offset_x, offset_y);
  2147.         }
  2148.         gui_print_text((UI_string_type) str_ptr);
  2149.     }
  2150. }
  2151. /*****************************************************************************
  2152.  * FUNCTION
  2153.  *  Cat214CategoryControlAreaPenDownHdlr
  2154.  * DESCRIPTION
  2155.  *  Cat 214 pen down hdlr
  2156.  * PARAMETERS
  2157.  *  pos     [IN]        Position
  2158.  * RETURNS
  2159.  *  void
  2160.  *****************************************************************************/
  2161. #if defined(__MMI_TOUCH_SCREEN__)
  2162. static MMI_BOOL Cat214CategoryControlAreaPenDownHdlr(mmi_pen_point_struct pos)
  2163. {
  2164.     /*----------------------------------------------------------------*/
  2165.     /* Local Variables                                                */
  2166.     /*----------------------------------------------------------------*/
  2167.     S32 content_offset_x;
  2168.     S32 content_offset_y;
  2169.     S32 content_width;
  2170.     S32 content_height;
  2171.     S32 image_offset_x;
  2172.     S32 image_offset_y;
  2173.     S32 image_width;
  2174.     S32 image_height;
  2175.     S32 i, j;
  2176.     S32 index;
  2177.     S32 cur_page_index;
  2178.     BOOL is_redraw_all;
  2179.     S32 item_per_page;
  2180.     gui_scrollbar_pen_enum scrollbar_event;
  2181.     gui_pen_event_param_struct scrollbar_param;
  2182.     /*----------------------------------------------------------------*/
  2183.     /* Code Body                                                      */
  2184.     /*----------------------------------------------------------------*/
  2185.     /* prepare parameters */
  2186.     if (r2lMMIFlag)
  2187.     {
  2188.         content_offset_x = current_MMI_theme->scrollbar_size;
  2189.     }
  2190.     else
  2191.     {
  2192.         content_offset_x = 0;
  2193.     }
  2194.     item_per_page = cat214_num_per_row * cat214_num_per_col;
  2195.     cat214_pen_down_on_scroll = FALSE;
  2196.     /* Scroll bar */
  2197.     if (gui_vertical_scrollbar_translate_pen_event(
  2198.             &MMI_fixed_list_menu.vbar,
  2199.             MMI_PEN_EVENT_DOWN,
  2200.             pos.x,
  2201.             pos.y,
  2202.             &scrollbar_event,
  2203.             &scrollbar_param))
  2204.     {
  2205.         cat214_pen_down_on_scroll = TRUE;
  2206.         if (scrollbar_event == GUI_SCROLLBAR_PEN_JUMP_TO_I)
  2207.         {
  2208.             index = cat214_hilighted_index + ((scrollbar_param._u.i) * item_per_page - cat214_page_index);
  2209.             if (index >= cat214_item_count)
  2210.             {
  2211.                 index = cat214_item_count - 1;
  2212.             }
  2213.             Cat214ShortCutHdlr(index);
  2214.         }
  2215.         return MMI_TRUE;
  2216.     }
  2217.     /* image matrix */
  2218.     content_width = UI_device_width - current_MMI_theme->scrollbar_size;
  2219.     content_offset_y = MMI_title_y + MMI_title_height;
  2220.     content_height = MMI_content_height;
  2221.     image_width = content_width - CAT214_OUTSIDE_SPACING * 2 - CAT214_INSIDE_SPACING * (cat214_num_per_col - 1);
  2222.     image_width /= cat214_num_per_col;
  2223.     image_height = content_height - CAT214_OUTSIDE_SPACING * 2 - CAT214_INSIDE_SPACING * (cat214_num_per_row - 1);
  2224.     image_height /= cat214_num_per_row;
  2225.     item_per_page = cat214_num_per_row * cat214_num_per_col;
  2226.     cur_page_index = (cat214_hilighted_index / item_per_page) * item_per_page;
  2227.     /* page changed, redraw whole page */
  2228.     is_redraw_all = (cur_page_index != cat214_page_index) ? TRUE : FALSE;
  2229.     cat214_page_index = (U16) cur_page_index;
  2230.     for (i = 0; i < cat214_num_per_row; i++)
  2231.     {
  2232.         for (j = 0; j < cat214_num_per_col; j++)
  2233.         {
  2234.             index = (cat214_page_index) + i * cat214_num_per_col + j;
  2235.             if (index < cat214_item_count)  /* within valid index range */
  2236.             {
  2237.                 image_offset_x =
  2238.                     image_width * j + CAT214_OUTSIDE_SPACING + CAT214_INSIDE_SPACING * j + content_offset_x;
  2239.                 image_offset_y =
  2240.                     image_height * i + CAT214_OUTSIDE_SPACING + CAT214_INSIDE_SPACING * i + content_offset_y;
  2241.                 if (pos.x >= image_offset_x && pos.x < image_offset_x + image_width && pos.y >= image_offset_y &&
  2242.                     pos.y < image_offset_y + image_height)
  2243.                 {
  2244.                     Cat214ShortCutHdlr(index);
  2245.                     cat214_pen_down_index = index;
  2246.                     return MMI_TRUE;
  2247.                 }
  2248.             }
  2249.         }
  2250.     }
  2251.     cat214_pen_down_index = -1;
  2252.     return MMI_FALSE;
  2253. }
  2254. #endif /* defined(__MMI_TOUCH_SCREEN__) */ 
  2255. /*****************************************************************************
  2256.  * FUNCTION
  2257.  *  Cat214CategoryControlAreaPenMoveHdlr
  2258.  * DESCRIPTION
  2259.  *  Cat 214 pen move hdlr
  2260.  * PARAMETERS
  2261.  *  pos     [IN]        Position
  2262.  * RETURNS
  2263.  *  void
  2264.  *****************************************************************************/
  2265. #if defined(__MMI_TOUCH_SCREEN__)
  2266. static MMI_BOOL Cat214CategoryControlAreaPenMoveHdlr(mmi_pen_point_struct pos)
  2267. {
  2268.     /*----------------------------------------------------------------*/
  2269.     /* Local Variables                                                */
  2270.     /*----------------------------------------------------------------*/
  2271.     S32 content_offset_x;
  2272.     S32 content_offset_y;
  2273.     S32 content_width;
  2274.     S32 content_height;
  2275.     S32 image_offset_x;
  2276.     S32 image_offset_y;
  2277.     S32 image_width;
  2278.     S32 image_height;
  2279.     S32 i, j;
  2280.     S32 index;
  2281.     S32 cur_page_index;
  2282.     BOOL is_redraw_all;
  2283.     S32 item_per_page;
  2284.     gui_scrollbar_pen_enum scrollbar_event;
  2285.     gui_pen_event_param_struct scrollbar_param;
  2286.     /*----------------------------------------------------------------*/
  2287.     /* Code Body                                                      */
  2288.     /*----------------------------------------------------------------*/
  2289.     /* prepare parameters */
  2290.     if (r2lMMIFlag)
  2291.     {
  2292.         content_offset_x = current_MMI_theme->scrollbar_size;
  2293.     }
  2294.     else
  2295.     {
  2296.         content_offset_x = 0;
  2297.     }
  2298.     item_per_page = cat214_num_per_row * cat214_num_per_col;
  2299.     if (cat214_pen_down_on_scroll)
  2300.     {
  2301.         /* Scroll bar */
  2302.         if (gui_vertical_scrollbar_translate_pen_event(
  2303.                 &MMI_fixed_list_menu.vbar,
  2304.                 MMI_PEN_EVENT_MOVE,
  2305.                 pos.x,
  2306.                 pos.y,
  2307.                 &scrollbar_event,
  2308.                 &scrollbar_param))
  2309.         {
  2310.             if (scrollbar_event == GUI_SCROLLBAR_PEN_JUMP_TO_I)
  2311.             {
  2312.                 index = cat214_hilighted_index + ((scrollbar_param._u.i) * item_per_page - cat214_page_index);
  2313.                 if (index >= cat214_item_count)
  2314.                 {
  2315.                     index = cat214_item_count - 1;
  2316.                 }
  2317.                 Cat214ShortCutHdlr(index);
  2318.             }
  2319.         }
  2320.         return MMI_TRUE;
  2321.     }
  2322.     /* image matrix */
  2323.     content_width = UI_device_width - current_MMI_theme->scrollbar_size;
  2324.     content_offset_y = MMI_title_y + MMI_title_height;
  2325.     content_height = MMI_content_height;
  2326.     image_width = content_width - CAT214_OUTSIDE_SPACING * 2 - CAT214_INSIDE_SPACING * (cat214_num_per_col - 1);
  2327.     image_width /= cat214_num_per_col;
  2328.     image_height = content_height - CAT214_OUTSIDE_SPACING * 2 - CAT214_INSIDE_SPACING * (cat214_num_per_row - 1);
  2329.     image_height /= cat214_num_per_row;
  2330.     item_per_page = cat214_num_per_row * cat214_num_per_col;
  2331.     cur_page_index = (cat214_hilighted_index / item_per_page) * item_per_page;
  2332.     /* page changed, redraw whole page */
  2333.     is_redraw_all = (cur_page_index != cat214_page_index) ? TRUE : FALSE;
  2334.     cat214_page_index = (U16) cur_page_index;
  2335.     for (i = 0; i < cat214_num_per_row; i++)
  2336.     {
  2337.         for (j = 0; j < cat214_num_per_col; j++)
  2338.         {
  2339.             index = (cat214_page_index) + i * cat214_num_per_col + j;
  2340.             if (index < cat214_item_count)  /* within valid index range */
  2341.             {
  2342.                 image_offset_x =
  2343.                     image_width * j + CAT214_OUTSIDE_SPACING + CAT214_INSIDE_SPACING * j + content_offset_x;
  2344.                 image_offset_y =
  2345.                     image_height * i + CAT214_OUTSIDE_SPACING + CAT214_INSIDE_SPACING * i + content_offset_y;
  2346.                 if (pos.x >= image_offset_x && pos.x < image_offset_x + image_width && pos.y >= image_offset_y &&
  2347.                     pos.y < image_offset_y + image_height)
  2348.                 {
  2349.                     Cat214ShortCutHdlr(index);
  2350.                     return MMI_TRUE;
  2351.                 }
  2352.             }
  2353.         }
  2354.     }
  2355.     return MMI_FALSE;
  2356. }
  2357. #endif /* defined(__MMI_TOUCH_SCREEN__) */ 
  2358. /*****************************************************************************
  2359.  * FUNCTION
  2360.  *  Cat214CategoryControlAreaPenUpHdlr
  2361.  * DESCRIPTION
  2362.  *  Cat 214 pen down hdlr
  2363.  * PARAMETERS
  2364.  *  pos     [IN]        Position
  2365.  * RETURNS
  2366.  *  void
  2367.  *****************************************************************************/
  2368. #if defined(__MMI_TOUCH_SCREEN__)
  2369. static MMI_BOOL Cat214CategoryControlAreaPenUpHdlr(mmi_pen_point_struct pos)
  2370. {
  2371.     /*----------------------------------------------------------------*/
  2372.     /* Local Variables                                                */
  2373.     /*----------------------------------------------------------------*/
  2374.     S32 content_offset_x;
  2375.     S32 content_offset_y;
  2376.     S32 content_width;
  2377.     S32 content_height;
  2378.     S32 image_offset_x;
  2379.     S32 image_offset_y;
  2380.     S32 image_width;
  2381.     S32 image_height;
  2382.     S32 i, j;
  2383.     S32 index;
  2384.     S32 cur_page_index;
  2385.     S32 item_per_page;
  2386.     gui_scrollbar_pen_enum scrollbar_event;
  2387.     gui_pen_event_param_struct scrollbar_param;
  2388.     /*----------------------------------------------------------------*/
  2389.     /* Code Body                                                      */
  2390.     /*----------------------------------------------------------------*/
  2391.     /* prepare parameters */
  2392.     if (r2lMMIFlag)
  2393.     {
  2394.         content_offset_x = current_MMI_theme->scrollbar_size;
  2395.     }
  2396.     else
  2397.     {
  2398.         content_offset_x = 0;
  2399.     }
  2400.     item_per_page = cat214_num_per_row * cat214_num_per_col;
  2401.     if (cat214_pen_down_on_scroll)
  2402.     {
  2403.         if (gui_vertical_scrollbar_translate_pen_event(
  2404.                 &MMI_fixed_list_menu.vbar,
  2405.                 MMI_PEN_EVENT_UP,
  2406.                 pos.x,
  2407.                 pos.y,
  2408.                 &scrollbar_event,
  2409.                 &scrollbar_param))
  2410.         {
  2411.             cat214_pen_down_on_scroll = FALSE;
  2412.         }
  2413.         if (scrollbar_event == GUI_SCROLLBAR_PEN_JUMP_TO_I)
  2414.         {
  2415.             index = cat214_hilighted_index + ((scrollbar_param._u.i) * item_per_page - cat214_page_index);
  2416.             if (index >= cat214_item_count)
  2417.             {
  2418.                 index = cat214_item_count - 1;
  2419.             }
  2420.             Cat214ShortCutHdlr(index);
  2421.         }
  2422.         return MMI_TRUE;
  2423.     }
  2424.     /* image matrix */
  2425.     content_width = UI_device_width - current_MMI_theme->scrollbar_size;
  2426.     content_offset_y = MMI_title_y + MMI_title_height;
  2427.     content_height = MMI_content_height;
  2428.     image_width = content_width - CAT214_OUTSIDE_SPACING * 2 - CAT214_INSIDE_SPACING * (cat214_num_per_col - 1);
  2429.     image_width /= cat214_num_per_col;
  2430.     image_height = content_height - CAT214_OUTSIDE_SPACING * 2 - CAT214_INSIDE_SPACING * (cat214_num_per_row - 1);
  2431.     image_height /= cat214_num_per_row;
  2432.     item_per_page = cat214_num_per_row * cat214_num_per_col;
  2433.     cur_page_index = (cat214_hilighted_index / item_per_page) * item_per_page;
  2434.     cat214_page_index = (U16) cur_page_index;
  2435.     for (i = 0; i < cat214_num_per_row; i++)
  2436.     {
  2437.         for (j = 0; j < cat214_num_per_col; j++)
  2438.         {
  2439.             index = (cat214_page_index) + i * cat214_num_per_col + j;
  2440.             if (index < cat214_item_count)  /* within valid index range */
  2441.             {
  2442.                 image_offset_x =
  2443.                     image_width * j + CAT214_OUTSIDE_SPACING + CAT214_INSIDE_SPACING * j + content_offset_x;
  2444.                 image_offset_y =
  2445.                     image_height * i + CAT214_OUTSIDE_SPACING + CAT214_INSIDE_SPACING * i + content_offset_y;
  2446.                 if (pos.x >= image_offset_x && pos.x < image_offset_x + image_width && pos.y >= image_offset_y &&
  2447.                     pos.y < image_offset_y + image_height)
  2448.                 {
  2449.                     if (cat214_pen_down_index == index)
  2450.                     {
  2451.                         execute_softkey_function(KEY_EVENT_UP, MMI_LEFT_SOFTKEY);
  2452.                     }
  2453.                     cat214_pen_down_index = -1;
  2454.                     return MMI_TRUE;
  2455.                 }
  2456.             }
  2457.         }
  2458.     }
  2459.     return MMI_FALSE;
  2460. }
  2461. #endif /* defined(__MMI_TOUCH_SCREEN__) */