/********************************************************************* * * BUTTON_Callback */ void BUTTON_Callback(WM_MESSAGE *pMsg) { BUTTON_Handle hObj = pMsg->hWin; BUTTON_Obj* pObj = BUTTON_H2P(hObj); /* Let widget handle the standard messages */ if (WIDGET_HandleActive(hObj, pMsg) == 0) { return; } switch (pMsg->MsgId) { #if BUTTON_REACT_ON_LEVEL case WM_PID_STATE_CHANGED: _OnPidStateChange(hObj, pObj, pMsg); return; /* Message handled. Do not call WM_DefaultProc, because the window may have been destroyed */ #endif case WM_TOUCH: _OnTouch(hObj, pObj, pMsg); return; /* Message handled. Do not call WM_DefaultProc, because the window may have been destroyed */ case WM_PAINT: GUI_DEBUG_LOG("BUTTON: _BUTTON_Callback(WM_PAINT)\n"); _Paint(pObj, hObj); return; case WM_DELETE: GUI_DEBUG_LOG("BUTTON: _BUTTON_Callback(WM_DELETE)\n"); _Delete(pObj); break; /* No return here ... WM_DefaultProc needs to be called */ #if 0 /* TBD: Button should react to space & Enter */ case WM_KEY: { int PressedCnt = ((WM_KEY_INFO*)(pMsg->Data.p))->PressedCnt; int Key = ((WM_KEY_INFO*)(pMsg->Data.p))->Key; if (PressedCnt > 0) { /* Key pressed? */ switch (Key) { case ' ': _ButtonPressed(hObj, pObj); return; } } else { switch (Key) { case ' ': _ButtonReleased(hObj, pObj, WM_NOTIFICATION_RELEASED); return; } } } break; #endif } WM_DefaultProc(pMsg); }
/********************************************************************* * * BUTTON_Callback */ void BUTTON_Callback(WM_MESSAGE *pMsg) { int PressedCnt, Key; BUTTON_Handle hObj = pMsg->hWin; BUTTON_Obj * pObj = (BUTTON_Obj *)GUI_ALLOC_h2p(hObj); /* Don't use use WIDGET_H2P because WIDGET_INIT_ID() has not be called at this point */ /* Let widget handle the standard messages */ if (WIDGET_HandleActive(hObj, pMsg) == 0) { return; } switch (pMsg->MsgId) { #if BUTTON_REACT_ON_LEVEL case WM_PID_STATE_CHANGED: _OnPidStateChange(hObj, pObj, pMsg); return; /* Message handled. Do not call WM_DefaultProc, because the window may have been destroyed */ #endif case WM_TOUCH: _OnTouch(hObj, pObj, pMsg); return; /* Message handled. Do not call WM_DefaultProc, because the window may have been destroyed */ case WM_PAINT: GUI_DEBUG_LOG("BUTTON: _BUTTON_Callback(WM_PAINT)\n"); _Paint(pObj, hObj); return; case WM_DELETE: GUI_DEBUG_LOG("BUTTON: _BUTTON_Callback(WM_DELETE)\n"); _Delete(pObj); break; /* No return here ... WM_DefaultProc needs to be called */ case WM_KEY: PressedCnt = ((WM_KEY_INFO*)(pMsg->Data.p))->PressedCnt; Key = ((WM_KEY_INFO*)(pMsg->Data.p))->Key; switch (Key) { case GUI_KEY_ENTER: if (PressedCnt > 0) { _OnButtonPressed(hObj, pObj); _OnButtonReleased(hObj, pObj, WM_NOTIFICATION_RELEASED); return; } break; case GUI_KEY_SPACE: if (PressedCnt > 0) { _OnButtonPressed(hObj, pObj); } else { _OnButtonReleased(hObj, pObj, WM_NOTIFICATION_RELEASED); } return; } } WM_DefaultProc(pMsg); }