MTK手机平台添加资源和菜单的方式
一、 菜单的修改或增加:
以一个例子的方式介绍如何添加一个菜单,例子如下:
在主菜单的“设置”菜单下增加一个“我的设定”子菜单,“我的设定”下有两个子菜单:“我
的设定1”和“我的设定2”,打开这两个菜单,分别显示一幅动画。
步骤如下:
1.在../plutommi/mmi/Setting/SettingInc目录下的SettingDefs.h文件中增加如下内容:
a. enum STR_SETTING_LIST的最后增加三个字符串ID的声明:
STR_MY_SETTING,
STR_MY_SETTING1,
STR_MY_SETTING2,
b. enum SCR_SETTING_LIST的最后增加三个Screen ID的声明:
SCR_MY_SETTING,
SCR_MY_SETTING1,
SCR_MY_SETTING2,
c. enum IMG_SETTING_LIST的最后增加一个Image ID的声明:
IMG_MY_SETTING,
d. 在../plutommi/mmi/Inc目录下GlobalMenuItems.h文件中enum GLOBALMENUITEMSID
的最后增加三个菜单ID的声明:(有的是在本AP或模块的*Defs.h中声明)
MENU_MY_SETTING,
MENU_MY_SETTING1,
MENU_MY_SETTING2,
2.在../plutommi/Customer/CustResource/PLUTO_MMI目录下的Ref_list.txt中添加三个字符串:
STR_MY_SETTING Undefined 10 My Setting My Setting 我的设定 我的设定
STR_MY_SETTING1 Undefined 10 My Setting1 My Setting1 我的设定1 我的设定1
STR_MY_SETTING2 Undefined 10 My Setting2 My Setting2 我的设定2 我的设定2
3. 在.. /plutommi/Customer/CustResource/PLUTO_MMI/Res_MMI目录下的Res_Setting.c增加如下
资源:
ADD_APPLICATION_MENUITEM((MENU_MY_SETTING,MAIN_MENU_SETTINGS_MENUID ,2,MENU_MY_SETTING1,MENU_MY_SETTING2,SHOW, MOVEABLEWITHINPARENT,
DISP_LIST,STR_MY_SETTING,0));
ADD_APPLICATION_MENUITEM((MENU_MY_SETTING1,MENU_MY_SETTING,0,SHOW,
MOVEABLEWITHINPARENT, DISP_LIST,STR_MY_SETTING1,0));
ADD_APPLICATION_MENUITEM((MENU_MY_SETTING2,MENU_MY_SETTING,0,SHOW,
MOVEABLEWITHINPARENT, DISP_LIST,STR_MY_SETTING2,0));
ADD_APPLICATION_IMAGE2(IMG_MY_SETTING,CUST_IMG_PATH"////MainLCD////SubMenu///Settings////MY_SETTING.GIF","My Setting.");
ADD_APPLICATION_STRING2(STR_MY_SETTING,"My Setting","MySetting");
ADD_APPLICATION_STRING2(STR_MY_SETTING1,"My Setting1","My Setting1");
ADD_APPLICATION_STRING2(STR_MY_SETTING2,"My Setting2","My Setting2");
4. 在.. /plutommi/Customer/CustResource/PLUTO_MMI/Res_MMI目录下的Res_MainMenu.c中修改如下:
ADD_APPLICATION_MENUITEM((MAIN_MENU_SETTINGS_MENUID,IDLE_SCREEN_
MENU_ID, 5,
MENU9102_INITIAL_SETUP,
.
.
.
改为:
ADD_APPLICATION_MENUITEM((MAIN_MENU_SETTINGS_MENUID,IDLE_SCREEN_
MENU_ID,6,
MENU_MY_SETTING,
MENU9102_INITIAL_SETUP,
5.在../plutommi/mmi/Setting/SettingInc/目录下的SettingProt.h中增加如下的函数声明:
void HighlightMySetting(void);
void HighlightMySetting1(void);
void HighlightMySetting2(void);
void EntryMySetting(void);
void EntryMySetting1(void);
void EntryMySetting2(void);
6.在../plutommi/mmi/Setting/SettingSrc/目录下的SettingSrc.c中增加如下的函数定义:
void HighlightMySetting(void)
{
SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
SetRightSoftkeyFunction(GoBackHistory,KEY_EVENT_UP);
SetKeyHandler(EntryMySetting, KEY_RIGHT_ARROW,KEY_EVENT_DOWN);
SetLeftSoftkeyFunction(EntryMySetting,KEY_EVENT_UP);
}
void HighlightMySetting1(void)
{
SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
SetRightSoftkeyFunction(GoBackHistory,KEY_EVENT_UP);
SetKeyHandler(EntryMySetting1, KEY_RIGHT_ARROW,KEY_EVENT_DOWN);
SetLeftSoftkeyFunction(EntryMySetting1,KEY_EVENT_UP);
}
void HighlightMySetting2(void)
{
SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
SetRightSoftkeyFunction(GoBackHistory,KEY_EVENT_UP);
SetKeyHandler(EntryMySetting2, KEY_RIGHT_ARROW,KEY_EVENT_DOWN);
SetLeftSoftkeyFunction(EntryMySetting2,KEY_EVENT_UP);
}
void EntryMySetting(void)
{
U16 nStrItemList[MAX_SUB_MENUS]; /* Stores the strings id of submenus returned */
U16 nNumofItem; /* Stores no of children in the submenu*/
U8* guiBuffer; /* Buffer holding history data */
U16 ImageList[MAX_SUB_MENUS];
EntryNewScreen(SCR_MY_SETTING, NULL, EntryMySetting, NULL);
/* 2 Get current screen to guibuffer for history purposes*/
guiBuffer= GetCurrGuiBuffer(SCR_MY_SETTING);
/* 3. Retrieve no of child of menu item to be displayed */
nNumofItem= GetNumOfChild(MENU_MY_SETTING);
/* 4. Retrieve string ids in sequence of given menu item to be displayed */
GetSequenceStringIds(MENU_MY_SETTING,nStrItemList);
GetSequenceImageIds(MENU_MY_SETTING, ImageList);
/* 5 Set current parent id*/
SetParentHandler(MENU_MY_SETTING);
/* 6 Register highlight handler to be called in menu screen */
RegisterHighlightHandler(ExecuteCurrHiliteHandler);
/* 7 Display Category1 Screen */
ShowCategory15Screen(STR_MY_SETTING, IMG_SCR_SETTING_CAPTION, STR_GLOBAL_OK, IMG_GLOBAL_OK,STR_GLOBAL_BACK, IMG_GLOBAL_BACK, nNumofItem, nStrItemList, ImageList, LIST_MENU, 0, guiBuffer);
/* 8.Register function with right softkey*/
SetRightSoftkeyFunction(GoBackHistory,KEY_EVENT_UP);
}
void EntryMySetting1(void)
{
S8 * string = GetString(STR_MY_SETTING1);
U16 imageId= IMG_MY_SETTING;
EntryNewScreen(SCR_MY_SETTING1, NULL, EntryMySetting1,NULL);
ShowCategory65Screen((U8*)string,imageId,NULL);
SetRightSoftkeyFunction(GoBackHistory,KEY_EVENT_UP);
}
void EntryMySetting2(void)
{
S8 * string = GetString(STR_MY_SETTING2);
U16 imageId= IMG_MY_SETTING;
EntryNewScreen(SCR_MY_SETTING2, NULL, EntryMySetting2, NULL);
ShowCategory65Screen((U8*)string,imageId,NULL);
SetRightSoftkeyFunction(GoBackHistory,KEY_EVENT_UP);
}
7. 在../plutommi/mmi/Setting/SettingSrc/目录下的SettingSrc.c中void InitSettingApp(void)函数下增
加如下代码:
SetHiliteHandler(MENU_MY_SETTING,HighlightMySetting);
SetHiliteHandler(MENU_MY_SETTING1,HighlightMySetting1);
SetHiliteHandler(MENU_MY_SETTING2,HighlightMySetting2);
基本概括如下:
a. 在Ref_list.txt和Res_*.c中增加资源;
b. 在*Defs.h中声明所有资源的ID,包括字符串ID、图片ID、菜单ID、窗口ID。
c. 在具体的实现代码文件中增加处理代码。