今天实现tab页形式的通话记录tab页图标的修改,即高亮的图标与非高亮时的图标不同。而MTK默认形式为高亮,非高亮为同一图标,只不过高亮时图标位置稍稍上移以突显出 高亮。此问题看似不难,而对刚接触tab页形式的MTK新手来说,也不易。于是我一点一点的分析tab图标的来源和去处。终于找到正解:
我发现了一个至关重要的变量g_tab_bar_items_p,它用于保存tab页相关信息,它的定义如下:/* Struct of tab bar item */ typedef struct _tab_bar_item_type { /* The icon of tab bar item */ PU8 icon; /* The text of tab bar item */ UI_string_type text; /* The flags of tab bar item */ U32 flags; #ifdef __MMI_OP11_TAB_BAR__ /* The duration of blinking, the unit is ms */ S32 blink_duration; #endif } tab_bar_item_type;
并将最终将信息传递给变量MMI_tab_bar_items用于创建最终的tab页。至于其中的来龙去脉,看我慢慢道来:
① 在函数mmi_advmix_entry_tab_call_log_list中通过函数mmi_advmix_fill_call_log_tab构建tab页信息,保存于临时变量tab_pages_info_array中。
② 通过参数的不断传递,通过函数mmi_frm_set_tab_bar_items将变量tab_pages_info_array信息保存于变量g_tab_bar_items_p中。
③ 在模板FTN_ShowCategory92Screen中通过函数mmi_frm_get_tab_bar_items从变量g_tab_bar_items_p中获得tab页信息保存于变量MMI_tab_bar_items中。
④ 函数wgui_create_horizontal_tab_bar运用变量MMI_tab_bar_items中的信息创建tab页。
整个过程便是如此,那么我要修改tab的信息必须做两处修改:
(1) 初始化修改,即在函数mmi_advmix_fill_call_log_tab中修改。另外两个函数mmi_slave_chist_fill_call_log_tab和mmi_chist_fill_call_log_tab修改类似。
修改如下:
void mmi_advmix_fill_call_log_tab(U8 tab_index, mmi_frm_tab_struct* tab_page) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ switch (tab_index) { case MMI_CHIST_TAB_ALL_CALLS: tab_page[tab_index].screen_id = SCR_ID_MTPNP_CHIST_TAB_ALL_CALLS_LIST; tab_page[tab_index].tab_entry_func = mmi_advmix_entry_tab_all_calls_list; tab_page[tab_index].tab_string =NULL; if(IsChineseSet()) { tab_page[tab_index].tab_icon = (U8*)GetImage(IMG_MTPNP_MENU_ALL_CALLS); } else { tab_page[tab_index].tab_icon = (U8*)GetImage(IMG_MTPNP_MENU_ALL_CALLS_EG); } if(g_adv_mix_cnx.currHiliteAdvTabIndex == MMI_CHIST_TAB_ALL_CALLS) { if(IsChineseSet()) { tab_page[tab_index].tab_icon = (U8*)GetImage(IMG_MTPNP_MENU_ALL_CALLS_HL); } else { tab_page[tab_index].tab_icon = (U8*)GetImage(IMG_MTPNP_MENU_ALL_CALLS_EG_HL); } } break; case MMI_CHIST_TAB_DIALED_CALLS: tab_page[tab_index].screen_id = SCR_ID_MTPNP_CHIST_TAB_DIALED_CALLS_LIST; tab_page[tab_index].tab_entry_func = mmi_advmix_entry_tab_dialed_calls_list; tab_page[tab_index].tab_string =NULL; if(IsChineseSet()) { tab_page[tab_index].tab_icon = (U8*)GetImage(IMG_MTPNP_MENU_DIALED_CALLS); } else { tab_page[tab_index].tab_icon = (U8*)GetImage(IMG_MTPNP_MENU_DIALED_CALLS_EG); } if(g_adv_mix_cnx.currHiliteAdvTabIndex == MMI_CHIST_TAB_DIALED_CALLS) { if(IsChineseSet()) { tab_page[tab_index].tab_icon = (U8*)GetImage(IMG_MTPNP_MENU_DIALED_CALLS_HL); } else { tab_page[tab_index].tab_icon = (U8*)GetImage(IMG_MTPNP_MENU_DIALED_CALLS_EG_HL); } } break; case MMI_CHIST_TAB_MISSED_CALLS: tab_page[tab_index].screen_id = SCR_ID_MTPNP_CHIST_TAB_MISSED_CALLS_LIST; tab_page[tab_index].tab_entry_func = mmi_advmix_entry_tab_missed_calls_list; tab_page[tab_index].tab_string =NULL; if(IsChineseSet()) { tab_page[tab_index].tab_icon = (U8*)GetImage(IMG_MTPNP_MENU_MISSED_CALLS); } else { tab_page[tab_index].tab_icon = (U8*)GetImage(IMG_MTPNP_MENU_MISSED_CALLS_EG); } if(g_adv_mix_cnx.currHiliteAdvTabIndex == MMI_CHIST_TAB_MISSED_CALLS) { if(IsChineseSet()) { tab_page[tab_index].tab_icon = (U8*)GetImage(IMG_MTPNP_MENU_MISSED_CALLS_HL); } else { tab_page[tab_index].tab_icon = (U8*)GetImage(IMG_MTPNP_MENU_MISSED_CALLS_EG_HL); } } break; case MMI_CHIST_TAB_RECVD_CALLS: tab_page[tab_index].screen_id = SCR_ID_MTPNP_CHIST_TAB_RECVD_CALLS_LIST; tab_page[tab_index].tab_entry_func = mmi_advmix_entry_tab_recvd_calls_list; tab_page[tab_index].tab_string =NULL; if(IsChineseSet()) { tab_page[tab_index].tab_icon = (U8*)GetImage(IMG_MTPNP_MENU_RECEIVED_CALLS); } else { tab_page[tab_index].tab_icon = (U8*)GetImage(IMG_MTPNP_MENU_RECEIVED_CALLS_EG); } if(g_adv_mix_cnx.currHiliteAdvTabIndex == MMI_CHIST_TAB_RECVD_CALLS) { if(IsChineseSet()) { tab_page[tab_index].tab_icon = (U8*)GetImage(IMG_MTPNP_MENU_RECEIVED_CALLS_HL); } else { tab_page[tab_index].tab_icon = (U8*)GetImage(IMG_MTPNP_MENU_RECEIVED_CALLS_EG_HL); } } break; #ifdef __FT_MMI_CALL_LOG_AUTO_MACHINE_LIST__ case MMI_CHIST_TAB_AUTO_ANSWER_MSG: tab_page[tab_index].screen_id = SCR_ID_CHIST_TAB_AUTOAM_LIST; tab_page[tab_index].tab_entry_func = mmi_adv_chist_entry_tab_autoam_list; tab_page[tab_index].tab_icon = (U8*)GetImage(IMG_ID_CHIST_TAB_AUTOAM_LIST); tab_page[tab_index].tab_string = NULL; break; #endif/* __FT_MMI_CALL_LOG_AUTO_MACHINE_LIST__ */ default: ASSERT(0); break; } }
(2) 动态修改,在构建tab页完成后,移动左右方向键更换高亮tab页之前修改。即在左右方向键响应函数中,函数mmi_frm_set_cur_sel_page之前做修改。这里封装了两个函数,即左方向键修改tab页函数和右方向键修改tab页函数。它们分别如下:
#ifdef __MMI_CHIST_UI_IN_TAB__ /***************************************************************************** * FUNCTION * mmi_chist_slave_tab_change_image_left * DESCRIPTION * modify tab page icon from left * PARAMETERS * index : the current highlight tab page index * RETURNS * void * Author: wangft * Time: 2010.2.14 *****************************************************************************/ void mmi_chist_slave_tab_change_image_left(U16 index) { if(index == MMI_CHIST_TAB_ALL_CALLS) { if(IsChineseSet()) { g_tab_bar_items_p[index].icon = (U8*)GetImage(IMG_MTPNP_MENU_ALL_CALLS_HL); /*往左移动复原下一个tab页图标*/ g_tab_bar_items_p[index + 1].icon = (U8*)GetImage(IMG_MTPNP_MENU_DIALED_CALLS); } else { g_tab_bar_items_p[index].icon = (U8*)GetImage(IMG_MTPNP_MENU_ALL_CALLS_EG_HL); g_tab_bar_items_p[index +1].icon = (U8*)GetImage(IMG_MTPNP_MENU_DIALED_CALLS_EG); } } else if(index == MMI_CHIST_TAB_DIALED_CALLS) { if(IsChineseSet()) { g_tab_bar_items_p[index].icon = (U8*)GetImage(IMG_MTPNP_MENU_DIALED_CALLS_HL); g_tab_bar_items_p[index +1].icon = (U8*)GetImage(IMG_MTPNP_MENU_RECEIVED_CALLS); } else { g_tab_bar_items_p[index].icon = (U8*)GetImage(IMG_MTPNP_MENU_DIALED_CALLS_EG_HL); g_tab_bar_items_p[index + 1].icon = (U8*)GetImage(IMG_MTPNP_MENU_RECEIVED_CALLS_EG); } } else if(index ==MMI_CHIST_TAB_RECVD_CALLS) { if(IsChineseSet()) { g_tab_bar_items_p[index].icon = (U8*)GetImage(IMG_MTPNP_MENU_RECEIVED_CALLS_HL); g_tab_bar_items_p[index + 1].icon = (U8*)GetImage(IMG_MTPNP_MENU_MISSED_CALLS); } else { g_tab_bar_items_p[index].icon = (U8*)GetImage(IMG_MTPNP_MENU_RECEIVED_CALLS_EG_HL); g_tab_bar_items_p[index +1].icon = (U8*)GetImage(IMG_MTPNP_MENU_MISSED_CALLS_EG); } } else if(index == MMI_CHIST_TAB_MISSED_CALLS) { if(IsChineseSet()) { g_tab_bar_items_p[index].icon = (U8*)GetImage(IMG_MTPNP_MENU_MISSED_CALLS_HL); /*往左移动复第一个tab页图标*/ g_tab_bar_items_p[MMI_CHIST_TAB_ALL_CALLS].icon = (U8*)GetImage(IMG_MTPNP_MENU_ALL_CALLS); } else { g_tab_bar_items_p[index].icon = (U8*)GetImage(IMG_MTPNP_MENU_MISSED_CALLS_EG_HL); /*往左移动复第一个tab页图标*/ g_tab_bar_items_p[MMI_CHIST_TAB_ALL_CALLS].icon = (U8*)GetImage(IMG_MTPNP_MENU_ALL_CALLS_EG); } } } /***************************************************************************** * FUNCTION * mmi_chist_slave_tab_change_image_right * DESCRIPTION * modify tab page icon from right * PARAMETERS * index : the current highlight tab page index * RETURNS * void * Author: wangft * Time: 2010.2.14 *****************************************************************************/ void mmi_chist_slave_tab_change_image_right(U16 index) { if(index == MMI_CHIST_TAB_ALL_CALLS) { if(IsChineseSet()) { g_tab_bar_items_p[index].icon = (U8*)GetImage(IMG_MTPNP_MENU_ALL_CALLS_HL); /*往右移动时复原最右边的图标*/ g_tab_bar_items_p[MMI_CHIST_TAB_CALL_LOG_TYPE_ENUM_TOTAL - 1].icon = (U8*)GetImage(IMG_MTPNP_MENU_MISSED_CALLS); } else { g_tab_bar_items_p[index].icon = (U8*)GetImage(IMG_MTPNP_MENU_ALL_CALLS_EG_HL); g_tab_bar_items_p[MMI_CHIST_TAB_CALL_LOG_TYPE_ENUM_TOTAL - 1].icon = (U8*)GetImage(IMG_MTPNP_MENU_MISSED_CALLS_EG); } } else if(index == MMI_CHIST_TAB_DIALED_CALLS) { if(IsChineseSet()) { g_tab_bar_items_p[index].icon = (U8*)GetImage(IMG_MTPNP_MENU_DIALED_CALLS_HL); /*往右移动时复原上一个tab页图标*/ g_tab_bar_items_p[index - 1].icon = (U8*)GetImage(IMG_MTPNP_MENU_ALL_CALLS); } else { g_tab_bar_items_p[index].icon = (U8*)GetImage(IMG_MTPNP_MENU_DIALED_CALLS_EG_HL); g_tab_bar_items_p[index - 1].icon = (U8*)GetImage(IMG_MTPNP_MENU_ALL_CALLS_EG); } } else if(index ==MMI_CHIST_TAB_RECVD_CALLS) { if(IsChineseSet()) { g_tab_bar_items_p[index].icon = (U8*)GetImage(IMG_MTPNP_MENU_RECEIVED_CALLS_HL); g_tab_bar_items_p[index - 1].icon = (U8*)GetImage(IMG_MTPNP_MENU_DIALED_CALLS); } else { g_tab_bar_items_p[index].icon = (U8*)GetImage(IMG_MTPNP_MENU_RECEIVED_CALLS_EG_HL); g_tab_bar_items_p[index - 1].icon = (U8*)GetImage(IMG_MTPNP_MENU_DIALED_CALLS_EG); } } else if(index == MMI_CHIST_TAB_MISSED_CALLS) { if(IsChineseSet()) { g_tab_bar_items_p[index].icon = (U8*)GetImage(IMG_MTPNP_MENU_MISSED_CALLS_HL); g_tab_bar_items_p[index - 1].icon = (U8*)GetImage(IMG_MTPNP_MENU_RECEIVED_CALLS); } else { g_tab_bar_items_p[index].icon = (U8*)GetImage(IMG_MTPNP_MENU_MISSED_CALLS_EG_HL); g_tab_bar_items_p[index - 1].icon = (U8*)GetImage(IMG_MTPNP_MENU_RECEIVED_CALLS_EG); } } } #endif
可以看出上面两处修改都修改了变量g_tab_bar_items_p,这样才能在以后的tab页构建过程中起作用。