📄 events.c
字号:
if (currFuncPtr)
{
(*currFuncPtr) ();
}
}
/*****************************************************************************
* FUNCTION
* GetCurrHiliteID
* DESCRIPTION
* This function is used for query the current highlighted menu item.
* PARAMETERS
* void
* RETURNS
* Returns the index of the currently highlighted menu item
*****************************************************************************/
U16 GetCurrHiliteID(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
return currHiliteID;
}
/*****************************************************************************
* FUNCTION
* SetHiliteHandler
* DESCRIPTION
* This function is used for register the handler for the menu item. If the
* menu items are pre-definable, the applications use this function to set
* the highlight handlers.
*
* Note: Please distinguish the function from RegisterHighlightHandler()
* which is provided by UI layer. SetHiliteHandler() is for single
* menu item; RegisterHighlightHandler() is global for all menu items.
* PARAMETERS
* itemid [IN] ID of the item for which highlight handler needs
* to be set.
* hiliteFuncPtr [IN] Function to be executed whenever item with above
* ID is highlighted.
* RETURNS
* void
*****************************************************************************/
void SetHiliteHandler(U16 itemid, FuncPtr hiliteFuncPtr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_EVENT_SETCURHILIHTE_HDLR, itemid, hiliteFuncPtr));
maxHiliteInfo[itemid].entryFuncPtr = hiliteFuncPtr;
}
/*****************************************************************************
* FUNCTION
* ClearHiliteHandler
* DESCRIPTION
* This function is used for clear hilite func handlers for a particular menu item
* PARAMETERS
* itemid [IN] Item ID to for which one want to disable highlight handler.
* RETURNS
* void
*****************************************************************************/
void ClearHiliteHandler(U16 itemid)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_EVENT_CLRCURHILIHTE_HDLR, itemid));
maxHiliteInfo[itemid].entryFuncPtr = NULL;
}
/*****************************************************************************
* FUNCTION
* ConstructHintsList
* DESCRIPTION
* Constructs Hint List for a static menu screen
* PARAMETERS
* parentID [IN] The parent screen ID to construct enough hint list
* string array.
* hintArray [OUT] The application fill the hint string into the output
* array.
* RETURNS
* void
*****************************************************************************/
extern MMI_BOOL mmi_frm_test_menu_item_hide(U16 menu_item_id);
void ConstructHintsList(U16 parentID, U8 **hintArray)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 i, noOfChild;
U16 hiliteItemID[MAX_SUB_MENUS];
U8 idx = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
noOfChild = (U8) GetNumOfChild(parentID);
for (i = 0; i < noOfChild; i++)
{
hiliteItemID[i] = GetSeqItemId((U16) parentID, (S16) i);
/* check if menuitem is hidden */
if (!mmi_frm_test_menu_item_hide(hiliteItemID[i])) /* the menuitem is not hidden */
{
if (maxHiliteInfo[hiliteItemID[i]].hintFuncPtr)
{
(*maxHiliteInfo[hiliteItemID[i]].hintFuncPtr) (idx);
hintArray[idx] = hintData[idx];
idx++;
}
else
{
hintArray[idx++] = NULL;
}
}
}
}
/*****************************************************************************
* FUNCTION
* SetHintHandler
* DESCRIPTION
* This function is used for register the handler for the menu item. The
* registered should be responsible for providing hint content of one menu
* item.
* PARAMETERS
* itemid [IN] ID of the item for which hint handler needs to be set.
* hintFuncPtr [IN] Function to be executed whenever item with above ID
* is highlighted.
* RETURNS
* void
*****************************************************************************/
void SetHintHandler(U16 itemid, FuncPtrShort hintFuncPtr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_EVENT_SETHINT_HDLR, itemid, hintFuncPtr));
maxHiliteInfo[itemid].hintFuncPtr = hintFuncPtr;
}
/*****************************************************************************
* FUNCTION
* ClearHintHandler
* DESCRIPTION
* This is used to clear hint function handler associated with ItemID.
* PARAMETERS
* itemid [IN] Item ID to for which one want to disable hint handler
* RETURNS
* void
*****************************************************************************/
void ClearHintHandler(U16 itemid)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_EVENT_CLRHINT_HDLR, itemid));
maxHiliteInfo[itemid].hintFuncPtr = NULL;
}
/*****************************************************************************
* FUNCTION
* SetParentHandler
* DESCRIPTION
* This is used to set current parent menu item ID. After the application
* set the parent menu item ID, the framework understand which menu is the
* application in and handle the highlight and hint handler.
* PARAMETERS
* parentID [IN] The parent menu item ID.
* RETURNS
* void
*****************************************************************************/
void SetParentHandler(U16 parentID)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_EVENT_SETPARENT_HDLR, parentID));
currParentID = parentID;
}
/* MTK Brian added for AT+CVIB, 2003/11/23 */
/*****************************************************************************
* FUNCTION
* GetParentHandler
* DESCRIPTION
* This is used to get current parent menu item ID.
* PARAMETERS
* void
* RETURNS
* Return the parent item ID.
*****************************************************************************/
U16 GetParentHandler(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
return currParentID;
}
/*****************************************************************************
* FUNCTION
* ClearInputEventHandler
* DESCRIPTION
* This function is used for clear all input device handlers associated
* with current screen.
* The input value should be one of following devices:
* MMI_DEVICE_KEY Key events
* MMI_DEVICE_PEN Pen events
* MMI_DEVICE_ALL All of above device events.
*
* PARAMETERS
* device [IN] Which device handlers would be cleared
* RETURNS
* void
*****************************************************************************/
void ClearInputEventHandler(U16 device)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (device & MMI_DEVICE_KEY)
{
ClearAllKeyHandler();
}
#ifdef __MMI_TOUCH_SCREEN__
if ( device & MMI_DEVICE_PEN )
{
wgui_clear_pen_handlers();
}
#endif
}
/*****************************************************************************
* FUNCTION
* SetProtocolEventHandler
* DESCRIPTION
* This function is used for register the protocol event handler. Whenever
* an event is received from the protocol or system corresponding function
* is executed.
* PARAMETERS
* funcPtr [IN] Function to be executed whenever a event is received
* from the protocol or system
* eventID [IN] Unique Protocol/System EventID.
* RETURNS
* void
*****************************************************************************/
void SetProtocolEventHandler(PsFuncPtr funcPtr, U16 eventID)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
static U16 maxUsedInHistory = 0;
U16 count;
S16 i, firstNotUsed;
S16 pos;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_ASSERT(eventID != 0);
MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_EVENT_SETPTO_HDLR, eventID, funcPtr, usedProtocolEvent,
maxProtocolEvent));
/* serach */
pos = -1;
firstNotUsed = -1;
for (count = 0; count < maxProtocolEvent; count++)
{
if (protocolEventHandler[count].eventID == eventID)
{
pos = count;
break;
}
/* BTW, find a non-used item */ ;
if ((firstNotUsed == -1) && (protocolEventHandler[count].eventID == MMI_EVENT_INVALID))
{
firstNotUsed = count;
}
}
if (pos != -1)
{
/* found */
if (funcPtr != NULL)
{
/* just need to update */
protocolEventHandler[pos].entryFuncPtr = funcPtr;
}
else
{
/* reset it */
protocolEventHandler[pos].eventID = MMI_EVENT_INVALID;
protocolEventHandler[pos].entryFuncPtr = NULL;
usedProtocolEvent--;
}
}
else
{
/* not found */
if (funcPtr != NULL)
{
/* newly set */
if (firstNotUsed != -1)
{
pos = firstNotUsed;
}
else
{
/* need to enlarge current searching list */
pos = maxProtocolEvent;
maxProtocolEvent++;
MMI_ASSERT(maxProtocolEvent < MAX_PROTOCOL_EVENT);
}
usedProtocolEvent++;
protocolEventHandler[pos].eventID = eventID;
protocolEventHandler[pos].entryFuncPtr = funcPtr;
}
else
{
/* do nothing */
}
}
/* recycle not-used items in the tail of list. It is for searching efficency */
for (i = (maxProtocolEvent - 1); i >= 0; i--)
{
if (protocolEventHandler[i].eventID != MMI_EVENT_INVALID)
{
break;
}
}
maxProtocolEvent = i + 1;
/* record the max value for array size analysis */
if (maxUsedInHistory < maxProtocolEvent)
{
PRINT_INFORMATION_2((MMI_TRACE_G1_FRM, "SetProtocolEventHandler old maxUsedInHistory = %d", maxUsedInHistory));
maxUsedInHistory = maxProtocolEvent;
PRINT_INFORMATION_2((MMI_TRACE_G1_FRM, "SetProtocolEventHandler maxUsedInHistory = %d", maxUsedInHistory));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -