MTK highlighting Mechanism

Source: Internet
Author: User

1 Introduction:
This article aims to introduce the processing logic of the MTK platform highlight mechanism. I believe it can be helpful to those who have just started the MTK platform, and it can also be used for project progress and other reasons at ordinary times, I am not very familiar with the basic knowledge of MTK. I can only watch and help the students who add menus and processing functions based on Huludao. They can take the initiative to gain an in-depth understanding of the problem and improve themselves.
I have not been engaged in MTK for a long time. The above words are too big, so I can still say it to new users. Some of the information in this document is incorrect and clear. Comments and discussions are welcome.
2. List of related functions and variables:
Voidregisterhighlighthandler (void (* f) (s32item_index ))
The General highlighting function of the registration window.
Mmi_list_highlight_handler
The global variable pointer of the general highlight processing function.
Voidexecutecurrhilitehandler (s32hiliteid)
The general handler of the highlighted menu item. It will find the handler corresponding to the menu item. Generally, registerhighlighthandler (executecurrhilitehandler) is created during window creation ).
Funcptrmmi_frm_get_hilite_hdlr (u16menu_id)
Obtain the menu highlight function corresponding to menu_id, which is obtained from the array of two function pointers. First look for the highlighted function pointer array of the dynamic menu, which is an array dynamically added in the program; if it cannot be found, then look for it in the static array, this array is generated during compilation. Generally, the menus added to functions such as res_mainmenu.c are compiled into a static array by the resource generation tool.
Mmi_frm_int_hilite_hdlr_table [] dynamic array.
Mmi_frm_const_hilite_hdlr_table [] Static array.
Currparentid
Global variable of current parent window
Voidsethilitehandler (u16itemid, funcptrhilitefuncptr)
Set the menuid of the dynamic highlighted array and its corresponding processing functions, which are generally used in custom menu items. For example, in an environment with unpredictable menu items such as image browsing, Java applications, and WAP records, we cannot do static menuid and processing functions, and we need to use dynamic implementation methods.
Hintdata [] []
[To be confirmed]: This is a dynamic menu data buffer, one-to-one correspondence with menuid. In other words, it is the display string of the menu. Some articles on the Internet and constructhintslist () should be wrong, mainly because the function annotation in the Code is static and should be wrong. Reference description:
3. constructhintslist ()
Constructshintlistforastaticmenuscreen
Voidconstructhintslist (u16parentid, u8 ** hintarray)
{......
(* Maxhiliteinfo [hiliteitemid [I]. hintfuncptr) (idx); // The function registered by sethinthandler is executed here
Hintarray [idx] = hintdata [idx]; // this statement is the core of the function, that is, the global variable hintdata [idx] array address
// Assign the pointer array to the user; check whether there is any data in hintdata [idx]
// Handle; the data of hintdata [idx] will be updated when the sethinthandler registration function is called.
// Initialize. Remember that the sethinthandler registration function is registered in sethilitehandler.
// Executed before the function.
I think constructhintslist () is used to create a dynamic menu, time relationship, to be analyzed.
3. highlights:
3.1 Procedure
After entering each window, there is basically a program similar to the following:
......
Entrynewscreen (em_debug_info_scr, null, entryemdebuginfo, null );
Guibuffer = getcurrguibuffer (em_debug_info_scr );
Nitems = getnumofchild (em_debug_info_menuid );
Getsequencestringids (em_debug_info_menuid, itemlist );
Setparenthandler (em_debug_info_menuid );
Registerhighlighthandler (executecurrhilitehandler );
Showcategory52screen (...)
Setrightsoftkeyfunction (gobackhistory, key_event_up );
......
3.2 Analysis
This is a general processing structure of the window creation process. Here we will briefly describe the specific implementation and functions of each function. Please read the code.
Entrynewscreen initializes the variables and processes required to create a window, exits the previous window, and clears the key processing function;
Setparenthandler is very important. It sets the menuid of the global variable of the current parent window to locate the current window, and then finds the menuid of the highlighted menu item in the menu tree based on it, after finding the menuid of the menu item, you can find the highlighted function corresponding to the menu item through mmi_frm_get_hilite_hdlr (u16menu_id). registerhighlighthandler registers executecurrhilitehandler as a general highlighted function, we only need to tell executecurrhilitehandler the menuid of the highlighted menu item, and it will find the execution function and start execution. At this point, we should have basically understood the highlighting mechanism and understood it as a very simple ^ _ ^;
Showcategory52screen () is just a window interface drawing function, and it has nothing to do with the event processing logic.
Setrightsoftkeyfunction (gobackhistory, key_event_up) and other functions set the key events to be responded to in this window, and set the corresponding processing function.
3.3 highlighted function trigger Process
Registerhighlighthandler registers executecurrhilitehandler as a general-purpose highlighting function. In fact, it assigns a value to the mmi_list_highlight_handler function pointer. Call mmi_list_highlight_handler to trigger the call.
The MTK platform supports various menu forms, such as plain text menus, checkbox menus, Radio menus, one image, two images, and two rows. Currently, only one standard menu is analyzed, and other methods are the same.
In standard_list_highlight_handler (s32item_index), the registered highlighted handler mmi_list_highlight_handler is executed, and standard_list_highlight_handler is a registration function. It is registered in handler () to handler, mmi_fixed_list_menu is the data structure of the menu component. It contains all the data of the menu component from display to function processing. How to display each component and how to respond to the buttons is not discussed here, in the future, I may write documents. If you are interested, read the code on your own, and the results will be better.
Here, mmi_fixed_list_menu.item_highlighted is executed by the Merge () function in this component, while gui_fixed_list_menu_switch_highlighted_item () is executed when the upper and lower buttons are executed, compared with the voidfixed_list_goto_previus_item (void) function on the response, it calls lifecycle (fixed_list_menu * m), while lifecycle (fixed_list_menu * m) Calls lifecycle (), which is triggered The process is complete.
If (flag & wgui_list_list_list_list_menu_disable_vol_key) is included in wgui_fixed_list_create_text_menu)
Register_fixed_list_keys_ex ();
Else
Register_fixed_list_keys ();
To register the key event processing function, the implementation process is very simple:
Voidregister_fixed_list_keys (void)
{
Setkeyhandler (fixed_list_goto_previus_item, key_up_arrow, key_event_down );
Setkeyhandler (fixed_list_goto_next_item, key_down_arrow, key_event_down );
Setkeyhandler (fixed_list_goto_previus_item, key_vol_up, key_event_down );
Setkeyhandler (fixed_list_goto_next_item, key_vol_down, key_event_down );
}
It is another topic about how to respond to key events and how to handle the logic of keys. It generally includes keyboard interruption, deshake, keyboard ing, detection, Process Communication, and some key processing mechanisms of applications, and has the opportunity to write documents again.
4. knowledge points:
4.1 Initialization
Some highlighted global variables will be initialized in initevents (), In the event. c file. A call stack relationship of this function during startup is as follows:
Initevents ();
Initeventhandlersbeforepoweron ();
Voidmmi_task (oslentrytype * entry_param)
Initevents (); will also be called in initframework (), and initframework () will have different calling processes due to different boot statuses, such as USB boot and alarm clock boot. For more information, see my document about the application startup process.
4.2 menu structure and search
4.2.1 menu number Array
Constcustom_menumtk_ncustmenus [] = {
{, (*) Nordermenuitem_0 },
{, 26218,26085, (*) nordermenuitem_1 },
{, 555, 0, (*) 0 },
{, (*) 0 },
{, 26173,0, (*) 0 },
{0, 0, 0, 0, 0, 0, (*) 0 },
{0, 0, 0, 0, 0, 0, (*) 0 },
{0, 0, 0, 0, 0, 0, (*) 0 },
{0, 0, 0, 0, 0, 0, (*) 0 },
{0, 0, 0, 0, 0, 0, (*) 0 },
{0, 0, 0, 0, 0, 0, (*) 0 },
........
}
Custom_menuncustmenus [max_menu_items];
4.2.2 find the highlighted window menuid through the parent window menuid and highlighted Index
U16getseqitemid_ext (u16parent_item_id, u16index)
{
/*----------------------------------------------------------------*/
/* Localvariables */
/*----------------------------------------------------------------*/
U8i = 0, idx = 0;
U16item_id = 0;
U8child_count = (u8) ncustmenus [parent_item_id-1]. nnumofmenuitem;
/*----------------------------------------------------------------*/
/* Codebody */
/*----------------------------------------------------------------*/
# Ifdefdevapp_resource
If (parent_item_id> = menu_id_devapp_start)
{
Returndevappgetseqitemid_ext (parent_item_id, index );
}
# Endif
For (I = 0; I <child_count; I ++)
{
Item_id = ncustmenus [parent_item_id-1]. nordermenuitemid [I];
If (! Mmi_frm_test_menu_item_hide (item_id)/* theitemisnothidden */
{
If (idx = index)
{
Break;
}
Else
{
Idx ++;
}
}
}
Mmi_trace (mmi_fw_trc_g2_gui, mmi_resgen_all_menu_hide, parent_item_id );
Returnitem_id;
}
4.2.3 use the menuid in the highlighted window to find the corresponding highlighted Function
Funcptrmmi_frm_get_hilite_hdlr (u16menu_id)
{
/*----------------------------------------------------------------*/
/* Localvariables */
/*----------------------------------------------------------------*/
U32index;
/*----------------------------------------------------------------*/
/* Codebody */
/*----------------------------------------------------------------*/
/* Firstlysearchthedynamictable */
If (mmi_frm_binary_search (u32) menu_id, (mmi_frm_pair_data_struct *) mmi_frm_int_hilite_hdlr_table,
(U32) mmi_frm_int_hilite_hdlr_count, & Index ))
{
Returnmmi_frm_int_hilite_hdlr_table [Index]. hilite_hdlr;
}
/* Andthensearchtheconstanttable. theconstanttableisgenerantedbyresgen .*/
Elseif (mmi_frm_binary_search (u32) menu_id,
(Mmi_frm_pair_data_struct *) mmi_frm_const_hilite_hdlr_table,
(U32) array_count (mmi_frm_const_hilite_hdlr_table), & Index ))
{
Returnmmi_frm_const_hilite_hdlr_table [Index]. hilite_hdlr;
}
Else
{
Returnnull;
}
}
This article comes from the silent http://www.imeans.net/, the original address: http://www.imeans.net/post/201004/44.html

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.