/**************************************************************************/ /*! * @brief The function inits the screen and its objects for first time case * @param pScreen - the pointer to screen * @return None * @note Initialize the the screen. This is keep as a public API to allow user application * initialize the screen before it native first use. *******************************************************************************/ void D4D_InitScreen(D4D_SCREEN* pScreen) { D4D_SCREEN_DATA* pData = pScreen->pData; D4D_OBJECT** pObj; D4D_MESSAGE localMsg; if(!pScreen) return; // prepare message localMsg.pScreen = pScreen; localMsg.nMsgId = D4D_MSG_ONINIT; pObj = (D4D_OBJECT**) pScreen->pObjects; // init objects while(*pObj != NULL) { localMsg.pObject = *pObj; // initialize the pointers on this screen in all screen objects D4D_SetObjectScreenPointer(*pObj, pScreen); // send the ON INIT message D4D_SendMessageMask(&localMsg, 0, D4D_OBJECT_F_NOTINIT); pObj++; } if(!(pData->flags & D4D_SCR_FINT_INITDONE)) { pData->flags |= D4D_SCR_FINT_INITDONE; D4D_FocusNextObject(pScreen, D4D_TRUE); // user's screen initialization if(pScreen->OnInit) pScreen->OnInit(); // Enable natively touch scren for screens if exit button is enabled if(pScreen->flags & D4D_SCR_F_EXIT) pData->flags |= D4D_SCR_FINT_TOUCHENABLE; } }
/**************************************************************//*! * * helper to invoke OBJECT's message handler * * all information need to be already prepared in d4d_msg * ******************************************************************/ void D4D_SendMessageMask(D4D_MESSAGE* pMsg, D4D_OBJECT_FLAGS parentFlagsMask, D4D_OBJECT_FLAGS endFlagMask) { D4D_OBJECT* pObject = pMsg->pObject; // Check if the object if((pObject->pData->flags & parentFlagsMask) != parentFlagsMask) return; // screen gets the first chance if((pObject->pData->flags & endFlagMask) == endFlagMask) if(pMsg->pScreen->OnObjectMsg) { // screen may discard the message by returning TRUE if(pMsg->pScreen->OnObjectMsg(pMsg)) return ; } if(pObject) { // now invoke the object's handler if((pObject->pData->flags & endFlagMask) == endFlagMask) { if(pObject->OnUsrMessage) { if(pObject->OnUsrMessage(pMsg)) return; } // Invoke to go the message to system handler of object if(pObject->pObjFunc->OnSysMessage) pObject->pObjFunc->OnSysMessage(pMsg); } if(pObject->pRelations) { D4D_OBJECT** pChildObj = (D4D_OBJECT**)&pObject->pRelations[D4D_OBJECT_USR_DATA_CHILD_IX]; while(*pChildObj) { pMsg->pObject = *pChildObj; D4D_SendMessageMask(pMsg, parentFlagsMask, endFlagMask); pChildObj++; } } } }
/**************************************************************//*! * * Handle the timeticks events of eGUI * ******************************************************************/ void D4D_HandleTimeTicks(D4D_SCREEN* pScreen) { if(d4d_systemFlags & D4D_SYSTEM_F_TIMETICK) { D4D_OBJECT** pObjects = (D4D_OBJECT**)pScreen->pObjects; d4d_systemFlags &= ~D4D_SYSTEM_F_TIMETICK; d4d_msg.pScreen = pScreen; d4d_msg.nMsgId = D4D_MSG_TIMETICK; // Go through the all top level objects while(*pObjects != NULL) { d4d_msg.pObject = *pObjects; // send timeticks to all top level objects includes it children D4D_SendMessageMask(&d4d_msg, D4D_OBJECT_F_VISIBLE , D4D_OBJECT_F_TIMETICK); pObjects++; } } }