Group Structure
1. Group Definition
The same as the screen ID.
Defined in XXX. Res
<Screen id = "grp_id_myapp_5"/> // group ID
<Screen id = "grp_id_myapp_6"/> // group ID
<Screen id = "scr_id_myapp_5"/> // screen ID
<Screen id = "scr_id_myapp_6"/> // screen ID
By compiling resources, the system automatically generates the mmi_rp_app_xxx_def.h file.
In mmi_rp_app_xxx_def.h
We can see the following definition. This is our group ID. We can see that group ID and screen ID are actually two things, but their usage is different.
Typedef Enum
{
Grp_id_myapp_head = 60382 + 1,/* base_id + 1 */
Grp_id_myapp_5,
Grp_id_myapp_6,
Scr_id_myapp_head,
Scr_id_myapp_5,
Scr_id_myapp_6,
Mmi_rp_app_myapp_scr_max
} Mmi_rp_app_myapp_scr_enum;
2. Use Group
Void entry_myapp_screen (void)
{
Mmi_id parent_id; // defines the parent group ID
Parent_id = mmi_frm_group_get_active_id (); // obtain the ID of the currently activated group.
// Insert the newly created group grp_id_myapp_head to parent_id.
Mmi_frm_group_create (parent_id,
Grp_id_myapp_head,
Mmi_myapp_proc, // mmi_myapp_proc is equivalent to the group callback function,
Null );
// Mmi_frm_group_enter is used to enter the group function. After analysis
Mmi_frm_group_enter (grp_id_myapp_head, mmi_frm_node_smart_close_flag );
// Entry_myapp_show_screen () and group_entry_myapp_show_screen () functions used to display menus
# If 0
Entry_myapp_show_screen ();
# Else
Group_entry_myapp_show_screen ();
# Endif
}
// All operations related to group grp_id_myapp_head will call the mmi_myapp_proc function.
// When evt_id_cui_menu_item_select is used, the corresponding menu function is provided for Cui.
Static mmi_ret mmi_myapp_proc (mmi_event_struct * EVT)
{
Switch (EVT-> evt_id)
{
Case evt_id_group_first_entry: myapp_black (); break; // called when you first enter the group
Case evt_id_group_inactive: myapp_black (); break; // called when activated
Case evt_id_group_active: myapp_black (); break; // called upon Activation
Case evt_id_group_goback: myapp_black (); break; // called when gobackhistory is called
Case evt_id_group_delete_req: myapp_black (); break;
Case evt_id_group_deinit: myapp_black (); break; // called upon Cancellation
Case evt_id_group_focused: myapp_black (); break;
Case evt_id_cui_menu_item_select: // provides the function for highlighting menus for Cui.
If (menu_evt-> highlighted_menu_id = menu_id_myapp_1)
{
Myapp_menu1_hight_hdr ();
}
Else if (menu_evt-> highlighted_menu_id = menu_id_myapp_2)
{
Myapp_menu2_hight_hdr ();
}
Else if (menu_evt-> highlighted_menu_id = menu_id_myapp_3)
{
Myapp_menu3_hight_hdr ();
}
Break;
Default: break;
}
Return mmi_ret_ OK;
}
// Group is used to display the form. The following is the display part.
Void group_entry_myapp_show_screen (void)
{
# If 1
U8 * guibuffer;
2010nstritemlist [10];
B2nnumofitem = 0;
/*----------------------------------------------------------------*/
/* Code body */
/*----------------------------------------------------------------*/
// Mmi_frm_scrn_enter is similar to the entrynewscreen function in the group operation.
If (! Mmi_frm_scrn_enter (
Grp_id_myapp_head, // group ID
Scr_id_myapp_head, // screnn ID
Null,
Group_entry_myapp_show_screen, // entry function
Mmi_frm_full_scrn) // full screen display
{
Return;
}
Guibuffer = mmi_frm_scrn_get_active_gui_buf (); // obtain the Buf
// The following features are not described below.
Registerhighlighthandler (executecurrhilitehandler );
Nnumofitem = getnumofchild_ext (menu_id_myapp_head );
Getsequencestringids_ext (menu_id_myapp_head, nstritemlist );
Setparenthandler (menu_id_myapp_head );
Showcategory15screen (
Str_global_options,
Null,
Str_global_ OK,
Img_global_ OK,
Str_global_back,
Img_global_back,
Nnumofitem,
Nstritemlist,
(2010*) gindexiconsimagelist,
List_menu,
0,
Guibuffer );
Clearkeyevents ();
Setkeyhandler (gobackhistory, key_left_arrow, key_event_down );
Setrightsoftkeyfunction (gobackhistory, key_event_up );
# Endif
}
3. Use of Cui
The purpose of Cui is to facilitate the display of menus. The example is as follows:
Void entry_myapp_show_screen (void)
{
Mmi_id menu_id; // define the ID
Menu_id = cui_menu_create (// create Cui
Grp_id_myapp_head, // group ID
Cui_menu_src_type_resource,
Cui_menu_type_from_resource,
Menu_id_myapp_head, // parent menu ID
Mmi_false,
(Void *) (u32) menu_id_myapp_head );
Cui_menu_set_default_title (// set the title and Image
Menu_id,
(Ui_string_type) getstring (str_global_abort ),
(Ui_image_type) getimage (img_global_activated ));
Cui_menu_run (menu_id); // execute Cui
}
The overall effect of entry_myapp_show_screen is the same as that of screen. We can see that entry_myapp_show_screen is much more concise than group_entry_myapp_show_screen. This is also the meaning of Cui, but the corresponding events highlighted by Cui menus cannot. register in the res file (for example: <menuitem
Id = "menu_id_myapp_3" str = "str_id_myapp_menu_3"
Highlight = "mmi_myapp_menu_3_hdr"/>). The event for highlighting the menu displayed by Cui must be defined in the function registered in the group creation such as mmi_myapp_proc (for example, Case evt_id_cui_menu_item_select: ........; Break ;).