MTK平台学习--进入和退出屏幕模板程序

// 文件名:  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( );

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值