gui_fixed_menus.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:255k
源码类别:
MTK
开发平台:
C/C++
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * gui_fixed_menus.c
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- * Fixed-list menu - UI component
- *
- * 1. The number of menu items stays unchanged after the UI component is created.
- * 2. The storage of all menu item data is preallocated.
- *
- * Author:
- * -------
- * -------
- * -------
- * -------
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- /**
- * Copyright Notice
- * (c) 2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
- * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
- * (It is illegal to remove this copyright notice from this software or any
- * portion of it)
- */
- /**********************************************************************************
- Filename: gui_fixed_menus.c
- Author: manju
- Date Created: July-22-2002
- Contains: PixTel UI routines for Fixed Menus
- **********************************************************************************/
- #include "MMI_Features.h"
- #include "gui_config.h"
- #include "gui_fixed_menus.h"
- #include "CustMenuRes.h"
- #include "wgui_inline_edit.h"
- #include "gui_windows.h"
- #include "DebugInitDef.h"
- #include "gui_themes.h"
- #include "wgui_categories_util.h"
- #include "gui_setting.h"
- #include "kal_non_specific_general_types.h"
- #include "lcd_sw_rnd.h"
- #include "gdi_include.h"
- #include "wgui.h"
- extern gdi_handle wgui_layer_1;
- extern gdi_handle wgui_base_layer;
- extern PU8 get_image(MMI_ID_TYPE);
- #if defined(__MMI_MATRIX_MAIN_MENU_FULL_BACKGROUND__) && defined(__MMI_MATRIX_MAIN_MENU_OPTIMIZE__)
- #define OPTIMIZE_MM_BUF_SIZE (100*100*2) //Old:7200 //KP Jerry modify on 2007-1-19
- U8 opt_mm_buf[OPTIMIZE_MM_BUF_SIZE];
- #endif /* defined(__MMI_MATRIX_MAIN_MENU_FULL_BACKGROUND__) && defined(__MMI_MATRIX_MAIN_MENU_OPTIMIZE__) */
- /*
- * Resident background filler cache of list menu shared among multiple screens
- */
- /* Enable resident filler cache if no hardware GIF and lcd size >= 176x220 */
- #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__))
- #define __MMI_UI_LIST_RESIDENT_FILLER_CACHE__
- #endif
- #ifdef __MMI_UI_LIST_RESIDENT_FILLER_CACHE__
- #define GUI_LIST_MENU_FILLER_CACHE_MAX_WIDTH GDI_LCD_WIDTH
- /* Sometimes menu height is slightly larger than MMI_CONTENT_HEIGHT */
- #define GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT (MMI_CONTENT_HEIGHT + 10)
- #if (GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT > GDI_LCD_HEIGHT)
- #undef GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT
- #define GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT GDI_LCD_HEIGHT
- #endif /* (GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT > GDI_LCD_HEIGHT) */
- /* Size of cache pool in byte */
- #define GUI_LIST_MENU_FILLER_CACHE_SIZE
- ((GUI_LIST_MENU_FILLER_CACHE_MAX_WIDTH * GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT * GDI_MAINLCD_BIT_PER_PIXEL + 7) / 8)
- /* Cached filler */
- static UI_filled_area *g_gui_list_menu_filler_cache_target = NULL;
- /* Cache pool of background filler (4-byte aligned for potential optimization) */
- static U32 g_gui_list_menu_filler_cache[(GUI_LIST_MENU_FILLER_CACHE_SIZE + 3) / 4];
- #endif /* __MMI_UI_LIST_RESIDENT_FILLER_CACHE__ */
- S32 mmi_fixed_menu_bg_id = -1;
- /* for R2L characters */
- extern BOOL r2lMMIFlag;
- extern S32 menu_item_inline_multiline_box(void);
- extern int gdi_layer_get_bit_per_pixel(void);
- extern PU8 get_image(U16 i);
- /* GUI: fixed list menu functions */
- UI_fixed_list_menu_theme *current_fixed_list_menu_theme = NULL;
- S32 current_fixed_list_menuitem_display_index = -1;
- /*****************************************************************************
- * FUNCTION
- * UI_dummy_menuitem_displayed_function
- * DESCRIPTION
- *
- * PARAMETERS
- * index [IN]
- * x1 [IN]
- * y1 [IN]
- * x2 [IN]
- * y2 [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void UI_dummy_menuitem_displayed_function(S32 index, S32 x1, S32 y1, S32 x2, S32 y2)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- UI_UNUSED_PARAMETER(index);
- UI_UNUSED_PARAMETER(x1);
- UI_UNUSED_PARAMETER(y1);
- UI_UNUSED_PARAMETER(x2);
- UI_UNUSED_PARAMETER(y2);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_set_fixed_list_menu_current_theme
- * DESCRIPTION
- * Applies the current theme to a fixed list menu
- * PARAMETERS
- * m [IN] Is the fixed list menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_fixed_list_menu_current_theme(fixed_list_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->flags |= current_fixed_list_menu_theme->flags;
- m->focussed_filler = current_fixed_list_menu_theme->focussed_filler;
- m->normal_filler = current_fixed_list_menu_theme->normal_filler;
- gui_resize_vertical_scrollbar(&m->vbar, current_fixed_list_menu_theme->vbar_width, m->vbar.height);
- gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - current_fixed_list_menu_theme->vbar_width, m->y);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_set_fixed_list_menu_theme
- * DESCRIPTION
- * Applies the given theme to a fixed list menu
- * PARAMETERS
- * m [IN] Is the fixed list menu object
- * t [IN] Is the theme
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_fixed_list_menu_theme(fixed_list_menu *m, UI_fixed_list_menu_theme *t)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->flags |= t->flags;
- m->focussed_filler = t->focussed_filler;
- m->normal_filler = t->normal_filler;
- gui_resize_vertical_scrollbar(&m->vbar, t->vbar_width, m->vbar.height);
- gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - current_fixed_list_menu_theme->vbar_width, m->y);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_create_fixed_list_menu
- * DESCRIPTION
- * Creates a fixed list menu object
- * PARAMETERS
- * m [IN] Is the fixed list menu object (pre-allocated)
- * x [IN] Is the left-top corner position
- * y [IN] Is the left-top corner position
- * width [IN] Are the dimensions
- * height [IN] Are the dimensions
- * RETURNS
- * void
- *****************************************************************************/
- void gui_create_fixed_list_menu(fixed_list_menu *m, S32 x, S32 y, S32 width, S32 height)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->flags = 0;
- m->x = x;
- m->y = y;
- m->width = width;
- m->height = height;
- m->n_items = 0;
- m->highlighted_item = 0;
- m->first_displayed_item = 0;
- m->last_displayed_item = 0;
- m->displayed_items = 0;
- m->spacing = 0;
- m->top = 0;
- gui_set_fixed_list_menu_current_theme(m);
- gui_create_vertical_scrollbar(
- &m->vbar,
- m->x + m->width - current_fixed_list_menu_theme->vbar_width,
- m->y,
- current_fixed_list_menu_theme->vbar_width,
- m->height);
- m->item_highlighted = UI_dummy_function_s32;
- m->item_unhighlighted = UI_dummy_function_s32;
- m->item_display_function = UI_fixed_menuitem_dummy_display_function;
- m->item_hide_function = UI_fixed_menuitem_dummy_display_function;
- m->item_measure_function = UI_fixed_menuitem_dummy_measure_function;
- m->item_highlight_function = UI_fixed_menuitem_dummy_highlight_function;
- m->item_remove_highlight_function = UI_fixed_menuitem_dummy_remove_highlight_function;
- m->item_resize_function = UI_fixed_menuitem_dummy_resize_function;
- m->items = NULL;
- m->common_item_data = NULL;
- m->item_displayed_callback = UI_dummy_menuitem_displayed_function;
- m->resized_before_locate = MMI_FALSE;
- m->act_layer_handle = GDI_LAYER_MAIN_BASE_LAYER_HANDLE;
- m->act_lcd_handle = GDI_LCD_MAIN_LCD_HANDLE;
- #ifdef __MMI_TOUCH_SCREEN__
- m->pen_event_current_selected_callback_function = NULL;
- m->pen_event_default_selected_callback_function = NULL;
- m->pen_redraw_menu_function = NULL;
- m->item_pen_function = UI_fixed_menuitem_dummy_pen_function;
- m->disable_move_highlight = MMI_FALSE;
- m->disable_up_select = MMI_FALSE;
- m->pen_scroll_delay_time = 0;
- m->pen_scroll_after_delay = -1;
- memset(&(m->pen_state), 0, sizeof(gui_list_pen_state_struct));
- #endif /* __MMI_TOUCH_SCREEN__ */
- }
- /*****************************************************************************
- * FUNCTION
- * gui_resize_fixed_list_menu
- * DESCRIPTION
- * Changes the size of a fixed list menu
- * PARAMETERS
- * m [IN] Is the fixed list menu object
- * width [IN] Is the new width
- * height [IN] Is the new height
- * RETURNS
- * void
- *****************************************************************************/
- void gui_resize_fixed_list_menu(fixed_list_menu *m, S32 width, S32 height)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->width = width;
- m->height = height;
- /*
- * Example: change highlight in inline editor, list menu is resized
- * according to virtual keyboard.
- * We have to recompute m->first_displayed_item
- */
- m->resized_before_locate = MMI_TRUE;
- gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - current_fixed_list_menu_theme->vbar_width, m->y);
- gui_resize_vertical_scrollbar(&m->vbar, m->vbar.width, m->height);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_move_fixed_list_menu
- * DESCRIPTION
- * Moves the fixed list menu to a different co-ordinate
- * PARAMETERS
- * m [IN] Is the fixed list menu object
- * x [IN] Is the new left-top corner position
- * y [IN] Is the new left-top corner position
- * RETURNS
- * void
- *****************************************************************************/
- void gui_move_fixed_list_menu(fixed_list_menu *m, S32 x, S32 y)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->x = x;
- m->y = y;
- gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - current_fixed_list_menu_theme->vbar_width, m->y);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_list_menu_locate_highlighted_item
- * DESCRIPTION
- * Used to locate the highlighted item in the fixed list menu
- *
- * This is an internal function
- * PARAMETERS
- * m [IN] Is the fixed list menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_list_menu_locate_highlighted_item(fixed_list_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 iwidth, iheight;
- #if 0
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #endif /* 0 */
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (m->flags & UI_LIST_MENU_FIRST_SHIFT_HIGHLIGHTED_ITEM)
- {
- S32 total_height = 0, i;
- U8 done = 0;
- S32 list_height = m->height;
- m->flags &= ~UI_LIST_MENU_FIRST_SHIFT_HIGHLIGHTED_ITEM;
- m->first_displayed_item = m->highlighted_item;
- for (i = m->n_items - 1; (i >= 0) && (!done); i--)
- {
- #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
- if (i == m->highlighted_item)
- {
- current_fixed_list_menuitem_display_index = -1;
- }
- else
- {
- current_fixed_list_menuitem_display_index = i;
- }
- #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- total_height += iheight;
- if (total_height > list_height + 1)
- {
- if (m->first_displayed_item > i)
- {
- done = 1;
- m->first_displayed_item = i + 1;
- m->last_displayed_item = m->n_items - 1;
- }
- break;
- }
- }
- if (total_height <= list_height)
- {
- m->first_displayed_item = 0;
- }
- total_height = 0;
- for (i = m->first_displayed_item; (i < m->n_items) && (!done); i++)
- {
- #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
- if (i == m->highlighted_item)
- {
- current_fixed_list_menuitem_display_index = -1;
- }
- else
- {
- current_fixed_list_menuitem_display_index = i;
- }
- #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- total_height += iheight;
- if (total_height > list_height + 1)
- {
- done = 1;
- m->last_displayed_item = i - 1;
- }
- }
- }
- else if (m->flags & UI_LIST_MENU_LAST_SHIFT_HIGHLIGHTED_ITEM)
- {
- S32 total_height = 0, i;
- U8 done = 0;
- S32 list_height = m->height;
- m->flags &= ~UI_LIST_MENU_LAST_SHIFT_HIGHLIGHTED_ITEM;
- m->last_displayed_item = m->highlighted_item;
- /* Check if in the first page */
- for (i = 0; (i < m->n_items) && !done; i++)
- {
- #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
- if (i == m->highlighted_item)
- {
- current_fixed_list_menuitem_display_index = -1;
- }
- else
- {
- current_fixed_list_menuitem_display_index = i;
- }
- #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- total_height += iheight;
- if (total_height > list_height + 1)
- {
- if (m->last_displayed_item < i)
- {
- done = 1;
- m->first_displayed_item = 0;
- m->last_displayed_item = i - 1;
- }
- break;
- }
- }
- /* Check if in the last page */
- if (!done && total_height <= list_height)
- {
- done = 1;
- m->first_displayed_item = 0;
- m->last_displayed_item = m->n_items - 1;
- }
- /* Align to the bottom */
- total_height = 0;
- if (!done)
- {
- for (i = m->last_displayed_item; (i >= 0) && (!done); i--)
- {
- #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
- if (i == m->highlighted_item)
- {
- current_fixed_list_menuitem_display_index = -1;
- }
- else
- {
- current_fixed_list_menuitem_display_index = i;
- }
- #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- total_height += iheight;
- if (total_height > list_height + 1)
- {
- done = 1;
- m->first_displayed_item = i + 1;
- }
- }
- if (!done)
- {
- m->first_displayed_item = 0;
- }
- }
- }
- else if (m->flags & UI_LIST_MENU_CENTER_HIGHLIGHTED)
- {
- m->first_displayed_item = m->highlighted_item - 1;
- if (m->first_displayed_item < 0)
- {
- m->first_displayed_item = m->n_items - 1;
- }
- m->last_displayed_item = m->highlighted_item + 1;
- if (m->last_displayed_item >= m->n_items)
- {
- m->last_displayed_item = 0;
- }
- }
- else
- {
- if (m->highlighted_item < m->first_displayed_item)
- {
- m->first_displayed_item = m->highlighted_item;
- }
- else if (m->highlighted_item > m->last_displayed_item)
- {
- U8 done = 0;
- S32 total_height = 0, i;
- S32 list_height = m->height;
- m->last_displayed_item = m->highlighted_item;
- for (i = m->last_displayed_item; i >= 0 && (!done); i--)
- {
- #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
- if (i == m->highlighted_item)
- {
- current_fixed_list_menuitem_display_index = -1;
- }
- else
- {
- current_fixed_list_menuitem_display_index = i;
- }
- #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- total_height += iheight;
- if (total_height > list_height)
- {
- done = 1;
- m->first_displayed_item = i + 1;
- }
- }
- }
- else
- {
- U8 done = 0;
- S32 total_height = 0, i;
- S32 list_height = m->height;
- for (i = m->first_displayed_item; i < m->n_items && (!done); i++)
- {
- #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
- if (i == m->highlighted_item)
- {
- current_fixed_list_menuitem_display_index = -1;
- }
- else
- {
- current_fixed_list_menuitem_display_index = i;
- }
- #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- total_height += iheight;
- if (total_height > list_height)
- {
- done = 1;
- m->last_displayed_item = i - 1;
- }
- }
- if (!done)
- {
- total_height = 0;
- for (i = m->n_items - 1; (i >= 0) && (!done); i--)
- {
- #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
- if (i == m->highlighted_item)
- {
- current_fixed_list_menuitem_display_index = -1;
- }
- else
- {
- current_fixed_list_menuitem_display_index = i;
- }
- #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- total_height += iheight;
- if (total_height > list_height)
- {
- done = 1;
- m->first_displayed_item = i + 1;
- m->last_displayed_item = m->n_items - 1;
- break;
- }
- }
- if (!done)
- {
- m->first_displayed_item = 0;
- m->last_displayed_item = m->n_items - 1;
- }
- }
- if (m->highlighted_item > m->last_displayed_item)
- {
- done = 0;
- total_height = 0;
- m->last_displayed_item = m->highlighted_item;
- for (i = m->last_displayed_item; i >= 0 && (!done); i--)
- {
- #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
- if (i == m->highlighted_item)
- {
- current_fixed_list_menuitem_display_index = -1;
- }
- else
- {
- current_fixed_list_menuitem_display_index = i;
- }
- #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- total_height += iheight;
- if (total_height > list_height)
- {
- done = 1;
- m->first_displayed_item = i + 1;
- }
- }
- }
- }
- }
- /* Located after resized */
- m->resized_before_locate = MMI_FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_list_menu_locate_previous_item
- * DESCRIPTION
- *
- * PARAMETERS
- * m [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_list_menu_locate_previous_item(fixed_list_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (m->flags & UI_LIST_MENU_CENTER_HIGHLIGHTED)
- {
- if (m->highlighted_item == 0)
- {
- m->first_displayed_item = m->n_items - 1;
- m->last_displayed_item = 1;
- }
- else
- {
- m->first_displayed_item = m->highlighted_item - 1;
- if (m->first_displayed_item < 0)
- {
- m->first_displayed_item = m->n_items - 1;
- }
- m->last_displayed_item = m->highlighted_item + 1;
- if (m->last_displayed_item > m->n_items - 1)
- {
- m->last_displayed_item = 0;
- }
- }
- }
- else
- {
- if (m->highlighted_item < m->first_displayed_item)
- {
- m->first_displayed_item = m->highlighted_item;
- }
- else if (m->resized_before_locate)
- {
- gui_fixed_list_menu_locate_highlighted_item(m);
- }
- #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
- else if (m->highlighted_item == m->last_displayed_item - 1)
- {
- S32 iwidth, iheight;
- U8 done = 0;
- S32 total_height = 0, i;
- S32 list_height = m->height;
- current_fixed_list_menuitem_display_index = -1;
- for (i = m->last_displayed_item; i >= 0 && (!done); i--)
- {
- if (i == m->highlighted_item)
- {
- current_fixed_list_menuitem_display_index = -1;
- }
- else
- {
- current_fixed_list_menuitem_display_index = i;
- }
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- total_height += iheight;
- if (total_height > list_height + 1)
- {
- done = 1;
- m->first_displayed_item = i + 1;
- }
- }
- }
- #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */
- }
- /* Located after resized */
- m->resized_before_locate = MMI_FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_list_menu_locate_next_item
- * DESCRIPTION
- *
- * PARAMETERS
- * m [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_list_menu_locate_next_item(fixed_list_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 iwidth, iheight;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (m->flags & UI_LIST_MENU_CENTER_HIGHLIGHTED)
- {
- m->first_displayed_item = m->highlighted_item - 1;
- if (m->first_displayed_item < 0)
- {
- m->first_displayed_item = m->n_items - 1;
- }
- m->last_displayed_item = m->highlighted_item + 1;
- if (m->last_displayed_item >= m->n_items)
- {
- m->last_displayed_item = 0;
- }
- }
- else
- {
- #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
- if (m->highlighted_item >= m->last_displayed_item)
- #else
- if (m->highlighted_item > m->last_displayed_item)
- #endif
- {
- U8 done = 0;
- S32 total_height = 0, i;
- S32 list_height = m->height;
- m->last_displayed_item = m->highlighted_item;
- for (i = m->last_displayed_item; i >= 0 && (!done); i--)
- {
- #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
- if (i == m->highlighted_item)
- {
- current_fixed_list_menuitem_display_index = -1;
- }
- else
- {
- current_fixed_list_menuitem_display_index = i;
- }
- #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- total_height += iheight;
- if (total_height > list_height + 1)
- {
- done = 1;
- m->first_displayed_item = i + 1;
- }
- }
- }
- else if (m->resized_before_locate)
- {
- gui_fixed_list_menu_locate_highlighted_item(m);
- }
- }
- /* Located after resized */
- m->resized_before_locate = MMI_FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * switch_fixed_list_highlighted_item
- * DESCRIPTION
- *
- * PARAMETERS
- * m [?]
- * last_highlighted_item [IN]
- * RETURNS
- * void
- *****************************************************************************/
- static void switch_fixed_list_highlighted_item(fixed_list_menu *m, S32 last_highlighted_item)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (last_highlighted_item != m->highlighted_item)
- {
- if ((last_highlighted_item >= 0) && (last_highlighted_item < m->n_items))
- {
- m->item_remove_highlight_function(m->items[last_highlighted_item], m->common_item_data);
- }
- if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
- {
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- m->item_unhighlighted(last_highlighted_item);
- #ifdef __MMI_TOUCH_SCREEN__
- m->pen_event_current_selected_callback_function = m->pen_event_default_selected_callback_function;
- #endif
- m->item_highlighted(m->highlighted_item);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_list_menu_goto_item
- * DESCRIPTION
- * Highlights a particular item
- *
- * The fixed list is not redrawn
- * PARAMETERS
- * m [IN] Is the fixed list menu object
- * i [IN] Is the index of the item to be highlighted (zero based)
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_list_menu_goto_item(fixed_list_menu *m, S32 i)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 last_highlighted_item;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if ((i < 0) || (i > m->n_items - 1))
- {
- return;
- }
- if (i == m->highlighted_item)
- {
- return;
- }
- last_highlighted_item = m->highlighted_item;
- m->highlighted_item = i;
- gui_fixed_list_menu_locate_highlighted_item(m);
- switch_fixed_list_highlighted_item(m, last_highlighted_item);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_list_menu_goto_next_item
- * DESCRIPTION
- * Higlights the next item
- *
- * The fixed list is not redrawn
- * PARAMETERS
- * m [IN] Is the fixed list menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_list_menu_goto_next_item(fixed_list_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 last_highlighted_item;
- U8 loop_flag = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (m->highlighted_item >= (m->n_items - 1))
- {
- if (m->flags & UI_LIST_MENU_LOOP)
- {
- loop_flag = 1;
- }
- else
- {
- return;
- }
- }
- last_highlighted_item = m->highlighted_item;
- if (loop_flag)
- {
- m->highlighted_item = 0;
- gui_fixed_list_menu_locate_previous_item(m);
- }
- else
- {
- m->highlighted_item++;
- gui_fixed_list_menu_locate_next_item(m);
- }
- switch_fixed_list_highlighted_item(m, last_highlighted_item);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_list_menu_goto_previous_item
- * DESCRIPTION
- * Higlights the previous item
- *
- * The fixed list is not redrawn
- * PARAMETERS
- * m [IN] Is the fixed list menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_list_menu_goto_previous_item(fixed_list_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 last_highlighted_item;
- U8 loop_flag = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (m->highlighted_item <= 0)
- {
- if (m->flags & UI_LIST_MENU_LOOP)
- {
- loop_flag = 1;
- }
- else
- {
- return;
- }
- }
- last_highlighted_item = m->highlighted_item;
- if (loop_flag)
- {
- m->highlighted_item = m->n_items - 1;
- gui_fixed_list_menu_locate_next_item(m);
- }
- else
- {
- m->highlighted_item--;
- gui_fixed_list_menu_locate_previous_item(m);
- }
- switch_fixed_list_highlighted_item(m, last_highlighted_item);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_list_menu_goto_next_page
- * DESCRIPTION
- * Higlights an item in the next page
- *
- * The fixed list is not redrawn
- * PARAMETERS
- * m [IN] Is the fixed list menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_list_menu_goto_next_page(fixed_list_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 last_highlighted_item;
- S32 iwidth, iheight;
- U8 done = 0;
- S32 total_height = 0, i;
- S32 list_height = m->height - 4;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- last_highlighted_item = m->highlighted_item;
- m->first_displayed_item += m->displayed_items;
- if (m->first_displayed_item > (m->n_items - 1))
- {
- m->first_displayed_item = (m->n_items - 1);
- m->last_displayed_item = m->first_displayed_item;
- }
- else
- {
- for (i = m->first_displayed_item; (i < m->n_items) && (!done); i++)
- {
- #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
- if (i == m->highlighted_item)
- {
- current_fixed_list_menuitem_display_index = -1;
- }
- else
- {
- current_fixed_list_menuitem_display_index = i;
- }
- #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- total_height += iheight;
- if (total_height > list_height + 1)
- {
- done = 1;
- m->last_displayed_item = i - 1;
- }
- }
- }
- for (i = m->last_displayed_item; i >= 0 && (!done); i--)
- {
- #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
- if (i == m->highlighted_item)
- {
- current_fixed_list_menuitem_display_index = -1;
- }
- else
- {
- current_fixed_list_menuitem_display_index = i;
- }
- #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- total_height += iheight;
- if (total_height > list_height + 1)
- {
- done = 1;
- m->first_displayed_item = i + 1;
- }
- }
- m->highlighted_item = m->first_displayed_item;
- switch_fixed_list_highlighted_item(m, last_highlighted_item);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_list_menu_goto_previous_page
- * DESCRIPTION
- * Higlights an item in the previous page
- *
- * The fixed list is not redrawn
- * PARAMETERS
- * m [IN] Is the fixed list menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_list_menu_goto_previous_page(fixed_list_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 last_highlighted_item;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- last_highlighted_item = m->highlighted_item;
- m->first_displayed_item -= m->displayed_items;
- if (m->first_displayed_item < 0)
- {
- m->first_displayed_item = 0;
- }
- m->highlighted_item = m->first_displayed_item;
- if (last_highlighted_item == m->highlighted_item)
- {
- return;
- }
- gui_fixed_list_menu_locate_highlighted_item(m);
- switch_fixed_list_highlighted_item(m, last_highlighted_item);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_list_menu_goto_first_item
- * DESCRIPTION
- * Higlights the first item
- *
- * The fixed list is not redrawn
- * PARAMETERS
- * m [IN] Is the fixed list menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_list_menu_goto_first_item(fixed_list_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 last_highlighted_item;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (m->highlighted_item == 0)
- {
- return;
- }
- last_highlighted_item = m->highlighted_item;
- m->highlighted_item = 0;
- gui_fixed_list_menu_locate_highlighted_item(m);
- switch_fixed_list_highlighted_item(m, last_highlighted_item);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_list_menu_goto_last_item
- * DESCRIPTION
- * Higlights the last item
- *
- * The fixed list is not redrawn
- * PARAMETERS
- * m [IN] Is the fixed list menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_list_menu_goto_last_item(fixed_list_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 last_highlighted_item;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (m->highlighted_item == (m->n_items - 1))
- {
- return;
- }
- last_highlighted_item = m->highlighted_item;
- m->highlighted_item = (m->n_items - 1);
- gui_fixed_list_menu_locate_highlighted_item(m);
- switch_fixed_list_highlighted_item(m, last_highlighted_item);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_show_menu_background_filler_from_cache
- * DESCRIPTION
- * Displays the menu background in another GDI layer
- * PARAMETERS
- * x1 [IN]
- * y1 [IN]
- * x2 [IN]
- * y2 [IN]
- * f [IN] Background filler
- * RETURNS
- * void
- *****************************************************************************/
- #ifdef __MMI_UI_LIST_CACHE_BACKGROUND__
- /* Check compile option dependency */
- #if !defined(__GDI_MEMORY_PROFILE_2__) || defined(__MMI_WALLPAPER_ON_BOTTOM__)
- #error "__MMI_UI_LIST_CACHE_BACKGROUND__ require __GDI_MEMORY_PROFILE_2__"
- #endif
- #ifdef __MMI_UI_LIST_RESIDENT_FILLER_CACHE__
- void gui_show_menu_background_filler_from_cache(S32 x1, S32 y1, S32 x2, S32 y2, UI_filled_area *f)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (!f)
- {
- return;
- }
- if (g_gui_list_menu_filler_cache_target != f)
- {
- /* Cache filler */
- gdi_handle cache_layer;
- g_gui_list_menu_filler_cache_target = f;
- gdi_layer_create_using_outside_memory(
- 0,
- 0,
- GUI_LIST_MENU_FILLER_CACHE_MAX_WIDTH,
- GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT,
- &cache_layer,
- (U8*) g_gui_list_menu_filler_cache,
- sizeof(g_gui_list_menu_filler_cache));
- gdi_layer_push_and_set_active(cache_layer);
- gui_draw_filled_area(
- 0,
- 0,
- GUI_LIST_MENU_FILLER_CACHE_MAX_WIDTH - 1,
- GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT - 1,
- f);
- gdi_layer_pop_and_restore_active();
- gdi_layer_free(cache_layer);
- }
- if ((x2 - x1 + 1 > GUI_LIST_MENU_FILLER_CACHE_MAX_WIDTH) || (y2 - y1 + 1 > GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT))
- {
- MMI_DBG_ASSERT(0); /* invaild cache */
- gui_draw_filled_area(x1, y1, x2, y2, f);
- }
- else
- {
- PU8 dest;
- S32 dest_layer_width, dest_layer_height;
- gdi_rect_struct dest_clip;
- gdi_layer_get_buffer_ptr(&dest);
- gdi_layer_get_dimension(&dest_layer_width, &dest_layer_height);
- dest_clip.x1 = x1;
- dest_clip.y1 = y1;
- dest_clip.x2 = x2;
- dest_clip.y2 = y2;
- gdi_2d_memory_blt(
- (U8*) g_gui_list_menu_filler_cache,
- GUI_LIST_MENU_FILLER_CACHE_MAX_WIDTH,
- 0,
- 0,
- GUI_LIST_MENU_FILLER_CACHE_MAX_WIDTH,
- GUI_LIST_MENU_FILLER_CACHE_MAX_HEIGHT,
- dest,
- dest_layer_width,
- x1,
- y1,
- dest_clip);
- }
- }
- #endif /* __MMI_UI_LIST_RESIDENT_FILLER_CACHE__ */
- /*****************************************************************************
- * FUNCTION
- * gui_show_menu_background_in_layer
- * DESCRIPTION
- *
- * PARAMETERS
- * x1 [IN]
- * y1 [IN]
- * x2 [IN]
- * y2 [IN]
- * f [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_show_menu_background_in_layer(S32 x1, S32 y1, S32 x2, S32 y2, UI_filled_area *f)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 width = x2 - x1 + 1;
- S32 height = y2 - y1 + 1;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /*
- * We do not use gui_set_transparent_source_layer() in this function because
- * not all list menu use gui_show_menu_background_in_layer(), then some menus
- * have transparency effect but others do not on platforms that
- * !defined(__MMI_WALLPAPER_ON_BOTTOM__) && defined (__MMI_UI_TRANSPARENT_EFFECT__)
- */
- if (!gui_is_entry_new_screen())
- {
- S32 layer_width, layer_height, layer_x, layer_y;
- gdi_layer_push_and_set_active(wgui_layer_1);
- gdi_layer_get_position(&layer_x, &layer_y);
- gdi_layer_get_dimension(&layer_width, &layer_height);
- if (layer_width != (x2 - x1 + 1) || layer_height != (y2 - y1 + 1))
- {
- MMI_DBG_ASSERT(0);
- }
- if (layer_x != x1 || layer_y != y1)
- {
- gdi_layer_set_position(x1, y1);
- }
- gdi_layer_pop_and_restore_active();
- if (dm_is_activated())
- {
- /*
- * If draw manager is reset by RedrawCategoryScreen(), original information of draw manager layers are discarded
- * We need to configure the layer information again.
- */
- dm_add_blt_layer(wgui_layer_1, DM_LAYER_BOTTOM);
- }
- gdi_draw_solid_rect(x1, y1, x2, y2, GDI_COLOR_TRANSPARENT);
- }
- else
- {
- gui_set_entry_new_screen(MMI_FALSE);
- gdi_layer_multi_layer_enable();
- gdi_layer_get_base_handle(&wgui_base_layer);
- /* Setup the base layer */
- gdi_layer_push_and_set_active(wgui_base_layer);
- gdi_layer_set_source_key(TRUE, GDI_COLOR_TRANSPARENT);
- gdi_layer_set_opacity(TRUE, UI_SUBMENU_OPACITY_BASED_LAYER);
- gdi_layer_push_clip();
- gdi_layer_set_clip(x1, y1, x2, y2);
- gdi_draw_solid_rect(x1, y1, x2, y2, GDI_COLOR_TRANSPARENT);
- gdi_layer_pop_clip();
- gdi_layer_pop_and_restore_active();
- /* Create multilayer buffer */
- if (wgui_layer_1 == GDI_LAYER_EMPTY_HANDLE)
- {
- if (dm_is_activated())
- {
- /* BLT layers are controlled by draw manager */
- dm_create_layer(x1, y1, width, height, &wgui_layer_1, DM_LAYER_BOTTOM);
- }
- else
- {
- gdi_layer_create(x1, y1, width, height, &wgui_layer_1);
- gdi_layer_set_blt_layer(wgui_layer_1, wgui_base_layer, 0, 0);
- }
- }
- gdi_layer_push_and_set_active(wgui_layer_1);
- #ifdef __MMI_UI_LIST_RESIDENT_FILLER_CACHE__
- gui_show_menu_background_filler_from_cache(0, 0, width - 1, height - 1, f);
- #else
- gui_draw_filled_area(0, 0, width - 1, height - 1, f);
- #endif
- gdi_layer_pop_and_restore_active();
- }
- }
- #endif /* __MMI_UI_LIST_CACHE_BACKGROUND__ */
- /*****************************************************************************
- * FUNCTION
- * gui_show_list_menu_background_outside_area
- * DESCRIPTION
- * Show the extended menu background outside the menu display area.
- *
- * For example, in handwriting mode of inline editor, we may want to draw
- * menu background in the bottom virtual keyboard area when the keyboard is hidden.
- *
- * Note: This API does not use any menu cache
- * PARAMETERS
- * m [IN] Is the list menu object
- * x1 [IN] left-top x
- * y1 [IN] left-top y
- * x2 [IN] right-bottom x
- * y2 [IN] right-bottom y
- * RETURNS
- * void
- *****************************************************************************/
- void gui_show_list_menu_background_outside_area(fixed_list_menu *m, S32 x1, S32 y1, S32 x2, S32 y2)
- {
- UI_filled_area *f;
- if (m->flags & UI_LIST_MENU_STATE_FOCUSSED)
- {
- f = m->focussed_filler;
- }
- else
- {
- f = m->normal_filler;
- }
- gui_push_clip();
- gui_set_clip(x1, y1, x2, y2);
- gui_draw_filled_area(m->x, m->y, x2, y2, f);
- gui_pop_clip();
- }
- /*****************************************************************************
- * FUNCTION
- * gui_show_fixed_list_menu
- * DESCRIPTION
- * Displays the fixed list menu
- * PARAMETERS
- * m [IN] Is the fixed list menu object
- * RETURNS
- * void
- *****************************************************************************/
- extern S32 MMI_current_menu_type;
- #ifdef __MMI_UI_DALMATIAN_FIXEDLIST__
- extern MMI_theme *current_MMI_theme;
- extern BOOL line_draw;
- extern fixed_list_menu MMI_fixed_list_menu;
- #endif /* __MMI_UI_DALMATIAN_FIXEDLIST__ */
- void gui_show_fixed_list_menu(fixed_list_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 x1, y1, x2, y2, y_offset;
- #ifdef __MMI_UI_DALMATIAN_FIXEDLIST__
- S32 ic, menu_grid_gap;
- #endif
- UI_filled_area *f;
- S32 i;
- S32 cx1, cy1, cx2, cy2;
- S32 tx1, ty1, tx2, ty2;
- S32 iwidth, iheight;
- U8 done = 0;
- S32 total_height, counter, list_height;
- U8 disable_draw = 0;
- MMI_BOOL show_scrollbar;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (m->flags & UI_LIST_MENU_DISABLE_DRAW)
- {
- disable_draw = 1;
- }
- gui_get_clip(&cx1, &cy1, &cx2, &cy2);
- gui_get_text_clip(&tx1, &ty1, &tx2, &ty2);
- x1 = m->x;
- y1 = m->y;
- x2 = x1 + m->width - 1;
- y2 = y1 + m->height - 1;
- /* Use the original x1, y1, x2, y2 for background filler */
- if (m->flags & UI_LIST_MENU_STATE_FOCUSSED)
- {
- f = m->focussed_filler;
- }
- else
- {
- f = m->normal_filler;
- }
- if (!disable_draw && (!(m->flags & UI_LIST_MENU_DISABLE_BACKGROUND)) && MMI_current_menu_type != PAGE_MENU)
- {
- gui_set_clip(x1, y1, x2, y2);
- if (!(m->flags & UI_LIST_MENU_DISABLE_BKGRND_IN_LAYER) && (wgui_is_wallpaper_on_bottom() == MMI_TRUE))
- {
- gdi_draw_solid_rect(x1, y1, x2, y2, GDI_COLOR_TRANSPARENT);
- /* PMT VIKAS START 20051217 */
- #if (defined (__MMI_UI_TRANSPARENT_EFFECT__) || defined (__MMI_UI_LIST_HIGHLIGHT_EFFECTS__))
- /* PMT VIKAS END 20051217 */
- if (gui_get_transparent_source_layer() == GDI_LAYER_EMPTY_HANDLE) /* 110705 WAP menu Clavin add */
- {
- gui_set_transparent_source_layer(dm_get_scr_bg_layer()); /* should remove */
- }
- #endif /* (defined (__MMI_UI_TRANSPARENT_EFFECT__) || defined (__MMI_UI_LIST_HIGHLIGHT_EFFECTS__)) */
- }
- #ifdef __MMI_UI_LIST_CACHE_BACKGROUND__
- else if (!(m->flags & UI_LIST_MENU_DISABLE_BKGRND_IN_LAYER) &&
- (dm_get_scr_bg_layer() == GDI_ERROR_HANDLE) && (gui_get_multilayer_mask() & UI_MUL_BKG_SUBMENU))
- {
- gui_show_menu_background_in_layer(x1, y1, x2, y2, f);
- }
- #endif /* __MMI_UI_LIST_CACHE_BACKGROUND__ */
- else
- {
- #if !defined(MT6205B) && !defined(MT6208)
- gui_draw_filled_area(x1, y1, x2, y2, f);
- #else /* !defined(MT6205B) && !defined(MT6208) */
- /* For low-end phone, disable list menu background can greately improve menu performance.
- We use the color of filler to draw the background (typically white). */
- color c = f->c;
- gdi_draw_solid_rect(x1, y1, x2, y2, gdi_act_color_from_rgb(255, c.r, c.g, c.b));
- #endif /* !defined(MT6205B) && !defined(MT6208) */
- }
- }
- if (m->flags & UI_LIST_MENU_ENABLE_TRANSITION)
- {
- color c = gui_color(255, 255, 255);
- gui_push_clip();
- gui_set_clip(x1, y1, x2, y2);
- gui_fill_rectangle(x1, y1, x2, y2, c);
- gui_pop_clip();
- }
- if (m->n_items <= 0)
- {
- return;
- }
- /* Check presence of scrollbar */
- show_scrollbar = MMI_FALSE;
- if (!(m->flags & UI_LIST_MENU_DISABLE_SCROLLBAR))
- {
- if (m->flags & UI_LIST_MENU_AUTO_DISABLE_SCROLLBAR)
- {
- if (m->first_displayed_item > 0)
- {
- show_scrollbar = MMI_TRUE;
- }
- else
- {
- /* FIXME. we need to compute m->displayed_items twice */
- gui_show_fixed_list_menu_no_draw(m);
- if (m->displayed_items >= m->n_items)
- {
- show_scrollbar = MMI_TRUE;
- }
- }
- }
- else
- {
- show_scrollbar = MMI_TRUE;
- }
- }
- /* Configure region of menu items */
- if (show_scrollbar)
- {
- if (!r2lMMIFlag)
- {
- x2 -= m->vbar.width;
- }
- else
- {
- x1 += m->vbar.width;
- }
- }
- /* Display menu items */
- if (MMI_current_menu_type == PAGE_MENU)
- {
- if (!disable_draw)
- {
- m->item_display_function(m->items[m->highlighted_item], m->common_item_data, m->x, m->y);
- }
- return;
- }
- y1 = m->y + m->top;
- list_height = m->height;
- gui_set_text_clip(x1, y1, x2, y2);
- gui_set_clip(x1, y1, x2, y2);
- total_height = 0;
- counter = 0;
- current_fixed_list_menuitem_display_index = -1;
- if (m->flags & UI_LIST_MENU_CENTER_HIGHLIGHTED)
- {
- #if 0 /* 111605 warning Calvin */
- #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #endif
- #endif /* 0 */
- m->item_measure_function(m->items[m->highlighted_item], m->common_item_data, &iwidth, &iheight);
- current_fixed_list_menuitem_display_index = m->first_displayed_item;
- m->item_display_function(m->items[m->first_displayed_item], m->common_item_data, x1, y1);
- current_fixed_list_menuitem_display_index = m->highlighted_item;
- m->item_display_function(m->items[m->highlighted_item], m->common_item_data, x1, y1 + iheight);
- current_fixed_list_menuitem_display_index = m->last_displayed_item;
- m->item_display_function(m->items[m->last_displayed_item], m->common_item_data, x1, y1 + iheight * 2);
- }
- else
- {
- for (i = m->first_displayed_item; (i < m->n_items && !done); i++)
- {
- if (i == m->highlighted_item)
- {
- current_fixed_list_menuitem_display_index = -1;
- }
- else
- {
- current_fixed_list_menuitem_display_index = i;
- }
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- y_offset = total_height;
- /* total_height+=iheight+m->spacing; */
- total_height += iheight;
- if (total_height > list_height + 1)
- {
- done = 1;
- /* This is required so that in trnasition if theire is no area to display the menu item it is not displayed */
- if ((counter == 0) && !disable_draw && !(m->flags & UI_LIST_MENU_ENABLE_TRANSITION))
- {
- m->item_display_function(m->items[i], m->common_item_data, x1, y_offset + y1);
- }
- }
- else
- {
- if (!disable_draw)
- {
- m->item_display_function(m->items[i], m->common_item_data, x1, y_offset + y1);
- }
- counter++;
- }
- #ifdef __MMI_UI_DALMATIAN_FIXEDLIST__
- if (line_draw && MMI_current_menu_type == LIST_MENU)
- {
- if (!r2lMMIFlag)
- {
- gui_draw_horizontal_line(
- x1,
- m->vbar.x - 2,
- y_offset + y1,
- current_MMI_theme->list_background_filler->border_color);
- }
- else
- {
- gui_draw_horizontal_line(
- x1,
- x2,
- y_offset + y1,
- current_MMI_theme->list_background_filler->border_color);
- }
- }
- #endif /* __MMI_UI_DALMATIAN_FIXEDLIST__ */
- }
- #ifdef __MMI_UI_DALMATIAN_FIXEDLIST__
- ic = i;
- /* To fix the grid issue due to top variable value. */
- menu_grid_gap = MMI_fixed_list_menu.height % iheight;
- menu_grid_gap -= m->top;
- if (line_draw && MMI_current_menu_type == LIST_MENU)
- {
- // To grid for sub menu screens
- // Used -2 for proper area selection
- if (ic == m->n_items)
- {
- if (!r2lMMIFlag)
- {
- gui_draw_horizontal_line(
- x1,
- m->vbar.x - 2,
- y_offset + y1 + iheight,
- current_MMI_theme->list_background_filler->border_color);
- }
- else
- {
- gui_draw_horizontal_line(
- x1,
- x2,
- y_offset + y1 + iheight,
- current_MMI_theme->list_background_filler->border_color);
- }
- }
- if (!r2lMMIFlag)
- {
- if (ic == m->n_items && done)
- {
- gui_draw_vertical_line(
- y1,
- y1 + y_offset,
- m->vbar.x - 2,
- current_MMI_theme->list_background_filler->border_color);
- }
- else
- {
- gui_draw_vertical_line(
- y1,
- ((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)),
- m->vbar.x - 2,
- current_MMI_theme->list_background_filler->border_color);
- }
- }
- else
- {
- if (i == m->n_items && done)
- {
- gui_draw_vertical_line(
- y1,
- y1 + y_offset,
- (m->vbar.x + m->vbar.width - m->width) + m->vbar.width,
- current_MMI_theme->list_background_filler->border_color);
- }
- else
- {
- gui_draw_vertical_line(
- y1,
- ((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)),
- (m->vbar.x + m->vbar.width - m->width) + m->vbar.width,
- current_MMI_theme->list_background_filler->border_color);
- }
- }
- }
- #endif /* __MMI_UI_DALMATIAN_FIXEDLIST__ */
- current_fixed_list_menuitem_display_index = -1;
- if (counter == 0)
- {
- m->last_displayed_item = m->first_displayed_item;
- }
- else
- {
- m->last_displayed_item = m->first_displayed_item + counter - 1;
- }
- m->displayed_items = counter;
- }
- gui_set_clip(cx1, cy1, cx2, cy2);
- gui_set_text_clip(tx1, ty1, tx2, ty2);
- /* Handle scrollbar */
- if (show_scrollbar)
- {
- /* FIXME. debug only. we can remove the check in the future */
- MMI_DBG_ASSERT(!(m->flags & UI_LIST_MENU_AUTO_DISABLE_SCROLLBAR) ||
- (total_height > list_height + 1) || (m->first_displayed_item > 0));
- if (r2lMMIFlag)
- {
- gui_move_vertical_scrollbar(&m->vbar, m->x, m->y);
- }
- else
- {
- gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - m->vbar.width, m->y);
- }
- gui_set_vertical_scrollbar_range(&m->vbar, m->n_items);
- gui_set_vertical_scrollbar_scale(&m->vbar, m->displayed_items);
- gui_set_vertical_scrollbar_value(&m->vbar, m->first_displayed_item);
- if (!disable_draw)
- {
- gui_show_vertical_scrollbar(&m->vbar);
- }
- }
- /* PMT VIKAS START 20051202 */
- #if defined (__MMI_UI_DALMATIAN_FIXEDLIST__) && !defined(__MMI_TOUCH_SCREEN__)
- if (line_draw && MMI_current_menu_type == LIST_MENU)
- /* PMT VIKAS END 20051202 */
- {
- gui_push_clip();
- if (!r2lMMIFlag)
- {
- gui_set_clip(m->vbar.x - 1, y1, m->vbar.x + m->vbar.width - 1, m->vbar.y + m->vbar.height - 1);
- }
- else
- {
- gui_set_clip(
- (m->vbar.x + m->vbar.width - m->width),
- y1,
- (m->vbar.x + m->vbar.width - m->width) + m->vbar.width,
- m->vbar.y + m->vbar.height - 1);
- }
- /* To grid for sub menu screens */
- if (!r2lMMIFlag)
- {
- 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 */
- 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 */
- 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 */
- }
- else
- {
- 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 */
- 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 */
- }
- gui_pop_clip();
- ic = 0;
- }
- #endif /* defined (__MMI_UI_DALMATIAN_FIXEDLIST__) && !defined(__MMI_TOUCH_SCREEN__) */
- }
- /*****************************************************************************
- * FUNCTION
- * gui_show_fixed_list_menu_no_draw
- * DESCRIPTION
- *
- * PARAMETERS
- * m [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_show_fixed_list_menu_no_draw(fixed_list_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i;
- S32 iwidth, iheight;
- U8 done = 0;
- S32 total_height, counter, list_height;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- list_height = m->height;
- total_height = 0;
- counter = 0;
- current_fixed_list_menuitem_display_index = -1;
- for (i = m->first_displayed_item; (i < m->n_items && !done); i++)
- {
- if (i == m->highlighted_item)
- {
- current_fixed_list_menuitem_display_index = -1;
- }
- else
- {
- current_fixed_list_menuitem_display_index = i;
- }
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- total_height += iheight;
- if (total_height > list_height + 1)
- {
- done = 1;
- }
- else
- {
- counter++;
- }
- }
- current_fixed_list_menuitem_display_index = -1;
- if (counter == 0)
- {
- m->last_displayed_item = m->first_displayed_item;
- }
- else
- {
- m->last_displayed_item = m->first_displayed_item + counter - 1;
- }
- m->displayed_items = counter;
- if (!(m->flags & UI_LIST_MENU_DISABLE_SCROLLBAR))
- {
- gui_set_vertical_scrollbar_range(&m->vbar, m->n_items);
- gui_set_vertical_scrollbar_scale(&m->vbar, m->displayed_items);
- gui_set_vertical_scrollbar_value(&m->vbar, m->first_displayed_item);
- }
- }
- #ifdef __MMI_TOUCH_SCREEN__
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_list_menu_translate_pen_position
- * DESCRIPTION
- * Translate position to item index
- *
- * if y < minimum bound, *item_index is first_displayed_item - 1 or 0
- * if y > maximum bound, *item_index is last_displayed_item + 1 or (n_items - 1)
- * Caller of this function might be sensitive to the return result.
- * Be careful when modifying this function.
- * PARAMETERS
- * m [IN] Is the fixed list menu object
- * y [IN] Y-axis coordinate
- * item_index [OUT]
- * RETURNS
- * whether the position is on menu items
- *****************************************************************************/
- BOOL gui_fixed_list_menu_translate_pen_position(fixed_list_menu *m, S32 y, S32 *item_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 total_height = 0, i;
- S32 iwidth, iheight;
- BOOL ret = MMI_FALSE;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- y -= m->y;
- if (m->n_items <= 0)
- {
- *item_index = 0;
- /* ret is false */
- }
- else if (y < 0)
- {
- *item_index = (m->first_displayed_item > 0) ? m->first_displayed_item - 1 : 0;
- /* ret is false */
- }
- else if (y >= m->height)
- {
- *item_index = (m->last_displayed_item < m->n_items - 1) ? m->last_displayed_item + 1 : m->n_items - 1;
- /* ret is false */
- }
- else
- {
- *item_index = m->n_items - 1;
- for (i = m->first_displayed_item; i < m->n_items; i++)
- {
- #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
- if (i == m->highlighted_item)
- {
- current_fixed_list_menuitem_display_index = -1;
- }
- else
- {
- current_fixed_list_menuitem_display_index = i;
- }
- #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- total_height += iheight;
- if (total_height > y)
- {
- *item_index = i;
- ret = MMI_TRUE;
- break;
- }
- }
- }
- return ret;
- }
- /*
- * IN: m, item_index
- * OUT: x, y
- */
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_list_menu_get_menuitem_position
- * DESCRIPTION
- *
- * PARAMETERS
- * m [?]
- * item_index [IN]
- * x [?]
- * y [?]
- * RETURNS
- * void
- *****************************************************************************/
- static void gui_fixed_list_menu_get_menuitem_position(fixed_list_menu *m, S32 item_index, S32 *x, S32 *y)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i, total_height = m->y;
- S32 iwidth, iheight;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- *x = m->x;
- if (item_index <= m->first_displayed_item)
- {
- *y = total_height;
- return;
- }
- for (i = m->first_displayed_item; i <= m->last_displayed_item; i++)
- {
- #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
- if (i == m->highlighted_item)
- {
- current_fixed_list_menuitem_display_index = -1;
- }
- else
- {
- current_fixed_list_menuitem_display_index = i;
- }
- #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- total_height += iheight;
- if (i + 1 == item_index)
- {
- *y = total_height;
- return;
- }
- }
- *y = total_height;
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_list_menu_scroll_by_pen
- * DESCRIPTION
- *
- * PARAMETERS
- * m [?]
- * first_displayed [IN]
- * menu_event [?]
- * RETURNS
- * void
- *****************************************************************************/
- static void gui_fixed_list_menu_scroll_by_pen(fixed_list_menu *m, S32 first_displayed, gui_list_pen_enum *menu_event)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 total_height = 0, i;
- S32 iwidth, iheight;
- S32 last_displayed = m->n_items - 1;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (first_displayed > m->highlighted_item)
- {
- m->flags |= UI_LIST_MENU_FIRST_SHIFT_HIGHLIGHTED_ITEM;
- gui_fixed_list_menu_goto_item(m, first_displayed);
- m->flags &= ~UI_LIST_MENU_FIRST_SHIFT_HIGHLIGHTED_ITEM;
- *menu_event = GUI_LIST_PEN_HIGHLIGHT_CHANGED;
- }
- else
- {
- for (i = first_displayed; i < m->n_items; i++)
- {
- #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
- if (i == m->highlighted_item)
- {
- current_fixed_list_menuitem_display_index = -1;
- }
- else
- {
- current_fixed_list_menuitem_display_index = i;
- }
- #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- total_height += iheight;
- if (total_height > m->height + 1)
- {
- last_displayed = i - 1;
- break;
- }
- }
- if (i == m->n_items)
- {
- last_displayed = m->n_items - 1;
- }
- if (last_displayed < m->highlighted_item)
- {
- m->flags |= UI_LIST_MENU_LAST_SHIFT_HIGHLIGHTED_ITEM;
- gui_fixed_list_menu_goto_item(m, last_displayed);
- m->flags &= ~UI_LIST_MENU_LAST_SHIFT_HIGHLIGHTED_ITEM;
- *menu_event = GUI_LIST_PEN_HIGHLIGHT_CHANGED;
- }
- else
- {
- m->first_displayed_item = first_displayed;
- m->last_displayed_item = last_displayed;
- *menu_event = GUI_LIST_PEN_NEED_REDRAW;
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_list_menu_translate_pen_event
- * DESCRIPTION
- *
- * PARAMETERS
- * m [?]
- * pen_event [IN]
- * x [IN]
- * y [IN]
- * menu_event [?]
- * RETURNS
- *
- *****************************************************************************/
- BOOL gui_fixed_list_menu_translate_pen_event(
- fixed_list_menu *m,
- mmi_pen_event_type_enum pen_event,
- S16 x,
- S16 y,
- gui_list_pen_enum *menu_event)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- BOOL ret;
- gui_list_pen_state_struct *pen_state;
- gui_scrollbar_pen_enum scrollbar_event;
- gui_pen_event_param_struct scrollbar_param;
- gui_list_pen_enum menuitem_event;
- gui_pen_event_param_struct menuitem_param;
- S32 item_index;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pen_state = &m->pen_state;
- ret = MMI_TRUE;
- *menu_event = GUI_LIST_PEN_NONE;
- if (m->flags & UI_LIST_MENU_DISABLE_PEN)
- {
- return MMI_FALSE;
- }
- if (pen_event != MMI_PEN_EVENT_DOWN && pen_state->pen_on_scrollbar)
- {
- gui_vertical_scrollbar_translate_pen_event(&m->vbar, pen_event, x, y, &scrollbar_event, &scrollbar_param);
- if (scrollbar_event == GUI_SCROLLBAR_PEN_JUMP_TO_I)
- {
- gui_fixed_list_menu_scroll_by_pen(m, scrollbar_param._u.i, menu_event);
- }
- }
- else if (pen_event != MMI_PEN_EVENT_DOWN && pen_state->handled_by_menu_item)
- {
- /* For example, tap down on checkbox of two-state menuitem, the subsequent move/up events are discarded */
- S32 item_x, item_y;
- gui_fixed_list_menu_get_menuitem_position(m, m->highlighted_item, &item_x, &item_y);
- m->item_pen_function(
- m->items[m->highlighted_item],
- m->common_item_data,
- item_x,
- item_y,
- pen_event,
- x,
- y,
- &menuitem_event,
- &menuitem_param);
- if (menuitem_event == GUI_TWOSTATE_PEN_TOGGLE)
- {
- menuitem_event = GUI_LIST_PEN_ITEM_SELECTED;
- }
- *menu_event = menuitem_event;
- }
- else
- {
- switch (pen_event)
- {
- case MMI_PEN_EVENT_DOWN:
- if (PEN_CHECK_BOUND(x, y, m->x, m->y, m->width, m->height))
- {
- pen_state->handled_by_menu_item = 0;
- pen_state->pen_on_scrollbar = 0;
- if (m->n_items <= 0)
- {
- /* In current design, scrollbar is hidden if m->n_items == 0 */
- ret = MMI_FALSE;
- }
- else if (!(m->flags & UI_LIST_MENU_DISABLE_SCROLLBAR) &&
- gui_vertical_scrollbar_translate_pen_event(
- &m->vbar,
- MMI_PEN_EVENT_DOWN,
- x,
- y,
- &scrollbar_event,
- &scrollbar_param))
- {
- pen_state->pen_on_scrollbar = 1;
- if (scrollbar_event == GUI_SCROLLBAR_PEN_JUMP_TO_I)
- {
- gui_fixed_list_menu_scroll_by_pen(m, scrollbar_param._u.i, menu_event);
- }
- }
- else
- {
- if (gui_fixed_list_menu_translate_pen_position(m, y, &item_index))
- {
- S32 item_x, item_y;
- if (item_index != m->highlighted_item)
- {
- gui_fixed_list_menu_goto_item(m, item_index);
- *menu_event = GUI_LIST_PEN_HIGHLIGHT_CHANGED;
- }
- /* Even if highlight is changed, we still need to invoke menuitem pen handler */
- gui_fixed_list_menu_get_menuitem_position(m, item_index, &item_x, &item_y);
- if (m->item_pen_function(
- m->items[item_index],
- m->common_item_data,
- item_x,
- item_y,
- MMI_PEN_EVENT_DOWN,
- x,
- y,
- &menuitem_event,
- &menuitem_param))
- {
- if (menuitem_event == GUI_TWOSTATE_PEN_TOGGLE)
- {
- menuitem_event = GUI_LIST_PEN_ITEM_SELECTED;
- }
- /* original menu_event could be GUI_LIST_PEN_HIGHLIGHT_CHANGED */
- if (menuitem_event != GUI_LIST_PEN_NONE)
- {
- *menu_event = menuitem_event;
- }
- pen_state->handled_by_menu_item = 1;
- }
- }
- else
- {
- /* # of menu items < # of displayable menu items */
- ret = MMI_FALSE;
- }
- }
- pen_state->first_highlighed_item = m->highlighted_item;
- pen_state->highlight_changed = 0;
- }
- else
- {
- ret = MMI_FALSE;
- }
- break;
- case MMI_PEN_EVENT_LONG_TAP:
- /* FALLTHROUGH no break */
- case MMI_PEN_EVENT_REPEAT:
- /* FALLTHROUGH no break */
- case MMI_PEN_EVENT_MOVE:
- if (!m->disable_move_highlight)
- {
- gui_fixed_list_menu_translate_pen_position(m, y, &item_index);
- if (item_index != m->highlighted_item)
- {
- gui_fixed_list_menu_goto_item(m, item_index);
- *menu_event = GUI_LIST_PEN_HIGHLIGHT_CHANGED;
- }
- }
- break;
- case MMI_PEN_EVENT_UP:
- if (!m->disable_up_select)
- {
- if (PEN_CHECK_BOUND(x, y, m->x, m->y, m->width, m->height))
- {
- gui_fixed_list_menu_translate_pen_position(m, y, &item_index);
- if (item_index != m->highlighted_item)
- {
- if (!m->disable_move_highlight)
- {
- /* If MMI_PEN_EVENT_MOVE is not delivered before moving to this item */
- gui_fixed_list_menu_goto_item(m, item_index);
- *menu_event = GUI_LIST_PEN_HIGHLIGHT_CHANGED;
- }
- }
- else if (pen_state->highlight_changed)
- {
- *menu_event = GUI_LIST_PEN_NONE;
- }
- else
- {
- *menu_event = GUI_LIST_PEN_ITEM_SELECTED;
- }
- }
- }
- break;
- case MMI_PEN_EVENT_ABORT:
- /* Do nothing */
- break;
- default:
- MMI_ASSERT(0);
- }
- }
- if (ret)
- {
- if (pen_state->first_highlighed_item != m->highlighted_item)
- {
- pen_state->highlight_changed = 1;
- }
- }
- return ret;
- }
- #endif /* __MMI_TOUCH_SCREEN__ */
- /*****************************************************************************
- * FUNCTION
- * gui_hide_fixed_list_menu_highlighted_item
- * DESCRIPTION
- * Hides the highlighted item in a fixed list menu
- * PARAMETERS
- * m [IN] Is the fixed list menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_hide_fixed_list_menu_highlighted_item(fixed_list_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 x1, y1, x2, y2, y_offset;
- S32 i;
- S32 cx1, cy1, cx2, cy2;
- S32 tx1, ty1, tx2, ty2;
- S32 iwidth, iheight;
- U8 done = 0;
- S32 total_height, counter, list_height;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- gui_get_clip(&cx1, &cy1, &cx2, &cy2);
- gui_get_text_clip(&tx1, &ty1, &tx2, &ty2);
- x1 = m->x;
- y1 = m->y;
- x2 = x1 + m->width - 1;
- y2 = y1 + m->height - 1;
- x1 += 3;
- x2 -= (3 - m->vbar.width);
- y1 += 3;
- y2 -= 3;
- list_height = m->height - 4;
- gui_set_text_clip(x1, y1, x2, y2);
- gui_set_clip(x1, y1, x2, y2);
- total_height = 0;
- counter = 0;
- for (i = m->first_displayed_item; (i < m->n_items && !done); i++)
- {
- y_offset = total_height;
- if (i == m->highlighted_item)
- {
- #if defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__)
- if (i == m->highlighted_item)
- {
- current_fixed_list_menuitem_display_index = -1;
- }
- else
- {
- current_fixed_list_menuitem_display_index = i;
- }
- #endif /* defined(__MMI_UI_TWO_LINE_MENUITEM_STYLES__) || defined(__MMI_UI_HINTS_IN_MENUITEM__) */
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- total_height += iheight;
- }
- if (total_height > list_height + 1)
- {
- done = 1;
- if ((counter == 0) && (i == m->highlighted_item))
- {
- m->item_hide_function(m->items[i], m->common_item_data, x1, y_offset + y1);
- }
- }
- else
- {
- if (i == m->highlighted_item)
- {
- m->item_hide_function(m->items[i], m->common_item_data, x1, y_offset + y1);
- }
- counter++;
- }
- }
- gui_set_clip(cx1, cy1, cx2, cy2);
- gui_set_text_clip(tx1, ty1, tx2, ty2);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_set_fixed_list_menu_item_functions
- * DESCRIPTION
- * Sets the functions used to display generic menuitems
- * PARAMETERS
- * m [IN] Is the fixed list menu object
- * item_display_function [IN] Is the function used to display an item
- * item_measure_function [IN] Is the function used to measure an item
- * item_highlight_function [OUT] Is the function used to highlight an item
- * item_remove_highlight_function [IN] Is the function used to remove highlight of an item
- * item_hide_function [IN] Is the function used to hide the menuitem
- * item_resize_function [IN]
- * width(?) [OUT] Height are the dimensions of the menuitem
- * item(?) [IN] Is the specific fixed menuitem
- * x(?) [IN] Position at which the menuitem was displayed
- * y(?) [IN] Position at which the menuitem was displayed
- * common_item_data(?) [IN] Common fixed menuitem
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_fixed_list_menu_item_functions(
- fixed_list_menu *m,
- void (*item_display_function) (void *item, void *common_item_data, S32 x, S32 y),
- void (*item_measure_function) (void *item, void *common_item_data, S32 *width, S32 *height),
- void (*item_highlight_function) (void *item, void *common_item_data),
- void (*item_remove_highlight_function) (void *item, void *common_item_data),
- void (*item_hide_function) (void *item, void *common_item_data, S32 x, S32 y),
- void (*item_resize_function) (S32 x, S32 y))
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->item_display_function = item_display_function;
- m->item_measure_function = item_measure_function;
- m->item_highlight_function = item_highlight_function;
- m->item_remove_highlight_function = item_remove_highlight_function;
- m->item_hide_function = item_hide_function;
- m->item_resize_function = item_resize_function;
- }
- #ifdef __MMI_TOUCH_SCREEN__
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_list_menu_set_pen_scroll_delay
- * DESCRIPTION
- * Sets the delay time that menu scrolling after scrollbar is scrolled by pen.
- *
- * Typically used in dynamic and asyncdynamic list menu because it need to load
- * data when menu is scrolled.
- *
- * THE SCROLL DELAY IS IMPLEMENTED IN DYNAMIC AND ASYNCDYNAMIC LIST ONLY.
- * THIS IS DUMMY FUNCTION FOR API CONSISTENCY.
- * PARAMETERS
- * m [IN] Is the fixed list menu object
- * delay_time [IN] In milliseconds
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_list_menu_set_pen_scroll_delay(fixed_list_menu *m, S32 delay_time)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- MMI_DBG_ASSERT(delay_time < (S32) 0x0000FFFF);
- m->pen_scroll_delay_time = (S16) delay_time;
- }
- /*****************************************************************************
- * FUNCTION
- * gui_set_fixed_list_menu_item_pen_function
- * DESCRIPTION
- * Sets the pen handler of menu item
- * PARAMETERS
- * m [IN] Is the fixed list menu object
- * item_pen_function [IN] Is the function functions used to handle pen events in menu item
- * disable_move_highlight [IN] Do not send GUI_LIST_PEN_HIGHLIGHT_CHANGED on Pen Move and (sometimes) Pen Up
- * disable_up_select [IN] Do not send GUI_LIST_PEN_ITEM_SELECTED on Pen Up.
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_fixed_list_menu_item_pen_function(
- fixed_list_menu *m,
- fixed_menuitem_pen_hdlr item_pen_function,
- BOOL disable_move_highlight,
- BOOL disable_up_select)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->item_pen_function = item_pen_function;
- m->disable_move_highlight = disable_move_highlight;
- m->disable_up_select = disable_up_select;
- }
- #endif /* __MMI_TOUCH_SCREEN__ */
- /*****************************************************************************
- * FUNCTION
- * gui_set_fixed_list_menu_common_item_data
- * DESCRIPTION
- * Sets the common item data that the list of items should use
- * PARAMETERS
- * m [IN] Is the fixed list menu object
- * c [IN] Is the common item data
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_fixed_list_menu_common_item_data(fixed_list_menu *m, void *c)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->common_item_data = c;
- }
- /* GUI: fixed matrix menu functions */
- UI_fixed_matrix_menu_theme *current_fixed_matrix_menu_theme = NULL;
- /*****************************************************************************
- * FUNCTION
- * gui_set_fixed_matrix_menu_current_theme
- * DESCRIPTION
- * Applies the current theme to a fixed matrix menu
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_fixed_matrix_menu_current_theme(fixed_matrix_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->flags |= current_fixed_matrix_menu_theme->flags;
- m->focussed_filler = current_fixed_matrix_menu_theme->focussed_filler;
- m->normal_filler = current_fixed_matrix_menu_theme->normal_filler;
- gui_resize_vertical_scrollbar(
- &m->vbar,
- current_fixed_matrix_menu_theme->vbar_width,
- m->height - current_fixed_matrix_menu_theme->hbar_height);
- gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - current_fixed_matrix_menu_theme->vbar_width, m->y);
- gui_resize_horizontal_scrollbar(
- &m->hbar,
- m->width - current_fixed_matrix_menu_theme->vbar_width,
- current_fixed_matrix_menu_theme->hbar_height);
- gui_move_horizontal_scrollbar(&m->hbar, m->x, m->y + m->height - current_fixed_matrix_menu_theme->hbar_height);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_set_fixed_matrix_menu_theme
- * DESCRIPTION
- * Applies the given theme to a fixed matrix menu
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * t [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_fixed_matrix_menu_theme(fixed_matrix_menu *m, UI_fixed_matrix_menu_theme *t)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->flags |= t->flags;
- m->focussed_filler = t->focussed_filler;
- m->normal_filler = t->normal_filler;
- gui_resize_vertical_scrollbar(
- &m->vbar,
- current_fixed_matrix_menu_theme->vbar_width,
- m->height - current_fixed_matrix_menu_theme->hbar_height);
- gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - current_fixed_matrix_menu_theme->vbar_width, m->y);
- gui_resize_horizontal_scrollbar(
- &m->hbar,
- m->width - current_fixed_matrix_menu_theme->vbar_width,
- current_fixed_matrix_menu_theme->hbar_height);
- gui_move_horizontal_scrollbar(&m->hbar, m->x, m->y + m->height - current_fixed_matrix_menu_theme->hbar_height);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_create_fixed_matrix_menu
- * DESCRIPTION
- * Creates a fixed matrix menu
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object (pre-allocated)
- * x [IN] Is the left-top corner position
- * y [IN] Is the left-top corner position
- * width [IN] Are the dimensions
- * height [IN] Are the dimensions
- * RETURNS
- * void
- *****************************************************************************/
- /* extern wgui_inline_item wgui_inline_items; */
- extern U8 matrix_main_menu_highlight_bitmap_data[];
- void gui_create_fixed_matrix_menu(fixed_matrix_menu *m, S32 x, S32 y, S32 width, S32 height)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->flags = 0;
- m->x = x;
- m->y = y;
- m->width = width;
- m->height = height;
- m->n_items = 0;
- m->n_columns = 0;
- m->n_rows = 0;
- m->items = NULL;
- m->highlighted_item = 0;
- m->first_displayed_row = 0;
- m->first_displayed_column = 0;
- m->displayed_columns = 0;
- m->displayed_rows = 0;
- m->highlighted_column = 0;
- m->highlighted_row = 0;
- m->item_height = 0;
- m->item_width = 0;
- gui_set_fixed_matrix_menu_current_theme(m);
- gui_create_vertical_scrollbar(
- &m->vbar,
- m->x + m->width - current_fixed_matrix_menu_theme->vbar_width - 1,
- m->y + 2,
- current_fixed_matrix_menu_theme->vbar_width,
- m->height - current_fixed_matrix_menu_theme->hbar_height - 3);
- gui_create_horizontal_scrollbar(
- &m->hbar,
- m->x + 2,
- m->y + m->height - current_fixed_matrix_menu_theme->hbar_height - 1,
- m->width - current_fixed_matrix_menu_theme->vbar_width - 3,
- current_fixed_matrix_menu_theme->hbar_height);
- m->item_highlighted = UI_dummy_function_s32;
- m->item_unhighlighted = UI_dummy_function_s32;
- m->item_display_function = UI_fixed_menuitem_dummy_display_function;
- m->item_hide_function = UI_fixed_menuitem_dummy_display_function;
- m->item_measure_function = UI_fixed_menuitem_dummy_measure_function;
- m->item_highlight_function = UI_fixed_menuitem_dummy_highlight_function;
- m->item_remove_highlight_function = UI_fixed_menuitem_dummy_remove_highlight_function;
- m->trigger_top_function = UI_dummy_function;
- m->trigger_bottom_function = UI_dummy_function;
- m->last_hilited_x = -1;
- m->last_hilited_y = -1;
- m->last_highlighted_item = -1;
- m->cache_bmp_x1 = 0;
- m->cache_bmp_x2 = 0;
- m->cache_bmp_y1 = 0;
- m->cache_bmp_y2 = 0;
- #if defined(__MMI_MATRIX_MAIN_MENU_FULL_BACKGROUND__) && defined(__MMI_MATRIX_MAIN_MENU_OPTIMIZE__)
- m->buffer.buf_ptr = opt_mm_buf;
- #else
- m->buffer.buf_ptr = (U8*) & matrix_main_menu_highlight_bitmap_data;
- #endif
- #ifdef __MMI_TOUCH_SCREEN__
- m->pen_event_current_selected_callback_function = NULL;
- m->pen_event_default_selected_callback_function = NULL;
- memset(&(m->pen_state), 0, sizeof(gui_matrix_pen_state_struct));
- #ifdef __MMI_BI_DEGREE_MAIN_MENU_STYLE__
- m->up_ind_area.x = 0;
- m->up_ind_area.y = 0;
- m->up_ind_area.width = 0;
- m->up_ind_area.height = 0;
- m->up_ind_area.string = NULL;
- m->up_ind_area.img_id = 0;
- m->down_ind_area.x = 0;
- m->down_ind_area.y = 0;
- m->down_ind_area.width = 0;
- m->down_ind_area.height = 0;
- m->down_ind_area.string = NULL;
- m->down_ind_area.img_id = 0;
- #endif /* __MMI_BI_DEGREE_MAIN_MENU_STYLE__ */
- #endif /* __MMI_TOUCH_SCREEN__ */
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_auto_calculate
- * DESCRIPTION
- * Automatically calculate a fixed matrix menu
- * (Decides the number of columns / rows to be displayed
- * and the number of items per row or column)
- *
- * Internal function
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * width [?]
- * height [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_matrix_menu_auto_calculate(fixed_matrix_menu *m, S32 *width, S32 *height)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 x1, y1, x2, y2;
- S32 menu_width, menu_height;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- x1 = m->x;
- y1 = m->y;
- x2 = x1 + m->width - 1;
- y2 = y1 + m->height - 1;
- #ifdef __MMI_BI_DEGREE_MAIN_MENU_STYLE__
- if (m->flags & UI_MATRIX_MENU_SHOW_IND_AREA)
- {
- menu_height = y2 - y1 - MMI_BI_DEGREE_MAIN_MENU_ARROW_BAR_HEIGHT + 1;
- }
- else
- #endif /* __MMI_BI_DEGREE_MAIN_MENU_STYLE__ */
- menu_height = y2 - y1 + 1;
- menu_width = x2 - x1 + 1;
- /* Autocalculate unspecified parameters */
- if (m->n_rows == 0 && m->n_columns == 0) /* both rows and columns is not specified by wgui */
- {
- S32 rows, columns, reminders;
- columns = menu_width / m->item_width;
- rows = pixtel_highdivide(m->n_items, columns);
- while ((columns * 2) / (rows * 3) > 1)
- {
- columns--;
- rows = pixtel_highdivide(m->n_items, columns);
- }
- reminders = m->n_items % columns;
- while (reminders != 0)
- {
- if (reminders + rows - 1 > columns - 1)
- {
- break;
- }
- else
- {
- columns--;
- rows = pixtel_highdivide(m->n_items, columns);
- reminders = m->n_items % columns;
- }
- }
- m->n_rows = rows;
- m->n_columns = columns;
- if (m->item_height <= 0)
- {
- m->item_height = menu_height / m->n_rows;
- }
- if (m->item_width <= 0)
- {
- m->item_width = menu_width / m->n_columns;
- }
- }
- else
- {
- if (m->item_height <= 0)
- {
- m->item_height = menu_height / m->n_rows;
- }
- if (m->n_rows <= 0)
- {
- m->n_rows = menu_height / m->item_height;
- }
- if (m->item_width <= 0)
- {
- m->item_width = menu_width / m->n_columns;
- }
- if (m->n_columns <= 0)
- {
- m->n_columns = menu_width / m->item_width;
- }
- }
- /* Fix rows and columns to match the number of items */
- if (m->n_items < m->n_columns)
- {
- m->n_rows = 1;
- m->n_columns = m->n_items;
- }
- else
- {
- if (m->n_rows > pixtel_highdivide(m->n_items, m->n_columns))
- {
- m->n_rows = pixtel_highdivide(m->n_items, m->n_columns);
- }
- if ((m->n_columns * m->n_rows) < m->n_items)
- {
- m->n_rows = pixtel_highdivide(m->n_items, m->n_columns);
- }
- }
- *width = menu_width;
- *height = menu_height;
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_auto_configure
- * DESCRIPTION
- * Automatically configures a fixed matrix menu
- * (Decides the number of columns / rows to be displayed
- * and the number of items per row or column)
- *
- * Internal function
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_matrix_menu_auto_configure(fixed_matrix_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 x1, y1, x2, y2;
- S32 menu_width, menu_height;
- U8 show_vbar = 0, show_hbar = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if ((m->n_columns <= 0) && (m->item_width <= 0))
- {
- return;
- }
- if ((m->n_rows <= 0) && (m->item_height <= 0))
- {
- return;
- }
- if (m->n_items == 0)
- {
- return;
- }
- x1 = m->x;
- y1 = m->y;
- x2 = x1 + m->width - 1;
- y2 = y1 + m->height - 1;
- menu_height = y2 - y1 + 1;
- menu_width = x2 - x1 + 1;
- gui_fixed_matrix_menu_auto_calculate(m, &menu_width, &menu_height);
- /* Calculate the number of displayed rows and columns */
- m->displayed_rows = menu_height / m->item_height;
- m->displayed_columns = menu_width / m->item_width;
- if (m->displayed_rows < m->n_rows)
- {
- m->flags |= UI_MATRIX_MENU_SHOW_IND_AREA;
- gui_fixed_matrix_menu_auto_calculate(m, &menu_width, &menu_height);
- }
- if (!(m->flags & UI_MATRIX_MENU_DISABLE_SCROLLBAR))
- {
- if ((!(m->flags & UI_MATRIX_MENU_AUTO_DISABLE_SCROLLBAR)) ||
- ((m->flags & UI_MATRIX_MENU_AUTO_DISABLE_SCROLLBAR) && (m->n_rows > m->displayed_rows)))
- {
- show_vbar = 1;
- }
- if ((!(m->flags & UI_MATRIX_MENU_AUTO_DISABLE_SCROLLBAR)) ||
- ((m->flags & UI_MATRIX_MENU_AUTO_DISABLE_SCROLLBAR) && (m->n_columns > m->displayed_columns)))
- {
- show_hbar = 1;
- }
- }
- if (show_vbar)
- {
- x2 -= m->vbar.width;
- }
- if (show_hbar)
- {
- y2 -= m->hbar.height;
- }
- menu_height = y2 - y1 + 1;
- menu_width = x2 - x1 + 1;
- /* Recalculate the number of rows that can be displayed */
- m->displayed_rows = menu_height / m->item_height;
- m->displayed_columns = menu_width / m->item_width;
- /* Fix the number of displayed rows and columns */
- if (m->displayed_columns > m->n_columns &&
- !(m->n_columns <= 1 && (m->flags & UI_MATRIX_MENU_ALIGN_LEFT_TOP)))
- {
- m->displayed_columns = m->n_columns;
- }
- if (m->displayed_rows > m->n_rows &&
- !(m->n_rows <= 1 && (m->flags & UI_MATRIX_MENU_ALIGN_LEFT_TOP)))
- {
- m->displayed_rows = m->n_rows;
- }
- #ifdef __MMI_BI_DEGREE_MAIN_MENU_STYLE__
- else
- {
- if (MMI_current_menu_type == LIST_MATRIX_MENU)
- {
- m->displayed_rows = menu_height / m->item_height;
- }
- }
- #endif /* __MMI_BI_DEGREE_MAIN_MENU_STYLE__ */
- /* Enable/Disable scrollbars */
- if (show_vbar)
- {
- m->flags |= UI_MATRIX_MENU_SHOW_VERTICAL_SCROLLBAR;
- }
- else
- {
- m->flags &= ~UI_MATRIX_MENU_SHOW_VERTICAL_SCROLLBAR;
- }
- if (show_hbar)
- {
- m->flags |= UI_MATRIX_MENU_SHOW_HORIZONTAL_SCROLLBAR;
- }
- else
- {
- m->flags &= ~UI_MATRIX_MENU_SHOW_HORIZONTAL_SCROLLBAR;
- }
- if (show_vbar && (!show_hbar))
- {
- gui_resize_vertical_scrollbar(&m->vbar, m->vbar.width, m->height);
- }
- if (show_hbar && (!show_vbar))
- {
- gui_resize_horizontal_scrollbar(&m->hbar, m->width, m->hbar.height);
- }
- if (show_vbar && show_hbar)
- {
- gui_resize_vertical_scrollbar(&m->vbar, m->vbar.width, m->height - m->hbar.height);
- gui_resize_horizontal_scrollbar(&m->hbar, m->width - m->vbar.width, m->hbar.height);
- }
- gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - current_fixed_matrix_menu_theme->vbar_width, m->y);
- gui_move_horizontal_scrollbar(&m->hbar, m->x, m->y + m->height - current_fixed_matrix_menu_theme->hbar_height);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_setup
- * DESCRIPTION
- * Used to set the number of rows, columns and item dimensions
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * item_width [IN] Is the width of each item | Any one of these two should be specified
- * item_height [IN] Is the height of each item | Any one of these two should be specified
- * n_columns [IN] Is the number of columns | and the other can be zero.
- * n_rows [IN] Is the number of rows | and the other can be zero.
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_matrix_menu_setup(fixed_matrix_menu *m, S32 item_width, S32 item_height, S32 n_columns, S32 n_rows)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->item_width = item_width;
- m->item_height = item_height;
- m->n_columns = n_columns;
- m->n_rows = n_rows;
- gui_fixed_matrix_menu_auto_configure(m);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_resize_fixed_matrix_menu
- * DESCRIPTION
- * Changes the size of a fixed matrix menu
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * width [IN] Is the new width
- * height [IN] Is the new height
- * RETURNS
- * void
- *****************************************************************************/
- void gui_resize_fixed_matrix_menu(fixed_matrix_menu *m, S32 width, S32 height)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->width = width;
- m->height = height;
- gui_resize_vertical_scrollbar(
- &m->vbar,
- current_fixed_matrix_menu_theme->vbar_width,
- m->height - current_fixed_matrix_menu_theme->hbar_height);
- gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - current_fixed_matrix_menu_theme->vbar_width, m->y);
- gui_resize_horizontal_scrollbar(
- &m->hbar,
- m->width - current_fixed_matrix_menu_theme->vbar_width,
- current_fixed_matrix_menu_theme->hbar_height);
- gui_move_horizontal_scrollbar(&m->hbar, m->x, m->y + m->height - current_fixed_matrix_menu_theme->hbar_height);
- gui_fixed_matrix_menu_auto_configure(m);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_move_fixed_matrix_menu
- * DESCRIPTION
- * Moves the fixed matrix menu to a new location
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * x [IN] Is the new left-top corner position
- * y [IN] Is the new left-top corner position
- * RETURNS
- * void
- *****************************************************************************/
- void gui_move_fixed_matrix_menu(fixed_matrix_menu *m, S32 x, S32 y)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->x = x;
- m->y = y;
- gui_move_vertical_scrollbar(&m->vbar, m->x + m->width - current_fixed_matrix_menu_theme->vbar_width, m->y);
- gui_move_horizontal_scrollbar(&m->hbar, m->x, m->y + m->height - current_fixed_matrix_menu_theme->hbar_height);
- gui_fixed_matrix_menu_auto_configure(m);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_locate_highlighted_item
- * DESCRIPTION
- * Used to locate the highlighted item in the fixed matrix menu
- *
- * Internal function
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_matrix_menu_locate_highlighted_item(fixed_matrix_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->highlighted_column = m->highlighted_item % m->n_columns;
- m->highlighted_row = m->highlighted_item / m->n_columns;
- if (m->highlighted_column < 0)
- {
- m->highlighted_column = 0;
- }
- if (m->highlighted_row < 0)
- {
- m->highlighted_row = 0;
- }
- if (m->highlighted_column > (m->n_columns - 1))
- {
- m->highlighted_column = m->n_columns - 1;
- }
- if (m->highlighted_row > (m->n_rows - 1))
- {
- m->highlighted_row = m->n_rows - 1;
- }
- if (m->flags & UI_MATRIX_MENU_FIRST_SHIFT_HIGHLIGHTED_ROW)
- {
- m->first_displayed_row = m->highlighted_row;
- if (m->first_displayed_row > m->n_rows - m->displayed_rows)
- {
- m->first_displayed_row = m->n_rows - m->displayed_rows;
- }
- }
- else if (m->flags & UI_MATRIX_MENU_LAST_SHIFT_HIGHLIGHTED_ROW)
- {
- m->first_displayed_row = m->highlighted_row - m->displayed_rows + 1;
- if (m->first_displayed_row < 0)
- {
- m->first_displayed_row = 0;
- }
- }
- if (m->flags & UI_MATRIX_MENU_FIRST_SHIFT_HIGHLIGHTED_COL)
- {
- m->first_displayed_column = m->highlighted_column;
- if (m->first_displayed_column > m->n_columns - m->displayed_columns)
- {
- m->first_displayed_column = m->n_columns - m->displayed_columns;
- }
- }
- else if (m->flags & UI_MATRIX_MENU_LAST_SHIFT_HIGHLIGHTED_COL)
- {
- m->first_displayed_column = m->highlighted_column - m->displayed_columns + 1;
- if (m->first_displayed_column < 0)
- {
- m->first_displayed_column = 0;
- }
- }
- if (m->highlighted_column < m->first_displayed_column)
- {
- m->first_displayed_column = m->highlighted_column;
- }
- if (m->highlighted_row < m->first_displayed_row)
- {
- m->first_displayed_row = m->highlighted_row;
- }
- if (m->highlighted_column > (m->first_displayed_column + m->displayed_columns - 1))
- {
- m->first_displayed_column = (m->highlighted_column - m->displayed_columns + 1);
- if (m->first_displayed_column > (m->n_columns - m->displayed_columns))
- {
- m->first_displayed_column = (m->n_columns - m->displayed_columns);
- }
- }
- if (m->highlighted_row > (m->first_displayed_row + m->displayed_rows - 1))
- {
- m->first_displayed_row = (m->highlighted_row - m->displayed_rows + 1);
- if (m->first_displayed_row > (m->n_rows - m->displayed_rows))
- {
- m->first_displayed_row = (m->n_rows - m->displayed_rows);
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_goto_next_item
- * DESCRIPTION
- * Highlights the next item
- *
- * Does not redraw the fixed matrix menu
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_matrix_menu_goto_next_item(fixed_matrix_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 old_highlighted_item = m->highlighted_item;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (m->highlighted_item >= (m->n_items - 1))
- {
- if (m->flags & UI_MATRIX_MENU_VERTICAL_TRIGGER)
- {
- if (m->trigger_bottom_function)
- {
- m->trigger_bottom_function();
- }
- return; /* exit point */
- }
- else if (m->flags & UI_MATRIX_MENU_LOOP)
- {
- m->highlighted_item = 0;
- }
- else
- {
- return;
- }
- }
- else
- {
- m->highlighted_item++;
- }
- gui_fixed_matrix_menu_locate_highlighted_item(m);
- if (old_highlighted_item != m->highlighted_item)
- {
- if ((old_highlighted_item >= 0) && (old_highlighted_item < m->n_items))
- {
- m->item_remove_highlight_function(m->items[old_highlighted_item], m->common_item_data);
- }
- if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
- {
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- m->item_unhighlighted(old_highlighted_item);
- m->item_highlighted(m->highlighted_item);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_goto_previous_item
- * DESCRIPTION
- * Highlights the previous item
- *
- * Does not redraw the fixed matrix menu
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_matrix_menu_goto_previous_item(fixed_matrix_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 old_highlighted_item = m->highlighted_item;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (m->highlighted_item <= 0)
- {
- if (m->flags & UI_MATRIX_MENU_VERTICAL_TRIGGER)
- {
- if (m->trigger_top_function)
- {
- m->trigger_top_function();
- }
- return; /* exit point */
- }
- else if (m->flags & UI_MATRIX_MENU_LOOP)
- {
- m->highlighted_item = m->n_items - 1;
- }
- else
- {
- return;
- }
- }
- else
- {
- m->highlighted_item--;
- }
- gui_fixed_matrix_menu_locate_highlighted_item(m);
- if (old_highlighted_item != m->highlighted_item)
- {
- if ((old_highlighted_item >= 0) && (old_highlighted_item < m->n_items))
- {
- m->item_remove_highlight_function(m->items[old_highlighted_item], m->common_item_data);
- }
- if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
- {
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- m->item_unhighlighted(old_highlighted_item);
- m->item_highlighted(m->highlighted_item);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_goto_previous_row
- * DESCRIPTION
- * Highlights an item in the previous row
- *
- * Does not redraw the fixed matrix menu
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_matrix_menu_goto_previous_row(fixed_matrix_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 old_highlighted_item;
- S32 old_highlighted_row;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- old_highlighted_row = m->highlighted_row;
- old_highlighted_item = m->highlighted_item;