/********************************************************************* * * _OnTouch */ static int _OnTouch(DROPDOWN_Handle hObj, 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) { WM_NotifyParent(hObj, WM_NOTIFICATION_CLICKED); } else { WM_NotifyParent(hObj, WM_NOTIFICATION_RELEASED); } } else { /* Mouse moved out */ WM_NotifyParent(hObj, WM_NOTIFICATION_MOVED_OUT); } return 0; /* Message handled */ }
/********************************************************************* * * _OnTouch */ static void _OnTouch(RADIO_Handle hObj, RADIO_Obj* pObj, WM_MESSAGE*pMsg) { int Notification; int Hit = 0; 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 y, Sel; y = pState->y; Sel = y / pObj->Spacing; y -= Sel * pObj->Spacing; if (y <= pObj->Height) { RADIO_SetValue(hObj, Sel); } if (WM_IsFocussable(hObj)) { WM_SetFocus(hObj); } 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("RADIO: Hit\n"); GUI_StoreKey(pObj->Widget.Id); } }
/********************************************************************* * * _SetValue */ static void _SetValue(EDIT_Handle hObj, I32 Value, int Unsigned) { EDIT_Obj* pObj; if (hObj) { WM_LOCK(); pObj = EDIT_H2P(hObj); /* Put in min/max range */ if (Unsigned) { if ((unsigned)Value < (unsigned)pObj->Min) { Value = pObj->Min; } if ((unsigned)Value > (unsigned)pObj->Max) { Value = pObj->Max; } } else { if (Value < pObj->Min) { Value = pObj->Min; } if (Value > pObj->Max) { Value = pObj->Max; } } if (pObj->CurrentValue != (U32)Value) { pObj->CurrentValue = Value; if (pObj->pfUpdateBuffer) { pObj->pfUpdateBuffer(hObj); } WM_InvalidateWindow(hObj); WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED); } WM_UNLOCK(); } }
/********************************************************************* * * LISTVIEW__SetSel */ void LISTVIEW__SetSel(LISTVIEW_Handle hObj, LISTVIEW_Obj* pObj, int NewSel) { int NumRows; NumRows = LISTVIEW__GetNumRows(pObj); if (NewSel >= NumRows) { NewSel = NumRows - 1; } if (NewSel < 0) { NewSel = -1; } if (NewSel != pObj->Sel) { char Disabled; LISTVIEW_ROW * pRow; pRow = (LISTVIEW_ROW *)GUI_ARRAY_GetpItem(&pObj->RowArray, NewSel); if (pRow) { Disabled = pRow->Disabled; } else { Disabled = 0; } if (Disabled == 0) { int OldSel; OldSel = pObj->Sel; pObj->Sel = NewSel; if (LISTVIEW__UpdateScrollPos(hObj, pObj)) { LISTVIEW__InvalidateInsideArea(hObj, pObj); } else { LISTVIEW__InvalidateRow(hObj, pObj, OldSel); LISTVIEW__InvalidateRow(hObj, pObj, NewSel); } WM_NotifyParent(hObj, WM_NOTIFICATION_SEL_CHANGED); } } }
/********************************************************************* * * _OnTouch */ static void _OnTouch(EDIT_Handle hObj, EDIT_Obj* pObj, WM_MESSAGE*pMsg) { const GUI_PID_STATE* pState = (const GUI_PID_STATE*)pMsg->Data.p; GUI_USE_PARA(pObj); if (pMsg->Data.p) { /* Something happened in our area (pressed or released) */ if (pState->Pressed) { GUI_DEBUG_LOG1("EDIT_Callback(WM_TOUCH, Pressed, Handle %d)\n",1); EDIT_SetCursorAtPixel(hObj, pState->x); WM_NotifyParent(hObj, WM_NOTIFICATION_CLICKED); } else { GUI_DEBUG_LOG1("EDIT_Callback(WM_TOUCH, Released, Handle %d)\n",1); WM_NotifyParent(hObj, WM_NOTIFICATION_RELEASED); } } else { GUI_DEBUG_LOG1("EDIT_Callback(WM_TOUCH, Moved out, Handle %d)\n",1); WM_NotifyParent(hObj, WM_NOTIFICATION_MOVED_OUT); } }
/********************************************************************* * * _DROPDOWN_Callback */ static void _DROPDOWN_Callback (WM_MESSAGE*pMsg) { DROPDOWN_Handle hObj = pMsg->hWin; DROPDOWN_Obj* pObj = DROPDOWN_H2P(hObj); char IsExpandedBeforeMsg; IsExpandedBeforeMsg = pObj->hListWin ? 1 : 0; /* Let widget handle the standard messages */ if (WIDGET_HandleActive(hObj, pMsg) == 0) { return; } switch (pMsg->MsgId) { case WM_NOTIFY_PARENT: switch (pMsg->Data.v) { case WM_NOTIFICATION_SCROLL_CHANGED: WM_NotifyParent(hObj, WM_NOTIFICATION_SCROLL_CHANGED); break; case WM_NOTIFICATION_CLICKED: DROPDOWN_SetSel(hObj, LISTBOX_GetSel(pObj->hListWin)); WM_SetFocus(hObj); break; case LISTBOX_NOTIFICATION_LOST_FOCUS: DROPDOWN_Collapse(hObj); break; } break; case WM_PID_STATE_CHANGED: if (IsExpandedBeforeMsg == 0) { /* Make sure we do not react a second time */ const WM_PID_STATE_CHANGED_INFO * pInfo = (const WM_PID_STATE_CHANGED_INFO*)pMsg->Data.p; if (pInfo->State) { DROPDOWN_Expand(hObj); } } break; case WM_TOUCH: if (_OnTouch(hObj, pMsg) == 0) { return; } break; case WM_PAINT: _Paint(hObj); break; case WM_DELETE: _FreeAttached(pObj); break; /* No return here ... WM_DefaultProc needs to be called */ case WM_KEY: if ( ((const WM_KEY_INFO*)(pMsg->Data.p))->PressedCnt >0) { int Key = ((const WM_KEY_INFO*)(pMsg->Data.p))->Key; switch (Key) { case GUI_KEY_TAB: break; /* Send to parent by not doing anything */ default: DROPDOWN_AddKey(hObj, Key); return; } } break; } WM_DefaultProc(pMsg); }
/********************************************************************* * * RADIO__SetValue */ void RADIO__SetValue(RADIO_Handle hObj, RADIO_Obj* pObj, int v) { if (v >= pObj->NumItems) { v = (int)pObj->NumItems - 1; } if (v != pObj->Sel) { pObj->Sel = v; WM_InvalidateWindow(hObj); WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED); } }
/********************************************************************* * * _OnButtonReleased */ static void _OnButtonReleased(BUTTON_Handle hObj, BUTTON_Obj* pObj, int Notification) { WIDGET_AndState(hObj, BUTTON_STATE_PRESSED); if (Notification == WM_NOTIFICATION_RELEASED) { GUI_DEBUG_LOG("BUTTON: Hit\n"); GUI_StoreKey(pObj->Widget.Id); } if (pObj->Widget.Win.Status & WM_SF_ISVIS) { WM_NotifyParent(hObj, Notification); } }
/********************************************************************* * * SLIDER_Inc */ void SLIDER_Inc(SLIDER_Handle hObj) { SLIDER_Obj* pObj; if (hObj) { WM_LOCK(); pObj = SLIDER_H2P(hObj); if (pObj->v < pObj->Max) { pObj->v++; WM_InvalidateWindow(hObj); WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED); } WM_UNLOCK(); } }
/********************************************************************* * * HSD_SLIDER_Loop */ void HSD_SLIDER_Loop(SLIDER_Handle hObj) { SLIDER_Obj * pObj; if(hObj) { WM_LOCK(); pObj = SLIDER_H2P(hObj); pObj->v = (pObj->v + 1 - pObj->Min) % (pObj->Max - pObj->Min + 1) + pObj->Min; WM_InvalidateWindow(hObj); WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED); WM_UNLOCK(); } }
/********************************************************************* * * DROPDOWN_Expand */ void DROPDOWN_Expand(DROPDOWN_Handle hObj) { int xSize, ySize, i, NumItems; WM_HWIN hLst; GUI_RECT r; WM_HWIN hParent; WM_Obj* pParent; DROPDOWN_Obj* pObj; if (hObj) { WM_LOCK(); pObj = DROPDOWN_H2P(hObj); if (pObj->hListWin == 0) { hParent = WM_GetParent(hObj); pParent = WM_H2P(hParent); xSize = WM__GetWindowSizeX(&pObj->Widget.Win); ySize = pObj->ySizeEx; NumItems = _GetNumItems(pObj); /* Get coordinates of window in client coordiantes of parent */ r = pObj->Widget.Win.Rect; GUI_MoveRect(&r, -pParent->Rect.x0, -pParent->Rect.y0); if (pObj->Flags & DROPDOWN_CF_UP) { r.y0 -= ySize; } else { r.y0 = r.y1; } hLst = LISTBOX_CreateAsChild(NULL, WM_GetParent(hObj), r.x0, r.y0 , xSize, ySize, WM_CF_SHOW); if (pObj->Flags & DROPDOWN_SF_AUTOSCROLLBAR) { LISTBOX_SetScrollbarWidth(hLst, pObj->ScrollbarWidth); LISTBOX_SetAutoScrollV(hLst, 1); } for (i = 0; i< NumItems; i++) { LISTBOX_AddString(hLst, _GetpItem(pObj, i)); } for (i = 0; i < GUI_COUNTOF(pObj->Props.aBackColor); i++) { LISTBOX_SetBkColor(hLst, i, pObj->Props.aBackColor[i]); } for (i = 0; i < GUI_COUNTOF(pObj->Props.aTextColor); i++) { LISTBOX_SetTextColor(hLst, i, pObj->Props.aTextColor[i]); } LISTBOX_SetItemSpacing(hLst, pObj->ItemSpacing); LISTBOX_SetFont(hLst, pObj->Props.pFont); WM_SetFocus(hLst); pObj->hListWin = hLst; LISTBOX_SetOwner(hLst, hObj); LISTBOX_SetSel(hLst, pObj->Sel); WM_NotifyParent(hObj, WM_NOTIFICATION_CLICKED); } WM_UNLOCK(); } }
/********************************************************************* * * _DeleteChar * * Deletes a character at the current cursor position and moves * all bytes after the cursor position. */ static void _DeleteChar(EDIT_Handle hObj, EDIT_Obj* pObj) { if (pObj->hpText) { unsigned CursorOffset; char* pText; pText = (char*) GUI_ALLOC_h2p(pObj->hpText); CursorOffset = GUI_UC__NumChars2NumBytes(pText, pObj->CursorPos); if (CursorOffset < strlen(pText)) { int NumBytes; pText += CursorOffset; NumBytes = GUI_UC_GetCharSize(pText); strcpy(pText, pText + NumBytes); WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED); } } }
/********************************************************************* * * SCROLLBAR_CreateAttached */ SCROLLBAR_Handle SCROLLBAR_CreateAttached(WM_HWIN hParent, int SpecialFlags) { SCROLLBAR_Handle hThis; int Id; int WinFlags; if (SpecialFlags & SCROLLBAR_CF_VERTICAL) { Id = GUI_ID_VSCROLL; WinFlags = WM_CF_SHOW | WM_CF_STAYONTOP | WM_CF_ANCHOR_RIGHT | WM_CF_ANCHOR_TOP | WM_CF_ANCHOR_BOTTOM; } else { Id = GUI_ID_HSCROLL; WinFlags = WM_CF_SHOW | WM_CF_STAYONTOP | WM_CF_ANCHOR_BOTTOM | WM_CF_ANCHOR_LEFT | WM_CF_ANCHOR_RIGHT; } hThis = SCROLLBAR_CreateEx(0, 0, 0, 0, hParent, WinFlags, SpecialFlags, Id); WM_NotifyParent(hThis, WM_NOTIFICATION_SCROLLBAR_ADDED); return hThis; }
/********************************************************************* * * HSD_SLIDER_Dec */ void HSD_SLIDER_Dec(SLIDER_Handle hObj) { SLIDER_Obj * pObj; if(hObj) { WM_LOCK(); pObj = SLIDER_H2P(hObj); if(pObj->v > pObj->Min) { pObj->v--; WM_InvalidateWindow(hObj); WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED); } WM_UNLOCK(); } }
/********************************************************************* * * _InsertChar * * Create space at the current cursor position and inserts a character. */ static int _InsertChar(EDIT_Handle hObj, EDIT_Obj* pObj, U16 Char) { if (_IsCharsAvailable(pObj, 1)) { int BytesNeeded; BytesNeeded = GUI_UC__CalcSizeOfChar(Char); if (_IsSpaceInBuffer(pObj, BytesNeeded)) { int CursorOffset; char* pText; pText = (char*) GUI_ALLOC_h2p(pObj->hpText); CursorOffset = GUI_UC__NumChars2NumBytes(pText, pObj->CursorPos); pText += CursorOffset; memmove(pText + BytesNeeded, pText, strlen(pText) + 1); GUI_UC_Encode(pText, Char); WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED); return 1; } } return 0; }
/********************************************************************* * * _OnTouch */ static int _OnTouch(LISTBOX_Handle hObj, LISTBOX_Obj* pObj, WM_MESSAGE*pMsg) { int Notification; int Sel; GUI_TOUCH_tState* pState = (GUI_TOUCH_tState*)pMsg->Data.p; int FontDistY = GUI_GetYDistOfFont(pObj->pFont); if (pMsg->Data.p) { /* Something happened in our area (pressed or released) */ if (pState->Pressed) { Sel = pState->y / FontDistY + pObj->ScrollState.v; WM_SetFocus(hObj); Notification = WM_NOTIFICATION_CLICKED; LISTBOX_SetSel(hObj, Sel); } else { Notification = WM_NOTIFICATION_RELEASED; } } else { /* Mouse moved out */ Notification = WM_NOTIFICATION_MOVED_OUT; } WM_NotifyParent(hObj, Notification); return 0; /* Message handled */ }
/********************************************************************* * * SLIDER_SetValue */ void SLIDER_SetValue(SLIDER_Handle hObj, int v) { SLIDER_Obj* pObj; if (hObj) { WM_LOCK(); pObj = SLIDER_H2P(hObj); /* Put in min/max range */ if (v < pObj->Min) { v = pObj->Min; } if (v > pObj->Max) { v = pObj->Max; } if (pObj->v != v) { pObj->v = v; WM_InvalidateWindow(hObj); WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED); } WM_UNLOCK(); } }
/********************************************************************* * * DROPDOWN_SetSel */ void DROPDOWN_SetSel(DROPDOWN_Handle hObj, int Sel) { int NumItems, MaxSel; DROPDOWN_Obj* pObj; if (hObj) { WM_LOCK(); pObj = DROPDOWN_H2P(hObj); ASSERT_IS_VALID_PTR(pObj); NumItems = _GetNumItems(pObj); MaxSel = NumItems ? NumItems-1 : 0; if (Sel > MaxSel) { Sel = MaxSel; } if (Sel != pObj->Sel) { pObj->Sel = Sel; DROPDOWN_Invalidate(hObj); WM_NotifyParent(hObj, WM_NOTIFICATION_SEL_CHANGED); } WM_UNLOCK(); } }
/********************************************************************* * * _OnTouch */ static void _OnTouch(BUTTON_Handle hObj, BUTTON_Obj* pObj, WM_MESSAGE*pMsg) { int Notification; int Hit = 0; 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) { WIDGET_OrState(hObj, BUTTON_STATE_PRESSED); Notification = WM_NOTIFICATION_CLICKED; WM_SetFocus(hObj); } else { Hit =1; Notification = WM_NOTIFICATION_RELEASED; WIDGET_AndState(hObj, BUTTON_STATE_PRESSED); } } else { Notification = WM_NOTIFICATION_MOVED_OUT; WIDGET_AndState(hObj, BUTTON_STATE_PRESSED); } WM_NotifyParent(hObj, Notification); if (Hit == 1) { GUI_DEBUG_LOG("BUTTON: Hit\n"); GUI_StoreKey(pObj->Widget.Id); } }
/********************************************************************* * * _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); } }
/********************************************************************* * * SCROLLBAR_SetValue */ void SCROLLBAR_SetValue(SCROLLBAR_Handle hObj, int v) { SCROLLBAR_Obj* pObj; int Max; if (hObj) { WM_LOCK(); pObj = SCROLLBAR_H2P(hObj); Max = pObj->NumItems - pObj->PageSize; if (Max < 0) Max =0; /* Put in min/max range */ if (v < 0) { v = 0; } if (v > Max) { v = Max; } if (pObj->v != v) { pObj->v = v; WM_InvalidateWindow(hObj); WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED); } WM_UNLOCK(); } }
void EDIT_AddKey(EDIT_Handle hObj, int Key) { EDIT_Obj* pObj; if (hObj == 0) return; WM_LOCK(); pObj = EDIT_H2P(hObj); if (pObj) { if (pObj->pfAddKeyEx) { pObj->pfAddKeyEx(pObj, hObj, Key); } else { char*s = (char*) WM_HMEM2Ptr(pObj->hpText); int len = (int)strlen(s); switch (Key) { case GUI_KEY_UP: { char c = *(s + pObj->CursorPos); if (c < 0x7f) { *(s + pObj->CursorPos) = c + 1; WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED); } } break; case GUI_KEY_DOWN: { char c = *(s + pObj->CursorPos); if (c > 0x20) { *(s + pObj->CursorPos) = c - 1; WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED); } } break; case GUI_KEY_RIGHT: if (pObj->CursorPos < (pObj->MaxLen - 1)) if (pObj->CursorPos < len) pObj->CursorPos++; break; case GUI_KEY_LEFT: if (pObj->CursorPos > 0) pObj->CursorPos--; break; case GUI_KEY_BACKSPACE: if ((len > 0) && (pObj->CursorPos > 0)) { int CopyLength = pObj->MaxLen - pObj->CursorPos; strncpy(s + pObj->CursorPos - 1, s + pObj->CursorPos, CopyLength); *(s + len - 1) = 0; WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED); pObj->CursorPos--; } break; case GUI_KEY_DELETE: if ((len > 0) && (pObj->CursorPos < len)) { if (len > 1) { int CopyLength = pObj->MaxLen - pObj->CursorPos - 1; strncpy(s + pObj->CursorPos, s + pObj->CursorPos + 1, CopyLength); } *(s + len - 1) = 0; WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED); } break; case GUI_KEY_INSERT: if (pObj->EditMode == GUI_EDIT_MODE_OVERWRITE) pObj->EditMode = GUI_EDIT_MODE_INSERT; else pObj->EditMode = GUI_EDIT_MODE_OVERWRITE; break; case GUI_KEY_ENTER: case GUI_KEY_ESCAPE: break; default: if ((Key >= 0x20) && (Key <= 0x7f)) { if (pObj->EditMode == GUI_EDIT_MODE_INSERT) { if (len < pObj->MaxLen) { int CopyLength = pObj->MaxLen - pObj->CursorPos - 1; memmove(s + pObj->CursorPos + 1, s + pObj->CursorPos, CopyLength); *(s + pObj->CursorPos) = Key; WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED); if (pObj->CursorPos < (pObj->MaxLen - 1)) pObj->CursorPos++; } } else { *(s + pObj->CursorPos) = Key; WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED); if (pObj->CursorPos < (pObj->MaxLen - 1)) pObj->CursorPos++; } } break; } } EDIT_Invalidate(hObj); } WM_UNLOCK(); }
/********************************************************************* * * EDIT_AddKey */ void EDIT_AddKey(EDIT_Handle hObj, int Key) { if (hObj) { EDIT_Obj* pObj; WM_LOCK(); pObj = EDIT_H2P(hObj); if (pObj) { if (pObj->pfAddKeyEx) { pObj->pfAddKeyEx(hObj, Key); } else { switch (Key) { case GUI_KEY_UP: if (pObj->hpText) { char* pText; U16 Char; pText = (char*) GUI_ALLOC_h2p(pObj->hpText); pText += GUI_UC__NumChars2NumBytes(pText, pObj->CursorPos); Char = GUI_UC_GetCharCode(pText); if (Char < 0x7f) { *pText = Char + 1; WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED); } } break; case GUI_KEY_DOWN: if (pObj->hpText) { char* pText; U16 Char; pText = (char*) GUI_ALLOC_h2p(pObj->hpText); pText += GUI_UC__NumChars2NumBytes(pText, pObj->CursorPos); Char = GUI_UC_GetCharCode(pText); if (Char > 0x20) { *pText = Char - 1; WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED); } } break; case GUI_KEY_RIGHT: EDIT__SetCursorPos(pObj, pObj->CursorPos + 1); break; case GUI_KEY_LEFT: EDIT__SetCursorPos(pObj, pObj->CursorPos - 1); break; case GUI_KEY_BACKSPACE: EDIT__SetCursorPos(pObj, pObj->CursorPos - 1); _DeleteChar(hObj, pObj); break; case GUI_KEY_DELETE: _DeleteChar(hObj, pObj); break; case GUI_KEY_INSERT: if (pObj->EditMode == GUI_EDIT_MODE_OVERWRITE) { pObj->EditMode = GUI_EDIT_MODE_INSERT; } else { pObj->EditMode = GUI_EDIT_MODE_OVERWRITE; EDIT__SetCursorPos(pObj, pObj->CursorPos); } break; default: if (Key >= 0x20) { if (pObj->EditMode != GUI_EDIT_MODE_INSERT) { _DeleteChar(hObj, pObj); } if (_InsertChar(hObj, pObj, Key)) { EDIT__SetCursorPos(pObj, pObj->CursorPos + 1); } } } } EDIT_Invalidate(hObj); } WM_UNLOCK(); } }
/********************************************************************* * * _OnButtonPressed */ static void _OnButtonPressed(BUTTON_Handle hObj, BUTTON_Obj* pObj) { WIDGET_OrState(hObj, BUTTON_STATE_PRESSED); if (pObj->Widget.Win.Status & WM_SF_ISVIS) { WM_NotifyParent(hObj, WM_NOTIFICATION_CLICKED); } }
/** * @brief Callback routine of the dialog * @param pMsg: pointer to a data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem, hClient; GUI_RECT r; int Id, NCode, offset; switch (pMsg->MsgId) { case WM_INIT_DIALOG: hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_DURATION); TEXT_SetFont(hItem, GUI_FONT_13HB_ASCII); TEXT_SetTextColor(hItem, 0x00804000); hClient = WM_GetClientWindow(pMsg->hWin); WM_GetClientRectEx(hClient, &r); hVideoScreen = WM_CreateWindowAsChild(r.x0 + 2, r.y0 + 2, r.x1 - 2, r.y1 - 118, hClient, WM_CF_SHOW, _cbVideoWindow , 0); hItem = WM_GetDialogItem(pMsg->hWin, PLAY_BUTTON_VIDEO); BUTTON_SetBitmapEx(hItem, 0, &bmButtonPlayPauseOn, 16, 6); BUTTON_SetBitmapEx(hItem, 1, &bmButtonPlayPauseOff,16, 6); hItem = WM_GetDialogItem(pMsg->hWin, PREV_BUTTON_VIDEO); BUTTON_SetBitmapEx(hItem, 0, &bmButtonPreviousOn, 16, 6); BUTTON_SetBitmapEx(hItem, 1, &bmButtonPreviousOff,16, 6); hItem = WM_GetDialogItem(pMsg->hWin, NEXT_BUTTON_VIDEO); BUTTON_SetBitmapEx(hItem, 0, &bmButtonNextOn, 16, 6); BUTTON_SetBitmapEx(hItem, 1, &bmButtonNextOff,16, 6); hItem = WM_GetDialogItem(pMsg->hWin, STOP_BUTTON_VIDEO); BUTTON_SetBitmapEx(hItem, 0, &bmButtonStopOn, 16, 6); BUTTON_SetBitmapEx(hItem, 1, &bmButtonStopOff,16, 6); hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_PROGRESS); SLIDER_SetRange(hItem, 0, 100); SLIDER_SetWidth( hItem, 5); VideoPlayer_State = VIDEO_IDLE; _GetMJPEGFileList("0:"); hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_FILE); if (FILEMGR_FileList.ptr == 0) { TEXT_SetFont(hItem, GUI_FONT_20B_ASCII); TEXT_SetTextColor(hItem, GUI_BROWN); } else { TEXT_SetFont(hItem, GUI_FONT_13B_ASCII); TEXT_SetTextColor(hItem, 0x00804000); } do_clear = 1; if (FILEMGR_FileList.ptr > 0) { if(f_open(&Video_File, (char *)FILEMGR_FileList.file[FILEMGR_FileList.idx].line, FA_OPEN_EXISTING | FA_READ) == FR_OK) { hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_FILE); TEXT_SetText(hItem, (char *)FILEMGR_FileList.file[FILEMGR_FileList.idx].line); VideoPlayer_State = VIDEO_PLAY; ImageOffset = 0; time_start = GUI_GetTime(); hItem = WM_GetDialogItem(pMsg->hWin, PLAY_BUTTON_VIDEO); BUTTON_SetBitmapEx(hItem, 0, &bmButtonPlay, 16, 6); BUTTON_SetBitmapEx(hItem, 1, &bmButtonPlayPauseOff,16, 6); } else { /* error */ } } break; case WM_PAINT: break; case WM_NOTIFY_CHILD_HAS_FOCUS: do_clear = 1; break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; if(NCode == WM_NOTIFICATION_CHILD_DELETED) { f_close(&Video_File); WM_NotifyParent(WM_GetParent(pMsg->hWin), 0x500); break; } switch(Id) { case PLAY_BUTTON_VIDEO: // Notifications sent by 'Button' switch(NCode) { case WM_NOTIFICATION_RELEASED: if(VideoPlayer_State == VIDEO_IDLE) { if (FILEMGR_FileList.ptr > 0) { if(f_open(&Video_File, (char *)FILEMGR_FileList.file[FILEMGR_FileList.idx].line, FA_OPEN_EXISTING | FA_READ) == FR_OK) { hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_FILE); TEXT_SetText(hItem, (char *)FILEMGR_FileList.file[FILEMGR_FileList.idx].line); VideoPlayer_State = VIDEO_PLAY; ImageOffset = 0; time_start = GUI_GetTime(); hItem = WM_GetDialogItem(pMsg->hWin, PLAY_BUTTON_VIDEO); BUTTON_SetBitmapEx(hItem, 0, &bmButtonPlay, 16, 6); BUTTON_SetBitmapEx(hItem, 1, &bmButtonPlayPauseOff,16, 6); } else { /* error */ } } else { /* No file */ } } else if(VideoPlayer_State == VIDEO_PLAY) { time_pause = GUI_GetTime(); hItem = WM_GetDialogItem(pMsg->hWin, PLAY_BUTTON_VIDEO); BUTTON_SetBitmapEx(hItem, 0, &bmButtonPause, 16, 6); BUTTON_SetBitmapEx(hItem, 1, &bmButtonPlayPauseOff,16, 6); VideoPlayer_State = VIDEO_PAUSE; } else if(VideoPlayer_State == VIDEO_PAUSE) { time_start = GUI_GetTime()+ time_start - time_pause ; hItem = WM_GetDialogItem(pMsg->hWin, PLAY_BUTTON_VIDEO); BUTTON_SetBitmapEx(hItem, 0, &bmButtonPlay, 16, 6); BUTTON_SetBitmapEx(hItem, 1, &bmButtonPlayPauseOff,16, 6); VideoPlayer_State = VIDEO_PLAY; } break; } break; case PREV_BUTTON_VIDEO: /* Notifications sent by 'Button' */ switch(NCode) { case WM_NOTIFICATION_RELEASED: if(VideoPlayer_State != VIDEO_IDLE) { ImageOffset = 0; time_start = GUI_GetTime(); VideoPlayer_State = VIDEO_PLAY; f_close(&Video_File); goto_previous_file(); hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_FILE); TEXT_SetText(hItem, (char *)FILEMGR_FileList.file[FILEMGR_FileList.idx].line); hItem = WM_GetDialogItem(pMsg->hWin, PLAY_BUTTON_VIDEO); BUTTON_SetBitmapEx(hItem, 0, &bmButtonPlay, 16, 6); BUTTON_SetBitmapEx(hItem, 1, &bmButtonPlayPauseOff,6, 6); } break; } break; case ID_VIDEO_EXIT: switch(NCode) { case WM_NOTIFICATION_RELEASED: { GUI_EndDialog(pMsg->hWin, 0); } break; } break; case ID_VIDEO_PROGRESS: /* Notifications sent by 'Progress Bar' */ switch(NCode) { case WM_NOTIFICATION_CLICKED: { progress_bar = 1; hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_PROGRESS); ImageOffset = (Video_File.fsize * SLIDER_GetValue(hItem))/100; offset =ImageOffset - Video_File.fptr; time_start -= (offset / frame_speed); } break; case WM_NOTIFICATION_RELEASED: progress_bar = 0; break; } break; case NEXT_BUTTON_VIDEO: /* Notifications sent by 'Button' */ switch(NCode) { case WM_NOTIFICATION_RELEASED: if(VideoPlayer_State != VIDEO_IDLE) { ImageOffset = 0; VideoPlayer_State = VIDEO_PLAY; time_start = GUI_GetTime(); f_close(&Video_File); goto_next_file(); hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_FILE); TEXT_SetText(hItem, (char *)FILEMGR_FileList.file[FILEMGR_FileList.idx].line); hItem = WM_GetDialogItem(pMsg->hWin, PLAY_BUTTON_VIDEO); BUTTON_SetBitmapEx(hItem, 0, &bmButtonPlay, 16, 6); BUTTON_SetBitmapEx(hItem, 1, &bmButtonPlayPauseOff,16, 6); } break; } break; case STOP_BUTTON_VIDEO: /* Notifications sent by 'Button' */ switch(NCode) { case WM_NOTIFICATION_RELEASED: VideoPlayer_State = VIDEO_IDLE; f_close(&Video_File); hItem = WM_GetDialogItem(pMsg->hWin, PLAY_BUTTON_VIDEO); BUTTON_SetBitmapEx(hItem, 0, &bmButtonPlayPauseOn, 16, 6); BUTTON_SetBitmapEx(hItem, 1, &bmButtonPlayPauseOff,16, 6); break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
/********************************************************************* * * WIDGET_HandleActive */ int WIDGET_HandleActive(WM_HWIN hObj, WM_MESSAGE* pMsg) { int Diff, Notification; WIDGET* pWidget = WIDGET_H2P(hObj); switch (pMsg->MsgId) { case WM_WIDGET_SET_EFFECT: Diff = pWidget->pEffect->EffectSize; pWidget->pEffect = (const WIDGET_EFFECT*)pMsg->Data.p; Diff -= pWidget->pEffect->EffectSize; _UpdateChildPostions(hObj, Diff); WM_InvalidateWindow(hObj); return 0; /* Message handled -> Return */ case WM_GET_ID: pMsg->Data.v = pWidget->Id; return 0; /* Message handled -> Return */ case WM_PID_STATE_CHANGED: if (pWidget->State & WIDGET_STATE_FOCUSSABLE) { const WM_PID_STATE_CHANGED_INFO * pInfo = (const WM_PID_STATE_CHANGED_INFO*)pMsg->Data.p; if (pInfo->State) { WM_SetFocus(hObj); } } break; case WM_TOUCH_CHILD: /* A descendent (child) has been touched or released. If it has been touched, we need to get to top. */ { const WM_MESSAGE * pMsgOrg; const GUI_PID_STATE * pState; pMsgOrg = (const WM_MESSAGE*)pMsg->Data.p; /* The original touch message */ pState = (const GUI_PID_STATE*)pMsgOrg->Data.p; if (pState) { /* Message may not have a valid pointer (moved out) ! */ if (pState->Pressed) { WM_BringToTop(hObj); return 0; /* Message handled -> Return */ } } } break; case WM_SET_ID: pWidget->Id = pMsg->Data.v; return 0; /* Message handled -> Return */ case WM_SET_FOCUS: if (pMsg->Data.v == 1) { WIDGET_SetState(hObj, pWidget->State | WIDGET_STATE_FOCUS); Notification = WM_NOTIFICATION_GOT_FOCUS; } else { WIDGET_SetState(hObj, pWidget->State & ~WIDGET_STATE_FOCUS); Notification = WM_NOTIFICATION_LOST_FOCUS; } WM_NotifyParent(hObj, Notification); pMsg->Data.v = 0; /* Focus change accepted */ return 0; case WM_GET_ACCEPT_FOCUS: pMsg->Data.v = (pWidget->State & WIDGET_STATE_FOCUSSABLE) ? 1 : 0; /* Can handle focus */ return 0; /* Message handled */ case WM_GET_INSIDE_RECT: WIDGET__GetInsideRect(pWidget, (GUI_RECT*)pMsg->Data.p); return 0; /* Message handled */ } return 1; /* Message NOT handled */ }
/** * @brief Callback routine of the dialog * @param pMsg: pointer to a data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int Id, NCode; switch (pMsg->MsgId) { case WM_INIT_DIALOG: /* Initialization of 'System Information' */ hItem = pMsg->hWin; FRAMEWIN_SetFont(hItem, GUI_FONT_13HB_ASCII); /* Initialization of 'Image' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_INFO); IMAGE_SetBitmap(hItem, bminfo); /* Initialization of 'Board : STM324x9I' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_BOARD); TEXT_SetFont(hItem, GUI_FONT_13HB_ASCII); TEXT_SetTextColor(hItem, 0x00804000); /* Initialization of 'Core: STM32F-4 Series' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_CORE); TEXT_SetFont(hItem, GUI_FONT_13HB_ASCII); TEXT_SetTextColor(hItem, 0x00804000); /* Initialization of 'Firmware Version : 1.0' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_CPU); TEXT_SetFont(hItem, GUI_FONT_13HB_ASCII); TEXT_SetTextColor(hItem, 0x00804000); /* Initialization of 'Copyright 2013 STMicroelectronics' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_VERSION); TEXT_SetFont(hItem, GUI_FONT_13HB_ASCII); TEXT_SetTextColor(hItem, 0x00804000); /* Initialization of 'CPU Speed : 168MHz' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_COPYRIGHT); TEXT_SetFont(hItem, GUI_FONT_13HB_ASCII); TEXT_SetTextColor(hItem, 0x00804000); /* Initialization of 'Close' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_INFO_CLOSE); BUTTON_SetFont(hItem, GUI_FONT_13HB_ASCII); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */ NCode = pMsg->Data.v; /* Notification code */ switch (NCode) { case WM_NOTIFICATION_RELEASED: /* React only if released */ switch (Id) { case ID_BUTTON_INFO_CLOSE: GUI_EndDialog(pMsg->hWin, 0); break; } break; case WM_NOTIFICATION_CHILD_DELETED: WM_NotifyParent(WM_GetParent(pMsg->hWin), 0x500); break; } break; default: WM_DefaultProc(pMsg); break; } }
/********************************************************************* * * _SliderPressed */ static void _SliderPressed(SLIDER_Handle hObj, SLIDER_Obj* pObj) { WIDGET_OrState(hObj, SLIDER_STATE_PRESSED); if (pObj->Widget.Win.Status & WM_SF_ISVIS) { WM_NotifyParent(hObj, WM_NOTIFICATION_CLICKED); } }
/** * @brief Callback routine of the dialog * @param pMsg: pointer to a data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int Id, NCode; RTC_TimeTypeDef RTC_TimeStructure; RTC_DateTypeDef RTC_DateStructure; uint8_t sec, min, hour, day, month; uint16_t year; uint8_t offset, max; static uint8_t TempStr[50]; switch (pMsg->MsgId) { case WM_PAINT: break; case WM_INIT_DIALOG: RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure); sec = RTC_TimeStructure.RTC_Seconds; min = RTC_TimeStructure.RTC_Minutes; hour = RTC_TimeStructure.RTC_Hours; RTC_GetDate(RTC_Format_BIN, &RTC_DateStructure); year = RTC_DateStructure.RTC_Year + 2000; month = RTC_DateStructure.RTC_Month; day = RTC_DateStructure.RTC_Date; /* Initialization of 'System Information' */ hItem = pMsg->hWin; FRAMEWIN_SetFont(hItem, GUI_FONT_13B_ASCII); /* Initialization of 'Close' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CLOSE_CLOCK); BUTTON_SetFont(hItem, GUI_FONT_13B_ASCII); /* Set date in text mode */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_DATE); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextColor(hItem, 0x00804000); WM_CreateWindowAsChild(80, 45, 354, 23, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbClockWindow , 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_CLOCK); TEXT_SetFont(hItem, &GUI_FontBauhaus9332); TEXT_SetTextColor(hItem, 0x00804000); /* Set Init values */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_DATE); /* Write date and clock */ sprintf((char *)TempStr, "%02d, %s, %04d",day , strMonth[month-1], year); TEXT_SetText(hItem, (char *)TempStr); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_CLOCK); sprintf((char *)TempStr, "%02d:%02d:%02d",hour , min, sec); TEXT_SetText(hItem, (char *)TempStr); GetDateOffset (year, month, &offset , &max); CALENDAR_SetDefaultSize(CALENDAR_SI_HEADER, 25 ); CALENDAR_SetDefaultSize(CALENDAR_SI_CELL_X, 30 ); CALENDAR_SetDefaultSize(CALENDAR_SI_CELL_Y, 20 ); CALENDAR_SetDefaultFont(CALENDAR_FI_CONTENT,GUI_FONT_16B_1 ); CALENDAR_SetDefaultFont(CALENDAR_FI_HEADER, GUI_FONT_16B_1) ; CALENDAR_Create(pMsg->hWin, 15, 70, year, month, day, 2, ID_CALENDAR, WM_CF_SHOW); WM_InvalidateWindow(pMsg->hWin); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */ NCode = pMsg->Data.v; /* Notification code */ switch (NCode) { case WM_NOTIFICATION_RELEASED: /* React only if released */ switch (Id) { case ID_BUTTON_CLOSE_CLOCK: GUI_EndDialog(pMsg->hWin, 0); break; case ID_BUTTON_SETTINGS_CLOCK: GUI_CreateDialogBox(_aDialogSettingsCreate, GUI_COUNTOF(_aDialogSettingsCreate), &_cbDialogSettings, pMsg->hWin, 0, 0); hNumPad = GUI_CreateDialogBox(_aDialogNumPad, GUI_COUNTOF(_aDialogNumPad), _cbDialogNumPad, WM_GetDesktopWindowEx(1), 0, 0); /* Create the numpad dialog */ WM_SetStayOnTop(hNumPad, 1); break; } break; case WM_NOTIFICATION_CHILD_DELETED: WM_NotifyParent(WM_GetParent(pMsg->hWin), 0x500); break; } break; default: WM_DefaultProc(pMsg); break; } }
/********************************************************************* * * _SliderReleased */ static void _SliderReleased(SLIDER_Handle hObj, SLIDER_Obj* pObj) { WIDGET_AndState(hObj, SLIDER_STATE_PRESSED); if (pObj->Widget.Win.Status & WM_SF_ISVIS) { WM_NotifyParent(hObj, WM_NOTIFICATION_RELEASED); } }