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

📄 im_gui.c

📁 MTK平台QQ移植
💻 C
📖 第 1 页 / 共 5 页
字号:
    {
        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 */
                IM_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 (!((S8)r2lMMIFlag))
        {
            x2 -= m->vbar.width;
        }
        else
        {
            x1 += m->vbar.width;
        }
    }


    y1 = m->y + m->top;

    list_height = m->height;

    if (!(m->flags & UI_LIST_MENU_DISABLE_MENUITEM_GAP))
    {    
        if (((S8)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;
    IM_current_fixed_list_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);

        IM_current_fixed_list_display_index = m->first_displayed_item;
        m->item_display_function(m->items[m->first_displayed_item], m->common_item_data, x1, y1);

        IM_current_fixed_list_display_index = m->highlighted_item;
        m->item_display_function(m->items[m->highlighted_item], m->common_item_data, x1, y1 + iheight);

        IM_current_fixed_list_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++)
        {
            IM_current_fixed_list_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 (!disable_draw && !(m->flags & UI_LIST_MENU_ENABLE_TRANSITION))
                {//(counter == 0) && 
                    m->item_display_function(m->items[i], m->common_item_data, x1, y_offset + y1);
                }
            }
            else
            {
                if (!disable_draw)
                {
#ifdef __MMI_UI_LIST_SLIDE_EFFECT__
                    if (i == m->highlighted_item)
                    {
                        m->highlight_x = x1;
                        m->highlight_y = y_offset + y1;
                    }
#endif
                    m->item_display_function(m->items[i], m->common_item_data, x1, y_offset + y1);
                }
                counter++;
            }
        }

        IM_current_fixed_list_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 ((S8)((S8)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);
        }
    }
}


#ifdef __MMI_TOUCH_SCREEN__


void IM_list_selected_handler()
{
    im_app_struct * app = IM_get_active_app_from_ui();
    im_common_obj_struct* item = NULL;

    if (app == NULL)
    {
        return;
    }
    item = (im_common_obj_struct*)IM_ui_get_active_item(app);
    if (item == NULL || item->obj_func->item_selected_function == NULL)
    {
        return;
    }
    if (item->obj_func->item_selected_function)
    {
        item->obj_func->item_selected_function(item);
    }
}


/*****************************************************************************
 * FUNCTION
 *  gui_fixed_icontext_menuitem_translate_pen_event
 * DESCRIPTION
 *  Pen event handler of the icontext menu item.
 * PARAMETERS
 *  item                    [IN]        private icontext menu item
 *  common_item_data        [IN]        common icontext menu item
 *  item_x                  [IN]        item x1
 *  item_y                  [IN]        item y1
 *  pen_event               [IN]        pen event type
 *  x                       [IN]        pen x
 *  y                       [IN]        pen y
 *  menuitem_event          [OUT]       pen event result
 *  menuitem_param          [IN]        pen event parameter
 * RETURNS
 *  Return MMI_TRUE if the pen event is handled; otherwise, MMI_FALSE. 
 *****************************************************************************/
BOOL IM_gui_fixed_menuitem_translate_pen_event(
        void *item,
        void *common_item_data,
        S32 item_x,
        S32 item_y,
        mmi_pen_event_type_enum pen_event,
        S16 x,
        S16 y,
        gui_list_pen_enum *menuitem_event,
        gui_pen_event_param_struct *menuitem_param)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S32 iwidth, iheight;
    S32 is_pen_in_checkbox;

    S32 item_index;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    *menuitem_event = GUI_LIST_PEN_NONE;

    item_index = menuitem_param->_u.i;


    GUI_PEN_EVENT_PARAM_SET_VOID(menuitem_param);
    return FALSE;

}


/*****************************************************************************
 * FUNCTION
 *  wgui_general_pen_list_menu_hdlr
 * DESCRIPTION
 *  General list menu event handler.
 * PARAMETERS
 *  point           [IN]        Pen point
 *  pen_event       [IN]        Pen event type
 * RETURNS
 *  void
 *****************************************************************************/
U8 IM_pen_list_menu_hdlr(mmi_pen_point_struct point, mmi_pen_event_type_enum pen_event)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    gui_list_pen_enum menu_event;
    BOOL ret;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    ret = IM_gui_fixed_list_menu_translate_pen_event(&MMI_fixed_list_menu, pen_event, point.x, point.y, &menu_event);

    if (!ret)
    {
        return MMI_FALSE;
    }

    if (menu_event == GUI_LIST_PEN_HIGHLIGHT_CHANGED ||
        menu_event == GUI_LIST_PEN_NEED_REDRAW || menu_event == GUI_LIST_PEN_ITEM_SELECTED)
    {

        IM_show_fixed_list();
        
    }
    if (menu_event == GUI_LIST_PEN_ITEM_SELECTED)
    {
        IM_list_selected_handler();
    }
    return MMI_TRUE;
}

/*****************************************************************************
 * FUNCTION
 *  IM_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]        fixed list menu object
 *  y               [IN]        y
 *  item_index      [OUT]       penned item index
 * RETURNS
 *  Return MMI_TRUE if y is within the menu; otherwise, MMI_FALSE.
 *****************************************************************************/
BOOL IM_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++)
        {
            IM_current_fixed_list_display_index = i;
            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;
}


/*****************************************************************************
 * FUNCTION
 *  IM_gui_fixed_list_menu_get_menuitem_position
 * DESCRIPTION
 *  Get menu item (x1, y1) by a specified item index.
 * PARAMETERS
 *  m           [IN]        dynamic list menu object         
 *  item_index  [IN]        item index
 *  x           [OUT]       x1 of the item  
 *  y           [OUT]       y1 of the item 
 * RETURNS
 *  void
 *****************************************************************************/
static void IM_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;

⌨️ 快捷键说明

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