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

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.  *   gui_fixed_menus.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   Fixed-list menu - UI component
  48.  *
  49.  *   1. The number of menu items stays unchanged after the UI component is created.
  50.  *   2. The storage of all menu item data is preallocated.
  51.  *
  52.  * Author:
  53.  * -------
  54.  * -------
  55.  * -------
  56.  * -------
  57.  *
  58.  *============================================================================
  59.  *             HISTORY
  60.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  61.  *------------------------------------------------------------------------------
  62.  * removed!
  63.  *
  64.  * removed!
  65.  * removed!
  66.  * removed!
  67.  *
  68.  * removed!
  69.  * removed!
  70.  * removed!
  71.  *
  72.  * removed!
  73.  * removed!
  74.  * removed!
  75.  *
  76.  * removed!
  77.  * removed!
  78.  * removed!
  79.  *
  80.  * removed!
  81.  * removed!
  82.  * removed!
  83.  *
  84.  * removed!
  85.  * removed!
  86.  * removed!
  87.  *
  88.  * removed!
  89.  * removed!
  90.  * removed!
  91.  *
  92.  * removed!
  93.  * removed!
  94.  * removed!
  95.  *
  96.  * removed!
  97.  * removed!
  98.  * removed!
  99.  *
  100.  * removed!
  101.  * removed!
  102.  * removed!
  103.  *
  104.  * removed!
  105.  * removed!
  106.  * removed!
  107.  *
  108.  * removed!
  109.  * removed!
  110.  * removed!
  111.  *
  112.  * removed!
  113.  * removed!
  114.  * removed!
  115.  *
  116.  * removed!
  117.  * removed!
  118.  * removed!
  119.  *
  120.  * removed!
  121.  * removed!
  122.  * removed!
  123.  *
  124.  * removed!
  125.  * removed!
  126.  * removed!
  127.  *
  128.  * removed!
  129.  * removed!
  130.  * removed!
  131.  *
  132.  * removed!
  133.  * removed!
  134.  * removed!
  135.  *
  136.  * removed!
  137.  * removed!
  138.  * removed!
  139.  *
  140.  * removed!
  141.  * removed!
  142.  * removed!
  143.  *
  144.  * removed!
  145.  * removed!
  146.  * removed!
  147.  *
  148.  * removed!
  149.  * removed!
  150.  * removed!
  151.  *
  152.  * removed!
  153.  * removed!
  154.  * removed!
  155.  *
  156.  * removed!
  157.  * removed!
  158.  * removed!
  159.  *
  160.  * removed!
  161.  * removed!
  162.  * removed!
  163.  *
  164.  * removed!
  165.  * removed!
  166.  * removed!
  167.  *
  168.  * removed!
  169.  * removed!
  170.  * removed!
  171.  *
  172.  * removed!
  173.  * removed!
  174.  * removed!
  175.  *
  176.  * removed!
  177.  * removed!
  178.  * removed!
  179.  *
  180.  * removed!
  181.  * removed!
  182.  * removed!
  183.  *
  184.  * removed!
  185.  * removed!
  186.  * removed!
  187.  *
  188.  * removed!
  189.  * removed!
  190.  * removed!
  191.  *
  192.  * removed!
  193.  * removed!
  194.  * removed!
  195.  *
  196.  * removed!
  197.  * removed!
  198.  * removed!
  199.  *
  200.  * removed!
  201.  * removed!
  202.  * removed!
  203.  *
  204.  * removed!
  205.  * removed!
  206.  * removed!
  207.  *
  208.  * removed!
  209.  * removed!
  210.  * removed!
  211.  *
  212.  * removed!
  213.  * removed!
  214.  * removed!
  215.  *
  216.  * removed!
  217.  * removed!
  218.  * removed!
  219.  *
  220.  * removed!
  221.  * removed!
  222.  * removed!
  223.  *
  224.  * removed!
  225.  * removed!
  226.  * removed!
  227.  *
  228.  * removed!
  229.  * removed!
  230.  * removed!
  231.  *
  232.  * removed!
  233.  * removed!
  234.  * removed!
  235.  *
  236.  *------------------------------------------------------------------------------
  237.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  238.  *============================================================================
  239.  ****************************************************************************/
  240. /**
  241.  * Copyright Notice
  242.  * (c) 2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  243.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  244.  *  (It is illegal to remove this copyright notice from this software or any
  245.  *  portion of it)
  246.  */
  247. /**********************************************************************************
  248.    Filename:      gui_fixed_menus.c
  249.    Author:        manju
  250.    Date Created:  July-22-2002
  251.    Contains:      PixTel UI routines for Fixed Menus
  252. **********************************************************************************/
  253. #include "MMI_Features.h"
  254. #include "gui_config.h"
  255. #include "gui_fixed_menus.h"
  256. #include "CustMenuRes.h"
  257. #include "wgui_inline_edit.h"
  258. #include "gui_windows.h"
  259. #include "DebugInitDef.h"
  260. #include "gui_themes.h"
  261. #include "wgui_categories_util.h"
  262. #include "gui_setting.h"
  263. #include "kal_non_specific_general_types.h"
  264. #include "lcd_sw_rnd.h"
  265. #include "gdi_include.h"
  266. #include "wgui.h"
  267. extern gdi_handle wgui_layer_1;
  268. extern gdi_handle wgui_base_layer;
  269. extern PU8 get_image(MMI_ID_TYPE);
  270. #if defined(__MMI_MATRIX_MAIN_MENU_FULL_BACKGROUND__) && defined(__MMI_MATRIX_MAIN_MENU_OPTIMIZE__)
  271. #define OPTIMIZE_MM_BUF_SIZE (100*100*2)   //Old:7200   //KP Jerry modify on 2007-1-19
  272. U8 opt_mm_buf[OPTIMIZE_MM_BUF_SIZE];
  273. #endif /* defined(__MMI_MATRIX_MAIN_MENU_FULL_BACKGROUND__) && defined(__MMI_MATRIX_MAIN_MENU_OPTIMIZE__) */ 
  274. /* 
  275.  * Resident background filler cache of list menu shared among multiple screens 
  276.  */
  277. /* Enable resident filler cache if no hardware GIF and lcd size >= 176x220 */
  278. #if (!defined(GDI_USING_HW_GIF) && !defined(GDI_USING_HW_GIF_V2)) && defined(__MMI_UI_LIST_CACHE_BACKGROUND__) && (!defined(__MMI_MAINLCD_128X128__) && !defined(__MMI_MAINLCD_128X160__))
  279. #define __MMI_UI_LIST_RESIDENT_FILLER_CACHE__
  280. #endif 
  281. #ifdef __MMI_UI_LIST_RESIDENT_FILLER_CACHE__
  282. #define GUI_LIST_MENU_FILLER_CACHE_MAX_WIDTH    GDI_LCD_WIDTH
  283. /* Sometimes menu height is slightly larger than MMI_CONTENT_HEIGHT */
  284. #define GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT   (MMI_CONTENT_HEIGHT + 10)
  285. #if (GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT > GDI_LCD_HEIGHT)
  286. #undef GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT
  287. #define GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT   GDI_LCD_HEIGHT
  288. #endif /* (GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT > GDI_LCD_HEIGHT) */ 
  289. /* Size of cache pool in byte */
  290. #define GUI_LIST_MENU_FILLER_CACHE_SIZE   
  291.    ((GUI_LIST_MENU_FILLER_CACHE_MAX_WIDTH * GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT * GDI_MAINLCD_BIT_PER_PIXEL + 7) / 8)
  292. /* Cached filler */
  293. static UI_filled_area *g_gui_list_menu_filler_cache_target = NULL;
  294. /* Cache pool of background filler (4-byte aligned for potential optimization) */
  295. static U32 g_gui_list_menu_filler_cache[(GUI_LIST_MENU_FILLER_CACHE_SIZE + 3) / 4];
  296. #endif /* __MMI_UI_LIST_RESIDENT_FILLER_CACHE__ */ 
  297. S32 mmi_fixed_menu_bg_id = -1;
  298. /* for R2L characters */
  299. extern BOOL r2lMMIFlag;
  300. extern S32 menu_item_inline_multiline_box(void);
  301. extern int gdi_layer_get_bit_per_pixel(void);
  302. extern PU8 get_image(U16 i);
  303. /* GUI: fixed list menu functions               */
  304. UI_fixed_list_menu_theme *current_fixed_list_menu_theme = NULL;
  305. S32 current_fixed_list_menuitem_display_index = -1;
  306. /*****************************************************************************
  307.  * FUNCTION
  308.  *  UI_dummy_menuitem_displayed_function
  309.  * DESCRIPTION
  310.  *  
  311.  * PARAMETERS
  312.  *  index       [IN]        
  313.  *  x1          [IN]        
  314.  *  y1          [IN]        
  315.  *  x2          [IN]        
  316.  *  y2          [IN]        
  317.  * RETURNS
  318.  *  void
  319.  *****************************************************************************/
  320. void UI_dummy_menuitem_displayed_function(S32 index, S32 x1, S32 y1, S32 x2, S32 y2)
  321. {
  322.     /*----------------------------------------------------------------*/
  323.     /* Local Variables                                                */
  324.     /*----------------------------------------------------------------*/
  325.     /*----------------------------------------------------------------*/
  326.     /* Code Body                                                      */
  327.     /*----------------------------------------------------------------*/
  328.     UI_UNUSED_PARAMETER(index);
  329.     UI_UNUSED_PARAMETER(x1);
  330.     UI_UNUSED_PARAMETER(y1);
  331.     UI_UNUSED_PARAMETER(x2);
  332.     UI_UNUSED_PARAMETER(y2);
  333. }
  334. /*****************************************************************************
  335.  * FUNCTION
  336.  *  gui_set_fixed_list_menu_current_theme
  337.  * DESCRIPTION
  338.  *  Applies the current theme to a fixed list menu
  339.  * PARAMETERS
  340.  *  m       [IN]        Is the fixed list menu object
  341.  * RETURNS
  342.  *  void
  343.  *****************************************************************************/
  344. void gui_set_fixed_list_menu_current_theme(fixed_list_menu *m)
  345. {
  346.     /*----------------------------------------------------------------*/
  347.     /* Local Variables                                                */
  348.     /*----------------------------------------------------------------*/
  349.     /*----------------------------------------------------------------*/
  350.     /* Code Body                                                      */
  351.     /*----------------------------------------------------------------*/
  352.     m->flags |= current_fixed_list_menu_theme->flags;
  353.     m->focussed_filler = current_fixed_list_menu_theme->focussed_filler;
  354.     m->normal_filler = current_fixed_list_menu_theme->normal_filler;
  355.     gui_resize_vertical_scrollbar(&m->vbar, current_fixed_list_menu_theme->vbar_width, m->vbar.height);
  356.     gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - current_fixed_list_menu_theme->vbar_width, m->y);
  357. }
  358. /*****************************************************************************
  359.  * FUNCTION
  360.  *  gui_set_fixed_list_menu_theme
  361.  * DESCRIPTION
  362.  *  Applies the given theme to a fixed list menu
  363.  * PARAMETERS
  364.  *  m       [IN]        Is the fixed list menu object
  365.  *  t       [IN]        Is the theme
  366.  * RETURNS
  367.  *  void
  368.  *****************************************************************************/
  369. void gui_set_fixed_list_menu_theme(fixed_list_menu *m, UI_fixed_list_menu_theme *t)
  370. {
  371.     /*----------------------------------------------------------------*/
  372.     /* Local Variables                                                */
  373.     /*----------------------------------------------------------------*/
  374.     /*----------------------------------------------------------------*/
  375.     /* Code Body                                                      */
  376.     /*----------------------------------------------------------------*/
  377.     m->flags |= t->flags;
  378.     m->focussed_filler = t->focussed_filler;
  379.     m->normal_filler = t->normal_filler;
  380.     gui_resize_vertical_scrollbar(&m->vbar, t->vbar_width, m->vbar.height);
  381.     gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - current_fixed_list_menu_theme->vbar_width, m->y);
  382. }
  383. /*****************************************************************************
  384.  * FUNCTION
  385.  *  gui_create_fixed_list_menu
  386.  * DESCRIPTION
  387.  *  Creates a fixed list menu object
  388.  * PARAMETERS
  389.  *  m           [IN]        Is the fixed list menu object (pre-allocated)
  390.  *  x           [IN]        Is the left-top corner position
  391.  *  y           [IN]        Is the left-top corner position
  392.  *  width       [IN]        Are the dimensions
  393.  *  height      [IN]        Are the dimensions
  394.  * RETURNS
  395.  *  void
  396.  *****************************************************************************/
  397. void gui_create_fixed_list_menu(fixed_list_menu *m, S32 x, S32 y, S32 width, S32 height)
  398. {
  399.     /*----------------------------------------------------------------*/
  400.     /* Local Variables                                                */
  401.     /*----------------------------------------------------------------*/
  402.     /*----------------------------------------------------------------*/
  403.     /* Code Body                                                      */
  404.     /*----------------------------------------------------------------*/
  405.     m->flags = 0;
  406.     m->x = x;
  407.     m->y = y;
  408.     m->width = width;
  409.     m->height = height;
  410.     m->n_items = 0;
  411.     m->highlighted_item = 0;
  412.     m->first_displayed_item = 0;
  413.     m->last_displayed_item = 0;
  414.     m->displayed_items = 0;
  415.     m->spacing = 0;
  416.     m->top = 0;
  417.     gui_set_fixed_list_menu_current_theme(m);
  418.     gui_create_vertical_scrollbar(
  419.         &m->vbar,
  420.         m->x + m->width - current_fixed_list_menu_theme->vbar_width,
  421.         m->y,
  422.         current_fixed_list_menu_theme->vbar_width,
  423.         m->height);
  424.     m->item_highlighted = UI_dummy_function_s32;
  425.     m->item_unhighlighted = UI_dummy_function_s32;
  426.     m->item_display_function = UI_fixed_menuitem_dummy_display_function;
  427.     m->item_hide_function = UI_fixed_menuitem_dummy_display_function;
  428.     m->item_measure_function = UI_fixed_menuitem_dummy_measure_function;
  429.     m->item_highlight_function = UI_fixed_menuitem_dummy_highlight_function;
  430.     m->item_remove_highlight_function = UI_fixed_menuitem_dummy_remove_highlight_function;
  431.     m->item_resize_function = UI_fixed_menuitem_dummy_resize_function;
  432.     m->items = NULL;
  433.     m->common_item_data = NULL;
  434.     m->item_displayed_callback = UI_dummy_menuitem_displayed_function;
  435.     m->resized_before_locate = MMI_FALSE;
  436.     m->act_layer_handle = GDI_LAYER_MAIN_BASE_LAYER_HANDLE;
  437.     m->act_lcd_handle = GDI_LCD_MAIN_LCD_HANDLE;
  438. #ifdef __MMI_TOUCH_SCREEN__
  439.     m->pen_event_current_selected_callback_function = NULL;
  440.     m->pen_event_default_selected_callback_function = NULL;
  441.     m->pen_redraw_menu_function = NULL;
  442.     m->item_pen_function = UI_fixed_menuitem_dummy_pen_function;
  443.     m->disable_move_highlight = MMI_FALSE;
  444.     m->disable_up_select = MMI_FALSE;
  445.     m->pen_scroll_delay_time = 0;
  446.     m->pen_scroll_after_delay = -1;
  447.     memset(&(m->pen_state), 0, sizeof(gui_list_pen_state_struct));
  448. #endif /* __MMI_TOUCH_SCREEN__ */ 
  449. }
  450. /*****************************************************************************
  451.  * FUNCTION
  452.  *  gui_resize_fixed_list_menu
  453.  * DESCRIPTION
  454.  *  Changes the size of a fixed list menu
  455.  * PARAMETERS
  456.  *  m           [IN]        Is the fixed list menu object
  457.  *  width       [IN]        Is the new width
  458.  *  height      [IN]        Is the new height
  459.  * RETURNS
  460.  *  void
  461.  *****************************************************************************/
  462. void gui_resize_fixed_list_menu(fixed_list_menu *m, S32 width, S32 height)
  463. {
  464.     /*----------------------------------------------------------------*/
  465.     /* Local Variables                                                */
  466.     /*----------------------------------------------------------------*/
  467.     /*----------------------------------------------------------------*/
  468.     /* Code Body                                                      */
  469.     /*----------------------------------------------------------------*/
  470.     m->width = width;
  471.     m->height = height;
  472.     /* 
  473.      * Example: change highlight in inline editor, list menu is resized 
  474.      * according to virtual keyboard.
  475.      * We have to recompute m->first_displayed_item
  476.      */
  477.     m->resized_before_locate = MMI_TRUE;
  478.     gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - current_fixed_list_menu_theme->vbar_width, m->y);
  479.     gui_resize_vertical_scrollbar(&m->vbar, m->vbar.width, m->height);
  480. }
  481. /*****************************************************************************
  482.  * FUNCTION
  483.  *  gui_move_fixed_list_menu
  484.  * DESCRIPTION
  485.  *  Moves the fixed list menu to a different co-ordinate
  486.  * PARAMETERS
  487.  *  m       [IN]        Is the fixed list menu object
  488.  *  x       [IN]        Is the new left-top corner position
  489.  *  y       [IN]        Is the new left-top corner position
  490.  * RETURNS
  491.  *  void
  492.  *****************************************************************************/
  493. void gui_move_fixed_list_menu(fixed_list_menu *m, S32 x, S32 y)
  494. {
  495.     /*----------------------------------------------------------------*/
  496.     /* Local Variables                                                */
  497.     /*----------------------------------------------------------------*/
  498.     /*----------------------------------------------------------------*/
  499.     /* Code Body                                                      */
  500.     /*----------------------------------------------------------------*/
  501.     m->x = x;
  502.     m->y = y;
  503.     gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - current_fixed_list_menu_theme->vbar_width, m->y);
  504. }
  505. /*****************************************************************************
  506.  * FUNCTION
  507.  *  gui_fixed_list_menu_locate_highlighted_item
  508.  * DESCRIPTION
  509.  *  Used to locate the highlighted item in the fixed list menu
  510.  *  
  511.  *  This is an internal function
  512.  * PARAMETERS
  513.  *  m       [IN]        Is the fixed list menu object
  514.  * RETURNS
  515.  *  void
  516.  *****************************************************************************/
  517. void gui_fixed_list_menu_locate_highlighted_item(fixed_list_menu *m)
  518. {
  519.     /*----------------------------------------------------------------*/
  520.     /* Local Variables                                                */
  521.     /*----------------------------------------------------------------*/
  522.     S32 iwidth, iheight;
  523. #if 0
  524. /* under construction !*/
  525. /* under construction !*/
  526. /* under construction !*/
  527. /* under construction !*/
  528. #endif /* 0 */ 
  529.     /*----------------------------------------------------------------*/
  530.     /* Code Body                                                      */
  531.     /*----------------------------------------------------------------*/
  532.     if (m->flags & UI_LIST_MENU_FIRST_SHIFT_HIGHLIGHTED_ITEM)
  533.     {
  534.         S32 total_height = 0, i;
  535.         U8 done = 0;
  536.         S32 list_height = m->height;
  537.         m->flags &= ~UI_LIST_MENU_FIRST_SHIFT_HIGHLIGHTED_ITEM;
  538.         m->first_displayed_item = m->highlighted_item;
  539.         for (i = m->n_items - 1; (i >= 0) && (!done); i--)
  540.         {
  541.         #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  542.             if (i == m->highlighted_item)
  543.             {
  544.                 current_fixed_list_menuitem_display_index = -1;
  545.             }
  546.             else
  547.             {
  548.                 current_fixed_list_menuitem_display_index = i;
  549.             }
  550.         #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  551.             m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
  552.             total_height += iheight;
  553.             if (total_height > list_height + 1)
  554.             {
  555.                 if (m->first_displayed_item > i)
  556.                 {
  557.                     done = 1;
  558.                     m->first_displayed_item = i + 1;
  559.                     m->last_displayed_item = m->n_items - 1;
  560.                 }
  561.                 break;
  562.             }
  563.         }
  564.         if (total_height <= list_height)
  565.         {
  566.             m->first_displayed_item = 0;
  567.         }
  568.         total_height = 0;
  569.         for (i = m->first_displayed_item; (i < m->n_items) && (!done); i++)
  570.         {
  571.         #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  572.             if (i == m->highlighted_item)
  573.             {
  574.                 current_fixed_list_menuitem_display_index = -1;
  575.             }
  576.             else
  577.             {
  578.                 current_fixed_list_menuitem_display_index = i;
  579.             }
  580.         #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  581.             m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
  582.             total_height += iheight;
  583.             if (total_height > list_height + 1)
  584.             {
  585.                 done = 1;
  586.                 m->last_displayed_item = i - 1;
  587.             }
  588.         }
  589.     }
  590.     else if (m->flags & UI_LIST_MENU_LAST_SHIFT_HIGHLIGHTED_ITEM)
  591.     {
  592.         S32 total_height = 0, i;
  593.         U8 done = 0;
  594.         S32 list_height = m->height;
  595.         m->flags &= ~UI_LIST_MENU_LAST_SHIFT_HIGHLIGHTED_ITEM;
  596.         m->last_displayed_item = m->highlighted_item;
  597.         /* Check if in the first page */
  598.         for (i = 0; (i < m->n_items) && !done; i++)
  599.         {
  600.         #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  601.             if (i == m->highlighted_item)
  602.             {
  603.                 current_fixed_list_menuitem_display_index = -1;
  604.             }
  605.             else
  606.             {
  607.                 current_fixed_list_menuitem_display_index = i;
  608.             }
  609.         #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  610.             m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
  611.             total_height += iheight;
  612.             if (total_height > list_height + 1)
  613.             {
  614.                 if (m->last_displayed_item < i)
  615.                 {
  616.                     done = 1;
  617.                     m->first_displayed_item = 0;
  618.                     m->last_displayed_item = i - 1;
  619.                 }
  620.                 break;
  621.             }
  622.         }
  623.         /* Check if in the last page */
  624.         if (!done && total_height <= list_height)
  625.         {
  626.             done = 1;
  627.             m->first_displayed_item = 0;
  628.             m->last_displayed_item = m->n_items - 1;
  629.         }
  630.         /* Align to the bottom */
  631.         total_height = 0;
  632.         if (!done)
  633.         {
  634.             for (i = m->last_displayed_item; (i >= 0) && (!done); i--)
  635.             {
  636.             #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  637.                 if (i == m->highlighted_item)
  638.                 {
  639.                     current_fixed_list_menuitem_display_index = -1;
  640.                 }
  641.                 else
  642.                 {
  643.                     current_fixed_list_menuitem_display_index = i;
  644.                 }
  645.             #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  646.                 m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
  647.                 total_height += iheight;
  648.                 if (total_height > list_height + 1)
  649.                 {
  650.                     done = 1;
  651.                     m->first_displayed_item = i + 1;
  652.                 }
  653.             }
  654.             if (!done)
  655.             {
  656.                 m->first_displayed_item = 0;
  657.             }
  658.         }
  659.     }
  660.     else if (m->flags & UI_LIST_MENU_CENTER_HIGHLIGHTED)
  661.     {
  662.         m->first_displayed_item = m->highlighted_item - 1;
  663.         if (m->first_displayed_item < 0)
  664.         {
  665.             m->first_displayed_item = m->n_items - 1;
  666.         }
  667.         m->last_displayed_item = m->highlighted_item + 1;
  668.         if (m->last_displayed_item >= m->n_items)
  669.         {
  670.             m->last_displayed_item = 0;
  671.         }
  672.     }
  673.     else
  674.     {
  675.         if (m->highlighted_item < m->first_displayed_item)
  676.         {
  677.             m->first_displayed_item = m->highlighted_item;
  678.         }
  679.         else if (m->highlighted_item > m->last_displayed_item)
  680.         {
  681.             U8 done = 0;
  682.             S32 total_height = 0, i;
  683.             S32 list_height = m->height;
  684.             m->last_displayed_item = m->highlighted_item;
  685.             for (i = m->last_displayed_item; i >= 0 && (!done); i--)
  686.             {
  687.             #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  688.                 if (i == m->highlighted_item)
  689.                 {
  690.                     current_fixed_list_menuitem_display_index = -1;
  691.                 }
  692.                 else
  693.                 {
  694.                     current_fixed_list_menuitem_display_index = i;
  695.                 }
  696.             #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  697.                 m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
  698.                 total_height += iheight;
  699.                 if (total_height > list_height)
  700.                 {
  701.                     done = 1;
  702.                     m->first_displayed_item = i + 1;
  703.                 }
  704.             }
  705.         }
  706.         else
  707.         {
  708.             U8 done = 0;
  709.             S32 total_height = 0, i;
  710.             S32 list_height = m->height;
  711.             for (i = m->first_displayed_item; i < m->n_items && (!done); i++)
  712.             {
  713.             #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  714.                 if (i == m->highlighted_item)
  715.                 {
  716.                     current_fixed_list_menuitem_display_index = -1;
  717.                 }
  718.                 else
  719.                 {
  720.                     current_fixed_list_menuitem_display_index = i;
  721.                 }
  722.             #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  723.                 m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
  724.                 total_height += iheight;
  725.                 if (total_height > list_height)
  726.                 {
  727.                     done = 1;
  728.                     m->last_displayed_item = i - 1;
  729.                 }
  730.             }
  731.             if (!done)
  732.             {
  733.                 total_height = 0;
  734.                 for (i = m->n_items - 1; (i >= 0) && (!done); i--)
  735.                 {
  736.                 #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  737.                     if (i == m->highlighted_item)
  738.                     {
  739.                         current_fixed_list_menuitem_display_index = -1;
  740.                     }
  741.                     else
  742.                     {
  743.                         current_fixed_list_menuitem_display_index = i;
  744.                     }
  745.                 #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  746.                     m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
  747.                     total_height += iheight;
  748.                     if (total_height > list_height)
  749.                     {
  750.                         done = 1;
  751.                         m->first_displayed_item = i + 1;
  752.                         m->last_displayed_item = m->n_items - 1;
  753.                         break;
  754.                     }
  755.                 }
  756.                 if (!done)
  757.                 {
  758.                     m->first_displayed_item = 0;
  759.                     m->last_displayed_item = m->n_items - 1;
  760.                 }
  761.             }
  762.             if (m->highlighted_item > m->last_displayed_item)
  763.             {
  764.                 done = 0;
  765.                 total_height = 0;
  766.                 m->last_displayed_item = m->highlighted_item;
  767.                 for (i = m->last_displayed_item; i >= 0 && (!done); i--)
  768.                 {
  769.                 #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  770.                     if (i == m->highlighted_item)
  771.                     {
  772.                         current_fixed_list_menuitem_display_index = -1;
  773.                     }
  774.                     else
  775.                     {
  776.                         current_fixed_list_menuitem_display_index = i;
  777.                     }
  778.                 #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  779.                     m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
  780.                     total_height += iheight;
  781.                     if (total_height > list_height)
  782.                     {
  783.                         done = 1;
  784.                         m->first_displayed_item = i + 1;
  785.                     }
  786.                 }
  787.             }
  788.         }
  789.     }
  790.     /* Located after resized */
  791.     m->resized_before_locate = MMI_FALSE;
  792. }
  793. /*****************************************************************************
  794.  * FUNCTION
  795.  *  gui_fixed_list_menu_locate_previous_item
  796.  * DESCRIPTION
  797.  *  
  798.  * PARAMETERS
  799.  *  m       [?]     
  800.  * RETURNS
  801.  *  void
  802.  *****************************************************************************/
  803. void gui_fixed_list_menu_locate_previous_item(fixed_list_menu *m)
  804. {
  805.     /*----------------------------------------------------------------*/
  806.     /* Local Variables                                                */
  807.     /*----------------------------------------------------------------*/
  808.     /*----------------------------------------------------------------*/
  809.     /* Code Body                                                      */
  810.     /*----------------------------------------------------------------*/
  811.     if (m->flags & UI_LIST_MENU_CENTER_HIGHLIGHTED)
  812.     {
  813.         if (m->highlighted_item == 0)
  814.         {
  815.             m->first_displayed_item = m->n_items - 1;
  816.             m->last_displayed_item = 1;
  817.         }
  818.         else
  819.         {
  820.             m->first_displayed_item = m->highlighted_item - 1;
  821.             if (m->first_displayed_item < 0)
  822.             {
  823.                 m->first_displayed_item = m->n_items - 1;
  824.             }
  825.             m->last_displayed_item = m->highlighted_item + 1;
  826.             if (m->last_displayed_item > m->n_items - 1)
  827.             {
  828.                 m->last_displayed_item = 0;
  829.             }
  830.         }
  831.     }
  832.     else
  833.     {
  834.         if (m->highlighted_item < m->first_displayed_item)
  835.         {
  836.             m->first_displayed_item = m->highlighted_item;
  837.         }
  838.         else if (m->resized_before_locate)
  839.         {
  840.             gui_fixed_list_menu_locate_highlighted_item(m);
  841.         }
  842.     #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  843.         else if (m->highlighted_item == m->last_displayed_item - 1)
  844.         {
  845.             S32 iwidth, iheight;
  846.             U8 done = 0;
  847.             S32 total_height = 0, i;
  848.             S32 list_height = m->height;
  849.             current_fixed_list_menuitem_display_index = -1;
  850.             for (i = m->last_displayed_item; i >= 0 && (!done); i--)
  851.             {
  852.                 if (i == m->highlighted_item)
  853.                 {
  854.                     current_fixed_list_menuitem_display_index = -1;
  855.                 }
  856.                 else
  857.                 {
  858.                     current_fixed_list_menuitem_display_index = i;
  859.                 }
  860.                 m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
  861.                 total_height += iheight;
  862.                 if (total_height > list_height + 1)
  863.                 {
  864.                     done = 1;
  865.                     m->first_displayed_item = i + 1;
  866.                 }
  867.             }
  868.         }
  869.     #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  870.     }
  871.     /* Located after resized */
  872.     m->resized_before_locate = MMI_FALSE;
  873. }
  874. /*****************************************************************************
  875.  * FUNCTION
  876.  *  gui_fixed_list_menu_locate_next_item
  877.  * DESCRIPTION
  878.  *  
  879.  * PARAMETERS
  880.  *  m       [?]     
  881.  * RETURNS
  882.  *  void
  883.  *****************************************************************************/
  884. void gui_fixed_list_menu_locate_next_item(fixed_list_menu *m)
  885. {
  886.     /*----------------------------------------------------------------*/
  887.     /* Local Variables                                                */
  888.     /*----------------------------------------------------------------*/
  889.     S32 iwidth, iheight;
  890.     /*----------------------------------------------------------------*/
  891.     /* Code Body                                                      */
  892.     /*----------------------------------------------------------------*/
  893.     if (m->flags & UI_LIST_MENU_CENTER_HIGHLIGHTED)
  894.     {
  895.         m->first_displayed_item = m->highlighted_item - 1;
  896.         if (m->first_displayed_item < 0)
  897.         {
  898.             m->first_displayed_item = m->n_items - 1;
  899.         }
  900.         m->last_displayed_item = m->highlighted_item + 1;
  901.         if (m->last_displayed_item >= m->n_items)
  902.         {
  903.             m->last_displayed_item = 0;
  904.         }
  905.     }
  906.     else
  907.     {
  908.     #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  909.         if (m->highlighted_item >= m->last_displayed_item)
  910.     #else 
  911.         if (m->highlighted_item > m->last_displayed_item)
  912.     #endif 
  913.         {
  914.             U8 done = 0;
  915.             S32 total_height = 0, i;
  916.             S32 list_height = m->height;
  917.             m->last_displayed_item = m->highlighted_item;
  918.             for (i = m->last_displayed_item; i >= 0 && (!done); i--)
  919.             {
  920.             #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  921.                 if (i == m->highlighted_item)
  922.                 {
  923.                     current_fixed_list_menuitem_display_index = -1;
  924.                 }
  925.                 else
  926.                 {
  927.                     current_fixed_list_menuitem_display_index = i;
  928.                 }
  929.             #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  930.                 m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
  931.                 total_height += iheight;
  932.                 if (total_height > list_height + 1)
  933.                 {
  934.                     done = 1;
  935.                     m->first_displayed_item = i + 1;
  936.                 }
  937.             }
  938.         }
  939.         else if (m->resized_before_locate)
  940.         {
  941.             gui_fixed_list_menu_locate_highlighted_item(m);
  942.         }
  943.     }
  944.     /* Located after resized */
  945.     m->resized_before_locate = MMI_FALSE;
  946. }
  947. /*****************************************************************************
  948.  * FUNCTION
  949.  *  switch_fixed_list_highlighted_item
  950.  * DESCRIPTION
  951.  *  
  952.  * PARAMETERS
  953.  *  m                           [?]         
  954.  *  last_highlighted_item       [IN]        
  955.  * RETURNS
  956.  *  void
  957.  *****************************************************************************/
  958. static void switch_fixed_list_highlighted_item(fixed_list_menu *m, S32 last_highlighted_item)
  959. {
  960.     /*----------------------------------------------------------------*/
  961.     /* Local Variables                                                */
  962.     /*----------------------------------------------------------------*/
  963.     /*----------------------------------------------------------------*/
  964.     /* Code Body                                                      */
  965.     /*----------------------------------------------------------------*/
  966.     if (last_highlighted_item != m->highlighted_item)
  967.     {
  968.         if ((last_highlighted_item >= 0) && (last_highlighted_item < m->n_items))
  969.         {
  970.             m->item_remove_highlight_function(m->items[last_highlighted_item], m->common_item_data);
  971.         }
  972.         if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
  973.         {
  974.             m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
  975.         }
  976.         m->item_unhighlighted(last_highlighted_item);
  977.     #ifdef __MMI_TOUCH_SCREEN__
  978.         m->pen_event_current_selected_callback_function = m->pen_event_default_selected_callback_function;
  979.     #endif 
  980.         m->item_highlighted(m->highlighted_item);
  981.     }
  982. }
  983. /*****************************************************************************
  984.  * FUNCTION
  985.  *  gui_fixed_list_menu_goto_item
  986.  * DESCRIPTION
  987.  *  Highlights a particular item
  988.  *  
  989.  *  The fixed list is not redrawn
  990.  * PARAMETERS
  991.  *  m       [IN]        Is the fixed list menu object
  992.  *  i       [IN]        Is the index of the item to be highlighted (zero based)
  993.  * RETURNS
  994.  *  void
  995.  *****************************************************************************/
  996. void gui_fixed_list_menu_goto_item(fixed_list_menu *m, S32 i)
  997. {
  998.     /*----------------------------------------------------------------*/
  999.     /* Local Variables                                                */
  1000.     /*----------------------------------------------------------------*/
  1001.     S32 last_highlighted_item;
  1002.     /*----------------------------------------------------------------*/
  1003.     /* Code Body                                                      */
  1004.     /*----------------------------------------------------------------*/
  1005.     if ((i < 0) || (i > m->n_items - 1))
  1006.     {
  1007.         return;
  1008.     }
  1009.     if (i == m->highlighted_item)
  1010.     {
  1011.         return;
  1012.     }
  1013.     last_highlighted_item = m->highlighted_item;
  1014.     m->highlighted_item = i;
  1015.     gui_fixed_list_menu_locate_highlighted_item(m);
  1016.     switch_fixed_list_highlighted_item(m, last_highlighted_item);
  1017. }
  1018. /*****************************************************************************
  1019.  * FUNCTION
  1020.  *  gui_fixed_list_menu_goto_next_item
  1021.  * DESCRIPTION
  1022.  *  Higlights the next item
  1023.  *  
  1024.  *  The fixed list is not redrawn
  1025.  * PARAMETERS
  1026.  *  m       [IN]        Is the fixed list menu object
  1027.  * RETURNS
  1028.  *  void
  1029.  *****************************************************************************/
  1030. void gui_fixed_list_menu_goto_next_item(fixed_list_menu *m)
  1031. {
  1032.     /*----------------------------------------------------------------*/
  1033.     /* Local Variables                                                */
  1034.     /*----------------------------------------------------------------*/
  1035.     S32 last_highlighted_item;
  1036.     U8 loop_flag = 0;
  1037.     /*----------------------------------------------------------------*/
  1038.     /* Code Body                                                      */
  1039.     /*----------------------------------------------------------------*/
  1040.     if (m->highlighted_item >= (m->n_items - 1))
  1041.     {
  1042.         if (m->flags & UI_LIST_MENU_LOOP)
  1043.         {
  1044.             loop_flag = 1;
  1045.         }
  1046.         else
  1047.         {
  1048.             return;
  1049.         }
  1050.     }
  1051.     last_highlighted_item = m->highlighted_item;
  1052.     if (loop_flag)
  1053.     {
  1054.         m->highlighted_item = 0;
  1055.         gui_fixed_list_menu_locate_previous_item(m);
  1056.     }
  1057.     else
  1058.     {
  1059.         m->highlighted_item++;
  1060.         gui_fixed_list_menu_locate_next_item(m);
  1061.     }
  1062.     switch_fixed_list_highlighted_item(m, last_highlighted_item);
  1063. }
  1064. /*****************************************************************************
  1065.  * FUNCTION
  1066.  *  gui_fixed_list_menu_goto_previous_item
  1067.  * DESCRIPTION
  1068.  *  Higlights the previous item
  1069.  *  
  1070.  *  The fixed list is not redrawn
  1071.  * PARAMETERS
  1072.  *  m       [IN]        Is the fixed list menu object
  1073.  * RETURNS
  1074.  *  void
  1075.  *****************************************************************************/
  1076. void gui_fixed_list_menu_goto_previous_item(fixed_list_menu *m)
  1077. {
  1078.     /*----------------------------------------------------------------*/
  1079.     /* Local Variables                                                */
  1080.     /*----------------------------------------------------------------*/
  1081.     S32 last_highlighted_item;
  1082.     U8 loop_flag = 0;
  1083.     /*----------------------------------------------------------------*/
  1084.     /* Code Body                                                      */
  1085.     /*----------------------------------------------------------------*/
  1086.     if (m->highlighted_item <= 0)
  1087.     {
  1088.         if (m->flags & UI_LIST_MENU_LOOP)
  1089.         {
  1090.             loop_flag = 1;
  1091.         }
  1092.         else
  1093.         {
  1094.             return;
  1095.         }
  1096.     }
  1097.     last_highlighted_item = m->highlighted_item;
  1098.     if (loop_flag)
  1099.     {
  1100.         m->highlighted_item = m->n_items - 1;
  1101.         gui_fixed_list_menu_locate_next_item(m);
  1102.     }
  1103.     else
  1104.     {
  1105.         m->highlighted_item--;
  1106.         gui_fixed_list_menu_locate_previous_item(m);
  1107.     }
  1108.     switch_fixed_list_highlighted_item(m, last_highlighted_item);
  1109. }
  1110. /*****************************************************************************
  1111.  * FUNCTION
  1112.  *  gui_fixed_list_menu_goto_next_page
  1113.  * DESCRIPTION
  1114.  *  Higlights an item in the next page
  1115.  *  
  1116.  *  The fixed list is not redrawn
  1117.  * PARAMETERS
  1118.  *  m       [IN]        Is the fixed list menu object
  1119.  * RETURNS
  1120.  *  void
  1121.  *****************************************************************************/
  1122. void gui_fixed_list_menu_goto_next_page(fixed_list_menu *m)
  1123. {
  1124.     /*----------------------------------------------------------------*/
  1125.     /* Local Variables                                                */
  1126.     /*----------------------------------------------------------------*/
  1127.     S32 last_highlighted_item;
  1128.     S32 iwidth, iheight;
  1129.     U8 done = 0;
  1130.     S32 total_height = 0, i;
  1131.     S32 list_height = m->height - 4;
  1132.     /*----------------------------------------------------------------*/
  1133.     /* Code Body                                                      */
  1134.     /*----------------------------------------------------------------*/
  1135.     last_highlighted_item = m->highlighted_item;
  1136.     m->first_displayed_item += m->displayed_items;
  1137.     if (m->first_displayed_item > (m->n_items - 1))
  1138.     {
  1139.         m->first_displayed_item = (m->n_items - 1);
  1140.         m->last_displayed_item = m->first_displayed_item;
  1141.     }
  1142.     else
  1143.     {
  1144.         for (i = m->first_displayed_item; (i < m->n_items) && (!done); i++)
  1145.         {
  1146.         #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  1147.             if (i == m->highlighted_item)
  1148.             {
  1149.                 current_fixed_list_menuitem_display_index = -1;
  1150.             }
  1151.             else
  1152.             {
  1153.                 current_fixed_list_menuitem_display_index = i;
  1154.             }
  1155.         #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  1156.             m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
  1157.             total_height += iheight;
  1158.             if (total_height > list_height + 1)
  1159.             {
  1160.                 done = 1;
  1161.                 m->last_displayed_item = i - 1;
  1162.             }
  1163.         }
  1164.     }
  1165.     for (i = m->last_displayed_item; i >= 0 && (!done); i--)
  1166.     {
  1167.     #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  1168.         if (i == m->highlighted_item)
  1169.         {
  1170.             current_fixed_list_menuitem_display_index = -1;
  1171.         }
  1172.         else
  1173.         {
  1174.             current_fixed_list_menuitem_display_index = i;
  1175.         }
  1176.     #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  1177.         m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
  1178.         total_height += iheight;
  1179.         if (total_height > list_height + 1)
  1180.         {
  1181.             done = 1;
  1182.             m->first_displayed_item = i + 1;
  1183.         }
  1184.     }
  1185.     m->highlighted_item = m->first_displayed_item;
  1186.     switch_fixed_list_highlighted_item(m, last_highlighted_item);
  1187. }
  1188. /*****************************************************************************
  1189.  * FUNCTION
  1190.  *  gui_fixed_list_menu_goto_previous_page
  1191.  * DESCRIPTION
  1192.  *  Higlights an item in the previous page
  1193.  *  
  1194.  *  The fixed list is not redrawn
  1195.  * PARAMETERS
  1196.  *  m       [IN]        Is the fixed list menu object
  1197.  * RETURNS
  1198.  *  void
  1199.  *****************************************************************************/
  1200. void gui_fixed_list_menu_goto_previous_page(fixed_list_menu *m)
  1201. {
  1202.     /*----------------------------------------------------------------*/
  1203.     /* Local Variables                                                */
  1204.     /*----------------------------------------------------------------*/
  1205.     S32 last_highlighted_item;
  1206.     /*----------------------------------------------------------------*/
  1207.     /* Code Body                                                      */
  1208.     /*----------------------------------------------------------------*/
  1209.     last_highlighted_item = m->highlighted_item;
  1210.     m->first_displayed_item -= m->displayed_items;
  1211.     if (m->first_displayed_item < 0)
  1212.     {
  1213.         m->first_displayed_item = 0;
  1214.     }
  1215.     m->highlighted_item = m->first_displayed_item;
  1216.     if (last_highlighted_item == m->highlighted_item)
  1217.     {
  1218.         return;
  1219.     }
  1220.     gui_fixed_list_menu_locate_highlighted_item(m);
  1221.     switch_fixed_list_highlighted_item(m, last_highlighted_item);
  1222. }
  1223. /*****************************************************************************
  1224.  * FUNCTION
  1225.  *  gui_fixed_list_menu_goto_first_item
  1226.  * DESCRIPTION
  1227.  *  Higlights the first item
  1228.  *  
  1229.  *  The fixed list is not redrawn
  1230.  * PARAMETERS
  1231.  *  m       [IN]        Is the fixed list menu object
  1232.  * RETURNS
  1233.  *  void
  1234.  *****************************************************************************/
  1235. void gui_fixed_list_menu_goto_first_item(fixed_list_menu *m)
  1236. {
  1237.     /*----------------------------------------------------------------*/
  1238.     /* Local Variables                                                */
  1239.     /*----------------------------------------------------------------*/
  1240.     S32 last_highlighted_item;
  1241.     /*----------------------------------------------------------------*/
  1242.     /* Code Body                                                      */
  1243.     /*----------------------------------------------------------------*/
  1244.     if (m->highlighted_item == 0)
  1245.     {
  1246.         return;
  1247.     }
  1248.     last_highlighted_item = m->highlighted_item;
  1249.     m->highlighted_item = 0;
  1250.     gui_fixed_list_menu_locate_highlighted_item(m);
  1251.     switch_fixed_list_highlighted_item(m, last_highlighted_item);
  1252. }
  1253. /*****************************************************************************
  1254.  * FUNCTION
  1255.  *  gui_fixed_list_menu_goto_last_item
  1256.  * DESCRIPTION
  1257.  *  Higlights the last item
  1258.  *  
  1259.  *  The fixed list is not redrawn
  1260.  * PARAMETERS
  1261.  *  m       [IN]        Is the fixed list menu object
  1262.  * RETURNS
  1263.  *  void
  1264.  *****************************************************************************/
  1265. void gui_fixed_list_menu_goto_last_item(fixed_list_menu *m)
  1266. {
  1267.     /*----------------------------------------------------------------*/
  1268.     /* Local Variables                                                */
  1269.     /*----------------------------------------------------------------*/
  1270.     S32 last_highlighted_item;
  1271.     /*----------------------------------------------------------------*/
  1272.     /* Code Body                                                      */
  1273.     /*----------------------------------------------------------------*/
  1274.     if (m->highlighted_item == (m->n_items - 1))
  1275.     {
  1276.         return;
  1277.     }
  1278.     last_highlighted_item = m->highlighted_item;
  1279.     m->highlighted_item = (m->n_items - 1);
  1280.     gui_fixed_list_menu_locate_highlighted_item(m);
  1281.     switch_fixed_list_highlighted_item(m, last_highlighted_item);
  1282. }
  1283. /*****************************************************************************
  1284.  * FUNCTION
  1285.  *  gui_show_menu_background_filler_from_cache
  1286.  * DESCRIPTION
  1287.  *  Displays the menu background in another GDI layer
  1288.  * PARAMETERS
  1289.  *  x1      [IN]        
  1290.  *  y1      [IN]        
  1291.  *  x2      [IN]        
  1292.  *  y2      [IN]        
  1293.  *  f       [IN]        Background filler
  1294.  * RETURNS
  1295.  *  void
  1296.  *****************************************************************************/
  1297. #ifdef __MMI_UI_LIST_CACHE_BACKGROUND__
  1298. /* Check compile option dependency */
  1299. #if !defined(__GDI_MEMORY_PROFILE_2__) || defined(__MMI_WALLPAPER_ON_BOTTOM__)
  1300. #error "__MMI_UI_LIST_CACHE_BACKGROUND__ require __GDI_MEMORY_PROFILE_2__"
  1301. #endif 
  1302. #ifdef __MMI_UI_LIST_RESIDENT_FILLER_CACHE__
  1303. void gui_show_menu_background_filler_from_cache(S32 x1, S32 y1, S32 x2, S32 y2, UI_filled_area *f)
  1304. {
  1305.     /*----------------------------------------------------------------*/
  1306.     /* Local Variables                                                */
  1307.     /*----------------------------------------------------------------*/
  1308.     /*----------------------------------------------------------------*/
  1309.     /* Code Body                                                      */
  1310.     /*----------------------------------------------------------------*/
  1311.     if (!f)
  1312.     {
  1313.         return;
  1314.     }
  1315.     if (g_gui_list_menu_filler_cache_target != f)
  1316.     {
  1317.         /* Cache filler */
  1318.         gdi_handle cache_layer;
  1319.         g_gui_list_menu_filler_cache_target = f;
  1320.         gdi_layer_create_using_outside_memory(
  1321.             0,
  1322.             0,
  1323.             GUI_LIST_MENU_FILLER_CACHE_MAX_WIDTH,
  1324.             GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT,
  1325.             &cache_layer,
  1326.             (U8*) g_gui_list_menu_filler_cache,
  1327.             sizeof(g_gui_list_menu_filler_cache));
  1328.         gdi_layer_push_and_set_active(cache_layer);
  1329.         gui_draw_filled_area(
  1330.             0,
  1331.             0,
  1332.             GUI_LIST_MENU_FILLER_CACHE_MAX_WIDTH - 1,
  1333.             GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT - 1,
  1334.             f);
  1335.         gdi_layer_pop_and_restore_active();
  1336.         gdi_layer_free(cache_layer);
  1337.     }
  1338.     if ((x2 - x1 + 1 > GUI_LIST_MENU_FILLER_CACHE_MAX_WIDTH) || (y2 - y1 + 1 > GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT))
  1339.     {
  1340.         MMI_DBG_ASSERT(0);  /* invaild cache */
  1341.         gui_draw_filled_area(x1, y1, x2, y2, f);
  1342.     }
  1343.     else
  1344.     {
  1345.         PU8 dest;
  1346.         S32 dest_layer_width, dest_layer_height;
  1347.         gdi_rect_struct dest_clip;
  1348.         gdi_layer_get_buffer_ptr(&dest);
  1349.         gdi_layer_get_dimension(&dest_layer_width, &dest_layer_height);
  1350.         dest_clip.x1 = x1;
  1351.         dest_clip.y1 = y1;
  1352.         dest_clip.x2 = x2;
  1353.         dest_clip.y2 = y2;
  1354.         gdi_2d_memory_blt(
  1355.             (U8*) g_gui_list_menu_filler_cache,
  1356.             GUI_LIST_MENU_FILLER_CACHE_MAX_WIDTH,
  1357.             0,
  1358.             0,
  1359.             GUI_LIST_MENU_FILLER_CACHE_MAX_WIDTH,
  1360.             GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT,
  1361.             dest,
  1362.             dest_layer_width,
  1363.             x1,
  1364.             y1,
  1365.             dest_clip);
  1366.     }
  1367. }
  1368. #endif /* __MMI_UI_LIST_RESIDENT_FILLER_CACHE__ */ 
  1369. /*****************************************************************************
  1370.  * FUNCTION
  1371.  *  gui_show_menu_background_in_layer
  1372.  * DESCRIPTION
  1373.  *  
  1374.  * PARAMETERS
  1375.  *  x1      [IN]        
  1376.  *  y1      [IN]        
  1377.  *  x2      [IN]        
  1378.  *  y2      [IN]        
  1379.  *  f       [?]         
  1380.  * RETURNS
  1381.  *  void
  1382.  *****************************************************************************/
  1383. void gui_show_menu_background_in_layer(S32 x1, S32 y1, S32 x2, S32 y2, UI_filled_area *f)
  1384. {
  1385.     /*----------------------------------------------------------------*/
  1386.     /* Local Variables                                                */
  1387.     /*----------------------------------------------------------------*/
  1388.     S32 width = x2 - x1 + 1;
  1389.     S32 height = y2 - y1 + 1;
  1390.     /*----------------------------------------------------------------*/
  1391.     /* Code Body                                                      */
  1392.     /*----------------------------------------------------------------*/
  1393.     /*
  1394.      * We do not use gui_set_transparent_source_layer() in this function because 
  1395.      * not all list menu use gui_show_menu_background_in_layer(), then some menus
  1396.      * have transparency effect but others do not on platforms that
  1397.      * !defined(__MMI_WALLPAPER_ON_BOTTOM__) && defined (__MMI_UI_TRANSPARENT_EFFECT__)
  1398.      */
  1399.     if (!gui_is_entry_new_screen())
  1400.     {
  1401.         S32 layer_width, layer_height, layer_x, layer_y;
  1402.         gdi_layer_push_and_set_active(wgui_layer_1);
  1403.         gdi_layer_get_position(&layer_x, &layer_y);
  1404.         gdi_layer_get_dimension(&layer_width, &layer_height);
  1405.         if (layer_width != (x2 - x1 + 1) || layer_height != (y2 - y1 + 1))
  1406.         {
  1407.             MMI_DBG_ASSERT(0);
  1408.         }
  1409.         if (layer_x != x1 || layer_y != y1)
  1410.         {
  1411.             gdi_layer_set_position(x1, y1);
  1412.         }
  1413.         gdi_layer_pop_and_restore_active();
  1414.         if (dm_is_activated())
  1415.         {
  1416.             /* 
  1417.              * If draw manager is reset by RedrawCategoryScreen(), original information of draw manager layers are discarded
  1418.              * We need to configure the layer information again.
  1419.              */
  1420.             dm_add_blt_layer(wgui_layer_1, DM_LAYER_BOTTOM);
  1421.         }
  1422.         gdi_draw_solid_rect(x1, y1, x2, y2, GDI_COLOR_TRANSPARENT);
  1423.     }
  1424.     else
  1425.     {
  1426.         gui_set_entry_new_screen(MMI_FALSE);
  1427.         gdi_layer_multi_layer_enable();
  1428.         gdi_layer_get_base_handle(&wgui_base_layer);
  1429.         /* Setup the base layer */
  1430.         gdi_layer_push_and_set_active(wgui_base_layer);
  1431.         gdi_layer_set_source_key(TRUE, GDI_COLOR_TRANSPARENT);
  1432.         gdi_layer_set_opacity(TRUE, UI_SUBMENU_OPACITY_BASED_LAYER);
  1433.         gdi_layer_push_clip();
  1434.         gdi_layer_set_clip(x1, y1, x2, y2);
  1435.         gdi_draw_solid_rect(x1, y1, x2, y2, GDI_COLOR_TRANSPARENT);
  1436.         gdi_layer_pop_clip();
  1437.         gdi_layer_pop_and_restore_active();
  1438.         /* Create multilayer buffer */
  1439.         if (wgui_layer_1 == GDI_LAYER_EMPTY_HANDLE)
  1440.         {
  1441.             if (dm_is_activated())
  1442.             {
  1443.                 /* BLT layers are controlled by draw manager */
  1444.                 dm_create_layer(x1, y1, width, height, &wgui_layer_1, DM_LAYER_BOTTOM);
  1445.             }
  1446.             else
  1447.             {
  1448.                 gdi_layer_create(x1, y1, width, height, &wgui_layer_1);
  1449.                 gdi_layer_set_blt_layer(wgui_layer_1, wgui_base_layer, 0, 0);
  1450.             }
  1451.         }
  1452.         gdi_layer_push_and_set_active(wgui_layer_1);
  1453.     #ifdef __MMI_UI_LIST_RESIDENT_FILLER_CACHE__
  1454.         gui_show_menu_background_filler_from_cache(0, 0, width - 1, height - 1, f);
  1455.     #else 
  1456.         gui_draw_filled_area(0, 0, width - 1, height - 1, f);
  1457.     #endif 
  1458.         gdi_layer_pop_and_restore_active();
  1459.     }
  1460. }
  1461. #endif /* __MMI_UI_LIST_CACHE_BACKGROUND__ */ 
  1462. /*****************************************************************************
  1463.  * FUNCTION
  1464.  *  gui_show_list_menu_background_outside_area
  1465.  * DESCRIPTION
  1466.  *  Show the extended menu background outside the menu display area. 
  1467.  *
  1468.  *  For example, in handwriting mode of inline editor, we may want to draw 
  1469.  *  menu background in the bottom virtual keyboard area when the keyboard is hidden.
  1470.  *
  1471.  *  Note: This API does not use any menu cache
  1472.  * PARAMETERS
  1473.  *  m       [IN]        Is the list menu object
  1474.  *  x1      [IN]        left-top x
  1475.  *  y1      [IN]        left-top y
  1476.  *  x2      [IN]        right-bottom x
  1477.  *  y2      [IN]        right-bottom y
  1478.  * RETURNS
  1479.  *  void
  1480.  *****************************************************************************/
  1481. void gui_show_list_menu_background_outside_area(fixed_list_menu *m, S32 x1, S32 y1, S32 x2, S32 y2)
  1482. {
  1483.     UI_filled_area *f;
  1484.     if (m->flags & UI_LIST_MENU_STATE_FOCUSSED)
  1485.     {
  1486.         f = m->focussed_filler;
  1487.     }
  1488.     else
  1489.     {
  1490.         f = m->normal_filler;
  1491.     }
  1492.     gui_push_clip();
  1493.     gui_set_clip(x1, y1, x2, y2);
  1494.     gui_draw_filled_area(m->x, m->y, x2, y2, f);
  1495.         
  1496.     gui_pop_clip();
  1497. }
  1498. /*****************************************************************************
  1499.  * FUNCTION
  1500.  *  gui_show_fixed_list_menu
  1501.  * DESCRIPTION
  1502.  *  Displays the fixed list menu
  1503.  * PARAMETERS
  1504.  *  m       [IN]        Is the fixed list menu object
  1505.  * RETURNS
  1506.  *  void
  1507.  *****************************************************************************/
  1508. extern S32 MMI_current_menu_type;
  1509. #ifdef __MMI_UI_DALMATIAN_FIXEDLIST__
  1510. extern MMI_theme *current_MMI_theme;
  1511. extern BOOL line_draw;
  1512. extern fixed_list_menu MMI_fixed_list_menu;
  1513. #endif /* __MMI_UI_DALMATIAN_FIXEDLIST__ */ 
  1514. void gui_show_fixed_list_menu(fixed_list_menu *m)
  1515. {
  1516.     /*----------------------------------------------------------------*/
  1517.     /* Local Variables                                                */
  1518.     /*----------------------------------------------------------------*/
  1519.     S32 x1, y1, x2, y2, y_offset;
  1520. #ifdef __MMI_UI_DALMATIAN_FIXEDLIST__
  1521.     S32 ic, menu_grid_gap;
  1522. #endif 
  1523.     UI_filled_area *f;
  1524.     S32 i;
  1525.     S32 cx1, cy1, cx2, cy2;
  1526.     S32 tx1, ty1, tx2, ty2;
  1527.     S32 iwidth, iheight;
  1528.     U8 done = 0;
  1529.     S32 total_height, counter, list_height;
  1530.     U8 disable_draw = 0;
  1531.     MMI_BOOL show_scrollbar;
  1532.     /*----------------------------------------------------------------*/
  1533.     /* Code Body                                                      */
  1534.     /*----------------------------------------------------------------*/
  1535.     if (m->flags & UI_LIST_MENU_DISABLE_DRAW)
  1536.     {
  1537.         disable_draw = 1;
  1538.     }
  1539.     gui_get_clip(&cx1, &cy1, &cx2, &cy2);
  1540.     gui_get_text_clip(&tx1, &ty1, &tx2, &ty2);
  1541.     x1 = m->x;
  1542.     y1 = m->y;
  1543.     x2 = x1 + m->width - 1;
  1544.     y2 = y1 + m->height - 1;
  1545.     /* Use the original x1, y1, x2, y2 for background filler */
  1546.     if (m->flags & UI_LIST_MENU_STATE_FOCUSSED)
  1547.     {
  1548.         f = m->focussed_filler;
  1549.     }
  1550.     else
  1551.     {
  1552.         f = m->normal_filler;
  1553.     }
  1554.     if (!disable_draw && (!(m->flags & UI_LIST_MENU_DISABLE_BACKGROUND)) && MMI_current_menu_type != PAGE_MENU)
  1555.     {
  1556.         gui_set_clip(x1, y1, x2, y2);
  1557.         if (!(m->flags & UI_LIST_MENU_DISABLE_BKGRND_IN_LAYER) && (wgui_is_wallpaper_on_bottom() == MMI_TRUE))
  1558.         {
  1559.             gdi_draw_solid_rect(x1, y1, x2, y2, GDI_COLOR_TRANSPARENT);
  1560.             /* PMT VIKAS START 20051217 */
  1561.         #if (defined (__MMI_UI_TRANSPARENT_EFFECT__) || defined (__MMI_UI_LIST_HIGHLIGHT_EFFECTS__))
  1562.             /* PMT VIKAS END 20051217 */
  1563.             if (gui_get_transparent_source_layer() == GDI_LAYER_EMPTY_HANDLE)   /* 110705 WAP menu Clavin add */
  1564.             {
  1565.                 gui_set_transparent_source_layer(dm_get_scr_bg_layer());        /* should remove */
  1566.             }
  1567.         #endif /* (defined (__MMI_UI_TRANSPARENT_EFFECT__) || defined (__MMI_UI_LIST_HIGHLIGHT_EFFECTS__)) */ 
  1568.         }
  1569.     #ifdef __MMI_UI_LIST_CACHE_BACKGROUND__
  1570.         else if (!(m->flags & UI_LIST_MENU_DISABLE_BKGRND_IN_LAYER) &&
  1571.                  (dm_get_scr_bg_layer() == GDI_ERROR_HANDLE) && (gui_get_multilayer_mask() & UI_MUL_BKG_SUBMENU))
  1572.         {
  1573.             gui_show_menu_background_in_layer(x1, y1, x2, y2, f);
  1574.         }
  1575.     #endif /* __MMI_UI_LIST_CACHE_BACKGROUND__ */ 
  1576.         else
  1577.         {
  1578.         #if !defined(MT6205B) && !defined(MT6208)
  1579.             gui_draw_filled_area(x1, y1, x2, y2, f);
  1580.         #else /* !defined(MT6205B) && !defined(MT6208) */
  1581.             /* For low-end phone, disable list menu background can greately improve menu performance. 
  1582.                We use the color of filler to draw the background (typically white). */
  1583.             color c = f->c;
  1584.             gdi_draw_solid_rect(x1, y1, x2, y2, gdi_act_color_from_rgb(255, c.r, c.g, c.b));
  1585.         #endif /* !defined(MT6205B) && !defined(MT6208) */
  1586.         }
  1587.     }
  1588.     if (m->flags & UI_LIST_MENU_ENABLE_TRANSITION)
  1589.     {
  1590.         color c = gui_color(255, 255, 255);
  1591.         gui_push_clip();
  1592.         gui_set_clip(x1, y1, x2, y2);
  1593.         gui_fill_rectangle(x1, y1, x2, y2, c);
  1594.         gui_pop_clip();
  1595.     }
  1596.     if (m->n_items <= 0)
  1597.     {
  1598.         return;
  1599.     }
  1600.     /* Check presence of scrollbar */
  1601.     show_scrollbar = MMI_FALSE;
  1602.     if (!(m->flags & UI_LIST_MENU_DISABLE_SCROLLBAR))
  1603.     {
  1604.         if (m->flags & UI_LIST_MENU_AUTO_DISABLE_SCROLLBAR)
  1605.         {
  1606.             if (m->first_displayed_item > 0)
  1607.             {
  1608.                 show_scrollbar = MMI_TRUE;
  1609.             }
  1610.             else
  1611.             {
  1612.                 /* FIXME. we need to compute m->displayed_items twice */
  1613.                 gui_show_fixed_list_menu_no_draw(m);
  1614.                 if (m->displayed_items >= m->n_items)
  1615.                 {
  1616.                     show_scrollbar = MMI_TRUE;
  1617.                 }
  1618.             }
  1619.         }
  1620.         else
  1621.         {
  1622.             show_scrollbar = MMI_TRUE;
  1623.         }
  1624.     }
  1625.     /* Configure region of menu items */
  1626.     if (show_scrollbar)
  1627.     {
  1628.         if (!r2lMMIFlag)
  1629.         {
  1630.             x2 -= m->vbar.width;
  1631.         }
  1632.         else
  1633.         {
  1634.             x1 += m->vbar.width;
  1635.         }
  1636.     }
  1637.     /* Display menu items */
  1638.     if (MMI_current_menu_type == PAGE_MENU)
  1639.     {
  1640.         if (!disable_draw)
  1641.         {
  1642.             m->item_display_function(m->items[m->highlighted_item], m->common_item_data, m->x, m->y);
  1643.         }
  1644.         return;
  1645.     }
  1646.     y1 = m->y + m->top;
  1647.     list_height = m->height;
  1648.     gui_set_text_clip(x1, y1, x2, y2);
  1649.     gui_set_clip(x1, y1, x2, y2);
  1650.     total_height = 0;
  1651.     counter = 0;
  1652.     current_fixed_list_menuitem_display_index = -1;
  1653.     if (m->flags & UI_LIST_MENU_CENTER_HIGHLIGHTED)
  1654.     {
  1655.     #if 0   /* 111605 warning Calvin */
  1656. #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  1657. /* under construction !*/
  1658. /* under construction !*/
  1659. /* under construction !*/
  1660. /* under construction !*/
  1661. #endif
  1662.     #endif /* 0 */ 
  1663.         m->item_measure_function(m->items[m->highlighted_item], m->common_item_data, &iwidth, &iheight);
  1664.         current_fixed_list_menuitem_display_index = m->first_displayed_item;
  1665.         m->item_display_function(m->items[m->first_displayed_item], m->common_item_data, x1, y1);
  1666.         current_fixed_list_menuitem_display_index = m->highlighted_item;
  1667.         m->item_display_function(m->items[m->highlighted_item], m->common_item_data, x1, y1 + iheight);
  1668.         current_fixed_list_menuitem_display_index = m->last_displayed_item;
  1669.         m->item_display_function(m->items[m->last_displayed_item], m->common_item_data, x1, y1 + iheight * 2);
  1670.     }
  1671.     else
  1672.     {
  1673.         for (i = m->first_displayed_item; (i < m->n_items && !done); i++)
  1674.         {
  1675.             if (i == m->highlighted_item)
  1676.             {
  1677.                 current_fixed_list_menuitem_display_index = -1;
  1678.             }
  1679.             else
  1680.             {
  1681.                 current_fixed_list_menuitem_display_index = i;
  1682.             }
  1683.             m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
  1684.             y_offset = total_height;
  1685.             /* total_height+=iheight+m->spacing; */
  1686.             total_height += iheight;
  1687.             if (total_height > list_height + 1)
  1688.             {
  1689.                 done = 1;
  1690.                 /* This is required so that in trnasition if theire is no area to display the menu item it is not displayed */
  1691.                 if ((counter == 0) && !disable_draw && !(m->flags & UI_LIST_MENU_ENABLE_TRANSITION))
  1692.                 {
  1693.                     m->item_display_function(m->items[i], m->common_item_data, x1, y_offset + y1);
  1694.                 }
  1695.             }
  1696.             else
  1697.             {
  1698.                 if (!disable_draw)
  1699.                 {
  1700.                     m->item_display_function(m->items[i], m->common_item_data, x1, y_offset + y1);
  1701.                 }
  1702.                 counter++;
  1703.             }
  1704.         #ifdef __MMI_UI_DALMATIAN_FIXEDLIST__
  1705.             if (line_draw && MMI_current_menu_type == LIST_MENU)
  1706.             {
  1707.                 if (!r2lMMIFlag)
  1708.                 {
  1709.                     gui_draw_horizontal_line(
  1710.                         x1,
  1711.                         m->vbar.x - 2,
  1712.                         y_offset + y1,
  1713.                         current_MMI_theme->list_background_filler->border_color);
  1714.                 }
  1715.                 else
  1716.                 {
  1717.                     gui_draw_horizontal_line(
  1718.                         x1,
  1719.                         x2,
  1720.                         y_offset + y1,
  1721.                         current_MMI_theme->list_background_filler->border_color);
  1722.                 }
  1723.             }
  1724.         #endif /* __MMI_UI_DALMATIAN_FIXEDLIST__ */ 
  1725.         }
  1726.     #ifdef __MMI_UI_DALMATIAN_FIXEDLIST__
  1727.         ic = i;
  1728.         /* To fix the grid issue due to top variable value. */
  1729.         menu_grid_gap = MMI_fixed_list_menu.height % iheight;
  1730.         menu_grid_gap -= m->top;
  1731.         if (line_draw && MMI_current_menu_type == LIST_MENU)
  1732.         {
  1733.             // To grid for sub menu screens
  1734.             // Used -2 for proper area selection
  1735.             if (ic == m->n_items)
  1736.             {
  1737.                 if (!r2lMMIFlag)
  1738.                 {
  1739.                     gui_draw_horizontal_line(
  1740.                         x1,
  1741.                         m->vbar.x - 2,
  1742.                         y_offset + y1 + iheight,
  1743.                         current_MMI_theme->list_background_filler->border_color);
  1744.                 }
  1745.                 else
  1746.                 {
  1747.                     gui_draw_horizontal_line(
  1748.                         x1,
  1749.                         x2,
  1750.                         y_offset + y1 + iheight,
  1751.                         current_MMI_theme->list_background_filler->border_color);
  1752.                 }
  1753.             }
  1754.             if (!r2lMMIFlag)
  1755.             {
  1756.                 if (ic == m->n_items && done)
  1757.                 {
  1758.                     gui_draw_vertical_line(
  1759.                         y1,
  1760.                         y1 + y_offset,
  1761.                         m->vbar.x - 2,
  1762.                         current_MMI_theme->list_background_filler->border_color);
  1763.                 }
  1764.                 else
  1765.                 {
  1766.                     gui_draw_vertical_line(
  1767.                         y1,
  1768.                         ((y1 + y_offset + iheight) > (UI_device_height - MMI_BUTTON_BAR_HEIGHT - menu_grid_gap) ? (UI_device_height - MMI_BUTTON_BAR_HEIGHT - menu_grid_gap) : (y1 + y_offset + iheight)),
  1769.                         m->vbar.x - 2,
  1770.                         current_MMI_theme->list_background_filler->border_color);
  1771.                 }
  1772.             }
  1773.             else
  1774.             {
  1775.                 if (i == m->n_items && done)
  1776.                 {
  1777.                     gui_draw_vertical_line(
  1778.                         y1,
  1779.                         y1 + y_offset,
  1780.                         (m->vbar.x + m->vbar.width - m->width) + m->vbar.width,
  1781.                         current_MMI_theme->list_background_filler->border_color);
  1782.                 }
  1783.                 else
  1784.                 {
  1785.                     gui_draw_vertical_line(
  1786.                         y1,
  1787.                         ((y1 + total_height) > (UI_device_height - MMI_BUTTON_BAR_HEIGHT - menu_grid_gap) ? (UI_device_height - MMI_BUTTON_BAR_HEIGHT - menu_grid_gap) : (y1 + total_height)),
  1788.                         (m->vbar.x + m->vbar.width - m->width) + m->vbar.width,
  1789.                         current_MMI_theme->list_background_filler->border_color);
  1790.                 }
  1791.             }
  1792.         }
  1793.     #endif /* __MMI_UI_DALMATIAN_FIXEDLIST__ */ 
  1794.         current_fixed_list_menuitem_display_index = -1;
  1795.         if (counter == 0)
  1796.         {
  1797.             m->last_displayed_item = m->first_displayed_item;
  1798.         }
  1799.         else
  1800.         {
  1801.             m->last_displayed_item = m->first_displayed_item + counter - 1;
  1802.         }
  1803.         m->displayed_items = counter;
  1804.     }
  1805.     gui_set_clip(cx1, cy1, cx2, cy2);
  1806.     gui_set_text_clip(tx1, ty1, tx2, ty2);
  1807.     /* Handle scrollbar */
  1808.     if (show_scrollbar)
  1809.     {
  1810.         /* FIXME. debug only. we can remove the check in the future */
  1811.         MMI_DBG_ASSERT(!(m->flags & UI_LIST_MENU_AUTO_DISABLE_SCROLLBAR) ||
  1812.                        (total_height > list_height + 1) || (m->first_displayed_item > 0));
  1813.         if (r2lMMIFlag)
  1814.         {
  1815.             gui_move_vertical_scrollbar(&m->vbar, m->x, m->y);
  1816.         }
  1817.         else
  1818.         {
  1819.             gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - m->vbar.width, m->y);
  1820.         }
  1821.         gui_set_vertical_scrollbar_range(&m->vbar, m->n_items);
  1822.         gui_set_vertical_scrollbar_scale(&m->vbar, m->displayed_items);
  1823.         gui_set_vertical_scrollbar_value(&m->vbar, m->first_displayed_item);
  1824.         if (!disable_draw)
  1825.         {
  1826.             gui_show_vertical_scrollbar(&m->vbar);
  1827.         }
  1828.     }
  1829.     /* PMT VIKAS START 20051202 */
  1830. #if defined (__MMI_UI_DALMATIAN_FIXEDLIST__) && !defined(__MMI_TOUCH_SCREEN__)
  1831.     if (line_draw && MMI_current_menu_type == LIST_MENU)
  1832.         /* PMT VIKAS END 20051202 */
  1833.     {
  1834.         gui_push_clip();
  1835.         if (!r2lMMIFlag)
  1836.         {
  1837.             gui_set_clip(m->vbar.x - 1, y1, m->vbar.x + m->vbar.width - 1, m->vbar.y + m->vbar.height - 1);
  1838.         }
  1839.         else
  1840.         {
  1841.             gui_set_clip(
  1842.                 (m->vbar.x + m->vbar.width - m->width),
  1843.                 y1,
  1844.                 (m->vbar.x + m->vbar.width - m->width) + m->vbar.width,
  1845.                 m->vbar.y + m->vbar.height - 1);
  1846.         }
  1847.         /* To grid for sub menu screens */
  1848.         if (!r2lMMIFlag)
  1849.         {
  1850.             gui_draw_vertical_line(y1, y1 + m->vbar.height - 4, m->vbar.x, current_MMI_theme->list_background_filler->border_color);    /* Start of scroll bar */
  1851.             gui_draw_vertical_line(y1, y1 + m->vbar.height - 4, (m->vbar.x + m->vbar.width) - 1, current_MMI_theme->list_background_filler->border_color);      /* End of Scroll bar */
  1852.             gui_draw_vertical_line(y1, y1 + m->vbar.height - 4, m->vbar.x - 1, current_MMI_theme->list_background_filler->c);   /* To show white gap betwen scroll bar & menu area */
  1853.         }
  1854.         else
  1855.         {
  1856.             gui_draw_vertical_line(y1, y1 + m->vbar.height - 4, m->vbar.x + m->vbar.width - m->width, current_MMI_theme->list_background_filler->border_color); /* Start of Scroll bar */
  1857.             gui_draw_vertical_line(y1, y1 + m->vbar.height - 4, (m->vbar.x + m->vbar.width - m->width) + m->vbar.width - 2, current_MMI_theme->list_background_filler->border_color);   /* End of Scroll bar */
  1858.         }
  1859.         gui_pop_clip();
  1860.         ic = 0;
  1861.     }
  1862. #endif /* defined (__MMI_UI_DALMATIAN_FIXEDLIST__) && !defined(__MMI_TOUCH_SCREEN__) */ 
  1863. }
  1864. /*****************************************************************************
  1865.  * FUNCTION
  1866.  *  gui_show_fixed_list_menu_no_draw
  1867.  * DESCRIPTION
  1868.  *  
  1869.  * PARAMETERS
  1870.  *  m       [?]     
  1871.  * RETURNS
  1872.  *  void
  1873.  *****************************************************************************/
  1874. void gui_show_fixed_list_menu_no_draw(fixed_list_menu *m)
  1875. {
  1876.     /*----------------------------------------------------------------*/
  1877.     /* Local Variables                                                */
  1878.     /*----------------------------------------------------------------*/
  1879.     S32 i;
  1880.     S32 iwidth, iheight;
  1881.     U8 done = 0;
  1882.     S32 total_height, counter, list_height;
  1883.     /*----------------------------------------------------------------*/
  1884.     /* Code Body                                                      */
  1885.     /*----------------------------------------------------------------*/
  1886.     list_height = m->height;
  1887.     total_height = 0;
  1888.     counter = 0;
  1889.     current_fixed_list_menuitem_display_index = -1;
  1890.     for (i = m->first_displayed_item; (i < m->n_items && !done); i++)
  1891.     {
  1892.         if (i == m->highlighted_item)
  1893.         {
  1894.             current_fixed_list_menuitem_display_index = -1;
  1895.         }
  1896.         else
  1897.         {
  1898.             current_fixed_list_menuitem_display_index = i;
  1899.         }
  1900.         m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
  1901.         total_height += iheight;
  1902.         if (total_height > list_height + 1)
  1903.         {
  1904.             done = 1;
  1905.         }
  1906.         else
  1907.         {
  1908.             counter++;
  1909.         }
  1910.     }
  1911.     current_fixed_list_menuitem_display_index = -1;
  1912.     if (counter == 0)
  1913.     {
  1914.         m->last_displayed_item = m->first_displayed_item;
  1915.     }
  1916.     else
  1917.     {
  1918.         m->last_displayed_item = m->first_displayed_item + counter - 1;
  1919.     }
  1920.     m->displayed_items = counter;
  1921.     if (!(m->flags & UI_LIST_MENU_DISABLE_SCROLLBAR))
  1922.     {
  1923.         gui_set_vertical_scrollbar_range(&m->vbar, m->n_items);
  1924.         gui_set_vertical_scrollbar_scale(&m->vbar, m->displayed_items);
  1925.         gui_set_vertical_scrollbar_value(&m->vbar, m->first_displayed_item);
  1926.     }
  1927. }
  1928. #ifdef __MMI_TOUCH_SCREEN__
  1929. /*****************************************************************************
  1930.  * FUNCTION
  1931.  *  gui_fixed_list_menu_translate_pen_position
  1932.  * DESCRIPTION
  1933.  *  Translate position to item index
  1934.  *  
  1935.  *  if y < minimum bound, *item_index is first_displayed_item - 1 or 0
  1936.  *  if y > maximum bound, *item_index is last_displayed_item + 1 or (n_items - 1)
  1937.  *  Caller of this function might be sensitive to the return result.
  1938.  *  Be careful when modifying this function.
  1939.  * PARAMETERS
  1940.  *  m               [IN]        Is the fixed list menu object
  1941.  *  y               [IN]        Y-axis coordinate
  1942.  *  item_index      [OUT]       
  1943.  * RETURNS
  1944.  *  whether the position is on menu items
  1945.  *****************************************************************************/
  1946. BOOL gui_fixed_list_menu_translate_pen_position(fixed_list_menu *m, S32 y, S32 *item_index)
  1947. {
  1948.     /*----------------------------------------------------------------*/
  1949.     /* Local Variables                                                */
  1950.     /*----------------------------------------------------------------*/
  1951.     S32 total_height = 0, i;
  1952.     S32 iwidth, iheight;
  1953.     BOOL ret = MMI_FALSE;
  1954.     /*----------------------------------------------------------------*/
  1955.     /* Code Body                                                      */
  1956.     /*----------------------------------------------------------------*/
  1957.     y -= m->y;
  1958.     if (m->n_items <= 0)
  1959.     {
  1960.         *item_index = 0;
  1961.         /* ret is false */
  1962.     }
  1963.     else if (y < 0)
  1964.     {
  1965.         *item_index = (m->first_displayed_item > 0) ? m->first_displayed_item - 1 : 0;
  1966.         /* ret is false */
  1967.     }
  1968.     else if (y >= m->height)
  1969.     {
  1970.         *item_index = (m->last_displayed_item < m->n_items - 1) ? m->last_displayed_item + 1 : m->n_items - 1;
  1971.         /* ret is false */
  1972.     }
  1973.     else
  1974.     {
  1975.         *item_index = m->n_items - 1;
  1976.         for (i = m->first_displayed_item; i < m->n_items; i++)
  1977.         {
  1978.         #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  1979.             if (i == m->highlighted_item)
  1980.             {
  1981.                 current_fixed_list_menuitem_display_index = -1;
  1982.             }
  1983.             else
  1984.             {
  1985.                 current_fixed_list_menuitem_display_index = i;
  1986.             }
  1987.         #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  1988.             m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
  1989.             total_height += iheight;
  1990.             if (total_height > y)
  1991.             {
  1992.                 *item_index = i;
  1993.                 ret = MMI_TRUE;
  1994.                 break;
  1995.             }
  1996.         }
  1997.     }
  1998.     return ret;
  1999. }
  2000. /* 
  2001.  * IN: m, item_index
  2002.  * OUT: x, y
  2003.  */
  2004. /*****************************************************************************
  2005.  * FUNCTION
  2006.  *  gui_fixed_list_menu_get_menuitem_position
  2007.  * DESCRIPTION
  2008.  *  
  2009.  * PARAMETERS
  2010.  *  m               [?]         
  2011.  *  item_index      [IN]        
  2012.  *  x               [?]         
  2013.  *  y               [?]         
  2014.  * RETURNS
  2015.  *  void
  2016.  *****************************************************************************/
  2017. static void gui_fixed_list_menu_get_menuitem_position(fixed_list_menu *m, S32 item_index, S32 *x, S32 *y)
  2018. {
  2019.     /*----------------------------------------------------------------*/
  2020.     /* Local Variables                                                */
  2021.     /*----------------------------------------------------------------*/
  2022.     S32 i, total_height = m->y;
  2023.     S32 iwidth, iheight;
  2024.     /*----------------------------------------------------------------*/
  2025.     /* Code Body                                                      */
  2026.     /*----------------------------------------------------------------*/
  2027.     *x = m->x;
  2028.     if (item_index <= m->first_displayed_item)
  2029.     {
  2030.         *y = total_height;
  2031.         return;
  2032.     }
  2033.     for (i = m->first_displayed_item; i <= m->last_displayed_item; i++)
  2034.     {
  2035.     #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  2036.         if (i == m->highlighted_item)
  2037.         {
  2038.             current_fixed_list_menuitem_display_index = -1;
  2039.         }
  2040.         else
  2041.         {
  2042.             current_fixed_list_menuitem_display_index = i;
  2043.         }
  2044.     #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  2045.         m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
  2046.         total_height += iheight;
  2047.         if (i + 1 == item_index)
  2048.         {
  2049.             *y = total_height;
  2050.             return;
  2051.         }
  2052.     }
  2053.     *y = total_height;
  2054. }
  2055. /*****************************************************************************
  2056.  * FUNCTION
  2057.  *  gui_fixed_list_menu_scroll_by_pen
  2058.  * DESCRIPTION
  2059.  *  
  2060.  * PARAMETERS
  2061.  *  m                   [?]         
  2062.  *  first_displayed     [IN]        
  2063.  *  menu_event          [?]         
  2064.  * RETURNS
  2065.  *  void
  2066.  *****************************************************************************/
  2067. static void gui_fixed_list_menu_scroll_by_pen(fixed_list_menu *m, S32 first_displayed, gui_list_pen_enum *menu_event)
  2068. {
  2069.     /*----------------------------------------------------------------*/
  2070.     /* Local Variables                                                */
  2071.     /*----------------------------------------------------------------*/
  2072.     S32 total_height = 0, i;
  2073.     S32 iwidth, iheight;
  2074.     S32 last_displayed = m->n_items - 1;
  2075.     /*----------------------------------------------------------------*/
  2076.     /* Code Body                                                      */
  2077.     /*----------------------------------------------------------------*/
  2078.     if (first_displayed > m->highlighted_item)
  2079.     {
  2080.         m->flags |= UI_LIST_MENU_FIRST_SHIFT_HIGHLIGHTED_ITEM;
  2081.         gui_fixed_list_menu_goto_item(m, first_displayed);
  2082.         m->flags &= ~UI_LIST_MENU_FIRST_SHIFT_HIGHLIGHTED_ITEM;
  2083.         *menu_event = GUI_LIST_PEN_HIGHLIGHT_CHANGED;
  2084.     }
  2085.     else
  2086.     {
  2087.         for (i = first_displayed; i < m->n_items; i++)
  2088.         {
  2089.         #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  2090.             if (i == m->highlighted_item)
  2091.             {
  2092.                 current_fixed_list_menuitem_display_index = -1;
  2093.             }
  2094.             else
  2095.             {
  2096.                 current_fixed_list_menuitem_display_index = i;
  2097.             }
  2098.         #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  2099.             m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
  2100.             total_height += iheight;
  2101.             if (total_height > m->height + 1)
  2102.             {
  2103.                 last_displayed = i - 1;
  2104.                 break;
  2105.             }
  2106.         }
  2107.         if (i == m->n_items)
  2108.         {
  2109.             last_displayed = m->n_items - 1;
  2110.         }
  2111.         if (last_displayed < m->highlighted_item)
  2112.         {
  2113.             m->flags |= UI_LIST_MENU_LAST_SHIFT_HIGHLIGHTED_ITEM;
  2114.             gui_fixed_list_menu_goto_item(m, last_displayed);
  2115.             m->flags &= ~UI_LIST_MENU_LAST_SHIFT_HIGHLIGHTED_ITEM;
  2116.             *menu_event = GUI_LIST_PEN_HIGHLIGHT_CHANGED;
  2117.         }
  2118.         else
  2119.         {
  2120.             m->first_displayed_item = first_displayed;
  2121.             m->last_displayed_item = last_displayed;
  2122.             *menu_event = GUI_LIST_PEN_NEED_REDRAW;
  2123.         }
  2124.     }
  2125. }
  2126. /*****************************************************************************
  2127.  * FUNCTION
  2128.  *  gui_fixed_list_menu_translate_pen_event
  2129.  * DESCRIPTION
  2130.  *  
  2131.  * PARAMETERS
  2132.  *  m               [?]         
  2133.  *  pen_event       [IN]        
  2134.  *  x               [IN]        
  2135.  *  y               [IN]        
  2136.  *  menu_event      [?]         
  2137.  * RETURNS
  2138.  *  
  2139.  *****************************************************************************/
  2140. BOOL gui_fixed_list_menu_translate_pen_event(
  2141.         fixed_list_menu *m,
  2142.         mmi_pen_event_type_enum pen_event,
  2143.         S16 x,
  2144.         S16 y,
  2145.         gui_list_pen_enum *menu_event)
  2146. {
  2147.     /*----------------------------------------------------------------*/
  2148.     /* Local Variables                                                */
  2149.     /*----------------------------------------------------------------*/
  2150.     BOOL ret;
  2151.     gui_list_pen_state_struct *pen_state;
  2152.     gui_scrollbar_pen_enum scrollbar_event;
  2153.     gui_pen_event_param_struct scrollbar_param;
  2154.     gui_list_pen_enum menuitem_event;
  2155.     gui_pen_event_param_struct menuitem_param;
  2156.     S32 item_index;
  2157.     /*----------------------------------------------------------------*/
  2158.     /* Code Body                                                      */
  2159.     /*----------------------------------------------------------------*/
  2160.     pen_state = &m->pen_state;
  2161.     ret = MMI_TRUE;
  2162.     *menu_event = GUI_LIST_PEN_NONE;
  2163.     if (m->flags & UI_LIST_MENU_DISABLE_PEN)
  2164.     {
  2165.         return MMI_FALSE;
  2166.     }
  2167.     if (pen_event != MMI_PEN_EVENT_DOWN && pen_state->pen_on_scrollbar)
  2168.     {
  2169.         gui_vertical_scrollbar_translate_pen_event(&m->vbar, pen_event, x, y, &scrollbar_event, &scrollbar_param);
  2170.         if (scrollbar_event == GUI_SCROLLBAR_PEN_JUMP_TO_I)
  2171.         {
  2172.             gui_fixed_list_menu_scroll_by_pen(m, scrollbar_param._u.i, menu_event);
  2173.         }
  2174.     }
  2175.     else if (pen_event != MMI_PEN_EVENT_DOWN && pen_state->handled_by_menu_item)
  2176.     {
  2177.         /* For example, tap down on checkbox of two-state menuitem, the subsequent move/up events are discarded */
  2178.         S32 item_x, item_y;
  2179.         gui_fixed_list_menu_get_menuitem_position(m, m->highlighted_item, &item_x, &item_y);
  2180.         m->item_pen_function(
  2181.             m->items[m->highlighted_item],
  2182.             m->common_item_data,
  2183.             item_x,
  2184.             item_y,
  2185.             pen_event,
  2186.             x,
  2187.             y,
  2188.             &menuitem_event,
  2189.             &menuitem_param);
  2190.         if (menuitem_event == GUI_TWOSTATE_PEN_TOGGLE)
  2191.         {
  2192.             menuitem_event = GUI_LIST_PEN_ITEM_SELECTED;
  2193.         }
  2194.         *menu_event = menuitem_event;
  2195.     }
  2196.     else
  2197.     {
  2198.         switch (pen_event)
  2199.         {
  2200.             case MMI_PEN_EVENT_DOWN:
  2201.                 if (PEN_CHECK_BOUND(x, y, m->x, m->y, m->width, m->height))
  2202.                 {
  2203.                     pen_state->handled_by_menu_item = 0;
  2204.                     pen_state->pen_on_scrollbar = 0;
  2205.                     if (m->n_items <= 0)
  2206.                     {
  2207.                         /* In current design, scrollbar is hidden if m->n_items == 0 */
  2208.                         ret = MMI_FALSE;
  2209.                     }
  2210.                     else if (!(m->flags & UI_LIST_MENU_DISABLE_SCROLLBAR) &&
  2211.                              gui_vertical_scrollbar_translate_pen_event(
  2212.                                 &m->vbar,
  2213.                                 MMI_PEN_EVENT_DOWN,
  2214.                                 x,
  2215.                                 y,
  2216.                                 &scrollbar_event,
  2217.                                 &scrollbar_param))
  2218.                     {
  2219.                         pen_state->pen_on_scrollbar = 1;
  2220.                         if (scrollbar_event == GUI_SCROLLBAR_PEN_JUMP_TO_I)
  2221.                         {
  2222.                             gui_fixed_list_menu_scroll_by_pen(m, scrollbar_param._u.i, menu_event);
  2223.                         }
  2224.                     }
  2225.                     else
  2226.                     {
  2227.                         if (gui_fixed_list_menu_translate_pen_position(m, y, &item_index))
  2228.                         {
  2229.                             S32 item_x, item_y;
  2230.                             if (item_index != m->highlighted_item)
  2231.                             {
  2232.                                 gui_fixed_list_menu_goto_item(m, item_index);
  2233.                                 *menu_event = GUI_LIST_PEN_HIGHLIGHT_CHANGED;
  2234.                             }
  2235.                             /* Even if highlight is changed, we still need to invoke menuitem pen handler */
  2236.                             gui_fixed_list_menu_get_menuitem_position(m, item_index, &item_x, &item_y);
  2237.                             if (m->item_pen_function(
  2238.                                     m->items[item_index],
  2239.                                     m->common_item_data,
  2240.                                     item_x,
  2241.                                     item_y,
  2242.                                     MMI_PEN_EVENT_DOWN,
  2243.                                     x,
  2244.                                     y,
  2245.                                     &menuitem_event,
  2246.                                     &menuitem_param))
  2247.                             {
  2248.                                 if (menuitem_event == GUI_TWOSTATE_PEN_TOGGLE)
  2249.                                 {
  2250.                                     menuitem_event = GUI_LIST_PEN_ITEM_SELECTED;
  2251.                                 }
  2252.                                 /* original menu_event could be GUI_LIST_PEN_HIGHLIGHT_CHANGED */
  2253.                                 if (menuitem_event != GUI_LIST_PEN_NONE)
  2254.                                 {
  2255.                                     *menu_event = menuitem_event;
  2256.                                 }
  2257.                                 pen_state->handled_by_menu_item = 1;
  2258.                             }
  2259.                         }
  2260.                         else
  2261.                         {
  2262.                             /* # of menu items < # of displayable menu items */
  2263.                             ret = MMI_FALSE;
  2264.                         }
  2265.                     }
  2266.                     pen_state->first_highlighed_item = m->highlighted_item;
  2267.                     pen_state->highlight_changed = 0;
  2268.                 }
  2269.                 else
  2270.                 {
  2271.                     ret = MMI_FALSE;
  2272.                 }
  2273.                 break;
  2274.             case MMI_PEN_EVENT_LONG_TAP:
  2275.                 /* FALLTHROUGH no break */
  2276.             case MMI_PEN_EVENT_REPEAT:
  2277.                 /* FALLTHROUGH no break */
  2278.             case MMI_PEN_EVENT_MOVE:
  2279.                 if (!m->disable_move_highlight)
  2280.                 {
  2281.                     gui_fixed_list_menu_translate_pen_position(m, y, &item_index);
  2282.                     if (item_index != m->highlighted_item)
  2283.                     {
  2284.                         gui_fixed_list_menu_goto_item(m, item_index);
  2285.                         *menu_event = GUI_LIST_PEN_HIGHLIGHT_CHANGED;
  2286.                     }
  2287.                 }
  2288.                 break;
  2289.             case MMI_PEN_EVENT_UP:
  2290.                 if (!m->disable_up_select)
  2291.                 {
  2292.                     if (PEN_CHECK_BOUND(x, y, m->x, m->y, m->width, m->height))
  2293.                     {
  2294.                         gui_fixed_list_menu_translate_pen_position(m, y, &item_index);
  2295.                         if (item_index != m->highlighted_item)
  2296.                         {
  2297.                             if (!m->disable_move_highlight)
  2298.                             {
  2299.                                 /* If MMI_PEN_EVENT_MOVE is not delivered before moving to this item */
  2300.                                 gui_fixed_list_menu_goto_item(m, item_index);
  2301.                                 *menu_event = GUI_LIST_PEN_HIGHLIGHT_CHANGED;
  2302.                             }
  2303.                         }
  2304.                         else if (pen_state->highlight_changed)
  2305.                         {
  2306.                             *menu_event = GUI_LIST_PEN_NONE;
  2307.                         }
  2308.                         else
  2309.                         {
  2310.                             *menu_event = GUI_LIST_PEN_ITEM_SELECTED;
  2311.                         }
  2312.                     }
  2313.                 }
  2314.                 break;
  2315.             case MMI_PEN_EVENT_ABORT:
  2316.                 /* Do nothing */
  2317.                 break;
  2318.             default:
  2319.                 MMI_ASSERT(0);
  2320.         }
  2321.     }
  2322.     if (ret)
  2323.     {
  2324.         if (pen_state->first_highlighed_item != m->highlighted_item)
  2325.         {
  2326.             pen_state->highlight_changed = 1;
  2327.         }
  2328.     }
  2329.     return ret;
  2330. }
  2331. #endif /* __MMI_TOUCH_SCREEN__ */ 
  2332. /*****************************************************************************
  2333.  * FUNCTION
  2334.  *  gui_hide_fixed_list_menu_highlighted_item
  2335.  * DESCRIPTION
  2336.  *  Hides the highlighted item in a fixed list menu
  2337.  * PARAMETERS
  2338.  *  m       [IN]        Is the fixed list menu object
  2339.  * RETURNS
  2340.  *  void
  2341.  *****************************************************************************/
  2342. void gui_hide_fixed_list_menu_highlighted_item(fixed_list_menu *m)
  2343. {
  2344.     /*----------------------------------------------------------------*/
  2345.     /* Local Variables                                                */
  2346.     /*----------------------------------------------------------------*/
  2347.     S32 x1, y1, x2, y2, y_offset;
  2348.     S32 i;
  2349.     S32 cx1, cy1, cx2, cy2;
  2350.     S32 tx1, ty1, tx2, ty2;
  2351.     S32 iwidth, iheight;
  2352.     U8 done = 0;
  2353.     S32 total_height, counter, list_height;
  2354.     /*----------------------------------------------------------------*/
  2355.     /* Code Body                                                      */
  2356.     /*----------------------------------------------------------------*/
  2357.     gui_get_clip(&cx1, &cy1, &cx2, &cy2);
  2358.     gui_get_text_clip(&tx1, &ty1, &tx2, &ty2);
  2359.     x1 = m->x;
  2360.     y1 = m->y;
  2361.     x2 = x1 + m->width - 1;
  2362.     y2 = y1 + m->height - 1;
  2363.     x1 += 3;
  2364.     x2 -= (3 - m->vbar.width);
  2365.     y1 += 3;
  2366.     y2 -= 3;
  2367.     list_height = m->height - 4;
  2368.     gui_set_text_clip(x1, y1, x2, y2);
  2369.     gui_set_clip(x1, y1, x2, y2);
  2370.     total_height = 0;
  2371.     counter = 0;
  2372.     for (i = m->first_displayed_item; (i < m->n_items && !done); i++)
  2373.     {
  2374.         y_offset = total_height;
  2375.         if (i == m->highlighted_item)
  2376.         {
  2377.         #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  2378.             if (i == m->highlighted_item)
  2379.             {
  2380.                 current_fixed_list_menuitem_display_index = -1;
  2381.             }
  2382.             else
  2383.             {
  2384.                 current_fixed_list_menuitem_display_index = i;
  2385.             }
  2386.         #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  2387.             m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
  2388.             total_height += iheight;
  2389.         }
  2390.         if (total_height > list_height + 1)
  2391.         {
  2392.             done = 1;
  2393.             if ((counter == 0) && (i == m->highlighted_item))
  2394.             {
  2395.                 m->item_hide_function(m->items[i], m->common_item_data, x1, y_offset + y1);
  2396.             }
  2397.         }
  2398.         else
  2399.         {
  2400.             if (i == m->highlighted_item)
  2401.             {
  2402.                 m->item_hide_function(m->items[i], m->common_item_data, x1, y_offset + y1);
  2403.             }
  2404.             counter++;
  2405.         }
  2406.     }
  2407.     gui_set_clip(cx1, cy1, cx2, cy2);
  2408.     gui_set_text_clip(tx1, ty1, tx2, ty2);
  2409. }
  2410. /*****************************************************************************
  2411.  * FUNCTION
  2412.  *  gui_set_fixed_list_menu_item_functions
  2413.  * DESCRIPTION
  2414.  *  Sets the functions used to display generic menuitems
  2415.  * PARAMETERS
  2416.  *  m                                   [IN]        Is the fixed list menu object
  2417.  *  item_display_function               [IN]        Is the function used to display an item
  2418.  *  item_measure_function               [IN]        Is the function used to measure an item
  2419.  *  item_highlight_function             [OUT]       Is the function used to highlight an item
  2420.  *  item_remove_highlight_function      [IN]        Is the function used to remove highlight of an item
  2421.  *  item_hide_function                  [IN]        Is the function used to hide the menuitem
  2422.  *  item_resize_function                [IN]        
  2423.  *  width(?)                            [OUT]       Height      are the dimensions of the menuitem
  2424.  *  item(?)                             [IN]        Is the specific fixed menuitem
  2425.  *  x(?)                                [IN]        Position at which the menuitem was displayed
  2426.  *  y(?)                                [IN]        Position at which the menuitem was displayed
  2427.  *  common_item_data(?)                 [IN]        Common fixed menuitem
  2428.  * RETURNS
  2429.  *  void
  2430.  *****************************************************************************/
  2431. void gui_set_fixed_list_menu_item_functions(
  2432.         fixed_list_menu *m,
  2433.         void (*item_display_function) (void *item, void *common_item_data, S32 x, S32 y),
  2434.         void (*item_measure_function) (void *item, void *common_item_data, S32 *width, S32 *height),
  2435.         void (*item_highlight_function) (void *item, void *common_item_data),
  2436.         void (*item_remove_highlight_function) (void *item, void *common_item_data),
  2437.         void (*item_hide_function) (void *item, void *common_item_data, S32 x, S32 y),
  2438.         void (*item_resize_function) (S32 x, S32 y))
  2439. {
  2440.     /*----------------------------------------------------------------*/
  2441.     /* Local Variables                                                */
  2442.     /*----------------------------------------------------------------*/
  2443.     /*----------------------------------------------------------------*/
  2444.     /* Code Body                                                      */
  2445.     /*----------------------------------------------------------------*/
  2446.     m->item_display_function = item_display_function;
  2447.     m->item_measure_function = item_measure_function;
  2448.     m->item_highlight_function = item_highlight_function;
  2449.     m->item_remove_highlight_function = item_remove_highlight_function;
  2450.     m->item_hide_function = item_hide_function;
  2451.     m->item_resize_function = item_resize_function;
  2452. }
  2453. #ifdef __MMI_TOUCH_SCREEN__
  2454. /*****************************************************************************
  2455.  * FUNCTION
  2456.  *  gui_fixed_list_menu_set_pen_scroll_delay
  2457.  * DESCRIPTION
  2458.  *  Sets the delay time that menu scrolling after scrollbar is scrolled by pen.
  2459.  *  
  2460.  *  Typically used in dynamic and asyncdynamic list menu because it need to load
  2461.  *  data when menu is scrolled.
  2462.  *  
  2463.  *  THE SCROLL DELAY IS IMPLEMENTED IN DYNAMIC AND ASYNCDYNAMIC LIST ONLY.
  2464.  *  THIS IS DUMMY FUNCTION FOR API CONSISTENCY.
  2465.  * PARAMETERS
  2466.  *  m               [IN]        Is the fixed list menu object
  2467.  *  delay_time      [IN]        In milliseconds
  2468.  * RETURNS
  2469.  *  void
  2470.  *****************************************************************************/
  2471. void gui_fixed_list_menu_set_pen_scroll_delay(fixed_list_menu *m, S32 delay_time)
  2472. {
  2473.     /*----------------------------------------------------------------*/
  2474.     /* Local Variables                                                */
  2475.     /*----------------------------------------------------------------*/
  2476.     /*----------------------------------------------------------------*/
  2477.     /* Code Body                                                      */
  2478.     /*----------------------------------------------------------------*/
  2479.     MMI_DBG_ASSERT(delay_time < (S32) 0x0000FFFF);
  2480.     m->pen_scroll_delay_time = (S16) delay_time;
  2481. }
  2482. /*****************************************************************************
  2483.  * FUNCTION
  2484.  *  gui_set_fixed_list_menu_item_pen_function
  2485.  * DESCRIPTION
  2486.  *  Sets the pen handler of menu item
  2487.  * PARAMETERS
  2488.  *  m                           [IN]        Is the fixed list menu object
  2489.  *  item_pen_function           [IN]        Is the function functions used to handle pen events in menu item
  2490.  *  disable_move_highlight      [IN]        Do not send GUI_LIST_PEN_HIGHLIGHT_CHANGED on Pen Move and (sometimes) Pen Up
  2491.  *  disable_up_select           [IN]        Do not send GUI_LIST_PEN_ITEM_SELECTED on Pen Up.
  2492.  * RETURNS
  2493.  *  void
  2494.  *****************************************************************************/
  2495. void gui_set_fixed_list_menu_item_pen_function(
  2496.         fixed_list_menu *m,
  2497.         fixed_menuitem_pen_hdlr item_pen_function,
  2498.         BOOL disable_move_highlight,
  2499.         BOOL disable_up_select)
  2500. {
  2501.     /*----------------------------------------------------------------*/
  2502.     /* Local Variables                                                */
  2503.     /*----------------------------------------------------------------*/
  2504.     /*----------------------------------------------------------------*/
  2505.     /* Code Body                                                      */
  2506.     /*----------------------------------------------------------------*/
  2507.     m->item_pen_function = item_pen_function;
  2508.     m->disable_move_highlight = disable_move_highlight;
  2509.     m->disable_up_select = disable_up_select;
  2510. }
  2511. #endif /* __MMI_TOUCH_SCREEN__ */ 
  2512. /*****************************************************************************
  2513.  * FUNCTION
  2514.  *  gui_set_fixed_list_menu_common_item_data
  2515.  * DESCRIPTION
  2516.  *  Sets the common item data that the list of items should use
  2517.  * PARAMETERS
  2518.  *  m       [IN]        Is the fixed list menu object
  2519.  *  c       [IN]        Is the common item data
  2520.  * RETURNS
  2521.  *  void
  2522.  *****************************************************************************/
  2523. void gui_set_fixed_list_menu_common_item_data(fixed_list_menu *m, void *c)
  2524. {
  2525.     /*----------------------------------------------------------------*/
  2526.     /* Local Variables                                                */
  2527.     /*----------------------------------------------------------------*/
  2528.     /*----------------------------------------------------------------*/
  2529.     /* Code Body                                                      */
  2530.     /*----------------------------------------------------------------*/
  2531.     m->common_item_data = c;
  2532. }
  2533. /* GUI: fixed matrix menu functions             */
  2534. UI_fixed_matrix_menu_theme *current_fixed_matrix_menu_theme = NULL;
  2535. /*****************************************************************************
  2536.  * FUNCTION
  2537.  *  gui_set_fixed_matrix_menu_current_theme
  2538.  * DESCRIPTION
  2539.  *  Applies the current theme to a fixed matrix menu
  2540.  * PARAMETERS
  2541.  *  m       [IN]        Is the fixed matrix menu object
  2542.  * RETURNS
  2543.  *  void
  2544.  *****************************************************************************/
  2545. void gui_set_fixed_matrix_menu_current_theme(fixed_matrix_menu *m)
  2546. {
  2547.     /*----------------------------------------------------------------*/
  2548.     /* Local Variables                                                */
  2549.     /*----------------------------------------------------------------*/
  2550.     /*----------------------------------------------------------------*/
  2551.     /* Code Body                                                      */
  2552.     /*----------------------------------------------------------------*/
  2553.     m->flags |= current_fixed_matrix_menu_theme->flags;
  2554.     m->focussed_filler = current_fixed_matrix_menu_theme->focussed_filler;
  2555.     m->normal_filler = current_fixed_matrix_menu_theme->normal_filler;
  2556.     gui_resize_vertical_scrollbar(
  2557.         &m->vbar,
  2558.         current_fixed_matrix_menu_theme->vbar_width,
  2559.         m->height - current_fixed_matrix_menu_theme->hbar_height);
  2560.     gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - current_fixed_matrix_menu_theme->vbar_width, m->y);
  2561.     gui_resize_horizontal_scrollbar(
  2562.         &m->hbar,
  2563.         m->width - current_fixed_matrix_menu_theme->vbar_width,
  2564.         current_fixed_matrix_menu_theme->hbar_height);
  2565.     gui_move_horizontal_scrollbar(&m->hbar, m->x, m->y + m->height - current_fixed_matrix_menu_theme->hbar_height);
  2566. }
  2567. /*****************************************************************************
  2568.  * FUNCTION
  2569.  *  gui_set_fixed_matrix_menu_theme
  2570.  * DESCRIPTION
  2571.  *  Applies the given theme to a fixed matrix menu
  2572.  * PARAMETERS
  2573.  *  m       [IN]        Is the fixed matrix menu object
  2574.  *  t       [?]         
  2575.  * RETURNS
  2576.  *  void
  2577.  *****************************************************************************/
  2578. void gui_set_fixed_matrix_menu_theme(fixed_matrix_menu *m, UI_fixed_matrix_menu_theme *t)
  2579. {
  2580.     /*----------------------------------------------------------------*/
  2581.     /* Local Variables                                                */
  2582.     /*----------------------------------------------------------------*/
  2583.     /*----------------------------------------------------------------*/
  2584.     /* Code Body                                                      */
  2585.     /*----------------------------------------------------------------*/
  2586.     m->flags |= t->flags;
  2587.     m->focussed_filler = t->focussed_filler;
  2588.     m->normal_filler = t->normal_filler;
  2589.     gui_resize_vertical_scrollbar(
  2590.         &m->vbar,
  2591.         current_fixed_matrix_menu_theme->vbar_width,
  2592.         m->height - current_fixed_matrix_menu_theme->hbar_height);
  2593.     gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - current_fixed_matrix_menu_theme->vbar_width, m->y);
  2594.     gui_resize_horizontal_scrollbar(
  2595.         &m->hbar,
  2596.         m->width - current_fixed_matrix_menu_theme->vbar_width,
  2597.         current_fixed_matrix_menu_theme->hbar_height);
  2598.     gui_move_horizontal_scrollbar(&m->hbar, m->x, m->y + m->height - current_fixed_matrix_menu_theme->hbar_height);
  2599. }
  2600. /*****************************************************************************
  2601.  * FUNCTION
  2602.  *  gui_create_fixed_matrix_menu
  2603.  * DESCRIPTION
  2604.  *  Creates a fixed matrix menu
  2605.  * PARAMETERS
  2606.  *  m           [IN]        Is the fixed matrix menu object  (pre-allocated)
  2607.  *  x           [IN]        Is the left-top corner position
  2608.  *  y           [IN]        Is the left-top corner position
  2609.  *  width       [IN]        Are the dimensions
  2610.  *  height      [IN]        Are the dimensions
  2611.  * RETURNS
  2612.  *  void
  2613.  *****************************************************************************/
  2614. /* extern wgui_inline_item wgui_inline_items; */
  2615. extern U8 matrix_main_menu_highlight_bitmap_data[];
  2616. void gui_create_fixed_matrix_menu(fixed_matrix_menu *m, S32 x, S32 y, S32 width, S32 height)
  2617. {
  2618.     /*----------------------------------------------------------------*/
  2619.     /* Local Variables                                                */
  2620.     /*----------------------------------------------------------------*/
  2621.     /*----------------------------------------------------------------*/
  2622.     /* Code Body                                                      */
  2623.     /*----------------------------------------------------------------*/
  2624.     m->flags = 0;
  2625.     m->x = x;
  2626.     m->y = y;
  2627.     m->width = width;
  2628.     m->height = height;
  2629.     m->n_items = 0;
  2630.     m->n_columns = 0;
  2631.     m->n_rows = 0;
  2632.     m->items = NULL;
  2633.     m->highlighted_item = 0;
  2634.     m->first_displayed_row = 0;
  2635.     m->first_displayed_column = 0;
  2636.     m->displayed_columns = 0;
  2637.     m->displayed_rows = 0;
  2638.     m->highlighted_column = 0;
  2639.     m->highlighted_row = 0;
  2640.     m->item_height = 0;
  2641.     m->item_width = 0;
  2642.     gui_set_fixed_matrix_menu_current_theme(m);
  2643.     gui_create_vertical_scrollbar(
  2644.         &m->vbar,
  2645.         m->x + m->width - current_fixed_matrix_menu_theme->vbar_width - 1,
  2646.         m->y + 2,
  2647.         current_fixed_matrix_menu_theme->vbar_width,
  2648.         m->height - current_fixed_matrix_menu_theme->hbar_height - 3);
  2649.     gui_create_horizontal_scrollbar(
  2650.         &m->hbar,
  2651.         m->x + 2,
  2652.         m->y + m->height - current_fixed_matrix_menu_theme->hbar_height - 1,
  2653.         m->width - current_fixed_matrix_menu_theme->vbar_width - 3,
  2654.         current_fixed_matrix_menu_theme->hbar_height);
  2655.     m->item_highlighted = UI_dummy_function_s32;
  2656.     m->item_unhighlighted = UI_dummy_function_s32;
  2657.     m->item_display_function = UI_fixed_menuitem_dummy_display_function;
  2658.     m->item_hide_function = UI_fixed_menuitem_dummy_display_function;
  2659.     m->item_measure_function = UI_fixed_menuitem_dummy_measure_function;
  2660.     m->item_highlight_function = UI_fixed_menuitem_dummy_highlight_function;
  2661.     m->item_remove_highlight_function = UI_fixed_menuitem_dummy_remove_highlight_function;
  2662.     m->trigger_top_function = UI_dummy_function;
  2663.     m->trigger_bottom_function = UI_dummy_function;
  2664.     m->last_hilited_x = -1;
  2665.     m->last_hilited_y = -1;
  2666.     m->last_highlighted_item = -1;
  2667.     m->cache_bmp_x1 = 0;
  2668.     m->cache_bmp_x2 = 0;
  2669.     m->cache_bmp_y1 = 0;
  2670.     m->cache_bmp_y2 = 0;
  2671. #if defined(__MMI_MATRIX_MAIN_MENU_FULL_BACKGROUND__) && defined(__MMI_MATRIX_MAIN_MENU_OPTIMIZE__)
  2672.     m->buffer.buf_ptr = opt_mm_buf;
  2673. #else 
  2674.     m->buffer.buf_ptr = (U8*) & matrix_main_menu_highlight_bitmap_data;
  2675. #endif 
  2676. #ifdef __MMI_TOUCH_SCREEN__
  2677.     m->pen_event_current_selected_callback_function = NULL;
  2678.     m->pen_event_default_selected_callback_function = NULL;
  2679.     memset(&(m->pen_state), 0, sizeof(gui_matrix_pen_state_struct));
  2680. #ifdef __MMI_BI_DEGREE_MAIN_MENU_STYLE__
  2681.     m->up_ind_area.x = 0;
  2682.     m->up_ind_area.y = 0;
  2683.     m->up_ind_area.width = 0;
  2684.     m->up_ind_area.height = 0;
  2685.     m->up_ind_area.string = NULL;
  2686.     m->up_ind_area.img_id = 0;
  2687.     m->down_ind_area.x = 0;
  2688.     m->down_ind_area.y = 0;
  2689.     m->down_ind_area.width = 0;
  2690.     m->down_ind_area.height = 0;
  2691.     m->down_ind_area.string = NULL;
  2692.     m->down_ind_area.img_id = 0;
  2693. #endif /* __MMI_BI_DEGREE_MAIN_MENU_STYLE__ */ 
  2694. #endif /* __MMI_TOUCH_SCREEN__ */ 
  2695. }
  2696. /*****************************************************************************
  2697.  * FUNCTION
  2698.  *  gui_fixed_matrix_menu_auto_calculate
  2699.  * DESCRIPTION
  2700.  *  Automatically calculate a fixed matrix menu
  2701.  *  (Decides the number of columns / rows to be displayed
  2702.  *  and the number of items per row or column)
  2703.  *  
  2704.  *  Internal function
  2705.  * PARAMETERS
  2706.  *  m           [IN]        Is the fixed matrix menu object
  2707.  *  width       [?]         
  2708.  *  height      [?]         
  2709.  * RETURNS
  2710.  *  void
  2711.  *****************************************************************************/
  2712. void gui_fixed_matrix_menu_auto_calculate(fixed_matrix_menu *m, S32 *width, S32 *height)
  2713. {
  2714.     /*----------------------------------------------------------------*/
  2715.     /* Local Variables                                                */
  2716.     /*----------------------------------------------------------------*/
  2717.     S32 x1, y1, x2, y2;
  2718.     S32 menu_width, menu_height;
  2719.     /*----------------------------------------------------------------*/
  2720.     /* Code Body                                                      */
  2721.     /*----------------------------------------------------------------*/
  2722.     x1 = m->x;
  2723.     y1 = m->y;
  2724.     x2 = x1 + m->width - 1;
  2725.     y2 = y1 + m->height - 1;
  2726. #ifdef __MMI_BI_DEGREE_MAIN_MENU_STYLE__
  2727.     if (m->flags & UI_MATRIX_MENU_SHOW_IND_AREA)
  2728.     {
  2729.         menu_height = y2 - y1 - MMI_BI_DEGREE_MAIN_MENU_ARROW_BAR_HEIGHT + 1;
  2730.     }
  2731.     else
  2732. #endif /* __MMI_BI_DEGREE_MAIN_MENU_STYLE__ */ 
  2733.         menu_height = y2 - y1 + 1;
  2734.     menu_width = x2 - x1 + 1;
  2735.     /* Autocalculate unspecified parameters               */
  2736.     if (m->n_rows == 0 && m->n_columns == 0)    /* both rows and columns is not specified by wgui */
  2737.     {
  2738.         S32 rows, columns, reminders;
  2739.         columns = menu_width / m->item_width;
  2740.         rows = pixtel_highdivide(m->n_items, columns);
  2741.         while ((columns * 2) / (rows * 3) > 1)
  2742.         {
  2743.             columns--;
  2744.             rows = pixtel_highdivide(m->n_items, columns);
  2745.         }
  2746.         reminders = m->n_items % columns;
  2747.         while (reminders != 0)
  2748.         {
  2749.             if (reminders + rows - 1 > columns - 1)
  2750.             {
  2751.                 break;
  2752.             }
  2753.             else
  2754.             {
  2755.                 columns--;
  2756.                 rows = pixtel_highdivide(m->n_items, columns);
  2757.                 reminders = m->n_items % columns;
  2758.             }
  2759.         }
  2760.         m->n_rows = rows;
  2761.         m->n_columns = columns;
  2762.         if (m->item_height <= 0)
  2763.         {
  2764.             m->item_height = menu_height / m->n_rows;
  2765.         }
  2766.         if (m->item_width <= 0)
  2767.         {
  2768.             m->item_width = menu_width / m->n_columns;
  2769.         }
  2770.     }
  2771.     else
  2772.     {
  2773.         if (m->item_height <= 0)
  2774.         {
  2775.             m->item_height = menu_height / m->n_rows;
  2776.         }
  2777.         if (m->n_rows <= 0)
  2778.         {
  2779.             m->n_rows = menu_height / m->item_height;
  2780.         }
  2781.         if (m->item_width <= 0)
  2782.         {
  2783.             m->item_width = menu_width / m->n_columns;
  2784.         }
  2785.         if (m->n_columns <= 0)
  2786.         {
  2787.             m->n_columns = menu_width / m->item_width;
  2788.         }
  2789.     }
  2790.     /* Fix rows and columns to match the number of items     */
  2791.     if (m->n_items < m->n_columns)
  2792.     {
  2793.         m->n_rows = 1;
  2794.         m->n_columns = m->n_items;
  2795.     }
  2796.     else
  2797.     {
  2798.         if (m->n_rows > pixtel_highdivide(m->n_items, m->n_columns))
  2799.         {
  2800.             m->n_rows = pixtel_highdivide(m->n_items, m->n_columns);
  2801.         }
  2802.         if ((m->n_columns * m->n_rows) < m->n_items)
  2803.         {
  2804.             m->n_rows = pixtel_highdivide(m->n_items, m->n_columns);
  2805.         }
  2806.     }
  2807.     *width = menu_width;
  2808.     *height = menu_height;
  2809. }
  2810. /*****************************************************************************
  2811.  * FUNCTION
  2812.  *  gui_fixed_matrix_menu_auto_configure
  2813.  * DESCRIPTION
  2814.  *  Automatically configures a fixed matrix menu
  2815.  *  (Decides the number of columns / rows to be displayed
  2816.  *  and the number of items per row or column)
  2817.  *  
  2818.  *  Internal function
  2819.  * PARAMETERS
  2820.  *  m       [IN]        Is the fixed matrix menu object
  2821.  * RETURNS
  2822.  *  void
  2823.  *****************************************************************************/
  2824. void gui_fixed_matrix_menu_auto_configure(fixed_matrix_menu *m)
  2825. {
  2826.     /*----------------------------------------------------------------*/
  2827.     /* Local Variables                                                */
  2828.     /*----------------------------------------------------------------*/
  2829.     S32 x1, y1, x2, y2;
  2830.     S32 menu_width, menu_height;
  2831.     U8 show_vbar = 0, show_hbar = 0;
  2832.     /*----------------------------------------------------------------*/
  2833.     /* Code Body                                                      */
  2834.     /*----------------------------------------------------------------*/
  2835.     if ((m->n_columns <= 0) && (m->item_width <= 0))
  2836.     {
  2837.         return;
  2838.     }
  2839.     if ((m->n_rows <= 0) && (m->item_height <= 0))
  2840.     {
  2841.         return;
  2842.     }
  2843.     if (m->n_items == 0)
  2844.     {
  2845.         return;
  2846.     }
  2847.     x1 = m->x;
  2848.     y1 = m->y;
  2849.     x2 = x1 + m->width - 1;
  2850.     y2 = y1 + m->height - 1;
  2851.     menu_height = y2 - y1 + 1;
  2852.     menu_width = x2 - x1 + 1;
  2853.     gui_fixed_matrix_menu_auto_calculate(m, &menu_width, &menu_height);
  2854.     /* Calculate the number of displayed rows and columns    */
  2855.     m->displayed_rows = menu_height / m->item_height;
  2856.     m->displayed_columns = menu_width / m->item_width;
  2857.     if (m->displayed_rows < m->n_rows)
  2858.     {
  2859.         m->flags |= UI_MATRIX_MENU_SHOW_IND_AREA;
  2860.         gui_fixed_matrix_menu_auto_calculate(m, &menu_width, &menu_height);
  2861.     }
  2862.     if (!(m->flags & UI_MATRIX_MENU_DISABLE_SCROLLBAR))
  2863.     {
  2864.         if ((!(m->flags & UI_MATRIX_MENU_AUTO_DISABLE_SCROLLBAR)) ||
  2865.             ((m->flags & UI_MATRIX_MENU_AUTO_DISABLE_SCROLLBAR) && (m->n_rows > m->displayed_rows)))
  2866.         {
  2867.             show_vbar = 1;
  2868.         }
  2869.         if ((!(m->flags & UI_MATRIX_MENU_AUTO_DISABLE_SCROLLBAR)) ||
  2870.             ((m->flags & UI_MATRIX_MENU_AUTO_DISABLE_SCROLLBAR) && (m->n_columns > m->displayed_columns)))
  2871.         {
  2872.             show_hbar = 1;
  2873.         }
  2874.     }
  2875.     if (show_vbar)
  2876.     {
  2877.         x2 -= m->vbar.width;
  2878.     }
  2879.     if (show_hbar)
  2880.     {
  2881.         y2 -= m->hbar.height;
  2882.     }
  2883.     menu_height = y2 - y1 + 1;
  2884.     menu_width = x2 - x1 + 1;
  2885.     /* Recalculate the number of rows that can be displayed  */
  2886.     m->displayed_rows = menu_height / m->item_height;
  2887.     m->displayed_columns = menu_width / m->item_width;
  2888.     /* Fix the number of displayed rows and columns       */
  2889.     if (m->displayed_columns > m->n_columns && 
  2890. !(m->n_columns <= 1 && (m->flags & UI_MATRIX_MENU_ALIGN_LEFT_TOP)))
  2891.     {
  2892.         m->displayed_columns = m->n_columns;
  2893.     }
  2894.     if (m->displayed_rows > m->n_rows && 
  2895. !(m->n_rows <= 1 && (m->flags & UI_MATRIX_MENU_ALIGN_LEFT_TOP)))
  2896.     {
  2897.         m->displayed_rows = m->n_rows;
  2898.     }
  2899. #ifdef __MMI_BI_DEGREE_MAIN_MENU_STYLE__
  2900.     else
  2901.     {
  2902.         if (MMI_current_menu_type == LIST_MATRIX_MENU)
  2903.         {
  2904.             m->displayed_rows = menu_height / m->item_height;
  2905.         }
  2906.     }
  2907. #endif /* __MMI_BI_DEGREE_MAIN_MENU_STYLE__ */ 
  2908.     /* Enable/Disable scrollbars                       */
  2909.     if (show_vbar)
  2910.     {
  2911.         m->flags |= UI_MATRIX_MENU_SHOW_VERTICAL_SCROLLBAR;
  2912.     }
  2913.     else
  2914.     {
  2915.         m->flags &= ~UI_MATRIX_MENU_SHOW_VERTICAL_SCROLLBAR;
  2916.     }
  2917.     if (show_hbar)
  2918.     {
  2919.         m->flags |= UI_MATRIX_MENU_SHOW_HORIZONTAL_SCROLLBAR;
  2920.     }
  2921.     else
  2922.     {
  2923.         m->flags &= ~UI_MATRIX_MENU_SHOW_HORIZONTAL_SCROLLBAR;
  2924.     }
  2925.     if (show_vbar && (!show_hbar))
  2926.     {
  2927.         gui_resize_vertical_scrollbar(&m->vbar, m->vbar.width, m->height);
  2928.     }
  2929.     if (show_hbar && (!show_vbar))
  2930.     {
  2931.         gui_resize_horizontal_scrollbar(&m->hbar, m->width, m->hbar.height);
  2932.     }
  2933.     if (show_vbar && show_hbar)
  2934.     {
  2935.         gui_resize_vertical_scrollbar(&m->vbar, m->vbar.width, m->height - m->hbar.height);
  2936.         gui_resize_horizontal_scrollbar(&m->hbar, m->width - m->vbar.width, m->hbar.height);
  2937.     }
  2938.     gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - current_fixed_matrix_menu_theme->vbar_width, m->y);
  2939.     gui_move_horizontal_scrollbar(&m->hbar, m->x, m->y + m->height - current_fixed_matrix_menu_theme->hbar_height);
  2940. }
  2941. /*****************************************************************************
  2942.  * FUNCTION
  2943.  *  gui_fixed_matrix_menu_setup
  2944.  * DESCRIPTION
  2945.  *  Used to set the number of rows, columns and item dimensions
  2946.  * PARAMETERS
  2947.  *  m               [IN]        Is the fixed matrix menu object
  2948.  *  item_width      [IN]        Is the width of each item  | Any one of these two should be specified
  2949.  *  item_height     [IN]        Is the height of each item | Any one of these two should be specified
  2950.  *  n_columns       [IN]        Is the number of columns   | and the other can be zero.
  2951.  *  n_rows          [IN]        Is the number of rows      | and the other can be zero.
  2952.  * RETURNS
  2953.  *  void
  2954.  *****************************************************************************/
  2955. void gui_fixed_matrix_menu_setup(fixed_matrix_menu *m, S32 item_width, S32 item_height, S32 n_columns, S32 n_rows)
  2956. {
  2957.     /*----------------------------------------------------------------*/
  2958.     /* Local Variables                                                */
  2959.     /*----------------------------------------------------------------*/
  2960.     /*----------------------------------------------------------------*/
  2961.     /* Code Body                                                      */
  2962.     /*----------------------------------------------------------------*/
  2963.     m->item_width = item_width;
  2964.     m->item_height = item_height;
  2965.     m->n_columns = n_columns;
  2966.     m->n_rows = n_rows;
  2967.     gui_fixed_matrix_menu_auto_configure(m);
  2968. }
  2969. /*****************************************************************************
  2970.  * FUNCTION
  2971.  *  gui_resize_fixed_matrix_menu
  2972.  * DESCRIPTION
  2973.  *  Changes the size of a fixed matrix menu
  2974.  * PARAMETERS
  2975.  *  m           [IN]        Is the fixed matrix menu object
  2976.  *  width       [IN]        Is the new width
  2977.  *  height      [IN]        Is the new height
  2978.  * RETURNS
  2979.  *  void
  2980.  *****************************************************************************/
  2981. void gui_resize_fixed_matrix_menu(fixed_matrix_menu *m, S32 width, S32 height)
  2982. {
  2983.     /*----------------------------------------------------------------*/
  2984.     /* Local Variables                                                */
  2985.     /*----------------------------------------------------------------*/
  2986.     /*----------------------------------------------------------------*/
  2987.     /* Code Body                                                      */
  2988.     /*----------------------------------------------------------------*/
  2989.     m->width = width;
  2990.     m->height = height;
  2991.     gui_resize_vertical_scrollbar(
  2992.         &m->vbar,
  2993.         current_fixed_matrix_menu_theme->vbar_width,
  2994.         m->height - current_fixed_matrix_menu_theme->hbar_height);
  2995.     gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - current_fixed_matrix_menu_theme->vbar_width, m->y);
  2996.     gui_resize_horizontal_scrollbar(
  2997.         &m->hbar,
  2998.         m->width - current_fixed_matrix_menu_theme->vbar_width,
  2999.         current_fixed_matrix_menu_theme->hbar_height);
  3000.     gui_move_horizontal_scrollbar(&m->hbar, m->x, m->y + m->height - current_fixed_matrix_menu_theme->hbar_height);
  3001.     gui_fixed_matrix_menu_auto_configure(m);
  3002. }
  3003. /*****************************************************************************
  3004.  * FUNCTION
  3005.  *  gui_move_fixed_matrix_menu
  3006.  * DESCRIPTION
  3007.  *  Moves the fixed matrix menu to a new location
  3008.  * PARAMETERS
  3009.  *  m       [IN]        Is the fixed matrix menu object
  3010.  *  x       [IN]        Is the new left-top corner position
  3011.  *  y       [IN]        Is the new left-top corner position
  3012.  * RETURNS
  3013.  *  void
  3014.  *****************************************************************************/
  3015. void gui_move_fixed_matrix_menu(fixed_matrix_menu *m, S32 x, S32 y)
  3016. {
  3017.     /*----------------------------------------------------------------*/
  3018.     /* Local Variables                                                */
  3019.     /*----------------------------------------------------------------*/
  3020.     /*----------------------------------------------------------------*/
  3021.     /* Code Body                                                      */
  3022.     /*----------------------------------------------------------------*/
  3023.     m->x = x;
  3024.     m->y = y;
  3025.     gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - current_fixed_matrix_menu_theme->vbar_width, m->y);
  3026.     gui_move_horizontal_scrollbar(&m->hbar, m->x, m->y + m->height - current_fixed_matrix_menu_theme->hbar_height);
  3027.     gui_fixed_matrix_menu_auto_configure(m);
  3028. }
  3029. /*****************************************************************************
  3030.  * FUNCTION
  3031.  *  gui_fixed_matrix_menu_locate_highlighted_item
  3032.  * DESCRIPTION
  3033.  *  Used to locate the highlighted item in the fixed matrix menu
  3034.  *  
  3035.  *  Internal function
  3036.  * PARAMETERS
  3037.  *  m       [IN]        Is the fixed matrix menu object
  3038.  * RETURNS
  3039.  *  void
  3040.  *****************************************************************************/
  3041. void gui_fixed_matrix_menu_locate_highlighted_item(fixed_matrix_menu *m)
  3042. {
  3043.     /*----------------------------------------------------------------*/
  3044.     /* Local Variables                                                */
  3045.     /*----------------------------------------------------------------*/
  3046.     /*----------------------------------------------------------------*/
  3047.     /* Code Body                                                      */
  3048.     /*----------------------------------------------------------------*/
  3049.     m->highlighted_column = m->highlighted_item % m->n_columns;
  3050.     m->highlighted_row = m->highlighted_item / m->n_columns;
  3051.     if (m->highlighted_column < 0)
  3052.     {
  3053.         m->highlighted_column = 0;
  3054.     }
  3055.     if (m->highlighted_row < 0)
  3056.     {
  3057.         m->highlighted_row = 0;
  3058.     }
  3059.     if (m->highlighted_column > (m->n_columns - 1))
  3060.     {
  3061.         m->highlighted_column = m->n_columns - 1;
  3062.     }
  3063.     if (m->highlighted_row > (m->n_rows - 1))
  3064.     {
  3065.         m->highlighted_row = m->n_rows - 1;
  3066.     }
  3067.     if (m->flags & UI_MATRIX_MENU_FIRST_SHIFT_HIGHLIGHTED_ROW)
  3068.     {
  3069.         m->first_displayed_row = m->highlighted_row;
  3070.         if (m->first_displayed_row > m->n_rows - m->displayed_rows)
  3071.         {
  3072.             m->first_displayed_row = m->n_rows - m->displayed_rows;
  3073.         }
  3074.     }
  3075.     else if (m->flags & UI_MATRIX_MENU_LAST_SHIFT_HIGHLIGHTED_ROW)
  3076.     {
  3077.         m->first_displayed_row = m->highlighted_row - m->displayed_rows + 1;
  3078.         if (m->first_displayed_row < 0)
  3079.         {
  3080.             m->first_displayed_row = 0;
  3081.         }
  3082.     }
  3083.     if (m->flags & UI_MATRIX_MENU_FIRST_SHIFT_HIGHLIGHTED_COL)
  3084.     {
  3085.         m->first_displayed_column = m->highlighted_column;
  3086.         if (m->first_displayed_column > m->n_columns - m->displayed_columns)
  3087.         {
  3088.             m->first_displayed_column = m->n_columns - m->displayed_columns;
  3089.         }
  3090.     }
  3091.     else if (m->flags & UI_MATRIX_MENU_LAST_SHIFT_HIGHLIGHTED_COL)
  3092.     {
  3093.         m->first_displayed_column = m->highlighted_column - m->displayed_columns + 1;
  3094.         if (m->first_displayed_column < 0)
  3095.         {
  3096.             m->first_displayed_column = 0;
  3097.         }
  3098.     }
  3099.     if (m->highlighted_column < m->first_displayed_column)
  3100.     {
  3101.         m->first_displayed_column = m->highlighted_column;
  3102.     }
  3103.     if (m->highlighted_row < m->first_displayed_row)
  3104.     {
  3105.         m->first_displayed_row = m->highlighted_row;
  3106.     }
  3107.     if (m->highlighted_column > (m->first_displayed_column + m->displayed_columns - 1))
  3108.     {
  3109.         m->first_displayed_column = (m->highlighted_column - m->displayed_columns + 1);
  3110.         if (m->first_displayed_column > (m->n_columns - m->displayed_columns))
  3111.         {
  3112.             m->first_displayed_column = (m->n_columns - m->displayed_columns);
  3113.         }
  3114.     }
  3115.     if (m->highlighted_row > (m->first_displayed_row + m->displayed_rows - 1))
  3116.     {
  3117.         m->first_displayed_row = (m->highlighted_row - m->displayed_rows + 1);
  3118.         if (m->first_displayed_row > (m->n_rows - m->displayed_rows))
  3119.         {
  3120.             m->first_displayed_row = (m->n_rows - m->displayed_rows);
  3121.         }
  3122.     }
  3123. }
  3124. /*****************************************************************************
  3125.  * FUNCTION
  3126.  *  gui_fixed_matrix_menu_goto_next_item
  3127.  * DESCRIPTION
  3128.  *  Highlights the next item
  3129.  *  
  3130.  *  Does not redraw the fixed matrix menu
  3131.  * PARAMETERS
  3132.  *  m       [IN]        Is the fixed matrix menu object
  3133.  * RETURNS
  3134.  *  void
  3135.  *****************************************************************************/
  3136. void gui_fixed_matrix_menu_goto_next_item(fixed_matrix_menu *m)
  3137. {
  3138.     /*----------------------------------------------------------------*/
  3139.     /* Local Variables                                                */
  3140.     /*----------------------------------------------------------------*/
  3141.     S32 old_highlighted_item = m->highlighted_item;
  3142.     /*----------------------------------------------------------------*/
  3143.     /* Code Body                                                      */
  3144.     /*----------------------------------------------------------------*/
  3145.     if (m->highlighted_item >= (m->n_items - 1))
  3146.     {
  3147.         if (m->flags & UI_MATRIX_MENU_VERTICAL_TRIGGER)
  3148.         {
  3149.             if (m->trigger_bottom_function)
  3150.             {
  3151.                 m->trigger_bottom_function();
  3152.             }
  3153.             return; /* exit point */
  3154.         }
  3155.         else if (m->flags & UI_MATRIX_MENU_LOOP)
  3156.         {
  3157.             m->highlighted_item = 0;
  3158.         }
  3159.         else
  3160.         {
  3161.             return;
  3162.         }
  3163.     }
  3164.     else
  3165.     {
  3166.         m->highlighted_item++;
  3167.     }
  3168.     gui_fixed_matrix_menu_locate_highlighted_item(m);
  3169.     if (old_highlighted_item != m->highlighted_item)
  3170.     {
  3171.         if ((old_highlighted_item >= 0) && (old_highlighted_item < m->n_items))
  3172.         {
  3173.             m->item_remove_highlight_function(m->items[old_highlighted_item], m->common_item_data);
  3174.         }
  3175.         if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
  3176.         {
  3177.             m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
  3178.         }
  3179.         m->item_unhighlighted(old_highlighted_item);
  3180.         m->item_highlighted(m->highlighted_item);
  3181.     }
  3182. }
  3183. /*****************************************************************************
  3184.  * FUNCTION
  3185.  *  gui_fixed_matrix_menu_goto_previous_item
  3186.  * DESCRIPTION
  3187.  *  Highlights the previous item
  3188.  *  
  3189.  *  Does not redraw the fixed matrix menu
  3190.  * PARAMETERS
  3191.  *  m       [IN]        Is the fixed matrix menu object
  3192.  * RETURNS
  3193.  *  void
  3194.  *****************************************************************************/
  3195. void gui_fixed_matrix_menu_goto_previous_item(fixed_matrix_menu *m)
  3196. {
  3197.     /*----------------------------------------------------------------*/
  3198.     /* Local Variables                                                */
  3199.     /*----------------------------------------------------------------*/
  3200.     S32 old_highlighted_item = m->highlighted_item;
  3201.     /*----------------------------------------------------------------*/
  3202.     /* Code Body                                                      */
  3203.     /*----------------------------------------------------------------*/
  3204.     if (m->highlighted_item <= 0)
  3205.     {
  3206.         if (m->flags & UI_MATRIX_MENU_VERTICAL_TRIGGER)
  3207.         {
  3208.             if (m->trigger_top_function)
  3209.             {
  3210.                 m->trigger_top_function();
  3211.             }
  3212.             return; /* exit point */
  3213.         }
  3214.         else if (m->flags & UI_MATRIX_MENU_LOOP)
  3215.         {
  3216.             m->highlighted_item = m->n_items - 1;
  3217.         }
  3218.         else
  3219.         {
  3220.             return;
  3221.         }
  3222.     }
  3223.     else
  3224.     {
  3225.         m->highlighted_item--;
  3226.     }
  3227.     gui_fixed_matrix_menu_locate_highlighted_item(m);
  3228.     if (old_highlighted_item != m->highlighted_item)
  3229.     {
  3230.         if ((old_highlighted_item >= 0) && (old_highlighted_item < m->n_items))
  3231.         {
  3232.             m->item_remove_highlight_function(m->items[old_highlighted_item], m->common_item_data);
  3233.         }
  3234.         if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
  3235.         {
  3236.             m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
  3237.         }
  3238.         m->item_unhighlighted(old_highlighted_item);
  3239.         m->item_highlighted(m->highlighted_item);
  3240.     }
  3241. }
  3242. /*****************************************************************************
  3243.  * FUNCTION
  3244.  *  gui_fixed_matrix_menu_goto_previous_row
  3245.  * DESCRIPTION
  3246.  *  Highlights an item in the previous row
  3247.  *  
  3248.  *  Does not redraw the fixed matrix menu
  3249.  * PARAMETERS
  3250.  *  m       [IN]        Is the fixed matrix menu object
  3251.  * RETURNS
  3252.  *  void
  3253.  *****************************************************************************/
  3254. void gui_fixed_matrix_menu_goto_previous_row(fixed_matrix_menu *m)
  3255. {
  3256.     /*----------------------------------------------------------------*/
  3257.     /* Local Variables                                                */
  3258.     /*----------------------------------------------------------------*/
  3259.     S32 old_highlighted_item;
  3260.     S32 old_highlighted_row;
  3261.     /*----------------------------------------------------------------*/
  3262.     /* Code Body                                                      */
  3263.     /*----------------------------------------------------------------*/
  3264.     old_highlighted_row = m->highlighted_row;
  3265.     old_highlighted_item = m->highlighted_item;