您的位置:首页 > 其它

进入和退出屏幕模板程序

2010-12-24 14:02 211 查看
// 文件名: EntryAndExitFunciton
// 描述 : 进入和退出屏幕模板程序

// 函数 : EntryNewMenu
// ExitMyAppMenu
// ExitNewMenu

// 以下是模板中使用的ID
// 菜单ID: MENU_ID_MYAPP_NEW
// 图标ID: ICON_ID_MYAPP_NEW
// 字串ID: STR_ID_MYAPP_NEW
// 屏幕ID: SCR_ID_MYAPP_NEW
// 模板ID: MMI_CATEGORYWTXYZ1_ID(ShowCategoryWTXYZ1Screen)

// 关于加载菜单: 我们需要知道的是,加载实际只是对菜单项的说明,在程序中没有实际意义,实际上菜单项的加载最后是
// 通过模板加载的,模板读取菜单项数据,然后在屏幕上显示出来

#define MAX_NEW_MENU_ITEMS 20 // 声明新菜单中的项目数最大值: 50

// 函数名: EntryNewMenu
// 功能 : 进入新的屏幕
// 输入 : 无
// 输出 : 无
// 说明 : 1. attributes与GetDispAttributeOfItem
// A. GetDispAttributeOfItem返回当前菜单的属性(attributes),原文说明如下:
// This is a display attribute flag like 1-list,2-Circular,3-Tab..etc.
// B. attributes来源 CUSTOM_MENU结构中的nDispAttribute项目
// C. GetDispAttributeOfItem有一个防止溢出错误的流程,具体看源程序
// 2. SetParentHandler
// 似乎跟Task那块有关……
// 3. ExecuteCurrExitHandler Function:
// This old ExecuteCurrExiHandler function already merged into EntryNewScreen.
// The detail migrated information please check the coding covention.
// 4. ExecuteCurrHiliteHandler
// 用来设置高亮句柄,在WGUI控件设置POPUP相关函数(句柄)时很有用
// 5. GetSequenceStringIds, GetSequenceImageIds
// 用在Res_Organizer.c中添加菜单时使用的资源(image_id,string_id)初始化子菜单,
// 否则需要手动设置,手动可设置任意ID
void EntryNewMenu( void )
{
/* Standard Local Variables */
U8 * guiBuffer ;
S32 attributes ;
S32 num_of_items ;
/* shold be modified */
S32 i ;
U16 list_of_items[MAX_NEW_MENU_ITEMS] ;
U16 list_of_icons[MAX_NEW_MENU_ITEMS] ;

/* Standard Code Body */
/* Before displaying the new screen over previous screen the following must be excuted */
// 1. Save the contents of previous screen
EntryNewScreen( SCR_ID_MYAPP_NEW, NULL, EntryNewMenu, NULL ) ;
//EntryNewScreen( SCR_ID_MYAPP_NEW, ExitNewScreen, NULL, NULL ) ;
// 2. Get the buffer to store the contents of screen to be displayed
guiBuffer = GetCurrGuiBuffer(SCR_ID_MYAPP_NEW) ; // Buffer holding history data
// 3. Get Display attribute for the following scree
attributes = GetDispAttributeOfItem(MENU_ID_MYAPP_NEW) ; // Stores diaplay attribute
// 4. Recive number of submenu items to be displayed( if this entry function is to display a list menu
num_of_items = GetNumOfChild(MENU_ID_MYAPP_NEW); // Stores no of children in the subment
// 5. Set the parent of new screen to be diplayed, so that the framework knows where this menu item appears
SetParentHandler(MENU_ID_MYAPP_NEW);
// 6. Recevice strings and images(icons) id, in sequence, of given menu item to be displayed.
// The sequence of strings or images is defined as per the registration of string items in the populate function
// as described in Section 6.
// In my mind, it's optional subject.
GetSequenceStringIds(MAIN_MENU_ORGANIZER_MENUID, item_list) ;
GetSequenceImageIds(MAIN_MENU_ORGANIZER_MENUID, item_icon) ;
// 7. Set the subment item to be displayed highlighted, on the next screen
// 8. Set the function to be excuted on pressing right or left soft key
// Register highlight handler to be called in menu screen
// It's in depend on the category code, so in my mind, it's also optional subject
RegisterHighlightHandler(ExecuteCurrHiliteHandler) ;
/* should be modified */
// 9. Set the function to be called on exiting the next screen
for( i=0; i<num_of_items; i++ )
{
list_of_items[i] = STR_ID_MYAPP_NEW+i ;
list_of_icons[i] = ICON_ID_MYAPP_NEW+i ;
}
ShowCategoryWT001Screen(
STR_GLOBAL_OK, IMG_GLOBAL_OK,
STR_GLOBAL_BACK, IMG_GLOBAL_BACK,
num_of_items,
list_of_items,
list_of_icons,
0,
guiBuffer
)
// 10.Rigister function with right softkey
// 一般情况下注册按键的操作如:
// SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
// SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
SetRightSoftkeyFunction(GoBackHistory,KEY_EVENT_UP); // 注册右软键响应函数
SetLeftSoftkeyFunction(mmi_myapp_category_popup,KEY_EVENT_UP); // 注册左软键响应函数
}

// 函数名: ExitMyAppMenu
// 功能 : 退出屏幕的基本函数
// 输入 : 无
// 输出 : 无
static void ExitMyAppMenu( void * entry_screen_pfunc, U16 screen_id )
{
history currHistory ;
S16 nHistory=0 ;

currHistory.scrnID = screen_id ;
currHistory.entryFuncPtr = entry_screen_pfunc ;
pfnUnicodeStrcpy((S8*)currHistory.inputBuffer,(S8*)&nHistory);
GetCategoryHistory( currHistory.guiBuffer );
AddHistory( currHistory );
}

// 函数名: ExitNewMenu
// 功能 : 进入新的屏幕
// 输入 : 无
// 输出 : 无
// 调用 : ExitMyAppMenu
void ExitNewMenu( void )
{
/* Standard Code Body */
ExitMyAppMenu( EntryNewMenu, SCR_ID_MYAPP_NEW );
/* should be modified */
gui_fixed_icontext_menuitem_stop_scroll( );
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: