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); }
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); } }
void D4D_IconOnMessage(D4D_MESSAGE* pMsg) { #if D4D_ICON_ENABLE_ANIMATION == D4D_TRUE D4D_ICON* pIcon = D4D_GET_ICON(pMsg->pObject); D4D_ICON_DATA* pData = pIcon->pData; #endif switch(pMsg->nMsgId) { case D4D_MSG_DRAW: D4D_IconOnDraw(pMsg); break; #ifdef D4D_LLD_TCH case D4D_MSG_TOUCHED: D4D_FocusSet(pMsg->pScreen, pMsg->pObject); break; #endif #if D4D_ICON_ENABLE_ANIMATION == D4D_TRUE case D4D_MSG_ONINIT: pMsg->pObject->pData->flags &= ~D4D_OBJECT_F_NOTINIT; pData->tickCounterTrshld = D4D_ICON_ANIMATION_TICK_COUNTER; break; case D4D_MSG_TIMETICK: if(pData->animationEnabled) { if(++(pData->tickCounter) > pData->tickCounterTrshld) { pData->tickCounter = 0; // update animation (change icon) D4D_IconChangeIndex(pMsg->pObject, 1); } } break; #endif default: // call the default behavior of all objects D4D_ObjOnMessage(pMsg); } }
void D4D_LabelOnMessage(D4D_MESSAGE* pMsg) { switch(pMsg->nMsgId) { case D4D_MSG_DRAW: D4D_LabelOnDraw(pMsg); break; #ifdef D4D_LLD_TCH case D4D_MSG_TOUCHED: D4D_FocusSet(pMsg->pScreen, pMsg->pObject); break; #endif default: // call the default behavior of all objects D4D_ObjOnMessage(pMsg); } }
/**************************************************************************/ /*! * @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); } } } }
static void D4D_CheckBoxTouched(D4D_MESSAGE* pMsg) { if(pMsg->pObject->pData->flags & (D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_FASTTOUCH)) { if((D4D_GetFocusedObject(pMsg->pScreen) == pMsg->pObject) || (pMsg->pObject->pData->flags & D4D_OBJECT_F_FASTTOUCH)) { D4D_CHECKBOX_STATUS* pStatus = D4D_GET_CHECKBOX_STATUS(pMsg->pObject); D4D_CHECKBOX* pCheckB = D4D_GET_CHECKBOX(pMsg->pObject); if(*pStatus & D4D_CHECKBOX_STATUS_CHECKED_MASK) *pStatus &= ~D4D_CHECKBOX_STATUS_CHECKED_MASK; else *pStatus |= D4D_CHECKBOX_STATUS_CHECKED_MASK; if(pCheckB->OnChange) pCheckB->OnChange(pMsg->pObject); D4D_InvalidateObject(pMsg->pObject, D4D_FALSE); } D4D_FocusSet(pMsg->pScreen, pMsg->pObject); } }
static void D4D_MenuOnTouch(D4D_MESSAGE* pMsg, D4D_POINT* pPoint) { D4D_OBJECT* pThis = pMsg->pObject; D4D_MENU* pMenu = D4D_GET_MENU(pThis); if(pThis->pData->flags & D4D_OBJECT_F_TABSTOP) { if((D4D_GetFocusedObject(pMsg->pScreen) == pThis) || (pThis->pData->flags & D4D_OBJECT_F_FASTTOUCH)) { D4D_FocusSet(pMsg->pScreen, pThis); D4D_MenuValue2Coor(pThis); if(pPoint->x < (pThis->position.x + pThis->size.cx - ((D4D_GET_MENU_SCROLL_BAR_HOR(pThis)->pData->flags & D4D_OBJECT_F_VISIBLE)? D4D_MENU_SCRLBR_WIDTH:0))) { // Select Menu Item D4D_COOR tmp_y; Byte tmpB; D4D_MENU_INDEX tmpItemsCnt = D4D_GetItemsCount(pMenu); tmp_y = (D4D_COOR)(pPoint->y - pThis->position.y); if(tmp_y <= _calc.titleBar_y) return; tmp_y -= _calc.titleBar_y; // now is in tmp_y offset of y from title bar // Check the list for(tmpB = pMenu->pData->page_ix; tmpB < _calc.itemsCnt; tmpB++) { // Check end if list if((tmpB - pMenu->pData->page_ix) >= _calc.posCnt) break; if(tmp_y < _calc.textOff) { // founded touched line if(pMenu->pData->ix != tmpB) { // Touched line is not focused pMenu->pData->ix = (D4D_MENU_INDEX)tmpB; }else { if(pMenu->OnClicked) pMenu->OnClicked(pThis, pMenu->pData->ix); } break; } tmp_y -= _calc.textOff; } D4D_InvalidateObject(pThis, D4D_FALSE); } }else { D4D_FocusSet(pMsg->pScreen, pThis); } } }
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); } }