/********************************************************************* * Function: void GOLSetFocus(OBJ_HEADER* object) * * PreCondition: none * * Input: pointer to the object to be focused * * Output: * * Side Effects: none * * Overview: moves keyboard focus to the object * * Note: none * ********************************************************************/ void GOLSetFocus(OBJ_HEADER* object){ if(!GOLCanBeFocused(object)) return; if(_pObjectFocused != NULL){ ClrState(_pObjectFocused, FOCUSED); SetState(_pObjectFocused, DRAW_FOCUS); } SetState(object, DRAW_FOCUS|FOCUSED); _pObjectFocused = object; }
/********************************************************************* * Function: OBJ_HEADER *GOLGetFocusNext() * * Overview: This function returns the pointer to the next object * in the active linked list which is able to receive * keyboard input. * * PreCondition: none * * Input: none * * Output: This returns the pointer of the next object in the * active list capable of receiving keyboard input. If * there is no object capable of receiving keyboard * inputs (i.e. none can be focused) NULL is returned. * * Side Effects: none * ********************************************************************/ OBJ_HEADER *GOLGetFocusNext(void) { OBJ_HEADER *pNextObj, *pObjStart; if(_pGolObjects == NULL) return (NULL); if(_pObjectFocused == NULL) { pNextObj = _pGolObjects; } else { pNextObj = _pObjectFocused; } pObjStart = pNextObj; do { pNextObj = (OBJ_HEADER *)pNextObj->pNxtObj; if(pNextObj == NULL) pNextObj = _pGolObjects; if(GOLCanBeFocused(pNextObj)) break; } while(pNextObj != pObjStart); // if we reached the starting point and the starting point cannot // be focused, then all objects cannot be focused. return NULL if(!GOLCanBeFocused(pNextObj)) return NULL; return (pNextObj); }
/********************************************************************* * Function: OBJ_HEADER *GOLGetFocusPrev() * * Overview: This function returns the pointer to the previous object * in the active linked list which is able to receive * keyboard input. * * PreCondition: none * * Input: none * * Output: This returns the pointer of the previous object in the * active list capable of receiving keyboard input. If * there is no object capable of receiving keyboard * inputs (i.e. none can be focused) NULL is returned. * * Side Effects: none * ********************************************************************/ OBJ_HEADER *GOLGetFocusPrev(void) { OBJ_HEADER *pPrevObj; OBJ_HEADER *pCurObj; OBJ_HEADER *pFocusedObj; if(_pGolObjects == NULL) return (NULL); if(_pObjectFocused == NULL) { pFocusedObj = _pGolObjects; } else { pFocusedObj = _pObjectFocused; } pPrevObj = NULL; pCurObj = pFocusedObj; while(1) { if(GOLCanBeFocused(pCurObj)) pPrevObj = pCurObj; if(pCurObj->pNxtObj == NULL) if(_pGolObjects == pFocusedObj) return (pPrevObj); if(pCurObj->pNxtObj == pFocusedObj) return (pPrevObj); pCurObj = (OBJ_HEADER *)pCurObj->pNxtObj; if(pCurObj == NULL) pCurObj = _pGolObjects; } }
/********************************************************************* * Function: OBJ_HEADER *GOLGetFocusNext(void) * * PreCondition: none * * Input: none * * Output: pointer to the object receiving messages from keyboard. * NULL if there are no objects supporting keyboard focus. * * Side Effects: none * * Overview: moves keyboard focus to the next object * in the current link list * * Note: none * ********************************************************************/ OBJ_HEADER *GOLGetFocusNext(void){ OBJ_HEADER *pNextObj; if(_pObjectFocused == NULL){ pNextObj = _pGolObjects; }else{ pNextObj = _pObjectFocused; } do{ pNextObj = pNextObj->pNxtObj; if(pNextObj == NULL) pNextObj = _pGolObjects; if(GOLCanBeFocused(pNextObj)) break; }while(pNextObj != _pObjectFocused); return pNextObj; }