/**************************************************************//*! * * Change the active screen * ******************************************************************/ static void D4D_ChangeScreen(D4D_SCREEN* pNewScreen, D4D_SCREEN* pOldScreen) { D4D_SCREEN_DATA* pData; D4D_MESSAGE tmp_msg; if(pNewScreen == NULL) return; if(pOldScreen == pNewScreen) return; tmp_msg.pScreen = pOldScreen; if(pOldScreen != NULL) { D4D_SetObjectFlags(pOldScreen->pData->focusedObject, D4D_OBJECT_F_REDRAWSTATE, D4D_FALSE); tmp_msg.nMsgId = D4D_MSG_KILLFOCUS; tmp_msg.pObject = pOldScreen->pData->focusedObject; D4D_SendMessage(&tmp_msg); // Draw NC screen area as an inactivate D4D_DrawScreenNC(pOldScreen, D4D_FALSE); // call de-activate event if(pOldScreen->OnDeactivate != NULL) pOldScreen->OnDeactivate(); } // invalidate the new screen (global complete redraw, not individual objects) D4D_InvalidateScreen(pNewScreen, D4D_TRUE); // if this is the first time activating pData = pNewScreen->pData; // Init the screen D4D_InitScreen(pNewScreen); D4D_SetObjectFlags(pData->focusedObject, D4D_OBJECT_F_REDRAWSTATE, D4D_FALSE); // Send to the object Focus message tmp_msg.pScreen = pNewScreen; tmp_msg.nMsgId = D4D_MSG_SETFOCUS; tmp_msg.pObject = pData->focusedObject; D4D_SendMessage(&tmp_msg); // inform the screen it has been activated if(pNewScreen->OnActivate) pNewScreen->OnActivate(); D4D_ClearKeysBuffer(); #ifdef D4D_LLD_TCH d4d_LastTouchedObj = NULL; #endif // finish all action for previous screen D4D_MouseChangedScreen(); }
/**************************************************************************/ /*! * @brief The function set the obejct focus to new object * @param pScreen - the pointer to screen * @param pObject - the pointer to object that should be focused * @return None * @note In case that there is no other issue (obejct exists, visible, enable ...) the focus is changed to given one *******************************************************************************/ void D4D_FocusSet(D4D_SCREEN* pScreen, D4D_OBJECT_PTR pObject) { D4D_SCREEN_DATA* pData = pScreen->pData; D4D_OBJECT* pFocusedObj = pData->focusedObject; D4D_OBJECT* pNewFocus; if(pScreen == NULL) return; // check if object is really item of the current screen pNewFocus = D4D_FindObject(pScreen, pObject); if(pNewFocus == NULL) return; if(pNewFocus == pFocusedObj) // is selected object same as focused? return; if((pNewFocus->pData->flags & (D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_ENABLED)) != (D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_ENABLED)) // is this object selectable? return; if(!D4D_IsEnabled(pNewFocus)) return; // invalidate object which is loosing focus D4D_SetObjectFlags(pFocusedObj, D4D_OBJECT_F_REDRAWSTATE, D4D_FALSE); // invalidate object which is getting focus D4D_SetObjectFlags(pNewFocus, D4D_OBJECT_F_REDRAWSTATE, D4D_FALSE); // move the focus pData->focusedObject = pNewFocus; // prepare message d4d_msg.pScreen = pScreen; d4d_msg.nMsgId = D4D_MSG_KILLFOCUS; d4d_msg.pObject = pFocusedObj; D4D_SendMessage(&d4d_msg); // prepare message d4d_msg.pScreen = pScreen; d4d_msg.nMsgId = D4D_MSG_SETFOCUS; d4d_msg.pObject = pNewFocus; D4D_SendMessage(&d4d_msg); }
/**************************************************************************/ /*! * @brief Function switch on capturing the keys to objects * @param pObj - pointer to the object. if the parameter is handled as NULL, * the function switch off the capturing the keys to object. * @return none. * @note This function sets the object to the capture keys state. In this state the object obtains all the * keys inputs including system navigation keys (escape, up, and down). In this state the object is using * capture colors from a color scheme. To switch off from this state the active screen has to be changed or * this function has to be called with the input parameter set to NULL. *******************************************************************************/ void D4D_CaptureKeys(D4D_OBJECT_PTR pObj) { // NOTE: we need to send message, but we may just be in the middle of // message processing (very likely). This may cause problem with // the global d4d_msg object as we are changing it... // We better use the temporary memory to instanitate the message D4D_MESSAGE* pMsg = (D4D_MESSAGE*) d4d_scratchPad; if(d4d_pKeysCapturer == pObj) return; pMsg->pScreen = D4D_GetActiveScreen(); if(d4d_pKeysCapturer) { D4D_SetObjectFlags(d4d_pKeysCapturer, D4D_OBJECT_F_REDRAWSTATE, D4D_FALSE); pMsg->nMsgId = D4D_MSG_KILLCAPTURE; pMsg->pObject = d4d_pKeysCapturer; D4D_SendMessage(pMsg); d4d_pKeysCapturer = NULL; } if(pObj != NULL) { if((pObj->pData->flags & (D4D_OBJECT_F_VISIBLE | D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_TABSTOP)) == (D4D_OBJECT_F_VISIBLE | D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_TABSTOP)) { if(D4D_IsEnabled((D4D_OBJECT*)pObj)) { D4D_FocusSet(D4D_GetActiveScreen(), pObj); d4d_pKeysCapturer = (D4D_OBJECT*) pObj; D4D_SetObjectFlags(d4d_pKeysCapturer, D4D_OBJECT_F_REDRAWSTATE, D4D_FALSE); pMsg->nMsgId = D4D_MSG_SETCAPTURE; pMsg->pObject = d4d_pKeysCapturer; D4D_SendMessage(pMsg); } } } }
/**************************************************************************/ /*! * @brief Function invalidate object to redraw on screen. * @param pObject - pointer to the object that should be invalidate. * @param bComplete - force complete redraw of object. * @return none. * @note This function invalidate object what in fact is that force eGUI to redraw * object on screen. By the bComplete parameter is select that will be * redraw also static parts of object. *******************************************************************************/ void D4D_InvalidateObject(D4D_OBJECT_PTR pObject, D4D_BOOL bComplete) { D4D_OBJECT_FLAGS flags = D4D_OBJECT_F_REDRAW; if(bComplete) flags |= D4D_OBJECT_F_REDRAWC; D4D_SetObjectFlags((D4D_OBJECT*)pObject, flags, D4D_TRUE); if(pObject->pData->pScreen) (pObject->pData->pScreen)->pData->flags |= D4D_SCR_FINT_CHECKOBJECTS; }
/**************************************************************************/ /*! * @brief The function mark the screen and its abject as "redraw pending" * @param pScreen - the pointer to screen that should be invalidate * @param bComplete - flag to mark the the screen and object MUST be redrawed completely, not only the active areas * @return None * @note Invalidate screen and its object in two ways - complete or active areas only. *******************************************************************************/ void D4D_InvalidateScreen(D4D_SCREEN* pScreen, D4D_BOOL bComplete) { if(!pScreen) return; pScreen->pData->flags |= D4D_SCR_FINT_CHECKOBJECTS; if(bComplete) { pScreen->pData->flags |= D4D_SCR_FINT_REDRAWC; } else { D4D_OBJECT** pObj = (D4D_OBJECT**)pScreen->pObjects; while(*pObj != NULL) { D4D_SetObjectFlags(*pObj, D4D_OBJECT_F_REDRAW, D4D_TRUE); pObj++; } } }
/**************************************************************//*! * * Function sets the flags of object and all it's childs * ******************************************************************/ void D4D_SetObjectFlags(D4D_OBJECT* pObject, D4D_OBJECT_FLAGS flagsMask, D4D_BOOL alsoChildren) { pObject->pData->flags |= flagsMask; if(alsoChildren && (pObject->pRelations)) { D4D_OBJECT** pChild = (D4D_OBJECT**)&(pObject->pRelations[D4D_OBJECT_USR_DATA_CHILD_IX]); while(*pChild) { D4D_SetObjectFlags(*pChild, flagsMask, D4D_TRUE); pChild++; } } if(flagsMask & (D4D_OBJECT_F_REDRAW | D4D_OBJECT_F_REDRAWC | D4D_OBJECT_F_REDRAWSTATE)) { if(pObject->pData->pScreen) (pObject->pData->pScreen)->pData->flags |= D4D_SCR_FINT_CHECKOBJECTS; } }
/**************************************************************************/ /*! * @brief The function change focus to the previous object in the given screen * @param pScreen - the pointer to screen * @return None * @note In case that there is no other usable object (visible, enable ...) the focus is not changed *******************************************************************************/ void D4D_FocusPrevObject(D4D_SCREEN* pScreen) { D4D_SCREEN_DATA* pData = pScreen->pData; const D4D_OBJECT* const* pObjects = pScreen->pObjects; D4D_OBJECT* pFocusedObj = pData->focusedObject; if(!pScreen) return; // sanity check of list of objects - contains Screen any object? if(*pObjects == NULL) return; do { // just get previous object pFocusedObj = D4D_FindPreviousObject(pFocusedObj, (((pFocusedObj->pData->flags) & (D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_VISIBLE)) == (D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_VISIBLE))); // object with focus enabled? if((pFocusedObj->pData->flags & (D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_VISIBLE)) == (D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_VISIBLE)) { D4D_OBJECT * pParent = pFocusedObj; D4D_BOOL couldBeFocused = D4D_TRUE; // Take care that the parents objects are also visible and enabled while(pParent = D4D_GetParentObject(pParent)) { if((pParent->pData->flags & (D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_VISIBLE)) != (D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_VISIBLE)) { couldBeFocused = D4D_FALSE; break; } } if(couldBeFocused) break; } // avoid endless loop if no focused object can be found }while(pFocusedObj != pData->focusedObject); if(pFocusedObj != pData->focusedObject) { // invalidate object which is loosing focus D4D_SetObjectFlags(pData->focusedObject, D4D_OBJECT_F_REDRAWSTATE, D4D_FALSE); // prepare message KILLFOCUS d4d_msg.pScreen = pScreen; d4d_msg.nMsgId = D4D_MSG_KILLFOCUS; d4d_msg.pObject = pData->focusedObject; D4D_SendMessage(&d4d_msg); // invalidate object which is getting focus D4D_SetObjectFlags((D4D_OBJECT*)pFocusedObj, D4D_OBJECT_F_REDRAWSTATE, D4D_FALSE); // move the focus pData->focusedObject = pFocusedObj; // prepare message d4d_msg.pScreen = pScreen; d4d_msg.nMsgId = D4D_MSG_SETFOCUS; d4d_msg.pObject = pFocusedObj; D4D_SendMessage(&d4d_msg); } }
/**************************************************************************/ /*! * @brief The function change focus to the next object in the given screen * @param pScreen - the pointer to screen * @param bInitialSearch - flag force start looking from the first object in screen object table * @return None * @note In case that there is no other usable object (visible, enable ...) the focus is not changed *******************************************************************************/ void D4D_FocusNextObject(D4D_SCREEN* pScreen, D4D_BOOL bInitialSearch) { D4D_SCREEN_DATA* pData = pScreen->pData; const D4D_OBJECT* const* pObjects = pScreen->pObjects; D4D_OBJECT* pFocusedObj = pData->focusedObject; if(!pScreen) return; // sanity check of list of objects - contains Screen any object? if(*pObjects == NULL) return; // currently focused object already has a tabstop if(bInitialSearch) { //SetUp start object pData->focusedObject = (D4D_OBJECT*)pObjects[0]; pFocusedObj = (D4D_OBJECT*)pObjects[0]; if((pObjects[0]->pData->flags & (D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_ENABLED)) == (D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_ENABLED)) return ; } do { // get next object pFocusedObj = D4D_FindNextObject(pFocusedObj, (((pFocusedObj->pData->flags) & (D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_VISIBLE)) == (D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_VISIBLE))); // object with focus enabled? if((pFocusedObj->pData->flags & (D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_VISIBLE)) == (D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_VISIBLE)) break; // avoid endless loop if no focused object can be found }while(((D4D_OBJECT*)pFocusedObj) != pData->focusedObject); if(((D4D_OBJECT*)pFocusedObj) != pData->focusedObject) { // invalidate object which is loosing focus D4D_SetObjectFlags(pData->focusedObject, D4D_OBJECT_F_REDRAWSTATE, D4D_FALSE); // prepare message KILLFOCUS d4d_msg.pScreen = pScreen; d4d_msg.nMsgId = D4D_MSG_KILLFOCUS; d4d_msg.pObject = pData->focusedObject; D4D_SendMessage(&d4d_msg); // invalidate object which is getting focus D4D_SetObjectFlags((D4D_OBJECT*)pFocusedObj, D4D_OBJECT_F_REDRAWSTATE, D4D_FALSE); // move the focus pData->focusedObject = ((D4D_OBJECT*)pFocusedObj); // prepare message d4d_msg.pScreen = pScreen; d4d_msg.nMsgId = D4D_MSG_SETFOCUS; d4d_msg.pObject = ((D4D_OBJECT*)pFocusedObj); D4D_SendMessage(&d4d_msg); } }