/********************************************************************* * * MENU_Attach */ void MENU_Attach(MENU_Handle hObj, WM_HWIN hDestWin, int x, int y, int xSize, int ySize, int Flags) { GUI_USE_PARA(Flags); if (hObj) { MENU_Obj* pObj; WM_LOCK(); pObj = MENU_H2P(hObj); if (pObj) { pObj->Width = ((xSize > 0) ? xSize : 0); pObj->Height = ((ySize > 0) ? ySize : 0); WM_AttachWindowAt(hObj, hDestWin, x, y); MENU__ResizeMenu(hObj, pObj); } WM_UNLOCK(); } }
/********************************************************************* * * MENU_Popup */ void MENU_Popup(MENU_Handle hObj, WM_HWIN hDestWin, int x, int y, int xSize, int ySize, int Flags) { GUI_USE_PARA(Flags); if (hObj && hDestWin) { MENU_Obj* pObj; WM_LOCK(); pObj = MENU_H2P(hObj); if (pObj) { pObj->Flags |= MENU_SF_POPUP; pObj->Width = ((xSize > 0) ? xSize : 0); pObj->Height = ((ySize > 0) ? ySize : 0); x += WM_GetWindowOrgX(hDestWin); y += WM_GetWindowOrgY(hDestWin); MENU_SetOwner(hObj, hDestWin); WM_AttachWindowAt(hObj, WM_HBKWIN, x, y); MENU__SendMenuMessage(hDestWin, hObj, MENU_ON_OPEN, 0); } WM_UNLOCK(); } }
/** * @brief Callback function of the image frame * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbImageWindow(WM_MESSAGE * pMsg) { WM_HWIN hItem; GUI_RECT r; int Id; const GUI_PID_STATE * pState; switch (pMsg->MsgId) { case WM_TOUCH: pState = (const GUI_PID_STATE *)pMsg->Data.p; if(pImageList->ptr > 0) { if (pState) { if (pState->Pressed == 1) { IMAGE_Enlarge ^= 1; if (IMAGE_Enlarge) { WM_AttachWindowAt(pMsg->hWin, WM_HBKWIN, 0, 0); WM_SetSize(pMsg->hWin, LCD_GetXSize(), LCD_GetYSize()); } else { WM_AttachWindowAt(pMsg->hWin, IMAGE_hWin, 6, 6); WM_SetSize(pMsg->hWin, 220, 134); } WM_InvalidateWindow(pMsg->hWin); } } } break; case WM_PAINT: WM_GetInsideRect(&r); GUI_ClearRectEx(&r); if (pImageList->ptr > 0) { if(_DrawImage(&Image_File, IMAGE_Enlarge, IMAGE_Type) > 0) { f_close(&Image_File); GUI_ClearRectEx(&r); GUI_DispStringAt("Error : Image cannot be displayed", 20, 80); if(hTimerTime != 0) { slideshow_state = OFF; hItem = WM_GetDialogItem(IMAGE_hWin, ID_SLIDE_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); WM_DeleteTimer(hTimerTime); hTimerTime = 0; } } } break; case WM_TIMER: Id = WM_GetTimerId(pMsg->Data.v); if(Id == ID_SLIDER_TIMER) { if(pImageList->ptr > 1) { if (file_pos < (pImageList->ptr - 1)) { file_pos++; } else if (file_pos == (pImageList->ptr - 1)) { file_pos=0; } if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { IMAGE_Type = IMAGE_TYPE_BMP; } else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { IMAGE_Type = IMAGE_TYPE_JPG; } f_close(&Image_File); f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); WM_InvalidateWindow(imFrame); hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST); LISTBOX_SetSel(hItem, file_pos); } WM_RestartTimer(pMsg->Data.v, (ImSettings.b.ss_timer * 1000)); } else if (Id == ID_PLAYLIST_TIMER) { playlist_select = 0; } break; case WM_DELETE: if(hTimerTime != 0) { WM_DeleteTimer(hTimerTime); hTimerTime = 0; } break; default: WM_DefaultProc(pMsg); } }
/** * @brief Callback function of the MJPEG frame * @param pMsg: pointer to a data structure of type WM_MESSAGE * @retval None */ static void _cbVideoWindow(WM_MESSAGE * pMsg) { char temp[20]; static WM_HTIMER hTimerTime; WM_HWIN hItem; const GUI_PID_STATE * pState; GUI_RECT r; WM_GetInsideRect(&r); switch (pMsg->MsgId) { case WM_TOUCH: if(VideoPlayer_State == VIDEO_PLAY) { pState = (const GUI_PID_STATE *)pMsg->Data.p; if (pState) { if (pState->Pressed == 1) { VIDEO_Enlarge ^= 1; if(VIDEO_Enlarge) { GUI_SetOrientation(GUI_SWAP_XY | GUI_MIRROR_Y); TS_Orientation = 1; WM_AttachWindowAt(pMsg->hWin, WM_GetDesktopWindowEx(1), 0, 0); WM_SetSize(pMsg->hWin, LCD_GetXSize(), LCD_GetYSize()); } else { WM_AttachWindow(pMsg->hWin, bkparent); GUI_SetOrientation(0); TS_Orientation = 0; WM_InvalidateWindow(bkparent); WM_AttachWindowAt(pMsg->hWin, VIDEO_hWin, 5, 16); WM_SetSize(pMsg->hWin,230, 170); do_clear = 1; } } } } break; case WM_CREATE: /* Create timer */ hTimerTime = WM_CreateTimer(pMsg->hWin, 0, 50, 0); break; case WM_TIMER: WM_InvalidateWindow(pMsg->hWin); WM_RestartTimer(pMsg->Data.v, 0); break; case WM_DELETE: WM_DeleteTimer(hTimerTime); break; case WM_PAINT: if(do_clear) { GUI_ClearRectEx(&r); do_clear = 0; } if(VideoPlayer_State == VIDEO_PLAY) { if(_PlayMJPEG(&Video_File) < 0) { VideoPlayer_State = VIDEO_PLAY; ImageOffset = 0; time_start = GUI_GetTime(); f_close(&Video_File); goto_next_file(); hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_VIDEO_FILE); TEXT_SetText(hItem, (char *)FILEMGR_FileList.file[FILEMGR_FileList.idx].line); } hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_VIDEO_PROGRESS); if (progress_bar == 0) { SLIDER_SetValue(hItem, (ImageOffset * 100 )/ Video_File.fsize); } hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_VIDEO_DURATION); duration = (GUI_GetTime() - time_start )/1000; if(duration < 0) duration = 0; sprintf(temp,"%02d:%02d", duration/60, duration%60); TEXT_SetText(hItem, temp); } else if(VideoPlayer_State == VIDEO_IDLE) { GUI_ClearRectEx(&r); } break; default: WM_DefaultProc(pMsg); } }