MTK界面代码详解——新增“Hello,world!”开机界面

主菜单界面入口 voif goto_main_menu(void)


/*****************************************************************************
 * FUNCTION
 *  goto_main_menu
 * DESCRIPTION
 *  Lanch the main menu group
 *****************************************************************************/
void goto_main_menu(void)
{
#ifdef __MYSTUDY_APPLICATION__
	mtk_helloworld();
	return;
#endif

#ifdef __MMI_VUI_LAUNCHER__
#ifdef __MMI_VUI_LAUNCHER_KEY__
	if(mmi_phnset_launcher_get_launcher_type() == MMI_PHNSET_LAUNCHER_KEY)
        vapp_launcher_mm_launch(NULL, 0);
	else
#endif
    vapp_drawer_launch(NULL, 0);
    return;
#endif /* __MMI_VUI_LAUNCHER__ */

#ifdef __MMI_VUI_LAUNCHER_KEY__
    vapp_launcher_mm_launch(NULL, 0);
    return;
#endif
    g_main_menu_group_id = mmi_frm_group_create(GRP_ID_ROOT, GRP_ID_AUTO_GEN, mmi_main_menu_proc, NULL);

    mmi_frm_group_enter(g_main_menu_group_id, MMI_FRM_NODE_SMART_CLOSE_FLAG);

    mmi_main_menu_entry();
}

 

界面的ID号 g_main_menu_group_id 需要自己创建,创建函数是mmi_frm_group_create(),创建 g_main_menu_group_id的目的是方便对界面统一化管理,当关闭界面时只要关闭g_main_menu_group_id即可,而不用逐一地去关闭子界面。

typedef U16                 MMI_ID;         /* app id, group id, screen id */

/*
**形参意义 parent_id group_id 
**        mmi_proc_func proc菜单的时间处理函数
*/
MMI_ID mmi_frm_group_create (MMI_ID parent_id, MMI_ID group_id, mmi_proc_func proc, void *user_data)
{
    
}

事件处理函数 mmi_main_menu_proc(mmi_event_struct* evt)

/*****************************************************************************
 * FUNCTION
 *  mmi_main_menu_proc
 * DESCRIPTION
 *  main menu group proc
 * PARAMETERS
 *  evt  [IN] event
 * RETURNS
 *  mmi_ret
 *****************************************************************************/
static mmi_ret mmi_main_menu_proc(mmi_event_struct* evt)
{
#ifdef __MMI_MAINMENU_SPREAD_SUPPORT__
    MMI_BOOL closeMenu = MMI_FALSE;
#endif

#ifdef __MMI_MAINMENU_SPREAD_SUPPORT__
	switch(evt->evt_id)
	{
        // 菜单进入
		case EVT_ID_CUI_MENU_LIST_ENTRY:
		{
			break;
		}
        // 菜单的选择
		case EVT_ID_CUI_MENU_ITEM_SELECT:
		{
			cui_menu_event_struct *event = (cui_menu_event_struct *)evt;

            if (event->highlighted_menu_id == MENU_ID_MAIN_MENU_OPTIONS_OPEN)
            {
                mmi_main_menu_launch_app();
            }
            else if (event->highlighted_menu_id == MENU_ID_MAIN_MENU_OPTIONS_UNINSTALLED)
            {
                mmi_main_menu_uninstall_app();
            }

			break;
		}
        // 菜单的退出
		case EVT_ID_CUI_MENU_CLOSE_REQUEST:
		{
			cui_menu_event_struct *event = (cui_menu_event_struct *)evt;
			
			cui_menu_close(event->sender_id);
			break;
		}
		default:
			break;
	}
#endif
    // 整个界面的激活和注销
    switch(evt->evt_id)
    {
        case EVT_ID_GROUP_ACTIVE:
        case EVT_ID_GROUP_INACTIVE:
        case EVT_ID_GROUP_DEINIT:
            break;
        default:
            break;
    }
    return MMI_RET_OK;
}

控件

/*
**CustCoordinates.c	D:\MT2503DMMI-11C\MT2503DMMI-11C\plutommi\Customer\CustResource
**
**这个文件定义了所有的控件
*/
const U8 category166[] = 
{
    2,
    DM_BASE_LAYER_START,                // 图层
    DM_CATEGORY_CONTROLLED_AREA         // 全屏的内容编辑
};

界面的显示部分ShowCategory***Screen()

/*****************************************************************************
 * FUNCTION
 *  ShowCategory314Screen
 * DESCRIPTION
 *  show category 314 screen
 * PARAMETERS
 *  title                       [IN]        Title string
 *  title_icon                  [IN]        Title icon ID
 *  number_of_items             [IN]        Total count of number
 *  list_of_items               [IN]        String list of items
 *  list_of_icons               [IN]        Icon list of items
 *  list_of_descriptions        [IN]        Description list of items
 *  highlighted_item            [IN]        Highlighted item
 *  history_buffer              [IN]        History buffer
 * RETURNS
 *  void
 *****************************************************************************/
void ShowCategory314Screen(
        U8 *title,
        U16 title_icon,
        S32 number_of_items,
        U16 *list_of_items,
        U16 *list_of_icons,
        U8 **list_of_descriptions,
        S32 highlighted_item,
        U8 *history_buffer)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    dm_data_struct dm_data;
    S32 i;
    U8 h_flag;
    GDI_HANDLE act_lcd = GDI_ERROR_HANDLE;
    gdi_handle sub_handle;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    SUBLCD_ExitCategoryFunction();
    gdi_lcd_get_active(&act_lcd);
    if (act_lcd != GDI_LCD_SUB_LCD_HANDLE)
    {
        UI_set_sub_LCD_graphics_context();
    }    
    gdi_layer_lock_frame_buffer();

    dm_add_title((UI_string_type) title, get_image(0)); /* sublcd can't show title icon */

    wgui_fixed_list_create_icontext_menu(
        number_of_items,
        highlighted_item,
        0,
        MMI_CATEGORY314_ID,
        history_buffer);

    wgui_status_icon_bar_reset_display(WGUI_STATUS_ICON_BAR_SUBLCD_H_BAR);

    resize_fixed_icontext_menuitems(
        MMI_fixed_list_menu.width - MMI_fixed_list_menu.vbar.width - 1,
        MMI_fixed_icontext_menuitem.height);

    MMI_fixed_list_menu.flags |= UI_LIST_MENU_DISABLE_BKGRND_IN_LAYER;

    gdi_layer_get_base_handle(&sub_handle);
    MMI_fixed_list_menu.act_layer_handle = sub_handle;
    MMI_fixed_list_menu.act_lcd_handle = GDI_LCD_SUB_LCD_HANDLE;
    wgui_fixed_list_begin_add_icontext_one_item();
    if (list_of_descriptions == NULL)
    {
        for (i = 0; i < number_of_items; i++)
        {
            wgui_fixed_list_add_icontext_one_item(i, (U8*) get_string(list_of_items[i]), wgui_get_list_menu_icon(i, list_of_icons[i]), NULL);
        }
    }
    else
    {
        for (i = 0; i < number_of_items; i++)
        {
            wgui_fixed_list_add_icontext_one_item(i, (U8*) get_string(list_of_items[i]), wgui_get_list_menu_icon(i, list_of_icons[i]), list_of_descriptions[i]);
        }
    }
    wgui_fixed_list_end_add_icontext_one_item();
    wgui_fixed_list_resize_icontext_menu(UI_device_width, UI_device_height - MMI_SUBLCD_TITLE_HEIGHT);

    gdi_layer_unlock_frame_buffer();

    SUBLCD_ExitCategoryFunction = ExitCategory314Screen;
    dm_setup_category_functions(dm_redraw_category_screen, dm_get_category_history, dm_get_category_history_size);
    dm_data.s32ScrId = (S32) GetActiveScreenId();
    dm_data.s32CatId = MMI_CATEGORY314_ID;
    dm_data.s32flags = DM_SUB_LCD_CONTEXT;
    dm_sublcd_setup_data(&dm_data);
    dm_sublcd_redraw_category_screen();

    if (act_lcd == GDI_LCD_MAIN_LCD_HANDLE)
    {
        UI_set_main_LCD_graphics_context();
    }

}

 界面的设计代码,这里可以自己修改编辑

/*****************************************************************************
 * FUNCTION
 *  DrawCate113CategoryControlArea
 * DESCRIPTION
 *  Cateogry 113 control area redraw callback
 *****************************************************************************/
static void DrawCate113CategoryControlArea(dm_coordinates *coordinate)
{

    UI_UNUSED_PARAMETER(coordinate);
    RedrawCate113IconArray();
}

 

按钮的注册 SetKeyHandler( ExitSubLCDMainMenuScreen, KEY_FWD, KEY_EVENT_UP);

void SetKeyHandler(FuncPtr funcPtr, U16 keyCode, U16 keyType)
{
    mmi_frm_set_key_handler(funcPtr, keyCode, keyType);
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值