static void D4D_SldrOnKeyUp(D4D_MESSAGE* pMsg) { D4D_SLIDER* pSldr = D4D_GET_SLIDER(pMsg->pObject); D4D_KEY_SCANCODE tmp_key = pMsg->prm.key; // capture the keyboard if enter is pressed if(tmp_key == D4D_KEY_SCANCODE_ENTER) { D4D_CaptureKeys(pMsg->pObject); return; } // exit capture if(tmp_key == D4D_KEY_SCANCODE_ESC) { D4D_CaptureKeys(NULL); return; } if(D4D_GetCapturedObject() == pMsg->pObject) { // increment value if((tmp_key == D4D_KEY_SCANCODE_RIGHT) || (tmp_key == D4D_KEY_SCANCODE_UP)) { D4D_SldrChangeValue(pMsg->pObject, pSldr->pData->limits.step); } // decrement value else if((tmp_key == D4D_KEY_SCANCODE_LEFT) || (tmp_key == D4D_KEY_SCANCODE_DOWN)) { D4D_SldrChangeValue(pMsg->pObject, (D4D_SLIDER_VALUE)(-pSldr->pData->limits.step)); } } }
/**************************************************************************/ /*! * @brief The function activate the new screen * @param pNewScreen - the pointer to new screen * @param bReplaceCurrent - the flag to tell function if the new screen should replace previous one in screen buffer * @return None * @note Enter new screen, remember the history if not only replacing *******************************************************************************/ void D4D_ActivateScreen(D4D_SCREEN* pNewScreen, D4D_BOOL bReplaceCurrent) { D4D_SCREEN* pOldScreen; // can not activate screen (no space left in history array) if(d4d_screenHistoryIndex >= D4D_SCREEN_HISTORY && !bReplaceCurrent) return ; if(!pNewScreen) return; // cancel key capture D4D_CaptureKeys(NULL); // deactivate current screen (if any) pOldScreen = D4D_GetActiveScreen(); if(pOldScreen != NULL) { // replacing this screen in history? if(bReplaceCurrent) d4d_screenHistoryIndex--; // note that we are sure this is >0 } // set the new screen as the active one d4d_screenHistory[d4d_screenHistoryIndex] = pNewScreen; d4d_screenHistoryIndex++; D4D_ChangeScreen(pNewScreen, pOldScreen); }
/**************************************************************************/ /*! * @brief Function control visibility of object on screen. * @param pObject - pointer to the object. * @param bShow - <D4D_TRUE - visible, D4D_FALSE - hidden> * @return none. * @note This function control the visibility of object on screen. The hide action * force invalidate of whole screen. *******************************************************************************/ void D4D_ShowObject(D4D_OBJECT_PTR pObject, D4D_BOOL bShow) { if(bShow) { pObject->pData->flags |= D4D_OBJECT_F_VISIBLE; D4D_InvalidateObject(pObject, D4D_FALSE); } else { pObject->pData->flags &= ~D4D_OBJECT_F_VISIBLE; if(d4d_pKeysCapturer == pObject) D4D_CaptureKeys(NULL); if((D4D_OBJECT*)pObject == D4D_GetFocusedObject(pObject->pData->pScreen)) D4D_FocusNextObject(pObject->pData->pScreen, D4D_FALSE); if(pObject->pRelations) { D4D_OBJECT* pParent = D4D_GetParentObject((D4D_OBJECT*)pObject); if(pParent) D4D_InvalidateObject(pParent, D4D_TRUE); else D4D_InvalidateScreen(pObject->pData->pScreen, D4D_TRUE); } else D4D_InvalidateScreen(pObject->pData->pScreen, D4D_TRUE); } }
static void D4D_ScrlBrOnTouch(D4D_MESSAGE* pMsg, D4D_POINT* point) { D4D_OBJECT* pThis = pMsg->pObject; if(pThis->pData->flags & (D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_FASTTOUCH)) { if((D4D_GetFocusedObject(pMsg->pScreen) == pThis) || (pThis->pData->flags & D4D_OBJECT_F_FASTTOUCH)) { D4D_SCROLL_BAR* pScrlBr = D4D_GET_SCROLL_BAR(pThis); D4D_SCRLBAR_DATA* pData = pScrlBr->pData; if(pThis->pData->flags & D4D_OBJECT_F_TABSTOP) D4D_CaptureKeys(pThis); if(pThis->size.cx > pThis->size.cy) { if(point->x > ((pThis->size.cx / 2) + pThis->position.x)) D4D_ScrlBrChangePosition(pThis, (D4D_INDEX_DELTA)(pData->step)); else D4D_ScrlBrChangePosition(pThis, (D4D_INDEX_DELTA)(-1 * pData->step)); }else { if(point->y > ((pThis->size.cy / 2) + pThis->position.y)) D4D_ScrlBrChangePosition(pThis, (D4D_INDEX_DELTA)(pData->step)); else D4D_ScrlBrChangePosition(pThis, (D4D_INDEX_DELTA)(-1 * pData->step)); } } if(pThis->pData->flags & D4D_OBJECT_F_TABSTOP) D4D_FocusSet(pMsg->pScreen, pThis); } }
static void D4D_SldrTouched(D4D_MESSAGE* pMsg, D4D_POINT* pPoint) { D4D_OBJECT* pThis = pMsg->pObject; D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis); if((D4D_GetFocusedObject(pMsg->pScreen) == pThis) || (pThis->pData->flags & D4D_OBJECT_F_FASTTOUCH)) { D4D_FocusSet(pMsg->pScreen, pThis); if(D4D_GetCapturedObject() != pThis) D4D_CaptureKeys(pThis); if(pThis->size.cx > pThis->size.cy) { if(pPoint->x > ((pThis->size.cx / 2) + pThis->position.x)) D4D_SldrChangeValue(pThis, pSldr->pData->limits.step); else D4D_SldrChangeValue(pThis, (D4D_SLIDER_VALUE)(-pSldr->pData->limits.step)); }else { if(pPoint->y < ((pThis->size.cy / 2) + pThis->position.y)) D4D_SldrChangeValue(pThis, pSldr->pData->limits.step); else D4D_SldrChangeValue(pThis, (D4D_SLIDER_VALUE)(-pSldr->pData->limits.step)); } }else D4D_FocusSet(pMsg->pScreen, pThis); }
void D4D_ScrlBrOnMessage(D4D_MESSAGE* pMsg) { D4D_OBJECT* pThis = pMsg->pObject; #if defined(D4D_LLD_TCH) || defined(D4D_LLD_MOUSE) D4D_POINT touchClickPoint; #endif switch(pMsg->nMsgId) { case D4D_MSG_DRAW: D4D_ScrlBrOnDraw(pMsg); break; case D4D_MSG_KEYDOWN: D4D_ScrlBrOnKeyDown(pMsg); break; #ifdef D4D_LLD_MOUSE case D4D_MSG_MOUSE_BTN_LEFT_UP: touchClickPoint = D4D_GetMouseCoordinates(pMsg->pObject); D4D_ScrlBrOnTouch(pMsg, &touchClickPoint); break; case D4D_MSG_MOUSE_BTN_WHEEL_UP: D4D_ScrlBrChangePosition(pThis, -1); break; case D4D_MSG_MOUSE_BTN_WHEEL_DOWN: D4D_ScrlBrChangePosition(pThis, 1); break; #endif #ifdef D4D_LLD_TCH case D4D_MSG_TOUCHED: case D4D_MSG_TOUCH_AUTO: touchClickPoint = D4D_GetTouchScreenCoordinates(pMsg->pObject); D4D_ScrlBrOnTouch(pMsg, &touchClickPoint); break; #endif case D4D_MSG_KILLFOCUS: D4D_CaptureKeys(NULL); case D4D_MSG_SETFOCUS: case D4D_MSG_SETCAPTURE: case D4D_MSG_KILLCAPTURE: D4D_InvalidateObject(pThis, D4D_FALSE); break; default: // call the default behavior of all objects D4D_ObjOnMessage(pMsg); } }
static void D4D_MenuOnKeyUp(D4D_MESSAGE* pMsg) { D4D_MENU* pMenu = D4D_GET_MENU(pMsg->pObject); if(pMsg->prm.key == D4D_KEY_SCANCODE_ENTER) { if(D4D_GetCapturedObject() != pMsg->pObject) { D4D_CaptureKeys(pMsg->pObject); }else { if(pMenu->OnClicked) pMenu->OnClicked(pMsg->pObject, pMenu->pData->ix); D4D_InvalidateObject(pMsg->pObject, D4D_FALSE); } } if(pMsg->prm.key == D4D_KEY_SCANCODE_ESC) { D4D_CaptureKeys(NULL); } }
void D4D_ComboBoxButtonFeedBack(D4D_OBJECT* pThis) { D4D_OBJECT* pParent = D4D_GetParentObject(pThis); D4D_OBJECT* pListBoxObject = D4D_GET_COMBO_BOX_LIST_BOX(pParent); if(D4D_IsVisible(pListBoxObject)) { D4D_ComboBoxStornoSelection(pParent); }else { D4D_ShowObject(pListBoxObject, D4D_TRUE); D4D_CaptureKeys(pListBoxObject); D4D_InvalidateObject(pParent, D4D_TRUE); } }
/**************************************************************************/ /*! * @brief The function return to base screen recorded in the history * @return None * @note Recall the base (first) screen in screen history buffer *******************************************************************************/ void D4D_EscapeToBaseScreen(void) { D4D_SCREEN* pOldScreen; // can not escape current screen, it is the top one if(d4d_screenHistoryIndex == 0) return; // cancel key capture D4D_CaptureKeys(NULL); // I can be sure this is not NULL pOldScreen = D4D_GetActiveScreen(); // pop the history stack d4d_screenHistoryIndex = 1; D4D_ChangeScreen(D4D_GetActiveScreen(), pOldScreen); }
/**************************************************************************/ /*! * @brief The function return to previous screen recorded in the history * @return None * @note Recall the previous screen in screen history buffer *******************************************************************************/ void D4D_EscapeScreen(void) { D4D_SCREEN* pOldScreen; // can not escape current screen, it is the top one if(d4d_screenHistoryIndex <= 1) return; // cancel key capture D4D_CaptureKeys(NULL); pOldScreen = D4D_GetActiveScreen(); // pop the history stack if(d4d_screenHistoryIndex > 1) d4d_screenHistoryIndex--; D4D_ChangeScreen(D4D_GetActiveScreen(), pOldScreen); }
/**************************************************************************/ /*! * @brief Function enables object * @param pObj - pointer to the object * @param bEnable - <D4D_TRUE - object enabled, D4D_FALSE - enabled disabled> * @return none. * @note This function sets the enabled property. When the object is enabled, it can accept all user * inputs and use normal colors. In the disable state the object is redrawn by grayscale colors and all user * inputs are ignored. The initialization state is set by parameter flags in the object declaration. This function * is targeted for using at run-time. *******************************************************************************/ void D4D_EnableObject(D4D_OBJECT_PTR pObj, D4D_BOOL bEnable) { //if(((pObj->pData->flags & D4D_OBJECT_F_ENABLED) && !bEnable) || (!(pObj->pData->flags & D4D_OBJECT_F_ENABLED) && bEnable)) if(D4D_LOG_EXOR((pObj->pData->flags & D4D_OBJECT_F_ENABLED), bEnable)) { if(bEnable) pObj->pData->flags |= D4D_OBJECT_F_ENABLED; else { pObj->pData->flags &= ~D4D_OBJECT_F_ENABLED; if((D4D_OBJECT*)pObj == d4d_pKeysCapturer) D4D_CaptureKeys(NULL); if((D4D_OBJECT*)pObj == D4D_GetFocusedObject(pObj->pData->pScreen)) D4D_FocusNextObject(pObj->pData->pScreen, D4D_FALSE); } D4D_InvalidateObject(pObj, D4D_TRUE); } }
// Screen on Activate function called with each screen activation static void ScreenWinMenu_OnActivate() { D4D_CaptureKeys(&scrWinMenu_menu); Log_AddScreenEvent("WinMenu", "OnActivate"); }
void D4D_TextBoxOnMessage(D4D_MESSAGE* pMsg) { D4D_OBJECT* pThis = pMsg->pObject; switch(pMsg->nMsgId) { case D4D_MSG_DRAW: D4D_TextBoxOnDraw(pMsg); break; case D4D_MSG_ONINIT: pThis->pData->flags &= ~D4D_OBJECT_F_NOTINIT; D4D_TextBoxOnInit(pThis); break; #ifdef D4D_LLD_TCH case D4D_MSG_TOUCHED: D4D_FocusSet(pMsg->pScreen, pThis); D4D_CaptureKeys(pThis); break; #endif #ifdef D4D_LLD_MOUSE case D4D_MSG_MOUSE_BTN_LEFT_UP: D4D_FocusSet(pMsg->pScreen, pThis); D4D_CaptureKeys(pThis); break; case D4D_MSG_MOUSE_BTN_WHEEL_UP: if(D4D_GET_TEXTBOX_SCROLL_BAR_HOR(pThis)->pData->flags & D4D_OBJECT_F_VISIBLE) D4D_ScrlBrChangePosition(D4D_GET_TEXTBOX_SCROLL_BAR_HOR(pThis), -1); break; case D4D_MSG_MOUSE_BTN_WHEEL_DOWN: if(D4D_GET_TEXTBOX_SCROLL_BAR_HOR(pThis)->pData->flags & D4D_OBJECT_F_VISIBLE) D4D_ScrlBrChangePosition(D4D_GET_TEXTBOX_SCROLL_BAR_HOR(pThis), 1); break; #endif case D4D_MSG_KEYUP: { D4D_KEY_SCANCODE tmp_key = pMsg->prm.key; // capture the keyboard if enter is pressed if(tmp_key == D4D_KEY_SCANCODE_ENTER) D4D_CaptureKeys(pThis); // exit capture if(tmp_key == D4D_KEY_SCANCODE_ESC) D4D_CaptureKeys(NULL); } break; case D4D_MSG_KILLFOCUS: D4D_CaptureKeys(NULL); case D4D_MSG_SETFOCUS: case D4D_MSG_SETCAPTURE: case D4D_MSG_KILLCAPTURE: //D4D_InvalidateObject(pThis, D4D_FALSE); break; default: // call the default behavior of all objects D4D_ObjOnMessage(pMsg); } }
void D4D_SldrOnMessage(D4D_MESSAGE* pMsg) { D4D_OBJECT* pThis = pMsg->pObject; D4D_CLR_SCHEME *pScheme_tmp = D4D_ObjectGetScheme(pThis); #if defined(D4D_LLD_TCH) static D4D_INDEX autoTouchTicks; #endif #if defined(D4D_LLD_MOUSE) D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis); #endif #if defined(D4D_LLD_TCH) || defined(D4D_LLD_MOUSE) D4D_POINT touchClickPoint; #endif switch(pMsg->nMsgId) { case D4D_MSG_DRAW: D4D_SldrOnDraw(pMsg); break; case D4D_MSG_KEYUP: D4D_SldrOnKeyUp(pMsg); break; case D4D_MSG_KILLFOCUS: D4D_CaptureKeys(NULL); break; case D4D_MSG_ONINIT: pThis->pData->flags &= ~D4D_OBJECT_F_NOTINIT; if(!(pThis->initFlags & (D4D_SLDR_F_BAR_AUTOCOLOR | D4D_SLDR_F_BAR_SCALECOLOR))) D4D_GET_SLIDER(pThis)->pData->colorBar = pScheme_tmp->objectDepend.slider.barFore; else D4D_GET_SLIDER(pThis)->pData->colorBar = D4D_SldrComputeColorBar(pThis, D4D_GET_SLIDER(pThis)->pData->value); break; #ifdef D4D_LLD_MOUSE case D4D_MSG_MOUSE_BTN_LEFT_UP: touchClickPoint = D4D_GetMouseCoordinates(pMsg->pObject); D4D_SldrTouched(pMsg, &touchClickPoint); break; case D4D_MSG_MOUSE_BTN_WHEEL_UP: D4D_SldrChangeValue(pThis, pSldr->pData->limits.step); break; case D4D_MSG_MOUSE_BTN_WHEEL_DOWN: D4D_SldrChangeValue(pThis, -pSldr->pData->limits.step); break; #endif #ifdef D4D_LLD_TCH case D4D_MSG_TOUCH_AUTO: if(pThis->initFlags & D4D_SLDR_F_AUTOTOUCH_OFF) break; if(autoTouchTicks--) break; case D4D_MSG_TOUCHED: autoTouchTicks = D4D_SLDR_AUTOTOUCHTICKS; touchClickPoint = D4D_GetTouchScreenCoordinates(pMsg->pObject); D4D_SldrTouched(pMsg, &touchClickPoint); break; #endif default: // call the default behavior of all objects D4D_ObjOnMessage(pMsg); } }