📄 新建 文本文档.txt
字号:
MTK平台学习--简单分析DM模板内部机制简单分析DM模板内部机制
1. DM模板的全局变量 g_dm_data
typedef struct
{
S32 s32ScrId;
S32 s32CatId;
S32 s32flags;
} dm_data_struct;
dm_data_struct g_dm_data;
2. analyse the API function
(1) dm_setup_data
在call dm_setup_data() 之前,DM的接口数据是存储在局部变量中的,根据MTK代码习惯,一般是dm_data
dm_setup_data主要作用就是将屏幕ID与模板ID关联起来;
(2) 重点分析 dm_redraw_category_screen( )
执行流程:
A. dm_search_coordinate_set( )
首先调用函数 dm_search_coordinate_set( )
作用:由给出的屏幕ID得到指向DM控制属性的指针;
B. dm_get_cat_scr_coordinates( )
然后调用函数 dm_get_cat_scr_coordinates( )
作用: 由于DM模板需要在其他组件被绘制前绘制窗体本身,
根据DM控制属性的第一项即基本属性得到窗体的属性值并更新指向属性的指针变量
注意: 在该函数被调用后,MMI将更新当前窗体
C. dm_get_coordinates( )
最后调用DM画图函数
在该函数内通过调用dm_get_coordinates( )以根据属性值更新全局属性变量,最后绘出图像
(3). DM模板的控件数组
控件在列表中放置的顺序:越往后的控件显示越靠上层,也越容易接收触摸屏操作
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=2151338
MTK平台学习--对MTK高亮事件的简单分析 对于MTK平台中高亮事件的简单分析,仅涉及MMI层的应用
牵涉函数:
void SetHiliteHandler( U16 itemid, FuncPtr hiliteFuncPtr );
void RegisterHighlightHandler( void (*f)(S32 item_index) );
void ExecuteCurrHiliteHandler( S32 hiliteid );
原理: 1. RegisterHighlightHandler(ExecuteCurrHiliteHandler)
A. ExecuteCurrHiliteHandler函数
通过当前高亮菜单的ID : hiliteItemID
执行与此ID关联的执行函数: maxHiliteInfo[hiliteItemID].entryFuncPtr
B. RegisterHighlightHandler函数
将上述函数指针(句柄)传给全局变量 MMI_list_highlight_handler 以便调用
2. 这里就有两个问题:
A. 高亮ID与高亮执行函数怎么关联的?
B. 全局的高亮句柄是怎么执行的?
3. 关联高亮ID与执行函数
SetHiliteHandler
该函数将ID与函数关联:
maxHiliteInfo[itemid].entryFuncPtr = hiliteFuncPtr ;
itemid是传入的菜单ID, hiliteFuncPtr是传入的高亮执行函数
4. 全局的高亮句柄的执行
由于暂时未涉及,没有具体分析。
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=2150580
MTK平台学习--对MTK按键事件的简单分析主要简单分析一下左右软件的事件,以左软键事件为例
牵涉到的常用函数:
void SetKeyHandler( FuncPtr funcPtr, U16 keyCode, U16 keyType );
void SetLeftSoftkeyFunction( void (*f)(void), MMI_key_event_type k );
void ChangeLeftSoftkey( U16 s, U16 i );
1. SetKeyHandler与SetLeftSoftkeyFunction
(1). SetKeyHandler
主要作用就是将需要起作用的函数的指针(funcPtr)
-->全局矩阵数组currKeyFuncPtrs[keyCode][keyType]的指定位置 ;
(2). SetLeftSoftkeyFunction
该函数内部主要流程:
Step1. call register_left_softkey_handler( )
这个函数call SetKeyHandler: 存储需要起作用的函数(left_softkey_down/left_softkey_up)
以left_softkey为例, 该函数首先首先刷新按键区域图像(redraw_softkey),
然后执行关联函数(softkey_functions[key][k]).
Step2. 在上一步里我们会发现,softkey_functions[key][k]里的函数指针没有初始化
通过 call set_left_softkey_function(f, k);
--->softkey_functions[key][k] = f;
这样,就成功的把按键按下/放开的作用函数与具体的动作关联起来了。
Step3. 最后call SetInputboxLSKFunction(f)
--->将上述函数与特定的输入(如触摸笔)关联起来。
(3). 以上两个函数的主要区别:
SetLeftSoftkeyFunction可以识别长按状态并且可以关联触摸笔操作等。
2. ChangeLeftSoftkey
主要执行流程:
Step1. call change_left_softkey: 设置左软键图表,文字
Step2. redraw_softkey: 刷新左软键显示区域
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=2150298
进入和退出屏幕模板程序 // 文件名: 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( );
}
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=2150508
MTK平台学习--History管理机制与EntryNewScreen函数的关系简单的分析一下History管理机制与EntryNewScreen的关系
1. 与EntryNewScreen函数有关的全局变量:
currEntryFuncPtr,
currExitScrnID, currTopScrnID,
currExitFuncPtr
2. EntryNewScreen函数部分流程:
Step1: 保存新屏幕ID(函数第一参数)-->currTopScrnID ;
Step2: 调用ExecuteCurrExitHandler ;
Step3: 保存新屏幕ID-->currExitScrnID ;
Step4: 调用SetGenericExitHandler ;
Step5: ......
......
3. 分析 ExecuteCurrExitHandler
函数原型: void ExecuteCurrExitHandler( void ) ;
A. 该函数主要流程就是依次调用了 ExecuteCurrExitHandler_Ext, ClearInputEventHandler
B. 主要分析 ExecuteCurrExitHandler_Ext函数的作用
函数原型: void ExecuteCurrExitHandler_Ext( void ) ;
函数功能: This function is used for executes current exit func handler without clear keys ;
函数主要流程(伪代码表示):
Step1: if(currEntryFuncPtr||currExitFuncPtr)
{
清除所有中断事件句柄 ;
}
Step2: if(currEntryFuncPtr)
{
ExitMyAppMenu( EntryNewMenu, SCR_ID_MYAPP_NEW );
// 将上次调用EntryNewScreen所记录的currExitScrnID, currEntryFuncPtr入栈
}
Step3: if(currExitFuncPtr)
{
mmu_frm_execute_scrn_exit_handler=MMI_TURE ;
(*currExitFuncPtr)( ) ;
mmu_frm_execute_scrn_exit_handler=MMI_FALSE ;
}
Step4: currEntryFuncPtr=currExitFuncPtr=NULL ;
Step5: DM屏幕模板退出函数 ;
Step6: ......
......
4. 分析 SetGenericExitHandler
函数原型: void SetGenericExitHandler( U16 scrnID, FuncPtr exitFuncPtr, FuncPtr entryFuncPtr ) ;
函数功能: currExitScrnID <-- scrnID ;
currExitFuncPtr <-- exitFuncPtr ;
currEntryFuncPtr <-- entryFuncPtr ;
说明 : 将EntryNewScreen的几个参数传递给全局变量,留待下次调用EntryNewScreen时调用
5. 牵涉到的退出函数:
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 );
}
6. 小结:
EntryNewScreen函数先将上次执行EntryNewScreen时记录的 currEntryFuncPt, currExitScrnID以History结构为载体记录入栈;
然后执行了退出函数;最后讲本窗口的scrnID, exitFuncPtr, entryFuncPtr存入全局变量,留待下次调用EntryNewScreen时使用。
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=2150427
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -