Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

// set the message callback function pointer
GFX_GOL_MessageCallbackSet(APP_ObjectMessageCallback);
...
while(1)
{
// Draw GOL objects
if(GFX_GOL_ObjectListDraw() == GFX_STATUS_SUCCESS)
{
// Get message from touch screen
TouchGetMsg(&msg);
// Process message
GFX_GOL_ObjectMessage(&msg);
}
}
Graphics Object Message Function
After the input device driver encodes the message, the message is sent by the application to the graphics library through the
GFX_GOL_ObjectMessage(). This function parses the active list of objects and determines if the message affects one or
more of the objects. The mechanism to check each object is simple: the GFX_GOL_ObjectMessage() calls each of the
object's ACTIONGET_FUNC. The ACTIONGET_FUNC of an object is the function that determines if the message affects
the object. This function returns a translated action (see GFX_GOL_TRANSLATED_ACTION enumeration).
If the object is not affected it replies with GFX_GOL_OBJECT_ACTION_INVALID. If the object is affected, it replies with the
appropriate translated action.
Object Message Callback Feature
If the object is affected, GFX_GOL_ObjectMessage() then calls the message callback function. The message callback
function is an application defined function. This is set initially using the
GFX_GOL_MessageCallbackSet(GFX_GOL_MESSAGE_CALLBACK_FUNC) call where
GFX_GOL_MESSAGE_CALLBACK_FUNC is a pointer to the defined callback function.
The message callback is an opportunity for the application to respond to user inputs. It is also an opportunity to block the
library from performing default state change to objects. See the documentation of the callback function for details.
The message callback returns true if the application wants to perform the default action set of the objects. If the callback
returns false, the application assumes all changes in the states of the object.
After the callback is executed, with a return value of true the ACTIONSET_FUNC of the affected object is called by
GFX_GOL_ObjectMessage(). This function performs the state change of the object due to the user input. The object is then
redrawn when GFX_GOL_ObjectListDraw() is called by the application.
Below is an example usage of the message callback function. A scroll bar is incremented and decremented by two buttons.
//*********************************************************************
// The message callback is called within GFX_GOL_ObjectMessage()
//*********************************************************************
// assume that 2 buttons and a scroll bar is present in the system
bool APP_MsgCallback(
uint16_t objMsg,
GFX_GOL_OBJ_HEADER *pObj,
GFX_GOL_MESSAGE *pMsg)
{
uint16_t objectID;
GFX_GOL_SCROLLBAR *pScrollBar;
objectID = GFX_GOL_ObjectIDGet(pObj);
if(objectID == ID_BTN1)
{
// check if button is pressed
if(objMsg == GFX_GOL_BUTTON_ACTION_PRESSED)
{
1.4 Using The Library MLA - Graphics Library Help Library Overview
49

e-Highlighter

Click to send permalink to address bar, or right-click to copy permalink.

Un-highlight all Un-highlight selectionu Highlight selectionh