⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gui_fixed_menus.c

📁 详细介绍MTK平台图层运用的好东西
💻 C
📖 第 1 页 / 共 5 页
字号:
 * DESCRIPTION
 *  Resize the fixed list menu.
 * PARAMETERS
 *  m           [IN]        fixed list menu object
 *  width       [IN]        width
 *  height      [IN]        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
 *  Move the fixed list menu.
 * PARAMETERS
 *  m       [IN]        fixed list menu object
 *  x       [IN]        x1
 *  y       [IN]        y1
 * 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
 *  Locate the highlighted menu item.
 * PARAMETERS
 *  m       [IN]        fixed list menu object
 * RETURNS
 *  void
 *****************************************************************************/
void gui_fixed_list_menu_locate_highlighted_item(fixed_list_menu *m)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S32 iwidth, iheight;

    /*----------------------------------------------------------------*/
    /* 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
 *  Locate the menu item previous to the highlighted item.
 * PARAMETERS
 *  m       [IN]        fixed list menu object   
 * 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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -