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

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*******************************************************************************
  36.  * Filename:
  37.  * ---------
  38.  * gui_dynamic_menus.c
  39.  *
  40.  * Project:
  41.  * --------
  42.  *   PlutoMMI
  43.  *
  44.  * Description:
  45.  * ------------
  46.  *   In order to use limited memory (size decided in compile-time) to load unlimited items (size decide in run-time) 
  47.  *   to a category screen, a modification in MMI for dynamic item loading is required as the following.
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  * -------
  53.  *
  54.  *============================================================================
  55.  *             HISTORY
  56.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  57.  *------------------------------------------------------------------------------
  58.  * removed!
  59.  *
  60.  * removed!
  61.  * removed!
  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.  *------------------------------------------------------------------------------
  121.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  122.  *============================================================================
  123.  ****************************************************************************/
  124. #include "MMI_Features.h"
  125. #include "gui_config.h"
  126. #include "gui_dynamic_menus.h"
  127. #include "wgui_dynamic_menuitems.h"
  128. #include "gui_windows.h"
  129. #include "DebugInitDef.h"
  130. #include "wgui_categories_util.h"
  131. /* PMT NEERAJ START 20050616 */
  132. #ifdef __MMI_UI_TAB_PANE__
  133. #include "wgui_tab.h"
  134. #endif 
  135. //PMT NEERAJ END 20050616
  136. //MTK Elvis for R2L characters
  137. extern BOOL r2lMMIFlag;
  138. /* MTK end */
  139. /*
  140.  * NOTE: we use load_chunk_dynamic_item_buffer from 
  141.  * first_displayed_item to (m->last_displayed_item + 1).
  142.  * It's because some UI functions access data of (m->last_displayed_item + 1).
  143.  *
  144.  */
  145. #ifdef __MMI_TOUCH_SCREEN__
  146. static void gui_dynamic_list_abort_scroll_timer(void);
  147. #endif 
  148. /* PMT VIKAS START 20050707 */
  149. #ifdef __MMI_UI_DALMATIAN_FIXEDLIST__
  150. extern MMI_theme *current_MMI_theme;
  151. extern line_draw;
  152. #endif /* __MMI_UI_DALMATIAN_FIXEDLIST__ */ 
  153. /* PMT VIKAS END 20050707 */
  154. /*****************************************************************************
  155.  * FUNCTION
  156.  *  gui_dynamic_list_menu_locate_highlighted_item
  157.  * DESCRIPTION
  158.  *  
  159.  * PARAMETERS
  160.  *  m       [?]     
  161.  * RETURNS
  162.  *  void
  163.  *****************************************************************************/
  164. void gui_dynamic_list_menu_locate_highlighted_item(fixed_list_menu *m)
  165. {
  166.     /*----------------------------------------------------------------*/
  167.     /* Local Variables                                                */
  168.     /*----------------------------------------------------------------*/
  169.     /* FIXME. handle the case that m->height < iheight */
  170.     S32 iwidth, iheight;
  171.     /*----------------------------------------------------------------*/
  172.     /* Code Body                                                      */
  173.     /*----------------------------------------------------------------*/
  174.     if (m->flags & UI_LIST_MENU_FIRST_SHIFT_HIGHLIGHTED_ITEM)
  175.     {
  176.         S32 total_height = 0, i;
  177.         U8 done = 0;
  178.         S32 list_height = m->height;
  179.         m->flags &= ~UI_LIST_MENU_FIRST_SHIFT_HIGHLIGHTED_ITEM;
  180.         m->first_displayed_item = m->highlighted_item;
  181.         for (i = m->n_items - 1; (i >= 0) && (!done); i--)
  182.         {
  183.             /* Use NULL to measure menu item height because the data of menu item might not be loaded yet */
  184.             //PMT NEERAJ START 20050712
  185.             //PMT NEERAJ START 20050825
  186.         #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  187.             /* PMT NEERAJ END 20050825 */
  188.             if (i == m->highlighted_item)
  189.             {
  190.                 current_fixed_list_menuitem_display_index = -1;
  191.             }
  192.             else
  193.             {
  194.                 current_fixed_list_menuitem_display_index = i;
  195.             }
  196.         #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  197.             /* PMT NEERAJ END 20050712 */
  198.             m->item_measure_function(NULL, m->common_item_data, &iwidth, &iheight);
  199.             total_height += iheight;
  200.             if (total_height > list_height + 1)
  201.             {
  202.                 if (m->first_displayed_item > i)
  203.                 {
  204.                     done = 1;
  205.                     m->first_displayed_item = i + 1;
  206.                     m->last_displayed_item = m->n_items - 1;
  207.                 }
  208.                 break;
  209.             }
  210.         }
  211.         if (total_height <= list_height)
  212.         {
  213.             m->first_displayed_item = 0;
  214.         }
  215.         total_height = 0;
  216.         for (i = m->first_displayed_item; (i < m->n_items) && (!done); i++)
  217.         {
  218.             //PMT NEERAJ START 20050712
  219.             //PMT NEERAJ START 20050825
  220.         #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  221.             /* PMT NEERAJ END 20050825 */
  222.             if (i == m->highlighted_item)
  223.             {
  224.                 current_fixed_list_menuitem_display_index = -1;
  225.             }
  226.             else
  227.             {
  228.                 current_fixed_list_menuitem_display_index = i;
  229.             }
  230.         #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  231.             /* PMT NEERAJ END 20050712 */
  232.             m->item_measure_function(NULL, m->common_item_data, &iwidth, &iheight);
  233.             total_height += iheight;
  234.             if (total_height > list_height + 1)
  235.             {
  236.                 done = 1;
  237.                 m->last_displayed_item = i - 1;
  238.             }
  239.         }
  240.     }
  241.     else if (m->flags & UI_LIST_MENU_LAST_SHIFT_HIGHLIGHTED_ITEM)
  242.     {
  243.         S32 total_height = 0, i;
  244.         U8 done = 0;
  245.         S32 list_height = m->height;
  246.         m->flags &= ~UI_LIST_MENU_LAST_SHIFT_HIGHLIGHTED_ITEM;
  247.         m->last_displayed_item = m->highlighted_item;
  248.         /* Check if in the first page */
  249.         for (i = 0; (i < m->n_items) && !done; i++)
  250.         {
  251.             //PMT NEERAJ START 20050712
  252.             //PMT NEERAJ START 20050825
  253.         #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  254.             /* PMT NEERAJ END 20050825 */
  255.             if (i == m->highlighted_item)
  256.             {
  257.                 current_fixed_list_menuitem_display_index = -1;
  258.             }
  259.             else
  260.             {
  261.                 current_fixed_list_menuitem_display_index = i;
  262.             }
  263.         #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  264.             /* PMT NEERAJ END 20050712 */
  265.             m->item_measure_function(NULL, m->common_item_data, &iwidth, &iheight);
  266.             total_height += iheight;
  267.             if (total_height > list_height + 1)
  268.             {
  269.                 if (m->last_displayed_item < i)
  270.                 {
  271.                     done = 1;
  272.                     m->first_displayed_item = 0;
  273.                     m->last_displayed_item = i - 1;
  274.                 }
  275.                 break;
  276.             }
  277.         }
  278.         /* Check if in the last page */
  279.         if (!done && total_height <= list_height)
  280.         {
  281.             done = 1;
  282.             m->first_displayed_item = 0;
  283.             m->last_displayed_item = m->n_items - 1;
  284.         }
  285.         /* Align to the bottom */
  286.         total_height = 0;
  287.         if (!done)
  288.         {
  289.             for (i = m->last_displayed_item; (i >= 0) && (!done); i--)
  290.             {
  291.                 //PMT NEERAJ START 20050712
  292.                 //PMT NEERAJ START 20050825
  293.             #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  294.                 /* PMT NEERAJ END 20050825 */
  295.                 if (i == m->highlighted_item)
  296.                 {
  297.                     current_fixed_list_menuitem_display_index = -1;
  298.                 }
  299.                 else
  300.                 {
  301.                     current_fixed_list_menuitem_display_index = i;
  302.                 }
  303.             #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  304.                 /* PMT NEERAJ END 20050712 */
  305.                 m->item_measure_function(NULL, m->common_item_data, &iwidth, &iheight);
  306.                 total_height += iheight;
  307.                 if (total_height > list_height + 1)
  308.                 {
  309.                     done = 1;
  310.                     m->first_displayed_item = i + 1;
  311.                 }
  312.             }
  313.             if (!done)
  314.             {
  315.                 m->first_displayed_item = 0;
  316.             }
  317.         }
  318.     }
  319.     else
  320.     {
  321.         if (m->highlighted_item < m->first_displayed_item)
  322.         {
  323.             /* Scroll up. Because m->n_items > m->displayed_items, it is simpler than UI_LIST_MENU_FIRST_SHIFT_HIGHLIGHTED_ITEM */
  324.             U8 done = 0;
  325.             S32 total_height = 0, i;
  326.             S32 list_height = m->height;
  327.             m->first_displayed_item = m->highlighted_item;
  328.             for (i = m->first_displayed_item; i < m->n_items && (!done); i++)
  329.             {
  330.                 //PMT NEERAJ START 20050712
  331.                 //PMT NEERAJ START 20050825
  332.             #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  333.                 /* PMT NEERAJ END 20050825 */
  334.                 if (i == m->highlighted_item)
  335.                 {
  336.                     current_fixed_list_menuitem_display_index = -1;
  337.                 }
  338.                 else
  339.                 {
  340.                     current_fixed_list_menuitem_display_index = i;
  341.                 }
  342.             #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  343.                 /* PMT NEERAJ END 20050712 */
  344.                 m->item_measure_function(NULL, m->common_item_data, &iwidth, &iheight);
  345.                 total_height += iheight;
  346.                 if (total_height > list_height + 1)
  347.                 {
  348.                     done = 1;
  349.                     m->last_displayed_item = i - 1;
  350.                 }
  351.             }
  352.         }
  353.         else if (m->highlighted_item > m->last_displayed_item)
  354.         {
  355.             /* Scroll down. Because m->n_items > m->displayed_items, it is simpler than UI_LIST_MENU_LAST_SHIFT_HIGHLIGHTED_ITEM */
  356.             U8 done = 0;
  357.             S32 total_height = 0, i;
  358.             S32 list_height = m->height;
  359.             m->last_displayed_item = m->highlighted_item;
  360.             for (i = m->last_displayed_item; i >= 0 && (!done); i--)
  361.             {
  362.                 //PMT NEERAJ START 20050712
  363.                 //PMT NEERAJ START 20050825
  364.             #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  365.                 /* PMT NEERAJ END 20050825 */
  366.                 if (i == m->highlighted_item)
  367.                 {
  368.                     current_fixed_list_menuitem_display_index = -1;
  369.                 }
  370.                 else
  371.                 {
  372.                     current_fixed_list_menuitem_display_index = i;
  373.                 }
  374.             #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  375.                 /* PMT NEERAJ END 20050712 */
  376.                 m->item_measure_function(NULL, m->common_item_data, &iwidth, &iheight);
  377.                 total_height += iheight;
  378.                 if (total_height > list_height + 1)
  379.                 {
  380.                     done = 1;
  381.                     m->first_displayed_item = i + 1;
  382.                 }
  383.             }
  384.         }
  385.         else
  386.         {
  387.             U8 done = 0;
  388.             S32 total_height = 0, i;
  389.             S32 list_height = m->height;
  390.             for (i = m->first_displayed_item; i < m->n_items && (!done); i++)
  391.             {
  392.                 //PMT NEERAJ START 20050712
  393.                 //PMT NEERAJ START 20050825
  394.             #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  395.                 /* PMT NEERAJ END 20050825 */
  396.                 if (i == m->highlighted_item)
  397.                 {
  398.                     current_fixed_list_menuitem_display_index = -1;
  399.                 }
  400.                 else
  401.                 {
  402.                     current_fixed_list_menuitem_display_index = i;
  403.                 }
  404.             #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  405.                 /* PMT NEERAJ END 20050712 */
  406.                 m->item_measure_function(NULL, m->common_item_data, &iwidth, &iheight);
  407.                 total_height += iheight;
  408.                 if (total_height > list_height + 1)
  409.                 {
  410.                     done = 1;
  411.                     m->last_displayed_item = i - 1;
  412.                 }
  413.             }
  414.             if (total_height <= list_height + 1) /* Check height from 'first displayed item' to 'last menu item' */
  415.             {
  416.                 total_height = 0;
  417.                 m->last_displayed_item = m->n_items - 1;
  418.                 for (i = m->n_items - 1; (i >= 0) && (!done); i--)
  419.                 {
  420.                 #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  421.                     if (i == m->highlighted_item)
  422.                     {
  423.                         current_fixed_list_menuitem_display_index = -1;
  424.                     }
  425.                     else
  426.                     {
  427.                         current_fixed_list_menuitem_display_index = i;
  428.                     }
  429.                 #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  430.                     m->item_measure_function(NULL, m->common_item_data, &iwidth, &iheight);
  431.                     total_height += iheight;
  432.                     if (total_height > list_height + 1)
  433.                     {
  434.                         if (m->first_displayed_item > i)
  435.                         {
  436.                             done = 1;
  437.                             m->first_displayed_item = i + 1;
  438.                         }
  439.                         break;
  440.                     }
  441.                 }
  442.                 if (total_height <= list_height + 1) /* Check new height after setting 'last displayed item' to 'last menu item' */
  443.                 {
  444.                     m->first_displayed_item = 0;
  445.                 }
  446.             }
  447.             if (m->highlighted_item > m->last_displayed_item)
  448.             {
  449.                 done = 0;
  450.                 total_height = 0;
  451.                 m->last_displayed_item = m->highlighted_item;
  452.                 for (i = m->last_displayed_item; i >= 0 && (!done); i--)
  453.                 {
  454.                 #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  455.                     if (i == m->highlighted_item)
  456.                     {
  457.                         current_fixed_list_menuitem_display_index = -1;
  458.                     }
  459.                     else
  460.                     {
  461.                         current_fixed_list_menuitem_display_index = i;
  462.                     }
  463.                 #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  464.                     m->item_measure_function(NULL, m->common_item_data, &iwidth, &iheight);
  465.                     total_height += iheight;
  466.                     if (total_height > list_height + 1)
  467.                     {
  468.                         done = 1;
  469.                         m->first_displayed_item = i + 1;
  470.                     }
  471.                 }
  472.             }
  473.         }
  474.     }
  475.     /* Load one more item because it might be accessed in gui_show_dynamic_list_menu() */
  476.     if (m->flags & UI_LIST_MENU_DISABLE_CACHE_DYNAMIC_DATA)
  477.     {
  478.         flush_dynamic_item_buffer_before_load_chunk();
  479.     }
  480.     load_chunk_dynamic_item_buffer(m->first_displayed_item, m->last_displayed_item - m->first_displayed_item + 2);
  481. }
  482. /*****************************************************************************
  483.  * FUNCTION
  484.  *  gui_dynamic_list_menu_locate_previous_item
  485.  * DESCRIPTION
  486.  *  
  487.  * PARAMETERS
  488.  *  m       [?]     
  489.  * RETURNS
  490.  *  void
  491.  *****************************************************************************/
  492. void gui_dynamic_list_menu_locate_previous_item(fixed_list_menu *m)
  493. {
  494.     /*----------------------------------------------------------------*/
  495.     /* Local Variables                                                */
  496.     /*----------------------------------------------------------------*/
  497.     /*----------------------------------------------------------------*/
  498.     /* Code Body                                                      */
  499.     /*----------------------------------------------------------------*/
  500.     if (m->flags & UI_LIST_MENU_DISABLE_CACHE_DYNAMIC_DATA)
  501.     {
  502.         /*
  503.          * FIXME: __MMI_UI_HINTS_IN_MENUITEM__ is not supported here.
  504.          * UI_LIST_MENU_DISABLE_CACHE_DYNAMIC_DATA is used only in Category 185.
  505.          */
  506.         if (m->highlighted_item < m->first_displayed_item)
  507.         {
  508.             /*
  509.              * Call gui_dynamic_list_menu_locate_highlighted_item() because 
  510.              * * we need to load data from first_displayed_item to last_displayed_item
  511.              * * We do not want to duplicate the code of computing last_displayed_item.
  512.              */
  513.             m->flags |= UI_LIST_MENU_FIRST_SHIFT_HIGHLIGHTED_ITEM;
  514.             gui_dynamic_list_menu_locate_highlighted_item(m);
  515.             m->flags &= ~UI_LIST_MENU_FIRST_SHIFT_HIGHLIGHTED_ITEM;
  516.         }
  517.     }
  518.     else if (m->highlighted_item < m->first_displayed_item)
  519.     {
  520.         m->first_displayed_item = m->highlighted_item;
  521.         load_chunk_dynamic_item_buffer(m->highlighted_item, 1);
  522.     }
  523.     /* PMT NEERAJ START 20050825 */
  524. #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  525.     /* PMT NEERAJ END 20050825 */
  526.     else
  527.     {
  528.         S32 iwidth, iheight;
  529.         if (m->highlighted_item == m->last_displayed_item - 1)
  530.         {
  531.             S32 total_height = 0, i;
  532.             S32 list_height = m->height;
  533.             m->first_displayed_item = 0;
  534.             for (i = m->last_displayed_item; i >= 0; i--)
  535.             {
  536.                 if (i == m->highlighted_item)
  537.                 {
  538.                     current_fixed_list_menuitem_display_index = -1;
  539.                 }
  540.                 else
  541.                 {
  542.                     current_fixed_list_menuitem_display_index = i;
  543.                 }
  544.                 m->item_measure_function(NULL, m->common_item_data, &iwidth, &iheight);
  545.                 total_height += iheight;
  546.                 if (total_height > list_height + 1)
  547.                 {
  548.                     m->first_displayed_item = i + 1;
  549.                     break;
  550.                 }
  551.             }
  552.             /* Load one more item because it might be accessed in gui_show_dynamic_list_menu() */
  553.             load_chunk_dynamic_item_buffer(m->first_displayed_item, 2);
  554.         }
  555.     }
  556. #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  557. }
  558. /*****************************************************************************
  559.  * FUNCTION
  560.  *  gui_dynamic_list_menu_locate_next_item
  561.  * DESCRIPTION
  562.  *  
  563.  * PARAMETERS
  564.  *  m       [?]     
  565.  * RETURNS
  566.  *  void
  567.  *****************************************************************************/
  568. void gui_dynamic_list_menu_locate_next_item(fixed_list_menu *m)
  569. {
  570.     /*----------------------------------------------------------------*/
  571.     /* Local Variables                                                */
  572.     /*----------------------------------------------------------------*/
  573.     S32 iwidth, iheight;
  574.     /*----------------------------------------------------------------*/
  575.     /* Code Body                                                      */
  576.     /*----------------------------------------------------------------*/
  577.     //PMT NEERAJ START 20050712
  578.     //PMT NEERAJ START 20050825
  579. #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  580.     /* PMT NEERAJ END 20050825 */
  581.     if (m->highlighted_item >= m->last_displayed_item)
  582. #else /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  583.     /* PMT NEERAJ END 20050712 */
  584.     if (m->highlighted_item > m->last_displayed_item)
  585.         /* PMT NEERAJ START 20050712 */
  586. #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  587.         /* PMT NEERAJ END 20050712 */
  588.     {
  589.         S32 total_height = 0, i;
  590.         S32 list_height = m->height;
  591.         m->last_displayed_item = m->highlighted_item;
  592.         m->first_displayed_item = 0;
  593.         for (i = m->last_displayed_item; i >= 0; i--)
  594.         {
  595.             //PMT NEERAJ START 20050712
  596.             //PMT NEERAJ START 20050825
  597.         #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  598.             /* PMT NEERAJ END 20050825 */
  599.             if (i == m->highlighted_item)
  600.             {
  601.                 current_fixed_list_menuitem_display_index = -1;
  602.             }
  603.             else
  604.             {
  605.                 current_fixed_list_menuitem_display_index = i;
  606.             }
  607.         #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  608.             /* PMT NEERAJ END 20050712 */
  609.             m->item_measure_function(NULL, m->common_item_data, &iwidth, &iheight);
  610.             total_height += iheight;
  611.             if (total_height > list_height + 1)
  612.             {
  613.                 m->first_displayed_item = i + 1;
  614.                 break;
  615.             }
  616.         }
  617.         /* Load one more item because it might be accessed in gui_show_dynamic_list_menu() */
  618.         if (m->flags & UI_LIST_MENU_DISABLE_CACHE_DYNAMIC_DATA)
  619.         {
  620.             flush_dynamic_item_buffer_before_load_chunk();
  621.             load_chunk_dynamic_item_buffer(
  622.                 m->first_displayed_item,
  623.                 m->last_displayed_item - m->first_displayed_item + 2);
  624.         }
  625.         else
  626.         {
  627.             load_chunk_dynamic_item_buffer(m->highlighted_item, 2);
  628.         }
  629.     }
  630. }
  631. /*****************************************************************************
  632.  * FUNCTION
  633.  *  switch_highlighted_item
  634.  * DESCRIPTION
  635.  *  
  636.  * PARAMETERS
  637.  *  m                           [?]         
  638.  *  last_highlighted_item       [IN]        
  639.  * RETURNS
  640.  *  void
  641.  *****************************************************************************/
  642. void switch_highlighted_item(fixed_list_menu *m, S32 last_highlighted_item)
  643. {
  644.     /*----------------------------------------------------------------*/
  645.     /* Local Variables                                                */
  646.     /*----------------------------------------------------------------*/
  647.     /*----------------------------------------------------------------*/
  648.     /* Code Body                                                      */
  649.     /*----------------------------------------------------------------*/
  650.     if (last_highlighted_item != m->highlighted_item)
  651.     {
  652.         if ((last_highlighted_item >= 0) && (last_highlighted_item < m->n_items))
  653.         {
  654.             if (in_dynamic_item_buffer(last_highlighted_item))
  655.             {
  656.                 m->item_remove_highlight_function(
  657.                     get_dynamic_item_from_buffer(last_highlighted_item),
  658.                     m->common_item_data);
  659.             }
  660.         }
  661.         if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
  662.         {
  663.             m->item_highlight_function(get_dynamic_item_from_buffer(m->highlighted_item), m->common_item_data);
  664.         }
  665.         m->item_unhighlighted(last_highlighted_item);
  666.     #ifdef __MMI_TOUCH_SCREEN__
  667.         m->pen_event_current_selected_callback_function = m->pen_event_default_selected_callback_function;
  668.     #endif 
  669.         m->item_highlighted(m->highlighted_item);
  670.     }
  671. #ifdef __MMI_UI_TAB_PANE__
  672.     if (is_tab_pane_displayed_on_current_screen())
  673.     {
  674.         register_tab_pane_keys();
  675.     }
  676. #endif /* __MMI_UI_TAB_PANE__ */ 
  677. }
  678. /*****************************************************************************
  679.  * FUNCTION
  680.  *  gui_dynamic_list_menu_goto_item
  681.  * DESCRIPTION
  682.  *  
  683.  * PARAMETERS
  684.  *  m       [?]         
  685.  *  i       [IN]        
  686.  * RETURNS
  687.  *  void
  688.  *****************************************************************************/
  689. void gui_dynamic_list_menu_goto_item(fixed_list_menu *m, S32 i)
  690. {
  691.     /*----------------------------------------------------------------*/
  692.     /* Local Variables                                                */
  693.     /*----------------------------------------------------------------*/
  694.     S32 last_highlighted_item;
  695.     /*----------------------------------------------------------------*/
  696.     /* Code Body                                                      */
  697.     /*----------------------------------------------------------------*/
  698. #ifdef __MMI_TOUCH_SCREEN__
  699.     /* If highlight is changed by keypad, abort scroll timer */
  700.     gui_dynamic_list_abort_scroll_timer();
  701. #endif /* __MMI_TOUCH_SCREEN__ */ 
  702.     if ((i < 0) || (i > m->n_items - 1))
  703.     {
  704.         return;
  705.     }
  706.     if (i == m->highlighted_item)
  707.     {
  708.         return;
  709.     }
  710.     last_highlighted_item = m->highlighted_item;
  711.     m->highlighted_item = i;
  712.     gui_dynamic_list_menu_locate_highlighted_item(m);
  713.     switch_highlighted_item(m, last_highlighted_item);
  714. }
  715. /*****************************************************************************
  716.  * FUNCTION
  717.  *  gui_dynamic_list_menu_goto_next_item
  718.  * DESCRIPTION
  719.  *  
  720.  * PARAMETERS
  721.  *  m       [?]     
  722.  * RETURNS
  723.  *  void
  724.  *****************************************************************************/
  725. void gui_dynamic_list_menu_goto_next_item(fixed_list_menu *m)
  726. {
  727.     /*----------------------------------------------------------------*/
  728.     /* Local Variables                                                */
  729.     /*----------------------------------------------------------------*/
  730.     S32 last_highlighted_item;
  731.     U8 loop_flag = 0;
  732.     /*----------------------------------------------------------------*/
  733.     /* Code Body                                                      */
  734.     /*----------------------------------------------------------------*/
  735. #ifdef __MMI_TOUCH_SCREEN__
  736.     /* If highlight is changed by keypad, abort scroll timer */
  737.     gui_dynamic_list_abort_scroll_timer();
  738. #endif /* __MMI_TOUCH_SCREEN__ */ 
  739.     if (m->highlighted_item >= m->n_items - 1)
  740.     {
  741.         if (m->flags & UI_LIST_MENU_LOOP)
  742.         {
  743.             loop_flag = 1;
  744.         }
  745.         else
  746.         {
  747.             return;
  748.         }
  749.     }
  750.     last_highlighted_item = m->highlighted_item;
  751.     if (loop_flag)
  752.     {
  753.         m->highlighted_item = 0;
  754.         gui_dynamic_list_menu_locate_highlighted_item(m);
  755.     }
  756.     else
  757.     {
  758.         m->highlighted_item++;
  759.         gui_dynamic_list_menu_locate_next_item(m);
  760.     }
  761.     switch_highlighted_item(m, last_highlighted_item);
  762. }
  763. /*****************************************************************************
  764.  * FUNCTION
  765.  *  gui_dynamic_list_menu_goto_previous_item
  766.  * DESCRIPTION
  767.  *  
  768.  * PARAMETERS
  769.  *  m       [?]     
  770.  * RETURNS
  771.  *  void
  772.  *****************************************************************************/
  773. void gui_dynamic_list_menu_goto_previous_item(fixed_list_menu *m)
  774. {
  775.     /*----------------------------------------------------------------*/
  776.     /* Local Variables                                                */
  777.     /*----------------------------------------------------------------*/
  778.     S32 last_highlighted_item;
  779.     U8 loop_flag = 0;
  780.     /*----------------------------------------------------------------*/
  781.     /* Code Body                                                      */
  782.     /*----------------------------------------------------------------*/
  783. #ifdef __MMI_TOUCH_SCREEN__
  784.     /* If highlight is changed by keypad, abort scroll timer */
  785.     gui_dynamic_list_abort_scroll_timer();
  786. #endif /* __MMI_TOUCH_SCREEN__ */ 
  787.     if (m->highlighted_item <= 0)
  788.     {
  789.         if (m->flags & UI_LIST_MENU_LOOP)
  790.         {
  791.             loop_flag = 1;
  792.         }
  793.         else
  794.         {
  795.             return;
  796.         }
  797.     }
  798.     last_highlighted_item = m->highlighted_item;
  799.     if (loop_flag)
  800.     {
  801.         m->highlighted_item = m->n_items - 1;
  802.         gui_dynamic_list_menu_locate_highlighted_item(m);
  803.     }
  804.     else
  805.     {
  806.         m->highlighted_item--;
  807.         gui_dynamic_list_menu_locate_previous_item(m);
  808.     }
  809.     switch_highlighted_item(m, last_highlighted_item);
  810. }
  811. /*****************************************************************************
  812.  * FUNCTION
  813.  *  gui_show_dynamic_list_menu
  814.  * DESCRIPTION
  815.  *  
  816.  * PARAMETERS
  817.  *  m       [?]     
  818.  * RETURNS
  819.  *  void
  820.  *****************************************************************************/
  821. /*
  822.  * #include "lcd_if.h"
  823.  * #include "gdi_datatype.h"
  824.  * #include "gdi_layer.h"
  825.  */
  826. #include "gdi_include.h"
  827. extern gdi_handle wgui_layer_1;
  828. extern gdi_handle wgui_base_layer;
  829. /* extern GDI_HANDLE dm_get_scr_bg_layer(void); */
  830. void gui_show_dynamic_list_menu(fixed_list_menu *m)
  831. {
  832.     /*----------------------------------------------------------------*/
  833.     /* Local Variables                                                */
  834.     /*----------------------------------------------------------------*/
  835.     S32 x1, y1, x2, y2, y_offset;
  836.     UI_filled_area *f;
  837.     S32 i;
  838.     S32 cx1, cy1, cx2, cy2;
  839.     S32 tx1, ty1, tx2, ty2;
  840.     S32 iwidth, iheight;
  841.     fixed_icontext_menuitem_type *item_p;
  842.     U8 done = 0;
  843.     S32 total_height, counter, list_height;
  844.     U8 disable_draw = 0;
  845.     S32 vbar_x = 0, vbar_button_x = 0;
  846.     /*----------------------------------------------------------------*/
  847.     /* Code Body                                                      */
  848.     /*----------------------------------------------------------------*/
  849.     if (m->flags & UI_LIST_MENU_DISABLE_DRAW)
  850.     {
  851.         disable_draw = 1;
  852.     }
  853.     gui_get_clip(&cx1, &cy1, &cx2, &cy2);
  854.     gui_get_text_clip(&tx1, &ty1, &tx2, &ty2);
  855.     x1 = m->x;
  856.     y1 = m->y;
  857.     x2 = x1 + m->width - 1;
  858.     y2 = y1 + m->height - 1;
  859.     if (m->flags & UI_LIST_MENU_STATE_FOCUSSED)
  860.     {
  861.         f = m->focussed_filler;
  862.     }
  863.     else
  864.     {
  865.         f = m->normal_filler;
  866.     }
  867.     gui_set_clip(x1, y1, x2, y2);
  868.     if (!disable_draw && !(m->flags & UI_LIST_MENU_DISABLE_BACKGROUND))
  869.     {
  870.         gui_set_clip(x1, y1, x2, y2);
  871.         if (!(m->flags & UI_LIST_MENU_DISABLE_BKGRND_IN_LAYER) && (wgui_is_wallpaper_on_bottom() == MMI_TRUE))
  872.         {
  873.             gdi_draw_solid_rect(x1, y1, x2, y2, GDI_COLOR_TRANSPARENT);
  874.             /* PMT VIKAS START 20051217 */
  875.         #if (defined (__MMI_UI_TRANSPARENT_EFFECT__) || defined (__MMI_UI_LIST_HIGHLIGHT_EFFECTS__))
  876.             /* PMT VIKAS END 20051217 */
  877.             if (gui_get_transparent_source_layer() == GDI_LAYER_EMPTY_HANDLE)   /* 110705 WAP menu Clavin add */
  878.             {
  879.                 gui_set_transparent_source_layer(dm_get_scr_bg_layer());        /* should remove */
  880.             }
  881.         #endif /* (defined (__MMI_UI_TRANSPARENT_EFFECT__) || defined (__MMI_UI_LIST_HIGHLIGHT_EFFECTS__)) */ 
  882.         }
  883.     #ifdef __MMI_UI_LIST_CACHE_BACKGROUND__
  884.         else if (!(m->flags & UI_LIST_MENU_DISABLE_BKGRND_IN_LAYER) && (gui_get_multilayer_mask() & UI_MUL_BKG_SUBMENU))
  885.         {
  886.             gui_show_menu_background_in_layer(x1, y1, x2, y2, f);
  887.         }
  888.     #endif /* __MMI_UI_LIST_CACHE_BACKGROUND__ */ 
  889.         else
  890.         {
  891.         #if !defined(MT6205B) && !defined(MT6208)
  892.             gui_draw_filled_area(x1, y1, x2, y2, f);
  893.         #else /* !defined(MT6205B) && !defined(MT6208) */
  894.             /* For low-end phone, disable list menu background can greately improve menu performance. 
  895.                We use the color of filler to draw the background (typically white). */
  896.             color c = f->c;
  897.             gdi_draw_solid_rect(x1, y1, x2, y2, gdi_act_color_from_rgb(255, c.r, c.g, c.b));
  898.         #endif /* !defined(MT6205B) && !defined(MT6208) */
  899.         }
  900.     }
  901.     if (m->n_items <= 0)
  902.     {
  903.         return;
  904.     }
  905.     if (r2lMMIFlag)
  906.     {
  907.         x1 += m->vbar.width;
  908.     }
  909.     else
  910.     {
  911.         x2 -= m->vbar.width;
  912.     }
  913.     /* 121704 Calvin changed */
  914.     /* y1 = m->y+1;// + m->top; */
  915.     y1 = m->y + m->top;
  916.     /* Calvin end */
  917.     list_height = m->height;
  918.     gui_set_text_clip(x1, y1, x2, y2);
  919.     gui_set_clip(x1, y1, x2, y2);
  920.     total_height = 0;
  921.     counter = 0;
  922.     current_fixed_list_menuitem_display_index = -1;
  923.     for (i = m->first_displayed_item; (i < m->n_items && !done); i++)
  924.     {
  925.         item_p = get_dynamic_item_from_buffer(i);
  926.         current_fixed_list_menuitem_display_index = (i == m->highlighted_item) ? -1 : i;
  927.         m->item_measure_function(NULL, m->common_item_data, &iwidth, &iheight);
  928.         y_offset = total_height;
  929.         total_height += iheight;
  930.     #ifdef __MMI_UI_DALMATIAN_FIXEDLIST__
  931.         if (line_draw)
  932.         {
  933.             /* Draw grid for dynamic variant menuscreen */
  934.             gui_draw_horizontal_line(x1, x2 - 1, y1, current_MMI_theme->list_background_filler->border_color);
  935.             /* PMT VIKAS START 20050817 */
  936.             gui_draw_horizontal_line(
  937.                 x1,
  938.                 x2 - 1,
  939.                 y1 + total_height,
  940.                 current_MMI_theme->list_background_filler->border_color);
  941.             /* PMT VIKAS END 20050817 */
  942.         }
  943.     #endif /* __MMI_UI_DALMATIAN_FIXEDLIST__ */ 
  944.         if (total_height > list_height + 1)
  945.         {
  946.             done = 1;
  947.             if ((counter == 0) && !disable_draw)
  948.             {
  949.                 m->item_display_function(item_p, m->common_item_data, x1, y_offset + y1);
  950.             }
  951.         }
  952.         else
  953.         {
  954.             if (!disable_draw)
  955.             {
  956.                 m->item_display_function(item_p, m->common_item_data, x1, y_offset + y1);
  957.             }
  958.             counter++;
  959.         }
  960.     }
  961.     /* PMT VIKAS START 20050817 */
  962. #ifdef __MMI_UI_DALMATIAN_FIXEDLIST__
  963.     if (line_draw)
  964.     {
  965.         // To grid for sub menu screens
  966.         // Used -2 for proper area selection
  967.         if (i == m->n_items)
  968.         {
  969.             if (!r2lMMIFlag)
  970.             {
  971.                 gui_draw_horizontal_line(
  972.                     x1,
  973.                     m->vbar.x - 2,
  974.                     y_offset + y1 + iheight,
  975.                     current_MMI_theme->list_background_filler->border_color);
  976.             }
  977.             else
  978.             {
  979.                 gui_draw_horizontal_line(
  980.                     x1,
  981.                     x2,
  982.                     y_offset + y1 + iheight,
  983.                     current_MMI_theme->list_background_filler->border_color);
  984.             }
  985.         }
  986.         if (!r2lMMIFlag)
  987.         {
  988.             if (i == m->n_items && done)
  989.             {
  990.                 gui_draw_vertical_line(
  991.                     y1,
  992.                     y1 + y_offset,
  993.                     m->vbar.x - 2,
  994.                     current_MMI_theme->list_background_filler->border_color);
  995.             }
  996.             else
  997.             {
  998.                 gui_draw_vertical_line(
  999.                     y1,
  1000.                     ((y1 + total_height) > (y1 + m->vbar.height - 4) ? (y1 + total_height - iheight) : (y1 + total_height)),
  1001.                     m->vbar.x - 2,
  1002.                     current_MMI_theme->list_background_filler->border_color);
  1003.             }
  1004.         }
  1005.         else
  1006.         {
  1007.             if (i == m->n_items && done)
  1008.             {
  1009.                 gui_draw_vertical_line(
  1010.                     y1,
  1011.                     y1 + y_offset,
  1012.                     (m->vbar.x + m->vbar.width - m->width) + m->vbar.width,
  1013.                     current_MMI_theme->list_background_filler->border_color);
  1014.             }
  1015.             else
  1016.             {
  1017.                 gui_draw_vertical_line(
  1018.                     y1,
  1019.                     ((y1 + total_height) > (y1 + m->vbar.height - 4) ? (y1 + total_height - iheight) : (y1 + total_height)),
  1020.                     (m->vbar.x + m->vbar.width - m->width) + m->vbar.width,
  1021.                     current_MMI_theme->list_background_filler->border_color);
  1022.             }
  1023.         }
  1024.     }
  1025. #endif /* __MMI_UI_DALMATIAN_FIXEDLIST__ */ 
  1026.     /* PMT VIKAS END 20050817 */
  1027.     current_fixed_list_menuitem_display_index = -1;
  1028.     m->last_displayed_item = (counter == 0) ? m->first_displayed_item : m->first_displayed_item + counter - 1;
  1029.     m->displayed_items = counter;
  1030.     gui_set_clip(cx1, cy1, cx2, cy2);
  1031.     gui_set_text_clip(tx1, ty1, tx2, ty2);
  1032.     if (!(m->flags & UI_LIST_MENU_DISABLE_SCROLLBAR))
  1033.     {
  1034.         gui_set_vertical_scrollbar_range(&m->vbar, m->n_items);
  1035.         gui_set_vertical_scrollbar_scale(&m->vbar, m->displayed_items);
  1036.         gui_set_vertical_scrollbar_value(&m->vbar, m->first_displayed_item);
  1037.         if (m->flags & UI_LIST_MENU_AUTO_DISABLE_SCROLLBAR)
  1038.         {
  1039.             if ((total_height > list_height + 1) || (m->first_displayed_item > 0))
  1040.             {
  1041.                 /* MTK Elvis for R2L characters */
  1042.                 if (r2lMMIFlag)
  1043.                 {
  1044.                     vbar_x = m->vbar.x;
  1045.                     vbar_button_x = m->vbar.scroll_button.x;
  1046.                     m->vbar.x = m->vbar.x + m->vbar.width - m->width;
  1047.                     m->vbar.scroll_button.x = m->vbar.scroll_button.x + m->vbar.scroll_button.width - m->width;
  1048.                     gui_show_vertical_scrollbar(&m->vbar);
  1049.                 }
  1050.                 else
  1051.                 {
  1052.                     gui_show_vertical_scrollbar(&m->vbar);
  1053.                 }
  1054.                 /* MTK end */
  1055.                 if (r2lMMIFlag)
  1056.                 {
  1057.                     m->vbar.x = vbar_x;
  1058.                     m->vbar.scroll_button.x = vbar_button_x;
  1059.                 }
  1060.             }
  1061.         }
  1062.         else
  1063.         {
  1064.             /* MTK Elvis for R2L characters */
  1065.             if (r2lMMIFlag)
  1066.             {
  1067.                 vbar_x = m->vbar.x;
  1068.                 vbar_button_x = m->vbar.scroll_button.x;
  1069.                 m->vbar.x = m->vbar.x + m->vbar.width - m->width;
  1070.                 m->vbar.scroll_button.x = m->vbar.scroll_button.x + m->vbar.scroll_button.width - m->width;
  1071.                 gui_show_vertical_scrollbar(&m->vbar);
  1072.             }
  1073.             else
  1074.             {
  1075.                 gui_show_vertical_scrollbar(&m->vbar);
  1076.             }
  1077.             /* MTK end */
  1078.             if (r2lMMIFlag)
  1079.             {
  1080.                 m->vbar.x = vbar_x;
  1081.                 m->vbar.scroll_button.x = vbar_button_x;
  1082.             }
  1083.         }
  1084.     }
  1085.     /* PMT VIKAS START 20050817 */
  1086. #ifdef __MMI_UI_DALMATIAN_FIXEDLIST__
  1087.     if (line_draw)
  1088.     {
  1089.         if (r2lMMIFlag)
  1090.         {
  1091.             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 */
  1092.             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 */
  1093.         }
  1094.         else
  1095.         {
  1096.             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 */
  1097.             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 */
  1098.         }
  1099.     }
  1100. #endif /* __MMI_UI_DALMATIAN_FIXEDLIST__ */ 
  1101.     /* PMT VIKAS END 20050817 */
  1102. }
  1103. /*****************************************************************************
  1104.  * FUNCTION
  1105.  *  gui_show_dynamic_list_menu_no_draw
  1106.  * DESCRIPTION
  1107.  *  
  1108.  * PARAMETERS
  1109.  *  m       [?]     
  1110.  * RETURNS
  1111.  *  void
  1112.  *****************************************************************************/
  1113. void gui_show_dynamic_list_menu_no_draw(fixed_list_menu *m)
  1114. {
  1115.     /*----------------------------------------------------------------*/
  1116.     /* Local Variables                                                */
  1117.     /*----------------------------------------------------------------*/
  1118.     S32 i;
  1119.     S32 iwidth, iheight;
  1120.     U8 done = 0;
  1121.     S32 total_height, counter, list_height;
  1122.     /*----------------------------------------------------------------*/
  1123.     /* Code Body                                                      */
  1124.     /*----------------------------------------------------------------*/
  1125.     list_height = m->height;
  1126.     total_height = 0;
  1127.     counter = 0;
  1128.     current_fixed_list_menuitem_display_index = -1;
  1129.     for (i = m->first_displayed_item; (i < m->n_items && !done); i++)
  1130.     {
  1131.         current_fixed_list_menuitem_display_index = (i == m->highlighted_item) ? -1 : i;
  1132.         m->item_measure_function(NULL, m->common_item_data, &iwidth, &iheight);
  1133.         total_height += iheight;
  1134.         if (total_height > list_height + 1)
  1135.         {
  1136.             done = 1;
  1137.         }
  1138.         else
  1139.         {
  1140.             counter++;
  1141.         }
  1142.     }
  1143.     current_fixed_list_menuitem_display_index = -1;
  1144.     m->last_displayed_item = (counter == 0) ? m->first_displayed_item : m->first_displayed_item + counter - 1;
  1145.     m->displayed_items = counter;
  1146.     if (!(m->flags & UI_LIST_MENU_DISABLE_SCROLLBAR))
  1147.     {
  1148.         gui_set_vertical_scrollbar_range(&m->vbar, m->n_items);
  1149.         gui_set_vertical_scrollbar_scale(&m->vbar, m->displayed_items);
  1150.         gui_set_vertical_scrollbar_value(&m->vbar, m->first_displayed_item);
  1151.     }
  1152. }
  1153. #ifdef __MMI_TOUCH_SCREEN__
  1154. static void gui_dynamic_list_menu_scroll_by_pen(
  1155.                 fixed_list_menu *m,
  1156.                 S32 first_displayed,
  1157.                 gui_list_pen_enum *menu_event);
  1158. static fixed_list_menu *gui_pen_scroll_dynamic_menu = NULL;
  1159. /* Because loading data takes some time (depending on the applications using dynamic list), 
  1160.    we use a timer to reduce gui_dynamic_list_menu_scroll_by_pen().  */
  1161. /*****************************************************************************
  1162.  * FUNCTION
  1163.  *  gui_dyamic_list_menu_scroll_timer_hdlr
  1164.  * DESCRIPTION
  1165.  *  
  1166.  * PARAMETERS
  1167.  *  void
  1168.  * RETURNS
  1169.  *  void
  1170.  *****************************************************************************/
  1171. static void gui_dyamic_list_menu_scroll_timer_hdlr(void)
  1172. {
  1173.     /*----------------------------------------------------------------*/
  1174.     /* Local Variables                                                */
  1175.     /*----------------------------------------------------------------*/
  1176.     fixed_list_menu *m = gui_pen_scroll_dynamic_menu;
  1177.     gui_list_pen_enum menu_event;
  1178.     /*----------------------------------------------------------------*/
  1179.     /* Code Body                                                      */
  1180.     /*----------------------------------------------------------------*/
  1181.     gui_pen_scroll_dynamic_menu = NULL;
  1182.     if (!m)
  1183.     {
  1184.         return;
  1185.     }
  1186.     gui_dynamic_list_menu_scroll_by_pen(m, m->pen_scroll_after_delay, &menu_event);
  1187.     if (menu_event == GUI_LIST_PEN_HIGHLIGHT_CHANGED || menu_event == GUI_LIST_PEN_NEED_REDRAW)
  1188.     {
  1189.         if (m->pen_redraw_menu_function)
  1190.         {
  1191.             m->pen_redraw_menu_function();
  1192.         }
  1193.         else
  1194.         {
  1195.             MMI_DBG_ASSERT(0);
  1196.         }
  1197.     }
  1198. }
  1199. /*****************************************************************************
  1200.  * FUNCTION
  1201.  *  gui_dynamic_list_abort_scroll_timer
  1202.  * DESCRIPTION
  1203.  *  
  1204.  * PARAMETERS
  1205.  *  void
  1206.  * RETURNS
  1207.  *  void
  1208.  *****************************************************************************/
  1209. static void gui_dynamic_list_abort_scroll_timer(void)
  1210. {
  1211.     /*----------------------------------------------------------------*/
  1212.     /* Local Variables                                                */
  1213.     /*----------------------------------------------------------------*/
  1214.     /*----------------------------------------------------------------*/
  1215.     /* Code Body                                                      */
  1216.     /*----------------------------------------------------------------*/
  1217.     gui_pen_scroll_dynamic_menu = NULL;
  1218. }
  1219. /*****************************************************************************
  1220.  * FUNCTION
  1221.  *  gui_dyamic_list_start_scroll_timer
  1222.  * DESCRIPTION
  1223.  *  
  1224.  * PARAMETERS
  1225.  *  m           [?]         
  1226.  *  value       [IN]        
  1227.  * RETURNS
  1228.  *  void
  1229.  *****************************************************************************/
  1230. static void gui_dyamic_list_start_scroll_timer(fixed_list_menu *m, S32 value)
  1231. {
  1232.     /*----------------------------------------------------------------*/
  1233.     /* Local Variables                                                */
  1234.     /*----------------------------------------------------------------*/
  1235.     /*----------------------------------------------------------------*/
  1236.     /* Code Body                                                      */
  1237.     /*----------------------------------------------------------------*/
  1238.     MMI_DBG_ASSERT(!gui_pen_scroll_dynamic_menu || gui_pen_scroll_dynamic_menu == m);
  1239.     m->pen_scroll_after_delay = value;
  1240.     gui_pen_scroll_dynamic_menu = m;
  1241.     gui_cancel_timer(gui_dyamic_list_menu_scroll_timer_hdlr);
  1242.     gui_start_timer(m->pen_scroll_delay_time, gui_dyamic_list_menu_scroll_timer_hdlr);
  1243.     gui_add_cleanup_hook(gui_dynamic_list_abort_scroll_timer);
  1244. }
  1245. /*****************************************************************************
  1246.  * FUNCTION
  1247.  *  gui_dynamic_list_menu_translate_pen_position
  1248.  * DESCRIPTION
  1249.  *  
  1250.  * PARAMETERS
  1251.  *  m               [?]         
  1252.  *  y               [IN]        
  1253.  *  item_index      [?]         
  1254.  * RETURNS
  1255.  *  
  1256.  *****************************************************************************/
  1257. static BOOL gui_dynamic_list_menu_translate_pen_position(fixed_list_menu *m, S32 y, S32 *item_index)
  1258. {
  1259.     /*----------------------------------------------------------------*/
  1260.     /* Local Variables                                                */
  1261.     /*----------------------------------------------------------------*/
  1262.     S32 total_height = 0, i;
  1263.     S32 iwidth, iheight;
  1264.     BOOL ret = MMI_FALSE;
  1265.     /*----------------------------------------------------------------*/
  1266.     /* Code Body                                                      */
  1267.     /*----------------------------------------------------------------*/
  1268.     y -= m->y;
  1269.     if (m->n_items <= 0)
  1270.     {
  1271.         *item_index = 0;
  1272.         /* ret is false */
  1273.     }
  1274.     else if (y < 0)
  1275.     {
  1276.         *item_index = (m->first_displayed_item > 0) ? m->first_displayed_item - 1 : 0;
  1277.         /* ret is false */
  1278.     }
  1279.     else if (y >= m->height)
  1280.     {
  1281.         *item_index = (m->last_displayed_item < m->n_items - 1) ? m->last_displayed_item + 1 : m->n_items - 1;
  1282.         /* ret is false */
  1283.     }
  1284.     else
  1285.     {
  1286.         *item_index = m->n_items - 1;
  1287.         for (i = m->first_displayed_item; i < m->n_items; i++)
  1288.         {
  1289.         #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  1290.             if (i == m->highlighted_item)
  1291.             {
  1292.                 current_fixed_list_menuitem_display_index = -1;
  1293.             }
  1294.             else
  1295.             {
  1296.                 current_fixed_list_menuitem_display_index = i;
  1297.             }
  1298.         #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  1299.             /* Use null because menu item might not be loaded yet */
  1300.             m->item_measure_function(NULL, m->common_item_data, &iwidth, &iheight);
  1301.             total_height += iheight;
  1302.             if (total_height > y)
  1303.             {
  1304.                 *item_index = i;
  1305.                 ret = MMI_TRUE;
  1306.                 break;
  1307.             }
  1308.         }
  1309.     }
  1310.     return ret;
  1311. }
  1312. /*****************************************************************************
  1313.  * FUNCTION
  1314.  *  gui_dynamic_list_menu_get_menuitem_position
  1315.  * DESCRIPTION
  1316.  *  
  1317.  * PARAMETERS
  1318.  *  m               [?]         
  1319.  *  item_index      [IN]        
  1320.  *  x               [?]         
  1321.  *  y               [?]         
  1322.  * RETURNS
  1323.  *  void
  1324.  *****************************************************************************/
  1325. static void gui_dynamic_list_menu_get_menuitem_position(fixed_list_menu *m, S32 item_index, S32 *x, S32 *y)
  1326. {
  1327.     /*----------------------------------------------------------------*/
  1328.     /* Local Variables                                                */
  1329.     /*----------------------------------------------------------------*/
  1330.     S32 i, total_height = m->y;
  1331.     S32 iwidth, iheight;
  1332.     /*----------------------------------------------------------------*/
  1333.     /* Code Body                                                      */
  1334.     /*----------------------------------------------------------------*/
  1335.     *x = m->x;
  1336.     if (item_index <= m->first_displayed_item)
  1337.     {
  1338.         *y = total_height;
  1339.         return;
  1340.     }
  1341.     for (i = m->first_displayed_item; i <= m->last_displayed_item; i++)
  1342.     {
  1343.     #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  1344.         if (i == m->highlighted_item)
  1345.         {
  1346.             current_fixed_list_menuitem_display_index = -1;
  1347.         }
  1348.         else
  1349.         {
  1350.             current_fixed_list_menuitem_display_index = i;
  1351.         }
  1352.     #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  1353.         /* Use null because menu item might not be loaded yet */
  1354.         m->item_measure_function(NULL, m->common_item_data, &iwidth, &iheight);
  1355.         total_height += iheight;
  1356.         if (i + 1 == item_index)
  1357.         {
  1358.             *y = total_height;
  1359.             return;
  1360.         }
  1361.     }
  1362.     *y = total_height;
  1363. }
  1364. /*****************************************************************************
  1365.  * FUNCTION
  1366.  *  gui_dynamic_list_menu_scroll_by_pen
  1367.  * DESCRIPTION
  1368.  *  
  1369.  * PARAMETERS
  1370.  *  m                   [?]         
  1371.  *  first_displayed     [IN]        
  1372.  *  menu_event          [?]         
  1373.  * RETURNS
  1374.  *  void
  1375.  *****************************************************************************/
  1376. static void gui_dynamic_list_menu_scroll_by_pen(
  1377.                 fixed_list_menu *m,
  1378.                 S32 first_displayed,
  1379.                 gui_list_pen_enum *menu_event)
  1380. {
  1381.     /*----------------------------------------------------------------*/
  1382.     /* Local Variables                                                */
  1383.     /*----------------------------------------------------------------*/
  1384.     S32 total_height = 0, i;
  1385.     S32 iwidth, iheight;
  1386.     S32 last_displayed;
  1387.     /*----------------------------------------------------------------*/
  1388.     /* Code Body                                                      */
  1389.     /*----------------------------------------------------------------*/
  1390.     if (first_displayed > m->highlighted_item)
  1391.     {
  1392.         m->flags |= UI_LIST_MENU_FIRST_SHIFT_HIGHLIGHTED_ITEM;
  1393.         gui_dynamic_list_menu_goto_item(m, first_displayed);
  1394.         m->flags &= ~UI_LIST_MENU_FIRST_SHIFT_HIGHLIGHTED_ITEM;
  1395.         *menu_event = GUI_LIST_PEN_HIGHLIGHT_CHANGED;
  1396.     }
  1397.     else
  1398.     {
  1399.         last_displayed = m->n_items - 1;
  1400.         for (i = first_displayed; i < m->n_items; i++)
  1401.         {
  1402.             //PMT NEERAJ START 20050712
  1403.             //PMT NEERAJ START 20050825
  1404.         #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
  1405.             /* PMT NEERAJ END 20050825 */
  1406.             if (i == m->highlighted_item)
  1407.             {
  1408.                 current_fixed_list_menuitem_display_index = -1;
  1409.             }
  1410.             else
  1411.             {
  1412.                 current_fixed_list_menuitem_display_index = i;
  1413.             }
  1414.         #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */ 
  1415.             /* PMT NEERAJ EMD 20050712 */
  1416.             /* Use null because menu item might not be loaded yet */
  1417.             m->item_measure_function(NULL, m->common_item_data, &iwidth, &iheight);
  1418.             total_height += iheight;
  1419.             if (total_height > m->height + 1)
  1420.             {
  1421.                 last_displayed = i - 1;
  1422.                 break;
  1423.             }
  1424.         }
  1425.         if (last_displayed < m->highlighted_item)
  1426.         {
  1427.             m->flags |= UI_LIST_MENU_LAST_SHIFT_HIGHLIGHTED_ITEM;
  1428.             gui_dynamic_list_menu_goto_item(m, last_displayed);
  1429.             m->flags &= ~UI_LIST_MENU_LAST_SHIFT_HIGHLIGHTED_ITEM;
  1430.             *menu_event = GUI_LIST_PEN_HIGHLIGHT_CHANGED;
  1431.         }
  1432.         else
  1433.         {
  1434.             m->first_displayed_item = first_displayed;
  1435.             m->last_displayed_item = last_displayed;
  1436.             /* Handle this in similar way to dynamic_list_goto_item_no_redraw() */
  1437.             if (m->flags & UI_LIST_MENU_DISABLE_CACHE_DYNAMIC_DATA)
  1438.             {
  1439.                 flush_dynamic_item_buffer_before_load_chunk();
  1440.             }
  1441.             load_chunk_dynamic_item_buffer(
  1442.                 m->first_displayed_item,
  1443.                 m->last_displayed_item - m->first_displayed_item + 2);
  1444.             switch_highlighted_item(m, -1);
  1445.             *menu_event = GUI_LIST_PEN_NEED_REDRAW;
  1446.         }
  1447.     }
  1448. }
  1449. /*****************************************************************************
  1450.  * FUNCTION
  1451.  *  gui_dynamic_list_menu_translate_pen_event
  1452.  * DESCRIPTION
  1453.  *  
  1454.  * PARAMETERS
  1455.  *  m               [?]         
  1456.  *  pen_event       [IN]        
  1457.  *  x               [IN]        
  1458.  *  y               [IN]        
  1459.  *  menu_event      [?]         
  1460.  * RETURNS
  1461.  *  
  1462.  *****************************************************************************/
  1463. BOOL gui_dynamic_list_menu_translate_pen_event(
  1464.         fixed_list_menu *m,
  1465.         mmi_pen_event_type_enum pen_event,
  1466.         S16 x,
  1467.         S16 y,
  1468.         gui_list_pen_enum *menu_event)
  1469. {
  1470.     /*----------------------------------------------------------------*/
  1471.     /* Local Variables                                                */
  1472.     /*----------------------------------------------------------------*/
  1473.     BOOL ret;
  1474.     gui_list_pen_state_struct *pen_state;
  1475.     gui_scrollbar_pen_enum scrollbar_event;
  1476.     gui_pen_event_param_struct scrollbar_param;
  1477.     gui_list_pen_enum menuitem_event;
  1478.     gui_pen_event_param_struct menuitem_param;
  1479.     S32 item_index;
  1480.     /*----------------------------------------------------------------*/
  1481.     /* Code Body                                                      */
  1482.     /*----------------------------------------------------------------*/
  1483.     pen_state = &m->pen_state;
  1484.     ret = MMI_TRUE;
  1485.     *menu_event = GUI_LIST_PEN_NONE;
  1486.     if (pen_event != MMI_PEN_EVENT_DOWN && pen_state->pen_on_scrollbar)
  1487.     {
  1488.         gui_vertical_scrollbar_translate_pen_event(&m->vbar, pen_event, x, y, &scrollbar_event, &scrollbar_param);
  1489.         if (scrollbar_event == GUI_SCROLLBAR_PEN_JUMP_TO_I)
  1490.         {
  1491.             if (m->pen_scroll_delay_time > 0)   /* Delay time for scrollbar scrolling */
  1492.             {
  1493.                 gui_dyamic_list_start_scroll_timer(m, scrollbar_param._u.i);
  1494.             }
  1495.             else
  1496.             {
  1497.                 gui_dynamic_list_menu_scroll_by_pen(m, scrollbar_param._u.i, menu_event);
  1498.             }
  1499.         }
  1500.     }
  1501.     else if (pen_event != MMI_PEN_EVENT_DOWN && pen_state->handled_by_menu_item)
  1502.     {
  1503.         /* For example, tap down on checkbox of two-state menuitem, the subsequent move/up events are discarded */
  1504.         S32 item_x, item_y;
  1505.         gui_dynamic_list_menu_get_menuitem_position(m, m->highlighted_item, &item_x, &item_y);
  1506.         m->item_pen_function(
  1507.             get_dynamic_item_from_buffer(m->highlighted_item),
  1508.             m->common_item_data,
  1509.             item_x,
  1510.             item_y,
  1511.             pen_event,
  1512.             x,
  1513.             y,
  1514.             &menuitem_event,
  1515.             &menuitem_param);
  1516.         if (menuitem_event == GUI_TWOSTATE_PEN_TOGGLE)
  1517.         {
  1518.             menuitem_event = GUI_LIST_PEN_ITEM_SELECTED;
  1519.         }
  1520.         *menu_event = menuitem_event;
  1521.     }
  1522.     else
  1523.     {
  1524.         switch (pen_event)
  1525.         {
  1526.             case MMI_PEN_EVENT_DOWN:
  1527.                 if (PEN_CHECK_BOUND(x, y, m->x, m->y, m->width, m->height))
  1528.                 {
  1529.                     pen_state->handled_by_menu_item = 0;
  1530.                     pen_state->pen_on_scrollbar = 0;
  1531.                     if (m->n_items <= 0)
  1532.                     {
  1533.                         /* In current design, scrollbar is hiden if m->n_items == 0 */
  1534.                         ret = MMI_FALSE;
  1535.                     }
  1536.                     else if (!(m->flags & UI_LIST_MENU_DISABLE_SCROLLBAR) &&
  1537.                              gui_vertical_scrollbar_translate_pen_event(
  1538.                                 &m->vbar,
  1539.                                 MMI_PEN_EVENT_DOWN,
  1540.                                 x,
  1541.                                 y,
  1542.                                 &scrollbar_event,
  1543.                                 &scrollbar_param))
  1544.                     {
  1545.                         pen_state->pen_on_scrollbar = 1;
  1546.                         if (scrollbar_event == GUI_SCROLLBAR_PEN_JUMP_TO_I)
  1547.                         {
  1548.                             if (m->pen_scroll_delay_time > 0)   /* Delay time for scrollbar scrolling */
  1549.                             {
  1550.                                 gui_dyamic_list_start_scroll_timer(m, scrollbar_param._u.i);
  1551.                             }
  1552.                             else
  1553.                             {
  1554.                                 gui_dynamic_list_menu_scroll_by_pen(m, scrollbar_param._u.i, menu_event);
  1555.                             }
  1556.                         }
  1557.                     }
  1558.                     else
  1559.                     {
  1560.                         if (gui_dynamic_list_menu_translate_pen_position(m, y, &item_index))
  1561.                         {
  1562.                             S32 item_x, item_y;
  1563.                             if (item_index != m->highlighted_item)
  1564.                             {
  1565.                                 gui_dynamic_list_menu_goto_item(m, item_index);
  1566.                                 *menu_event = GUI_LIST_PEN_HIGHLIGHT_CHANGED;
  1567.                             }
  1568.                             /* Even if highlight is changed, we still need to invoke menuitem pen handler */
  1569.                             gui_dynamic_list_menu_get_menuitem_position(m, item_index, &item_x, &item_y);
  1570.                             if (m->
  1571.                                 item_pen_function(
  1572.                                     get_dynamic_item_from_buffer(item_index),
  1573.                                     m->common_item_data,
  1574.                                     item_x,
  1575.                                     item_y,
  1576.                                     MMI_PEN_EVENT_DOWN,
  1577.                                     x,
  1578.                                     y,
  1579.                                     &menuitem_event,
  1580.                                     &menuitem_param))
  1581.                             {
  1582.                                 if (menuitem_event == GUI_TWOSTATE_PEN_TOGGLE)
  1583.                                 {
  1584.                                     menuitem_event = GUI_LIST_PEN_ITEM_SELECTED;
  1585.                                 }
  1586.                                 /* original menu_event could be GUI_LIST_PEN_HIGHLIGHT_CHANGED */
  1587.                                 if (menuitem_event != GUI_LIST_PEN_NONE)
  1588.                                 {
  1589.                                     *menu_event = menuitem_event;
  1590.                                 }
  1591.                                 pen_state->handled_by_menu_item = 1;
  1592.                             }
  1593.                         }
  1594.                         else
  1595.                         {
  1596.                             /* # of menu items < # of displayable menu items */
  1597.                             ret = MMI_FALSE;
  1598.                         }
  1599.                     }
  1600.                     pen_state->first_highlighed_item = m->highlighted_item;
  1601.                     pen_state->highlight_changed = 0;
  1602.                 }
  1603.                 else
  1604.                 {
  1605.                     ret = MMI_FALSE;
  1606.                 }
  1607.                 break;
  1608.             case MMI_PEN_EVENT_LONG_TAP:
  1609.                 /* FALLTHROUGH no break */
  1610.             case MMI_PEN_EVENT_REPEAT:
  1611.                 /* FALLTHROUGH no break */
  1612.             case MMI_PEN_EVENT_MOVE:
  1613.                 if (!m->disable_move_highlight)
  1614.                 {
  1615.                     gui_dynamic_list_menu_translate_pen_position(m, y, &item_index);
  1616.                     if (item_index != m->highlighted_item)
  1617.                     {
  1618.                         gui_dynamic_list_menu_goto_item(m, item_index);
  1619.                         *menu_event = GUI_LIST_PEN_HIGHLIGHT_CHANGED;
  1620.                     }
  1621.                 }
  1622.                 break;
  1623.             case MMI_PEN_EVENT_UP:
  1624.                 if (!m->disable_up_select)
  1625.                 {
  1626.                     if (PEN_CHECK_BOUND(x, y, m->x, m->y, m->width, m->height))
  1627.                     {
  1628.                         gui_dynamic_list_menu_translate_pen_position(m, y, &item_index);
  1629.                         if (item_index != m->highlighted_item)
  1630.                         {
  1631.                             if (!m->disable_move_highlight)
  1632.                             {
  1633.                                 /* If MMI_PEN_EVENT_MOVE is not delivered before moving to this item */
  1634.                                 gui_dynamic_list_menu_goto_item(m, item_index);
  1635.                                 *menu_event = GUI_LIST_PEN_HIGHLIGHT_CHANGED;
  1636.                             }
  1637.                         }
  1638.                         else if (pen_state->highlight_changed)
  1639.                         {
  1640.                             *menu_event = GUI_LIST_PEN_NONE;
  1641.                         }
  1642.                         else
  1643.                         {
  1644.                             *menu_event = GUI_LIST_PEN_ITEM_SELECTED;
  1645.                         }
  1646.                     }
  1647.                 }
  1648.                 break;
  1649.             case MMI_PEN_EVENT_ABORT:
  1650.                 /* Do nothing */
  1651.                 break;
  1652.             default:
  1653.                 MMI_ASSERT(0);
  1654.         }
  1655.     }
  1656.     if (ret)
  1657.     {
  1658.         if (pen_state->first_highlighed_item != m->highlighted_item)
  1659.         {
  1660.             pen_state->highlight_changed = 1;
  1661.         }
  1662.     }
  1663.     return ret;
  1664. }
  1665. #endif /* __MMI_TOUCH_SCREEN__ */