|
资源分配,菜单,字符串,对话框的综合例子:
1.声明各种ID(字符串ID、屏幕ID、图片ID):
a. 增加字符串ID的声明:
plutommi\mmi\Setting\SettingInc\SettingDefs.h
enum STR_SETTING_LIST
{
}
的最后添加:
STR_MY_SETTING,
STR_MY_SETTING1,
STR_MY_SETTING2,
b.增加ScreenID声明:
plutommi\mmi\Setting\SettingInc\SettingDefs.h
enum SCR_SETTING_LIST
{
}
的最后添加:
SCR_MY_SETTING,
SCR_MY_SETTING1,
SCR_MY_SETTING2,
c.增加图片ID声明:
plutommi\mmi\Setting\SettingInc\SettingDefs.h
enum IMG_SETTING_LIST
{
}
的最后添加:
IMG_MY_SETTING,
IMG_MY_SETTING1,
IMG_MY_SETTING2
2.添加3个菜单ID的声明:
plutommi\mmi\Inc\GlobalMenuItems.h
enum GLOBALMENUITEMSID
{
}
的后面添加三个菜单项的ID
MENU_MY_SETTING,
MENU_MY_SETTING1,
MENU_MY_SETTING2,
注意加的位置一定要在“MAX_MENU_ITEMS_VALUE,”之前
最好加在* Add new menuitems definitions before here 之前
3.字符串资源的添加:
.\plutommi\Customer\CustResource\PLUTO_MMI\ref_list.txt
每个字符之间用"TAB"键隔开
4.增加菜单项,图片等的资源
.\plutommi\Customer\CustResource\PLUTO_MMI\Res_MMI\Res_Setting.c
下添加:
void populateSettingMenu(void)
{
}
这个函数的 “Code body”下添加:
ADD_APPLICATION_MENUITEM((MENU_MY_SETTING,
MAIN_MENU_SETTINGS_MENUID,2,MENU_MY_SETTING1,
MENU_MY_SETTING2,SHOW, MOVEABLEWITHINPARENT,
DISP_LIST,STR_MY_SETTING,IMG_MY_SETTING));
ADD_APPLICATION_MENUITEM((MENU_MY_SETTING1,
MENU_MY_SETTING,0,SHOW,
MOVEABLEWITHINPARENT, DISP_LIST,STR_MY_SETTING1,IMG_MY_SETTING1));
ADD_APPLICATION_MENUITEM((MENU_MY_SETTING2,
MENU_MY_SETTING,0,SHOW,MOVEABLEWITHINPARENT, DISP_LIST,STR_MY_SETTING2,IMG_MY_SETTING2));
ADD_APPLICATION_IMAGE2(IMG_MY_SETTING,CUST_IMG_PATH"\\\\MainLCD\\\\SubMenu\\\\Settings\\\\MY_SETTING.pbm","My Setting");
ADD_APPLICATION_IMAGE2(IMG_MY_SETTING,CUST_IMG_PATH"\\\\MainLCD\\\\SubMenu\\\\Settings\\\\MY_SETTING1.pbm","My Setting1");
ADD_APPLICATION_IMAGE2(IMG_MY_SETTING,CUST_IMG_PATH"\\\\MainLCD\\\\SubMenu\\\\Settings\\\\MY_SETTING2.pbm","My Setting2");
ADD_APPLICATION_STRING2(STR_MY_SETTING,"My Setting","My Setting");
ADD_APPLICATION_STRING2(STR_MY_SETTING1,"My Setting1","My Setting1");
ADD_APPLICATION_STRING2(STR_MY_SETTING2,"My Setting2","My Setting2");
/**************************************************************
解释部分:
以下是比较完整的ADD_APPLICATION_MENUITEM函数:
ADD_APPLICATION_MENUITEM((MAIN_MENU_SETTINGS_MENUID,IDLE_SCREEN_MENU_ID,
#ifdef __MMI_SOUND_EFFECT__
////+ 1
#endif
#if defined(__MMI_TOUCH_SCREEN__) || defined(__MMI_HANDWRITING_PAD__)
1 +
#endif
1 + /* For fmgr; Added by Tomsu, 20071115*/
1 + /* For Profiles; Added by Tomsu, 20071115 */
1 + /* For themes; Added by Tomsu, 20071115 */
6,
MENU_MY_SETTING,
MENU9102_INITIAL_SETUP,
MENU8237_SCR8093_MNGCALL_MENU_MAIN,
MENU9185_NETWORK_SETUP,
MENU9101_SECURITY,
MAIN_MENU_PROFILES_MENUID, /* Added by Tomsu, 20071115 */
MENU3101_THEMES, /* Added by Tomsu, 20071115 */
#ifdef __MMI_SOUND_EFFECT__
//MENU_SETTING_SOUND_EFFECT,
#endif
MAIN_MENU_FILE_MNGR_MENUID, /* Added by Tomsu, 20071115 */
MENU_SETTING_RESTORE,
0,MOVEABLEWITHINPARENT|INSERTABLE,1,MAIN_MENU_SETTINGS_TEXT,
MAIN_MENU_SETTINGS_ICON));
**/
(1)MAIN_MENU_SETTINGS_MENUID(第一项):菜单ID
(2)IDLE_SCREEN_MENU_ID(第二项):上一级菜单的ID,即父菜单ID,
(3)6(第三项):该菜单下一级菜单的数目
(4)MOVEABLEWITHINPARENT|INSERTABLE---这个菜单的转移属性
(5)MAIN_MENU_SETTINGS_TEXT--该菜单的显示文本
(6)MAIN_MENU_SETTINGS_ICON--该菜单对应的图标
(7)SHOW---菜单的显示方式
(8)DISP_LIST--显示风格
ADD_APPLICATION_IMAGE2(IMG_MY_SETTING,CUST_IMG_PATH"\\\\MainLCD\\\\SubMenu\\\\Settings\\\\MY_SETTING2.pbm","My Setting2")
(1)IMG_MY_SETTING--图片ID
(2)CUST_IMG_PATH"\\\\MainLCD\\\\SubMenu\\\\Settings\\\\MY_SETTING2.pbm" ---路径,CUST_IMG_PATH--这一个宏
(3)"My Setting2"--描述
注1:图片的更改在:plutommi\Customer\Images\PLUTO240X320\MainLCD\Submenu\Settings
注2:可试一下后缀不改,看发生什么
5.把我们的"My_Setting"菜单,加到其他菜单下
.\plutommi\Customer\CustResource\PLUTO_MMI\Res_MMI\Res_MainMenu.c
修改ADD_APPLICATION_MENUITEM((MAIN_MENU_SETTINGS_MENUID,IDLE_SCREEN_MENU_ID,.........)
把它的子菜单项的数目增加1,把“MENU_MY_SETTING,”加在子菜单数目的后面。
6.声明菜单高亮函数和弹出对话框函数:
.\plutommi\mmi\Setting\SettingInc\SettingProt.h增加以下函数声明:
“Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! ”下面添加:
void HighlightMySetting(void); //高亮菜单项,以便选中
void HighlightMySetting1(void);
void HighlightMySetting2(void);
void EntryMySetting(void); //进入菜单项,进入Menulist
void EntryMySetting1(void);//弹出对话框,dialog
void EntryMySetting2(void);
7.构建函数:
.\plutommi\mmi\Setting\SettingSrc\SettingSrc.c
里构建。
在 “* InitSettingApp”下添加以下函数:
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);
}
8.对高亮句柄进行声明:
\plutommi\mmi\Setting\SettingSrc\SettingSrc.c
在以下函数
void InitSettingApp(void)
{
}
“/* Code Body ”下添加
SetHiliteHandler(MENU_MY_SETTING,HighlightMySetting);
SetHiliteHandler(MENU_MY_SETTING1,HighlightMySetting1);
SetHiliteHandler(MENU_MY_SETTING2,HighlightMySetting2);
完整版本请见http://www.51qianru.cn/bbs/
曙海教育
曙海嵌入式学院3G通信培训中心
(课程:MTK培训,Android培训,iPhone培训)
电话:021-51875830
网址:http://www.51qianru.cn
讲师:李现路
版权所有-曙海教育 转发请注明出处
|
|