有次一個客戶須要設計一個六宮的矩陣菜單,簡單看了一下菜單API,發現也十分簡單,使用矩陣菜單使用前要先調用 wgui_fixed_matrix_create_menu初始化,而後調用wgui_fixed_matrix_begin_add_one_item給菜單添加菜單項,使用FOR調用wgui_fixed_matrix_add_one_item添加,再使用configure_fixed_matrix設置每項菜單個數大小.最後使用wgui_fixed_matrix_end_add_one_item結束矩陣菜單設置.剩下就是根據須要對菜單屬性設置了.MMI_fixed_icontext_menuitem.flags和MMI_fixed_matrix_menu.flagsapp
void ShowCategory14NewScreen(
U16 title,
U16 title_icon,
U16 left_softkey,
U16 left_softkey_icon,
U16 right_softkey,
U16 right_softkey_icon,
S32 number_of_items,
U16 *list_of_items,
U16 *list_of_icons,
S32 flags,
S32 highlighted_item,
U8 *history_buffer)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
dm_data_struct dm_data;
S32 i, ixsize, iysize;ide
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
gdi_layer_lock_frame_buffer();
//沒有標題和標題圖片oop
dm_add_softkey(get_string(left_softkey), get_image(left_softkey_icon),
get_string(right_softkey), get_image(right_softkey_icon));ui
// 畫背景
wgui_set_wallpaper_on_bottom(MMI_TRUE);設計
dm_set_scr_bg_image(MATRIX_MAIN_MENU_1, NULL, -1, -1, 255);
wgui_fixed_matrix_create_menu(number_of_items, highlighted_item, 0,
MMI_CATEGORY15_MATRIX_ID, history_buffer);圖片
wgui_fixed_matrix_begin_add_one_item();
for (i = 0; i < number_of_items; i++)
{
wgui_fixed_matrix_add_one_item(i, (U8*)get_string(list_of_items[i]),
get_image(list_of_icons[i]));get
}string
#ifdef __MMI_MATRIX_MAIN_MENU_OPTIMIZE__
/* allocate matrix highlight buffer from SCR ASM */
MMI_fixed_matrix_menu.buffer.buf_ptr = (U8*)
applib_mem_screen_alloc(MMI_MAIN_MENU_MATRIX_HIGHLIGHTED_BUF_SIZE);it
MMI_ASSERT(MMI_fixed_matrix_menu.buffer.buf_ptr != NULL);
#endif /* __MMI_MATRIX_MAIN_MENU_OPTIMIZE__ */io
MMI_fixed_matrix_menu.flags |= UI_MATRIX_MENU_LOOP;
wgui_fixed_matrix_override_highlight_handler(my_matrix_highlight_handler);
if (number_of_items > 6)
{
ixsize = (MMI_content_width - MMI_fixed_matrix_menu.vbar.width - 6) / 2;
}
else
{
ixsize = (MMI_content_width - 6) / 2;
}
iysize = (MMI_content_height - 6) / 3;
#if 0 //沒有圖片,不顯示圖片
gui_measure_image(get_image(list_of_icons[0]), &ixsize, &iysize);
#endif
configure_fixed_matrix(ixsize, iysize, 2, 0);
wgui_fixed_matrix_end_add_one_item();
//不顯示文本,圖片帶字串
MMI_fixed_icontext_menuitem.flags |= UI_MENUITEM_DISABLE_TEXT_DISPLAY;
MMI_fixed_matrix_menu.flags |= UI_MATRIX_MENU_FOR_MAINMENU;
gdi_layer_unlock_frame_buffer();
ExitCategoryFunction = ExitCategory14NewScreen;
RedrawCategoryFunction = dm_redraw_category_screen;
GetCategoryHistory = dm_get_category_history;
GetCategoryHistorySize = dm_get_category_history_size;
dm_data.s32ScrId = (S32) GetActiveScreenId();
dm_data.s32CatId = MMI_CATEGORY14_NEW_MATRIX_ID;
register_fixed_matrix_loop_keys();
dm_data.s32flags = 0;
dm_setup_data(&dm_data);
dm_redraw_category_screen();
}