第一个目前可用的flag标记宏判断,!(flags & UI_MENUITEM_DISABLE_TEXT_DISPLAY)
设置字体,字体位置,
gui_set_font(&MMI_small_font);
gui_measure_string(_text, &sw, &sh);
if (flags & UI_MENUITEM_CENTER_TEXT_X)
{
old_text_x = m->text_x;
m->text_x = (m->width >> 1) - (sw >> 1);
if (m->text_x < 0)
{
m->text_x = 0;
}
if (flags & UI_MENUITEM_CENTER_TEXT_Y)
{
old_text_y = m->text_y;
m->text_y = (m->height >> 1) - (sh >> 1);
}
old_text_x 保存原来的文本位置, m->text_x可设置为中间对齐.
if (_icon != UI_NULL_IMAGE)
{
gui_measure_image(_icon, &icon_width, &icon_height);
if (flags & UI_MENUITEM_CENTER_ICON_X)
{
old_icon_x = m->icon_x;
m->icon_x = (m->width >> 1) - (icon_width >> 1);
}
if (flags & UI_MENUITEM_CENTER_ICON_Y)
{
old_icon_y = m->icon_y;
m->icon_y = (m->height >> 1) - (icon_height >> 1);
}
}
设置图标的位置。
text_x = m->text_x;
text_y = m->text_y;
将m->text_x赋予text_x,以后就对text_x操作。
if ((flags & UI_MENUITEM_STATE_FOCUSSED) && !(flags & UI_MENUITEM_DISABLE_HIGHLIGHT))
{
if (!(flags & UI_MENUITEM_DISABLE_BACKGROUND_ALWAYS))
{
f = m->focussed_filler;
}
设置背景
{
text_color = m->focussed_text_color;
}
设置字体颜色
gui_push_clip();
进入剪裁区
gui_set_clip(x1, y1, x2, y2);
设置剪裁区为menuitem区
set_start_position_and_item_parameters_for_list_highlighter_effect(item, common_item_data, x1, y1);
gui_draw_list_filled_area(x1, y1, x2, y2, f);
画背景
if (_icon != UI_NULL_IMAGE && !((m->ext_flags & UI_MENUITEM_EXT_SHOW_IN_MARQUEE) &&
animation_flag))
{
if (mi->item_icon_handle != GDI_ERROR_HANDLE)
{
gdi_image_stop_animation(mi->item_icon_handle);
mi->item_icon_handle = GDI_ERROR_HANDLE;
}
if (animation_flag)
{
if (MMI_current_menu_type == MATRIX_MENU || (MMI_current_menu_type ==
MATRIX_PAGE_MENU))
{
if (MMI_fixed_matrix_menu.flags & UI_MATRIX_MENU_FOR_MAINMENU)
{
if (!gui_main_menu_matrix_slide_is_under_control())
{
gui_show_animation_with_background_image(
x1 + m->icon_x,
y1 + m->icon_y,
MMI_mm_animation,
current_MMI_theme->matrix_main_menu_highlight_image,
(gdi_handle*)&mi->item_icon_handle);
}
}
else
{
gdi_image_draw_animation(
x1 + m->icon_x,
y1 + m->icon_y,
mi->item_icon,
(gdi_handle*)&mi->item_icon_handle);
}
}
这块代码是显示动画的,可以先放放
else if (MMI_current_menu_type == LIST_MENU)
{
S32 x_clip = 0, y_clip = 0;
gui_push_clip();
if (m->icon_x > 0)
{
x_clip = m->icon_x;
}
if (m->icon_y > 0)
{
y_clip = m->icon_y;
}
if (!r2lMMIFlag)
{
gui_set_clip(x1 + x_clip, y1 + y_clip, x1 + m->text_x - 2, y1 + m->height - 1);
gdi_image_draw_animation_single_frame(x1 + m->icon_x, y1 + m->icon_y, (U8*) _icon, 0);
}
else
{
gui_set_clip(x2 - m->text_x + 2, y1 + y_clip, x2 - x_clip, y1 + m->height - 1);
gdi_image_draw_animation_single_frame(x2 - m->icon_x - icon_width + 1, y1 + m->icon_y, (U8*) _icon, 0);
}
gui_pop_clip();
针对的是无动画的情形,设置画图标的区域,
if (!(flags & UI_MENUITEM_DISABLE_TEXT_DISPLAY))
{
gui_push_text_clip();
if (f && (f->flags & UI_FILLED_AREA_BORDER))
{
gui_set_text_clip(x1 + m->text_x, y1, x2 - 2 - time_w, y2);
}
else
{
gui_set_text_clip(x1 + m->text_x, y1, x2 - time_w, y2);
}
设置文本剪裁区,注意,使用的是gui_set_text_clip()函数。time_w为零,意义不明
max_text_width = x2 - (x1 + m->text_x) + 1;
gui_menuitem_adjust_text_clip_for_right_gap(m);
if (MMI_current_menu_type == LIST_MENU)
{
max_text_width -= GUI_MENUITEM_TEXT_RIGHT_GAP;
}
设置文本显示区域的宽度。
gui_move_text_cursor(x1 + text_x, y1 + text_y);
gui_set_line_height(sh);
设置行高
gui_set_text_color(text_color);
设置文本的颜色
gui_list_show_text(m, mi, x1 + text_x, y1 + text_y, max_text_width - 1);
显示文本,用的是gui_list_show_text函数,可以考虑换一下
gui_pop_text_clip();
跳出文本剪裁区
gui_pop_clip();
跳出menuitem剪裁区
gui_display_pop_up_description(x, y, m->width, m->height);
g_mmi_frm_cntx.dump_screen_info.hightlight_type = MMI_SCREEN_HIGHLIGHT_NONE;
不懂
if (!(flags & UI_MENUITEM_DISABLE_TEXT_DISPLAY))
{
if (flags & UI_MENUITEM_CENTER_TEXT_X)
{
m->text_x = old_text_x;
}
if (flags & UI_MENUITEM_CENTER_TEXT_Y)
{
m->text_y = old_text_y;
}
}
if (_icon != UI_NULL_IMAGE)
{
if (flags & UI_MENUITEM_CENTER_ICON_X)
{
m->icon_x = old_icon_x;
}
if (flags & UI_MENUITEM_CENTER_ICON_Y)
{
m->icon_y = old_icon_y;
}
}
还原相应的坐标