展訊功能機平臺視窗建立
阿新 • • 發佈:2019-02-06
PUBLIC MMI_HANDLE_T MMK_CreateWin( uint32* win_table_ptr, ADD_DATA add_data_ptr ) { MMI_WINDOW_TABLE_CREATE_T win_table_create = {0}; win_table_create.applet_handle = MMK_GetFirstAppletHandle(); win_table_create.parent_win_handle = 0; win_table_create.win_table_ptr = win_table_ptr; win_table_create.add_data_ptr = add_data_ptr; return MMK_CreateWinTable( &win_table_create ); }
呼叫MMK_CreateWin建立一個視窗。win_table_ptr是一個視窗陣列。add_data_ptr座位傳遞給視窗的引數,為void *型別
#define WINDOW_TABLE(_WINTAB_) const uint32 _WINTAB_[] /**---------------------------------------------------------------------------* ** Macro Declaration * **---------------------------------------------------------------------------*/ #define WIN_PRIO(_PRIO_) MMK_WINPRIO, _PRIO_ #define WIN_FUNC(_FUNC_) MMK_WINFUNC, _FUNC_ #define WIN_ID(_ID_) MMK_WINID, _ID_ // create the menu control #define CREATE_MENU_CTRL(_GROUP_ID_, _CTRL_ID_) \ MMK_CREATE_MENU, _GROUP_ID_, _CTRL_ID_ // create the menu control #define CREATE_MAINMENU_CTRL(_TYPE_, _CTRL_ID_) \ MMK_CREATE_MAINMENU, _TYPE_, _CTRL_ID_ // create the pop_up menu control #define CREATE_POPMENU_CTRL(_GROUP_ID_, _CTRL_ID_) \ MMK_CREATE_POPMENU, _GROUP_ID_, _CTRL_ID_ // create the msgbox control #define CREATE_MSGBOX_CTRL(_STYLE_, _CTRL_ID_) \ MMK_CREATE_MSGBOX, _STYLE_, _CTRL_ID_ // create the prgbox control #define CREATE_PRGBOX_CTRL(_TYPE_, _CTRL_ID_) \ MMK_CREATE_PRGBOX, _TYPE_, _CTRL_ID_ // create the text control #define CREATE_TEXT_CTRL(_CTRL_ID_) \ MMK_CREATE_TEXT, _CTRL_ID_ // create the listbox control #define CREATE_LISTBOX_CTRL(_LIST_TYPE_, _CTRL_ID_) \ MMK_CREATE_LISTBOX, _LIST_TYPE_, _CTRL_ID_ // create the text edit box control #define CREATE_EDIT_TEXT_CTRL(_STR_MAX_LEN_, _CTRL_ID_) \ MMK_CREATE_EDIT_TEXT, _STR_MAX_LEN_, _CTRL_ID_ // create the phone number edit box control #define CREATE_EDIT_PHONENUM_CTRL(_STR_MAX_LEN_, _CTRL_ID_) \ MMK_CREATE_EDIT_PHONENUM, _STR_MAX_LEN_, _CTRL_ID_ // create the digital edit box control #define CREATE_EDIT_DIGITAL_CTRL(_STR_MAX_LEN_, _CTRL_ID_) \ MMK_CREATE_EDIT_DIGITAL, _STR_MAX_LEN_, _CTRL_ID_ // create the password edit box control #define CREATE_EDIT_PASSWORD_CTRL(_STR_MAX_LEN_, _CTRL_ID_) \ MMK_CREATE_EDIT_PASSWORD, _STR_MAX_LEN_, _CTRL_ID_ // create the list edit box control #define CREATE_EDIT_LIST_CTRL(_ITEM_NUM_, _ITEM_STR_MAX_LEN_, _CTRL_ID_) \ MMK_CREATE_EDIT_LIST, _ITEM_NUM_, _ITEM_STR_MAX_LEN_, _CTRL_ID_ // create the date edit box control #define CREATE_EDIT_DATE_CTRL(_CTRL_ID_) \ MMK_CREATE_EDIT_DATE, _CTRL_ID_ // create the time edit box control #define CREATE_EDIT_TIME_CTRL(_CTRL_ID_) \ MMK_CREATE_EDIT_TIME, _CTRL_ID_ // create the date edit box control #define CREATE_EDIT_TOUCH_DATE_CTRL(_CTRL_ID_) \ MMK_CREATE_EDIT_TOUCH_DATE, _CTRL_ID_ // create the time edit box control #define CREATE_EDIT_TOUCH_TIME_CTRL(_CTRL_ID_) \ MMK_CREATE_EDIT_TOUCH_TIME, _CTRL_ID_ // create the time edit box control #define CREATE_EDIT_PICKER_CTRL(_CTRL_ID_) \ MMK_CREATE_EDIT_PICKER, _CTRL_ID_ // create the ip edit box control #define CREATE_EDIT_IP_CTRL(_CTRL_ID_) \ MMK_CREATE_EDIT_IP, _CTRL_ID_ // create the animation #define CREATE_ANIM_CTRL(_CTRL_ID_,_WIN_ID_) \ MMK_CREATE_ANIM, _CTRL_ID_,_WIN_ID_ // window title id #define WIN_TITLE(_TITEL_ID_) MMK_CREATE_TITLE, _TITEL_ID_ // window background picture id #define WIN_BACKGROUND_ID(_BACKGROUND_ID_) MMK_WINBACKGROUNDID, _BACKGROUND_ID_ // create the label control #define CREATE_LABEL_CTRL(_ALIGN_, _CTRL_ID_) \ MMK_CREATE_LABEL, _ALIGN_, _CTRL_ID_ // create the button control #define CREATE_BUTTON_CTRL(_BG_IMAGE_ID, _CTRL_ID_) \ MMK_CREATE_BUTTON, _BG_IMAGE_ID, _CTRL_ID_ // create the checkbox control #define CREATE_CHECKBOX_CTRL(_CTRL_ID_) \ MMK_CREATE_CHECKBOX, _CTRL_ID_ //create the drop down list box #define CREATE_DROPDOWNLIST_CTRL(PAGE_ITEM_NUM, _TYPE_, _CTRL_ID_) \ MMK_CREATE_DROPDOWNLIST, PAGE_ITEM_NUM, _TYPE_, _CTRL_ID_ // create the iconlist control #define CREATE_ICONLIST_CTRL(_CTRL_ID_) \ MMK_CREATE_ICONLIST, _CTRL_ID_ // create the iconfolder control #define CREATE_ICONFOLDER_CTRL(_CTRL_ID_) \ MMK_CREATE_ICONFOLDER, _CTRL_ID_ //create the rich text control #define CREATE_RICHTEXT_CTRL(_CTRL_ID_) \ MMK_CREATE_RICHTEXT, _CTRL_ID_ // create the tab control #define CREATE_TAB_CTRL( _TAB_TYPE_, _TAB_STATE_, _CTRL_ID_) \ MMK_CREATE_TAB, _TAB_TYPE_, _TAB_STATE_, _CTRL_ID_ // create the setting list control #define CREATE_SETLIST_CTRL(_CTRL_ID_) \ MMK_CREATE_SETLIST, _CTRL_ID_ // create the combox control #define CREATE_COMBOX_CTRL(PAGE_ITEM_NUM, _TYPE_,_CTRL_ID_) \ MMK_CREATE_COMBOX, PAGE_ITEM_NUM, _TYPE_, _CTRL_ID_ // create status bar control #define WIN_STATUSBAR MMK_CREATE_STATUSBAR // not auto create status bar control #define WIN_HIDE_STATUS MMK_HIDE_STATUSBAR // create tips control #define WIN_TIPS MMK_CREATE_TIPS //create the softkey control #define WIN_SOFTKEY(_LEFT_SOFT_ID_, _MID_SOFT_ID_, _RIGHT_SOFT_ID_) \ MMK_CREATE_SOFTKEY, _LEFT_SOFT_ID_, _MID_SOFT_ID_, _RIGHT_SOFT_ID_ #define WIN_STYLE(_WIN_STYLE_) MMK_WINDOW_STYLE , _WIN_STYLE_ #define WIN_MOVE_STYLE(_WIN_MOVE_STYLE_) MMK_WINDOW_ANIM_MOVE_SYTLE , _WIN_MOVE_STYLE_ #define WIN_SUPPORT_ANGLE(_WIN_SUPPORT_ANGLE_) MMK_WINDOW_SUPPORT_ANGLE , _WIN_SUPPORT_ANGLE_ #ifdef GUIF_SCROLLKEY #define WIN_SCROLLKEY(_LEFT_SCROLL_KEY_ID_, _RIGHT_SCROLL_KEY_ID_, _LEFT_SCROLL_TEXT_ID_, _RIGHT_SCROLL_TEXT_ID_, _LEFT_SCROLL_SKIN_IDX_, _RIGHT_SCROLL_SKIN_IDX_) \ MMK_CREATE_SCROLLKEY, _LEFT_SCROLL_KEY_ID_, _RIGHT_SCROLL_KEY_ID_, _LEFT_SCROLL_TEXT_ID_, _RIGHT_SCROLL_TEXT_ID_, _LEFT_SCROLL_SKIN_IDX_, _RIGHT_SCROLL_SKIN_IDX_ #endif //create the form control #define CREATE_FORM_CTRL(_LAYOUT_, _CTRL_ID_) \ MMK_CREATE_FORM, _LAYOUT_, _CTRL_ID_ //create the owner draw control #define CREATE_OWNDRAW_CTRL(_CTRL_ID_, _CALL_BACK_) \ MMK_CREATE_OWNDRAW, _CTRL_ID_, _CALL_BACK_ #define CREATE_TOOLBAR_CTRL(_CTRL_ID_ ) \ MMK_CREATE_TOOLBAR, _CTRL_ID_ #define CREATE_SLIDER_CTRL(_CTRL_ID_ ) \ MMK_CREATE_SLIDER, _CTRL_ID_ #define CREATE_PROGRESS_CTRL(_CTRL_ID_ ) \ MMK_CREATE_PROGRESS, _CTRL_ID_ #define CREATE_LETTERBARS_CTRL(_CTRL_ID_ ) \ MMK_CREATE_LETTERSBAR, _CTRL_ID_ //create scroll control #define CREATE_SCROLL_CTRL(_CTRL_ID_) \ MMK_CREATE_SCROLL, _CTRL_ID_ #define END_WIN MMK_END_WIN // create child text #define CHILD_TEXT_CTRL(_IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_TEXT, _IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_ // create child text edit #define CHILD_EDIT_TEXT_CTRL(_IS_GET_ACTIVE_, _STR_MAX_LEN_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_EDIT_TEXT, _IS_GET_ACTIVE_, _STR_MAX_LEN_, _CTRL_ID_, _PARENT_CTRL_ID_ // create child phone number edit #define CHILD_EDIT_PHONENUM_CTRL(_IS_GET_ACTIVE_, _STR_MAX_LEN_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_EDIT_PHONENUM, _IS_GET_ACTIVE_, _STR_MAX_LEN_, _CTRL_ID_, _PARENT_CTRL_ID_ // create child digital edit #define CHILD_EDIT_DIGITAL_CTRL(_IS_GET_ACTIVE_, _STR_MAX_LEN_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_EDIT_DIGITAL, _IS_GET_ACTIVE_, _STR_MAX_LEN_, _CTRL_ID_, _PARENT_CTRL_ID_ // create child password edit #define CHILD_EDIT_PASSWORD_CTRL(_IS_GET_ACTIVE_, _STR_MAX_LEN_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_EDIT_PASSWORD, _IS_GET_ACTIVE_, _STR_MAX_LEN_, _CTRL_ID_, _PARENT_CTRL_ID_ // create child list edit #define CHILD_EDIT_LIST_CTRL(_IS_GET_ACTIVE_, _ITEM_NUM_, _ITEM_STR_MAX_LEN_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_EDIT_LIST, _IS_GET_ACTIVE_, _ITEM_NUM_, _ITEM_STR_MAX_LEN_, _CTRL_ID_, _PARENT_CTRL_ID_ // create child date edit #define CHILD_EDIT_DATE_CTRL(_IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_EDIT_DATE, _IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_ // create child time edit #define CHILD_EDIT_TIME_CTRL(_IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_EDIT_TIME, _IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_ // create child touch date edit #define CHILD_EDIT_TOUCH_DATE_CTRL(_IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_EDIT_TOUCH_DATE, _IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_ // create child touch time edit #define CHILD_EDIT_TOUCH_TIME_CTRL(_IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_EDIT_TOUCH_TIME, _IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_ // create child touch time edit #define CHILD_EDIT_PICKER_CTRL(_IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_EDIT_PICKER, _IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_ // create child ip edit #define CHILD_EDIT_IP_CTRL(_IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_EDIT_IP, _IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_ // create child animation #define CHILD_ANIM_CTRL(_IS_BG,_IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_ANIM, _IS_BG, _IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_ // create child label #define CHILD_LABEL_CTRL(_ALIGN_, _IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_LABEL, _ALIGN_, _IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_ // create child button #define CHILD_BUTTON_CTRL(_IS_GET_ACTIVE_, _BG_IMAGE_ID, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_BUTTON, _IS_GET_ACTIVE_, _BG_IMAGE_ID, _CTRL_ID_, _PARENT_CTRL_ID_ // create child checkbox #define CHILD_CHECKBOX_CTRL(_IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_CHECKBOX, _IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_ //create the drop down list box #define CHILD_DROPDOWNLIST_CTRL(_IS_GET_ACTIVE_, _CTRL_ID_,_PARENT_CTRL_ID_) \ CREATE_CHILD_DROPDOWNLIST, _IS_GET_ACTIVE_, _CTRL_ID_,_PARENT_CTRL_ID_ // create child setlist #define CHILD_SETLIST_CTRL(_IS_GET_ACTIVE_, _CTRL_ID_,_PARENT_CTRL_ID_) \ CREATE_CHILD_SETLIST, _IS_GET_ACTIVE_, _CTRL_ID_,_PARENT_CTRL_ID_ // create child owner draw #define CHILD_OWNDRAW_CTRL(_IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_, _CALL_BACK_) \ CREATE_CHILD_OWNDRAW, _IS_GET_ACTIVE_, _CTRL_ID_,_PARENT_CTRL_ID_, _CALL_BACK_ // create the form control #define CHILD_FORM_CTRL(_IS_GET_ACTIVE_, _LAYOUT_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_FORM, _IS_GET_ACTIVE_, _LAYOUT_, _CTRL_ID_, _PARENT_CTRL_ID_ // create the list control #define CHILD_LIST_CTRL(_IS_GET_ACTIVE_, _LIST_TYPE_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_LIST, _IS_GET_ACTIVE_, _LIST_TYPE_, _CTRL_ID_, _PARENT_CTRL_ID_ // create the softkey control #define CHILD_SOFTKEY_CTRL(_LEFTSOFT_ID_, _MIDSOFT_ID_, _RIGHT_SOFT_ID_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_SOFTKEY, _LEFTSOFT_ID_, _MIDSOFT_ID_, _RIGHT_SOFT_ID_, _CTRL_ID_, _PARENT_CTRL_ID_ // create the slider control #define CHILD_SLIDER_CTRL(_IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_SLIDER, _IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_ // create the progress control #define CHILD_PROGRESS_CTRL(_IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_) \ CREATE_CHILD_PROGRESS, _IS_GET_ACTIVE_, _CTRL_ID_, _PARENT_CTRL_ID_ //create the drop down list box #define CHILD_COMBOX_CTRL(_IS_GET_ACTIVE_, _CTRL_ID_,_PARENT_CTRL_ID_) \ CREATE_CHILD_COMBOX, _IS_GET_ACTIVE_, _CTRL_ID_,_PARENT_CTRL_ID_
win_table_ptr其實就是一個數組,包含了視窗的基本屬性(ID , handle,ctrl。。。。)。至於這些屬性怎麼被系統一一解析的,會在後面的視窗解析處說明。
由MMI轉入到MMK AppletCreateWindow
1、建立前的基本準備:入參檢查、MMK_AddTreeNode新增視窗節點
2、建立視窗:WinTableCreate->CreateWin
3、解析視窗表:MMK_ParseWinTab
①、PreParseWinTab,解析視窗的公共關鍵字。設定好視窗的狀態
LOCAL BOOLEAN PreParseWinTab( MMI_HANDLE_T win_handle, uint32 *win_tab_ptr ) { BOOLEAN result = FALSE; uint32 *value_ptr = PNULL; uint32 ins = 0; value_ptr = win_tab_ptr; while ((END_WIN != *value_ptr) && (CAF_END_WIN != *value_ptr)) { ins = *value_ptr; value_ptr++; if ((MMK_WINDOW_STYLE == ins) || (CAF_PARSEWIN_WINDOW_STYLE == ins)) { result = SetWinStyle(win_handle,&value_ptr); } else if (MMK_CREATE_TITLE == ins || CAF_PARSEWIN_WINTITLEID == ins) { result = SetTitleStyle(win_handle,&value_ptr); } else if (MMK_CREATE_STATUSBAR == ins) { result = SetStatusBarStyle(win_handle,&value_ptr); } else if (MMK_CREATE_SOFTKEY == ins || CAF_PARSEWIN_CREATE_SOFTKEY == ins) { result = SetSoftkeyStyle(win_handle,&value_ptr); } else if ((FIRST_PARSE <= ins) && (END_WIN > ins)) { result = DummyParse(&value_ptr, MMKParseInfo[ins - FIRST_PARSE].param_num); } else if ((CHILD_CTRL_FIRST <= ins) && (LAST_CHILD > ins)) { result = DummyParse(&value_ptr, FormChildCtrlParseInfo[ins - CHILD_CTRL_FIRST].param_num); } else if ((CAF_PARSEWIN_FIRST <= ins) && (CAF_PARSEWIN_MAX > ins)) { result = DummyParse(&value_ptr, CAFParseInfo[ins - CAF_PARSEWIN_FIRST].param_num); } else { SCI_ASSERT(FALSE); /*assert verified*/ } if (!result) { break; } }
②、ParseWinTab呼叫不同的空間建立函式,來建立不同的控制元件。以及為新視窗設定好handle等
LOCAL BOOLEAN ParseWinTab(
MMI_HANDLE_T win_handle,
uint32 *win_tab_ptr
)
{
BOOLEAN result = FALSE;
uint32 *value_ptr = PNULL;
uint32 ins = 0;
value_ptr = win_tab_ptr;
while ((END_WIN != *value_ptr) && (CAF_END_WIN != *value_ptr))
{
ins = *value_ptr;
value_ptr++;
if ((FIRST_PARSE <= ins) && (END_WIN > ins))
{
result = MMKParseInfo[ins - FIRST_PARSE].parse_func(win_handle,&value_ptr);
}
else if ((CHILD_CTRL_FIRST <= ins) && (LAST_CHILD > ins))
{
result = GUIFORM_ParseChild((ins - CHILD_CTRL_FIRST),win_handle,&value_ptr);
}
else if ((CAF_PARSEWIN_FIRST <= ins) && (CAF_PARSEWIN_MAX > ins))
{
result = CAFParseInfo[ins - CAF_PARSEWIN_FIRST].parse_func(win_handle,&value_ptr);
}
else
{
SCI_ASSERT(FALSE); /*assert verified*/
}
if (!result)
{
break;
}
}
return result;
}
③、MMK_CreateDefaultControl建立公共控制元件(狀態列等)
PUBLIC BOOLEAN MMK_CreateDefaultControl(
MMI_HANDLE_T win_handle,
MMK_DEFAULT_CTRL_PARAM_T *param_ptr
)
{
BOOLEAN result = TRUE;
if (PNULL == param_ptr)
{
result = FALSE;
}
#if defined (MAINLCD_SIZE_176X220) || defined (MAINLCD_SIZE_128X160)
if (MAIN_IDLE_WIN_ID != MMK_GetWinId(MMK_ConvertIdToHandle(win_handle)))
{
//no status bar
}
else
#endif
{
// 判斷條件需與MMK_IsWinIncludeStatusbar保持一致
if (result
&& MMK_GetWinDisplayStyleState(win_handle, WS_HAS_STATUSBAR)
&& !MMK_GetWinDisplayStyleState(win_handle, WS_HAS_TRANSPARENT)
&& !MMK_IsChildWin(win_handle))
{
if (!MMK_IsIncludeStatusBar(win_handle))
{
result = GUIWIN_CreateStbDyn(win_handle);
}
}
}
return result;
}
4、開啟視窗:MMK_OpenWin
設定焦點
SetFocusChildWin( win_node_ptr->base_node.handle );
向handle傳送open訊息
MMK_SendMsg(win_node_ptr->base_node.handle, MSG_OPEN_WINDOW, PNULL);
一直我們自己畫的視窗就是在open訊息裡搞事的。