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

📄 gui_fixed_menus.c

📁 详细介绍MTK平台图层运用的好东西
💻 C
📖 第 1 页 / 共 5 页
字号:
    #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;

    gui_fixed_list_menu_switch_highlighted_item(m, last_highlighted_item);
}


/*****************************************************************************
 * FUNCTION
 *  gui_fixed_list_menu_goto_previous_page
 * DESCRIPTION
 *  Go to the previous page.
 * PARAMETERS
 *  m       [IN]        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);

    gui_fixed_list_menu_switch_highlighted_item(m, last_highlighted_item);
}


/*****************************************************************************
 * FUNCTION
 *  gui_fixed_list_menu_goto_first_item
 * DESCRIPTION
 *  Go to the first item.
 * PARAMETERS
 *  m       [IN]        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);

    gui_fixed_list_menu_switch_highlighted_item(m, last_highlighted_item);
}


/*****************************************************************************
 * FUNCTION
 *  gui_fixed_list_menu_goto_last_item
 * DESCRIPTION
 *  Go to the last item.
 * PARAMETERS
 *  m       [IN]        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);

    gui_fixed_list_menu_switch_highlighted_item(m, last_highlighted_item);
}


/*****************************************************************************
 * 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]        fixed 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
 *  Show the fixed list menu.
 * PARAMETERS
 *  m       [IN]        fixed list menu object
 * RETURNS
 *  void
 *****************************************************************************/
void gui_show_fixed_list_menu(fixed_list_menu *m)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S32 x1, y1, x2, y2, y_offset;

    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 the image highlight dimension does not fit, use default list highlight filler */
    gui_menuitem_verify_image_highlight_dimension(m->common_item_data); 

    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);

        #if (defined (__MMI_UI_TRANSPARENT_EFFECT__) || defined (__MMI_UI_LIST_HIGHLIGHT_EFFECTS__))
            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__)) */ 
        }
        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;

    if (!(m->flags & UI_LIST_MENU_DISABLE_MENUITEM_GAP))
    {    
        if (r2lMMIFlag)
        {
            x1 += GUI_MENUITEM_X2_GAP;
            x2 -= GUI_MENUITEM_X1_GAP;
        }
        else
        {
            x1 += GUI_MENUITEM_X1_GAP;
            x2 -= GUI_MENUITEM_X2_GAP;    
        }
    }
    
    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)
    {
        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->current_displayed_item = i;

            m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);

            y_offset = total_height;
            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)
                {
                    if (i == m->highlighted_item)

⌨️ 快捷键说明

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