An application consists of one or more windows.
Window creation process (Hello sprd ):
(1) create a window table ()
Macro window_table defines the window data information table, in window_parse.h
Window_table (mmi_hello_sprd_win_tab) =
{
Win_id (mmi_hello_sprd_win_id), // window ID
Win_func (uint32) handlehellosprdwinmsg), // processing function
Win_title (txt_hello_title), // window title
Win_softkey (stxt_ OK, txt_null, stxt_return ),
End_win
};
(2) Registration window ID
Temporarily stored in mmi_app/common/h/mmi_id.def
Win_id_def (mmi_hello_sprd_win_id, "mmi_hello_sprd_win_id ")
(3) mmk is located in mmk_app.h
Add case_msg_app_ OK to the handler in the idle window:
Mmk_createwin (uint32 *) mmi_hello_sprd_win_tab, pnull );
(4) Write a window handler; otherwise, an empty window is not displayed. (Window callback function)
First, declare that local mmi_result_e handlehellosprdwinmsg (
Mmi_win_id_t win_id,
Mmi_message_id_e msg_id,
Dparam Param
);
Then implement the function: the window processing function is actually a big case statement, mainly processing internal and external messages from the system.
Local mmi_result_e handlehellosprdwinmsg (
Mmi_win_id_t win_id,
Mmi_message_id_e msg_id,
Dparam Param
)
{Mmi_result_e recode = mmi_result_true;
Switch (msg_id)
{
Case msg_open_window: // window opening message
Break;
Case msg_full_paint: // refresh window message
{
Gui_ LCD _dev_info LCD _dev_info = {gui_main_ LCD _id, gui_block_main };
Gui_point_t start_point = {1, 1 };
Gui_rect_t rect = {0, 239,319}; // full screen area
Mmi_string_t text_str = {0 };
Mmires_gettext (txt_hello_sprd, win_id, & text_str );
Gui_fillrect (& LCD _dev_info, rect, mmi_white_color );
Start_point.x = 1;
Start_point.y = 30;
LCD _displaystring (& LCD _dev_info, start_point, text_str.wstr_ptr, text_str.wstr_len, 0, mmi_black_color, song_font_16, 0); // string display interface
Start_point.x = 1;
Start_point.y = 50;
Guires_displayimg (& start_point, pnull, pnull, win_id, hello_sprd_test, & LCD _dev_info );
Hellodrawline ();
Hellodrawrect ();
Hellofillrect ();
}
Break;
Case msg_app_ OK:
Mmk_createwin (uint32 *) mmi_test_menu_win_tab, pnull );
Break;
Case msg_get_focus: // The Window obtains the focus.
Break;
Case msg_lose_focus: // window loses focus
Break;
Case msg_app_cancel: // 2010-05-10
Mmk_closewin (mmi_hello_sprd_win_id );
Break;
Case msg_close_window: // close the window message
Break;
Default:
Recode = mmi_result_false;
Break;
}
Return recode;
}
To sum up the steps for creating a window:
(1) create a window table
(2) Registration window ID
(3) Call mmk_createwin to create a window
(4) Implement window processing functions
Message Definitions for some case statements:
Msg_open_window: open a window
Msg_get_focus: The Window obtains the focus.
Msg_full_paint: refresh window
Msg_lose_focus: The Window loses focus.
Msg_close_window: Close the window
Msg_app_cancel: Right-click the message (cancel or return)
Resources (Static and Dynamic Resources)
Including strings, images, menus, font libraries, and sounds.
Resource Project definition file: mmi_res_prj_def.h
Module resource ID definition file: for example, the common module common_mdu_def.h File
Add string resource:
(1)in the resource folder, open str_table.xls
Add (ID, maxlength, English) at the end of the file)
(2) Open common_mdu_def.h
Add res_add_string (txt_hello_sprd, "Hello sprd ")
Use of string resources:
{
Gui_point_t start_point = {1, 1 ,};
Gui_rect_t rect = {0, 239,319 };
Mmi_string_t text_str = {0}; // defines string resource information.
Mmires_gettext (txt_hello_sprd, win_id, & text_str); // obtain string resource information
Gui_fillrect (& LCD _dev_info, rect, mmi_white_color );
LCD _displaystring (& LCD _dev_info, start_point, text_str.wstr_ptr,
Text_str.wstr_len, 0, mmi_black_color, song_font_16, 0 );
}
Add image resources:
(1) Save the image to the ms_code \ ms_mmi \ source \ resource \ mmi_res_240x320 \ common \ mmi_res_default \ imag \ common of the corresponding module.
(2) Add in common_mdu_def.h (note the path)
Res_add_img (hello_sprd_test, "\ mmi_res _ ##\\ imag \ common \ hello_sprd_test.bmp", img_cmp_bmp _16_565_raw, 0)
(3 ){
Start_point.x = 1;
Start_point.y = 50;
Guires_displayimg (& start_point, pnull, pnull, win_id, hello_sprd_test, & LCD _dev_info );
}
Add menu resources:
(1) mmi_menutable.c
// Added on August 1, May 17
# Define menu_def (_ tableid, _ itemptr, _ style, _ titlestr, _ title_icon, _ title_numicon, _ title_background ,\
_ Itemcount )\
_ Itemptr, _ style, _ titlestr, _ title_icon, _ title_numicon, _ title_background, _ itemcount,
Const guimenu_item_t menu_hello_table [] =
{
{Id_hello_test1, tip_null, {stxt_ OK, txt_null, stxt_return}, txt_hello_test1, image_secmenu_icon_set_call, 0, 0 },
{Id_hello_test2, tip_null, {stxt_ OK, txt_null, stxt_return}, txt_hello_test2, image_secmenu_icon_set_call, 0, 0 },
{Id_hello_test3, tip_null, {stxt_ OK, txt_null, stxt_return}, txt_hello_test2, image_secmenu_icon_set_call, 0, 0 },
(2) Add the menu group ID definition to mmi_menutable.def.
Menu_def (menu_hello_table, menu_hello_table, partition, txt_null, image_common_title_bar, image_null, image_null, guimenu_item_num (menu_hello_table ))
(3) add menu ID
Typedef Enum // menu ID
{
Id_hello_test1,
Id_hello_test2,
Id_hello_test3,
Id_hello_total
} Mmi_hello_menu_id_e;
(4) add in mainapp. c
Window_table (mmi_test_menu_win_tab) =
{
Win_id (mmi_test_menu_win_id ),
Win_func (uint32) handletestmenuwinmsg ),
Win_title (txt_null ),
Create_menu_ctrl (0, mmi_client_rect_top, mmi_mainscreen_right_max_pixel, mmi_client_rect_bottom, menu_hello_table, mmi_test_menu_ctrl_id ),
Win_softkey (stxt_ OK, txt_null, stxt_return ),
End_win
};
(1) View menu item data definition: const guimenu_item_t menu_settings [] =
It helps you understand the meaning of menus. In the mmi_menutable.c File
Menu group data:
First, define the data retrieved from the menu_def macro in the file:
# Define menu_def (...)....
Const guimenu_group_t menu_table [] ={} // This is required if it is an additional module,
Otherwise, when added to another module, a redefinition error occurs.
(2) define the menu group ID and menu group data
Menu_def (...)... // defines the menu data macro
Define menu data information (array), const guimenu_item_t menu_hello_table [] =
{
{Id_hello_test1, tip_null, {stxt_ OK, txt_null, stxt_return}, txt_hello_test1, image_secmenu_icon_set_call, 0, 0 },
{Id_hello_test2, tip_null, {stxt_ OK, txt_null, stxt_return}, txt_hello_test2, image_secmenu_icon_set_call, 0, 0 },
{Id_hello_test3, tip_null, {stxt_ OK, txt_null, stxt_return}, txt_hello_test2, image_secmenu_icon_set_call, 0, 0 },
};
(3) define the menu item ID
Typedef Enum {
Id_hello_tset1,
Id_hello_tset2,
Id_hello_tset3,
Id_hello_total
} Mmi_hello_menu_id_e;
(4) create a window list
Window_table (mmi_test_menu_win_tab) = {}
(5)
Case msg_app_ OK:
Mmk_createwin (uint32 *) mmi_test_menu_win_tab, pnull );
Add handletestmenuwinmsg () to the window ()
Set the active status of the message. Otherwise, the message cannot be received.
Case msg_open_window:
Mmk_setatvctrl (win_id, mmi_test_menu_ctrl_id );
If you add a new module, you can separate the IDs and create a sample_id.h file.
Window ID
Typdef Enum {
Mmihello_win_id_start = (mmi_module_sample <16 ),
Mmi_hello_sprd_win_id,
Mmi_test_mune_win_id,
Mmihello_max_win_id
} Mmihello_window_id_e;
Control ID
Typedef Enum
{
Mmihello_ctrl_id_start = mmihello_max_win_id,
MMI_TEST-menu_ctrl_id,
Mmihello_max_ctrl_id
} Mmihello_control_id_e;