MTK矩阵菜单用法

有次一个客户需要设计一个六宫的矩阵菜单,简单看了一下菜单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.flags

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;

 /*----------------------------------------------------------------*/
 /* Code Body                                                      */
 /*----------------------------------------------------------------*/
 gdi_layer_lock_frame_buffer();
 //没有标题和标题图片

 dm_add_softkey(get_string(left_softkey), get_image(left_softkey_icon),
get_string(right_softkey), get_image(right_softkey_icon));

// 画背景
    
 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]));

 }

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

            MMI_ASSERT(MMI_fixed_matrix_menu.buffer.buf_ptr != NULL);
        #endif /* __MMI_MATRIX_MAIN_MENU_OPTIMIZE__ */

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

}

转载于:https://my.oschina.net/blogercn/blog/1823

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值