/********************************************************************* * * _OnTouch */ static void _OnTouch(SLIDER_Handle hObj, SLIDER_Obj* pObj, WM_MESSAGE*pMsg) { const GUI_PID_STATE* pState = (const GUI_PID_STATE*)pMsg->Data.p; if (pMsg->Data.p) { /* Something happened in our area (pressed or released) */ if (pState->Pressed) { int x0, xsize, x, Sel, Range; Range = (pObj->Max - pObj->Min); x0 = 1 + pObj->Width / 2; /* 1 pixel focus rectangle + width of actual slider */ x = (pObj->Widget.State & WIDGET_STATE_VERTICAL) ? pState->y : pState->x; x -= x0; xsize = WIDGET__GetWindowSizeX(hObj) - 2 * x0; if (x <= 0) { Sel = pObj->Min; } else if (x >= xsize) { Sel = pObj->Max; } else { int Div; Div = xsize ? xsize : 1; /* Make sure we do not divide by 0, even though xsize should never be 0 in this case anyhow */ Sel = pObj->Min + ((U32)Range * (U32)x + Div / 2) / Div; } if (WM_IsFocussable(hObj)) { WM_SetFocus(hObj); } WM_SetCapture(hObj, 1); SLIDER_SetValue(hObj, Sel); if ((pObj->Widget.State & SLIDER_STATE_PRESSED) == 0){ _SliderPressed(hObj, pObj); } } else { /* React only if button was pressed before ... avoid problems with moving / hiding windows above (such as dropdown) */ if (pObj->Widget.State & SLIDER_STATE_PRESSED) { _SliderReleased(hObj, pObj); } } } }
/********************************************************************* * * WM_SetCaptureMove */ void WM_SetCaptureMove(WM_HWIN hWin, const GUI_PID_STATE* pState, int MinVisibility) { if (!WM_HasCaptured(hWin)) { WM_SetCapture(hWin, 1); /* Set capture with auto release */ WM__CapturePoint.x = pState->x; WM__CapturePoint.y = pState->y; } else { /* Moving ... let the window move ! */ int dx, dy; dx = pState->x - WM__CapturePoint.x; dy = pState->y - WM__CapturePoint.y; /* make sure at least a part of the windows stays inside of its parent */ if (MinVisibility == 0) { WM_MoveWindow(hWin, dx, dy); } else { GUI_RECT Rect, RectParent; /* make sure at least a part of the windows stays inside of its parent */ WM_GetWindowRectEx(hWin, &Rect); WM_GetWindowRectEx(WM_GetParent(hWin), &RectParent); GUI_MoveRect(&Rect, dx, dy); GUI__ReduceRect(&RectParent, &RectParent, MinVisibility); if (GUI_RectsIntersect(&Rect, &RectParent)) { WM_MoveWindow(hWin, dx, dy); } } } }
/********************************************************************* * * _OnTouch */ static void _OnTouch(SLIDER_Handle hObj, SLIDER_Obj* pObj, WM_MESSAGE*pMsg) { GUI_TOUCH_tState* pState = (GUI_TOUCH_tState*)pMsg->Data.p; if (pMsg->Data.p) { /* Something happened in our area (pressed or released) */ if (pState->Pressed) { int Sel; int Range = (pObj->Max - pObj->Min); int x0, xsize; int x; x0 = 1 + pObj->Width/2; /* 1 pixel focus rectangle + width of actual slider */ x = (pObj->Widget.State & WIDGET_STATE_VERTICAL) ? pState->y : pState->x; x -= x0; xsize = WIDGET__GetWindowSizeX(hObj) - 2 * x0; if (x <= 0) { Sel = pObj->Min; } else if (x >= xsize) { Sel = pObj->Max; } else { Sel = GUI__DivideRound(Range* x, xsize); Sel += pObj->Min; } WM_SetFocus(hObj); WM_SetCapture(hObj, 1); SLIDER_SetValue(hObj, Sel); } } }
/********************************************************************* * * _SetCapture */ static void _SetCapture(FRAMEWIN_Handle hWin, int x, int y, int Mode) { if ((_HasCaptured & REPOS_X) == 0) { _CaptureX = x; } if ((_HasCaptured & REPOS_Y) == 0) { _CaptureY = y; } if (!_HasCaptured) { WM_SetCapture(hWin, 1); _HasCaptured = Mode; } }
/********************************************************************* * * _OnTouch */ static void _OnTouch(SCROLLBAR_Handle hObj, SCROLLBAR_Obj* pObj, WM_MESSAGE*pMsg) { SCROLLBAR_POSITIONS Pos; GUI_PID_STATE* pState = (GUI_PID_STATE*)pMsg->Data.p; if (pMsg->Data.p) { /* Something happened in our area (pressed or released) */ if (pState->Pressed) { int Sel; int Range; int x; Sel = pObj->v; _CalcPositions(pObj, &Pos); Range = pObj->NumItems - pObj->PageSize; /* Swap mouse coordinates if necessary */ if (pObj->Widget.State & WIDGET_STATE_VERTICAL) { int t = pState->x; pState->x = pState->y; pState->y = t; } x = pState->x; if (x <= Pos.x1_LeftArrow) { /* left arrow (line left) */ Sel--; } else if (x < Pos.x0_Thumb) { /* left area (page left) */ Sel -= pObj->PageSize; } else if (x <= Pos.x1_Thumb) { /* Thumb area */ if (Pos.xSizeMoveable > 0) { x = x - Pos.ThumbSize/2 - Pos.x1_LeftArrow-1; Sel = GUI__DivideRound(Range * x, Pos.xSizeMoveable); } } else if (x < Pos.x0_RightArrow) { /* right area (page right) */ Sel += pObj->PageSize; } else if (x <= Pos.x1_RightArrow) { Sel++; } /* WM_SetFocus(hObj); */ WM_SetCapture(hObj, 1); SCROLLBAR_SetValue(hObj, Sel); if ((pObj->Widget.State & SCROLLBAR_STATE_PRESSED) == 0){ _ScrollbarPressed(hObj, pObj); } } else { /* React only if button was pressed before ... avoid problems with moving / hiding windows above (such as dropdown) */ if (pObj->Widget.State & SCROLLBAR_STATE_PRESSED) { _ScrollbarReleased(hObj, pObj); } } } }
/********************************************************************* * * _SetCapture */ static void _SetCapture(FRAMEWIN_Handle hWin, int x, int y, int Mode) { if ((_CaptureFlags & FRAMEWIN_REPOS_X) == 0) { _CaptureX = x; } if ((_CaptureFlags & FRAMEWIN_REPOS_Y) == 0) { _CaptureY = y; } if (Mode) { if (WM_HasCaptured(hWin) == 0) { WM_SetCapture(hWin, 0); } #if GUI_SUPPORT_CURSOR _SetResizeCursor(Mode); #endif if (Mode & FRAMEWIN_MOUSEOVER) { Mode = 0; } _CaptureFlags = (Mode | FRAMEWIN_MOUSEOVER); } }
static void _OnTouch(FRAMEWIN_Handle hWin, FRAMEWIN_Obj* pObj, WM_MESSAGE* pMsg) { GUI_TOUCH_tState* pState; pState = (GUI_TOUCH_tState*)pMsg->Data.p; if (pMsg->Data.p) { /* Something happened in our area (pressed or released) */ if (pState->Pressed) { WM_SetFocus(hWin); WM_BringToTop(hWin); if (pObj->Flags & FRAMEWIN_SF_MOVEABLE) { if (!WM_HasCaptured(hWin)) { WM_SetCapture(hWin, 1); pObj->CapturePoint.x = pState->x; pObj->CapturePoint.y = pState->y; } else { int dx, dy; dx = pState->x - pObj->CapturePoint.x; dy = pState->y - pObj->CapturePoint.y; WM_MoveWindow(hWin, dx, dy); } } } } }
/********************************************************************* * * _OnTouch */ static void _OnTouch(CHECKBOX_Handle hObj, CHECKBOX_Obj* pObj, WM_MESSAGE*pMsg) { int Notification = 0; int Hit = 0; const GUI_PID_STATE* pState = (const GUI_PID_STATE*)pMsg->Data.p; if (pMsg->Data.p) { /* Something happened in our area (pressed or released) */ if (!WM_HasCaptured(hObj)) { if (pState->Pressed) { WM_SetCapture(hObj, 1); CHECKBOX_SetState(hObj, (pObj->CurrentState + 1) % pObj->NumStates); Notification = WM_NOTIFICATION_CLICKED; } else { Hit =1; Notification = WM_NOTIFICATION_RELEASED; } } } else { Notification = WM_NOTIFICATION_MOVED_OUT; } WM_NotifyParent(hObj, Notification); if (Hit == 1) { GUI_DEBUG_LOG("CHECKBOX: Hit\n"); GUI_StoreKey(pObj->Widget.Id); } }
/*---------------------------------------------------------------------------* * Routine: _PFMainDialog *---------------------------------------------------------------------------* * Description: * Callback function used by emWin to process events. * Inputs: * WM_MESSAGE *pMsg -- message structure for current dialog. *---------------------------------------------------------------------------*/ static void _PFMainDialog(WM_MESSAGE *pMsg) { int Id, NCode; WM_HWIN hItem; GUI_PID_STATE *p_touchState; T_ImageMessage message; switch (pMsg->MsgId){ case WM_INIT_DIALOG: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; LAFSetup(pMsg->hWin, ID_WINDOW, PFMainLayout); hItem = WM_GetDialogItem(pMsg->hWin, ID_REVERSE_BUTTON); BUTTON_SetBitmap(hItem, BUTTON_BI_UNPRESSED, &REVERSE_BUTTON); BUTTON_SetBitmap(hItem, BUTTON_BI_PRESSED, &REVERSE_BUTTON); BUTTON_SetBitmap(hItem, BUTTON_BI_DISABLED, &REVERSE_BUTTON); hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_PAUSE_BUTTON); BUTTON_SetBitmap(hItem, BUTTON_BI_UNPRESSED, &PLAY_BUTTON); BUTTON_SetBitmap(hItem, BUTTON_BI_PRESSED, &PLAY_BUTTON); BUTTON_SetBitmap(hItem, BUTTON_BI_DISABLED, &PLAY_BUTTON); hItem = WM_GetDialogItem(pMsg->hWin, ID_FORWARD_BUTTON); BUTTON_SetBitmap(hItem, BUTTON_BI_UNPRESSED, &FORWARD_BUTTON); BUTTON_SetBitmap(hItem, BUTTON_BI_PRESSED, &FORWARD_BUTTON); BUTTON_SetBitmap(hItem, BUTTON_BI_DISABLED, &FORWARD_BUTTON); hItem = WM_GetDialogItem(pMsg->hWin, ID_SETTINGS_BUTTON); BUTTON_SetBitmap(hItem, BUTTON_BI_UNPRESSED, &SETTINGS_BUTTON); BUTTON_SetBitmap(hItem, BUTTON_BI_PRESSED, &SETTINGS_BUTTON); BUTTON_SetBitmap(hItem, BUTTON_BI_DISABLED, &SETTINGS_BUTTON); G_OverlayTimer = WM_CreateTimer(pMsg->hWin, ID_OVERLAY_TIMER, OVERLAY_TIMEOUT_MS, 0); G_UpdateTimer = WM_CreateTimer(pMsg->hWin, ID_UPDATE_TIMER, UPDATE_TIME_MS, 0); G_PictureChangeTimer = WM_CreateTimer(pMsg->hWin, ID_PICTURECHANGE_TIMER, 0, 0); if (!G_Current) { G_Current = GUI_MEMDEV_Create(0, 0, UEZ_LCD_DISPLAY_WIDTH, UEZ_LCD_DISPLAY_HEIGHT); GUI_MEMDEV_Select(G_Current); GUI_BMP_Draw(G_CurrentImage, 0, 0); GUI_MEMDEV_Select(0); } WM_SetHasTrans(pMsg->hWin); message = IMAGE_INITILIZE; UEZQueueSend(G_ImageLoadQueue, (void*)&message, 50); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; if( !LAFHandleEvent(PFMainLayout, pMsg, NCode, Id)){ //Handle special cases here } break; case WM_TIMER: NCode = pMsg->Data.v; if (G_Active) { if (NCode == G_OverlayTimer) { IHideButtonsAndText(pMsg); //Grab all the touches WM_SetCapture(pMsg->hWin, 0); } else if (NCode == G_PictureChangeTimer) { //put up new picture if(G_AutoPlayOn) { IHandleForward(pMsg, WM_NOTIFICATION_RELEASED, ID_FORWARD_BUTTON); WM_RestartTimer(G_PictureChangeTimer, 5000); } } else if (NCode == G_UpdateTimer) { IUpdateFields(pMsg); WM_RestartTimer(G_UpdateTimer, UPDATE_TIME_MS); } } break; case WM_TOUCH: p_touchState = (GUI_PID_STATE *)(pMsg->Data.p); if (!p_touchState->Pressed) { WM_RestartTimer(G_OverlayTimer, OVERLAY_TIMEOUT_MS); //Show all the hidden text on buttons hItem = WM_GetDialogItem(pMsg->hWin, ID_TITLE_TEXT); WM_ShowWindow(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_SETTINGS_BUTTON); WM_ShowWindow(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_REVERSE_BUTTON); WM_ShowWindow(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_PAUSE_BUTTON); WM_ShowWindow(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_FORWARD_BUTTON); WM_ShowWindow(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_TIMEDATE_TEXT); WM_ShowWindow(hItem); WM_ReleaseCapture(); IUpdateFields(pMsg); } break; case WM_POST_PAINT: GUI_BMP_Draw(G_CurrentImage, 0, 0); break; case WM_APP_GAINED_FOCUS: G_Active = ETrue; WM_SetCapture(pMsg->hWin, 0); IHideButtonsAndText(pMsg); IUpdateFields(pMsg); break; case WM_APP_LOST_FOCUS: G_Active = EFalse; IHideButtonsAndText(pMsg); WM_ReleaseCapture(); G_AutoPlayOn = EFalse; break; default: WM_DefaultProc(pMsg); break; } }