/** * @brief Audio direct open * @param filename: audio file name * @retval None */ static void AudioDirectOpen(char *filename) { WM_HWIN hItem; static char tmp[FILEMGR_FILE_NAME_SIZE]; pWavList->ptr = 0; uint32_t duration; AUDIOPLAYER_Init(); AUDIOPLAYER_hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_GetDesktopWindowEx(1), 0, 26); if(AUDIOPLAYER_hWin != 0) { if(AUDIOPLAYER_GetFileInfo(filename, &WavInfo) == 0) { /* Update Play list */ pWavList->ptr = 0; file_pos = 0; FILEMGR_GetFileOnly (tmp, filename); hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST); strcpy((char *)pWavList->file[pWavList->ptr].name, filename); LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, pWavList->ptr, tmp); duration = WavInfo.FileSize / WavInfo.ByteRate; sprintf((char *)tmp , "%02lu:%02lu", duration/60, duration%60 ); LISTVIEW_SetItemText(hItem, 1, pWavList->ptr, tmp); pWavList->ptr++; LISTVIEW_SetSel(hItem, 0); _PlayFile(filename); } } }
/** * @brief Notify the end of wav file. * @param None. * @retval Audio state. */ AUDIOPLAYER_ErrorTypdef AUDIOPLAYER_NotifyEndOfFile(void) { WM_HWIN hItem; AUDIOPLAYER_Stop(); if(PlayerSettings.b.repeat != REPEAT_NONE) { if (PlayerSettings.b.repeat == REPEAT_ALL) { if(file_pos < (pWavList->ptr - 1)) { file_pos++; } else { file_pos = 0; } LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos); } _PlayFile((char *)pWavList->file[file_pos].name); } else { PlayerSettings.b.pause = PLAY_ACTIVE; hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_PLAY_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); } return AUDIOPLAYER_ERROR_NONE; }
/** * @brief Video direct open * @param filename: video file name * @retval None */ static void VideoDirectOpen(char *filename) { WM_HWIN hItem; int ItemNbr; static char tmp[FILEMGR_FILE_NAME_SIZE]; VIDEOPLAYER_hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_GetDesktopWindowEx(1), 0, 26); if(VIDEOPLAYER_hWin != 0) { pVideoList->ptr = 0; FILEMGR_GetFileOnly (tmp, filename); hItem = WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST); /* Update Playlist */ strcpy((char *)pVideoList->file[pVideoList->ptr].name, filename); ItemNbr = LISTVIEW_GetNumRows(hItem); while(ItemNbr--) { LISTVIEW_DeleteRow(hItem, ItemNbr); } LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, pVideoList->ptr, tmp); pVideoList->ptr++; file_pos = 0; LISTVIEW_SetSel(hItem, 0); _StartPlay((char *)pVideoList->file[file_pos].name); WM_InvalidateWindow(hFrame); } }
/** * @brief Callback function for movie player. Uses multiple buffering if * available to avoid tearing effects. * @param hMem: pointer to parent handle * @param Notification: notification ID * @param CurrentFrame: current playing frame * @retval None */ void _cbNotify(GUI_HMEM hMem, int Notification, U32 CurrentFrame) { long progress; WM_HWIN hItem; switch (Notification) { case GUI_MOVIE_NOTIFICATION_PREDRAW: GUI_MULTIBUF_Begin(); break; case GUI_MOVIE_NOTIFICATION_POSTDRAW: GUI_MULTIBUF_End(); progress = 100 * GUI_MOVIE_GetFrameIndex(hMovie)/ Video_Info.NumFrames; hItem = WM_GetDialogItem(VIDEOPLAYER_hWin, ID_PROGRESS_SLIDER); SLIDER_SetValue(hItem, progress); break; case GUI_MOVIE_NOTIFICATION_STOP: if(GUI_MOVIE_GetFrameIndex(hMovie) >= (Video_Info.NumFrames - 1)) { if( FullScreen == 1) { WM_InvalidateWindow(hBigFrame); WM_Update(hBigFrame); } _StopPlay(); if(PlayerSettings.b.repeat != REPEAT_NONE) { if (PlayerSettings.b.repeat == REPEAT_ALL) { if(Video_file_pos < (pVideoList->ptr - 1)) { Video_file_pos++; } else { Video_file_pos = 0; } LISTVIEW_SetSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST), Video_file_pos); } _StartPlay((char *)pVideoList->file[Video_file_pos].name); } else { hItem = WM_GetDialogItem(VIDEOPLAYER_hWin, ID_PLAY_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); } } break; } }
/**监控列表 LISTVIEW 的监听器(回调函数) * */ static void myListViewListener(WM_MESSAGE* pMsg) { const WM_KEY_INFO * pInfo; WM_HWIN thisListView = pMsg->hWin; switch(pMsg->MsgId) { // case WM_PAINT: // // GUI_SetColor(GUI_BLACK); // GUI_SetFont(&GUI_Font24_1); // GUI_DispStringAt("egg",330,160); // GUI_DispStringAt("eggg",400,450); // LISTVIEW_Callback(pMsg); // break; case WM_SET_FOCUS: if(LISTVIEW_GetNumRows(pMsg->hWin) && (LISTVIEW_GetSel(pMsg->hWin)<0)) LISTVIEW_SetSel(pMsg->hWin, 0); LISTVIEW_Callback(pMsg); break; case WM_KEY: pInfo = (WM_KEY_INFO*)pMsg->Data.p; switch(pInfo->Key) { case GUI_KEY_UP: case GUI_KEY_DOWN: LISTVIEW_Callback(pMsg); showSelectedBoatInfo(thisListView); break; case GUI_KEY_LEFT: WM_SetFocus(menuWin); break; case GUI_KEY_MENU: // WM_BringToBottom(thisListView); WM_BringToTop(hDlg_FishMap); WM_SetFocus(hDlg_FishMap); break; default: LISTVIEW_Callback(pMsg); break; } break; default: LISTVIEW_Callback(pMsg); break; } }
/********************************************************************* * * _SetSelFromPos */ static void _SetSelFromPos(LISTVIEW_Handle hObj, LISTVIEW_Obj* pObj, const GUI_PID_STATE* pState) { GUI_RECT Rect; int x, y, HeaderHeight; HeaderHeight = HEADER_GetHeight(pObj->hHeader); WM_GetInsideRectExScrollbar(hObj, &Rect); x = pState->x - Rect.x0; y = pState->y - Rect.y0 - HeaderHeight; Rect.x1 -= Rect.x0; Rect.y1 -= Rect.y0; if ((x >= 0) && (x <= Rect.x1) && (y >= 0) && (y <= (Rect.y1 - HeaderHeight))) { unsigned Sel; Sel = (y / LISTVIEW__GetRowDistY(pObj)) + pObj->ScrollStateV.v; if (Sel < GUI_ARRAY_GetNumItems(&pObj->RowArray)) { LISTVIEW_SetSel(hObj, Sel); } } }
/********************************************************************* * * LISTVIEW_DisableSort * * Purpose: * Disables sorting for the given listview object. */ void LISTVIEW_DisableSort(LISTVIEW_Handle hObj) { if (hObj) { LISTVIEW_Obj * pObj; WM_LOCK(); pObj = LISTVIEW_H2P(hObj); if (pObj->hSort) { int Sel = _GetSelUnsorted(pObj); _Free(pObj->hSort); pObj->hSort = 0; pObj->SortIndex = -1; pObj->IsPresorted = 0; pObj->IsSorted = 0; HEADER_SetDirIndicator(pObj->hHeader, -1, 0); LISTVIEW_SetSel(hObj, Sel); LISTVIEW__InvalidateInsideArea(hObj, pObj); } WM_UNLOCK(); } }
static void LV_JumpToRowOf(WM_HWIN thisListView, int row) { int visibleRowNum = 0; /// 本页可见的列表项条目数 int orgIndex = 0; /// 本页起始列表项对应的SimpBerth索引 int i = 0; if(row+1 < N_boat){ row = N_boat -1; } visibleRowNum = (N_boat-1) % LV_PAGE_SIZE +1; orgIndex = N_boat - visibleRowNum; for(i=0; i<visibleRowNum; i++){ disttostr(pStrBuf, SimpBerthes[orgIndex].Dist); LISTVIEW_SetItemText(thisListView, LV_AllList_Col_DIST, i, pStrBuf); sprintf(pStrBuf, "%09ld", SimpBerthes[orgIndex].pBerth->Boat.user_id); LISTVIEW_SetItemText(thisListView, LV_AllList_Col_MMSI, i, pStrBuf); if(MNTState_None == SimpBerthes[orgIndex].pBerth->mntState){ LISTVIEW_SetItemText(thisListView, LV_AllList_Col_STT, i, "啊"); } else{ LISTVIEW_SetItemText(thisListView, LV_AllList_Col_STT, i, "吖"); } } for(; i<LV_PAGE_SIZE; i++){ LISTVIEW_GetItemText(thisListView, LV_AllList_Col_MMSI, i, pStrBuf, 11); if(strlen(pStrBuf) > 0){ LISTVIEW_SetItemText(thisListView, LV_AllList_Col_DIST, i, ""); LISTVIEW_SetItemText(thisListView, LV_AllList_Col_MMSI, i, ""); LISTVIEW_SetItemText(thisListView, LV_AllList_Col_STT, i, ""); } } LISTVIEW_SetSel(thisListView, visibleRowNum -1); }
/**监控设置 LISTVIEW 的监听器(回调函数) * */ static void myListViewListener(WM_MESSAGE* pMsg) { const WM_KEY_INFO * pInfo; WM_HWIN thisListView = pMsg->hWin; WM_MESSAGE myMsg; int i = 0; MNT_BERTH * pIterator = NULL; int selectedRow = -1; int index = -1; switch(pMsg->MsgId) { case WM_SET_FOCUS: if(pMsg->Data.v) { if(LISTVIEW_GetNumRows(pMsg->hWin)) { LISTVIEW_SetSel(pMsg->hWin, 0); } if(pMntHeader) { myMsg.hWin = WM_GetClientWindow(mntSettingWin); myMsg.MsgId = USER_MSG_LV_MOVE; myMsg.Data.p = (void*)pMntHeader; WM_SendMessage(myMsg.hWin, &myMsg); } } LISTVIEW_Callback(pMsg); break; case WM_KEY: pInfo = (WM_KEY_INFO*)pMsg->Data.p; switch(pInfo->Key) { case GUI_KEY_PWM_INC: WM_SendMessageNoPara(subWins[3], USER_MSG_DIM); break; case GUI_KEY_UP: case GUI_KEY_DOWN: LISTVIEW_Callback(pMsg); selectedRow = LISTVIEW_GetSel(thisListView); pIterator = pMntHeader; for(index=0; index < selectedRow; index++) { pIterator = pIterator->pNext; } myMsg.hWin = WM_GetClientWindow(mntSettingWin); myMsg.MsgId = USER_MSG_LV_MOVE; myMsg.Data.p = (void*)pIterator; WM_SendMessage(myMsg.hWin, &myMsg); break; case GUI_KEY_RIGHT: if(pMntHeader) { selectedRow = LISTVIEW_GetSel(thisListView); pIterator = pMntHeader; for(index=0; index < selectedRow; index++) { pIterator = pIterator->pNext; } if(pIterator) { if(pIterator->chsState == MNTState_Monitored) { pIterator->chsState = MNTState_Choosen; LISTVIEW_SetItemText(thisListView, 2, selectedRow, "吖"); } else if(pIterator->chsState == MNTState_None) { pIterator->chsState = MNTState_Default; LISTVIEW_SetItemText(thisListView, 2, selectedRow, "吖"); } } // else // { // INFO("Err!"); // } myMsg.hWin = WM_GetClientWindow(mntSettingWin); myMsg.hWinSrc = pMsg->hWin; myMsg.Data.p = (void*)pIterator; myMsg.MsgId = USER_MSG_FOCUS; WM_SendMessage(myMsg.hWin, &myMsg); } // WM_SetFocus(mntSettingWin); break; case GUI_KEY_ENTER: selectedRow = LISTVIEW_GetSel(thisListView); pIterator = pMntHeader; for(index=0;index<selectedRow;index++) { pIterator = pIterator->pNext; } switch(pIterator->chsState) { case MNTState_Choosen: pIterator->chsState = MNTState_Monitored; LISTVIEW_SetItemText(thisListView, 2, selectedRow, "啊"); break; case MNTState_Default: pIterator->chsState = MNTState_None; LISTVIEW_SetItemText(thisListView, 2, selectedRow, "啊"); break; case MNTState_None: pIterator->chsState = MNTState_Default; LISTVIEW_SetItemText(thisListView, 2, selectedRow, "吖"); break; default: pIterator->chsState = MNTState_Choosen; LISTVIEW_SetItemText(thisListView, 2, selectedRow, "吖"); break; } break; case GUI_KEY_BACKSPACE: if(pMntHeader) { pIterator = pMntHeader; while(pIterator) { pIterator->chsState = MNTState_Monitored; pIterator = pIterator->pNext; } myMsg.hWin = WM_GetClientWindow(menuWin); myMsg.MsgId = USER_MSG_DFULT_CNT; myMsg.Data.v = 0; WM_SendMessage(myMsg.hWin, &myMsg); } WM_SetFocus(menuWin); break; case GUI_KEY_MENU: WM_BringToTop(mapWin); WM_SetFocus(mapWin); break; default: LISTVIEW_Callback(pMsg); break; } break; default: LISTVIEW_Callback(pMsg); break; } }
/** * @brief Callback routine of the dialog * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int NCode; int Id, ItemNbr; int result; int duration, volume, index; static char tmp[FILEMGR_FILE_NAME_SIZE]; switch (pMsg->MsgId) { case WM_INIT_DIALOG: pWavList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef)); pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO)); pWavList->ptr = 0; /* Initialization of 'Listview' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST); LISTVIEW_AddColumn(hItem, 132, "Track", GUI_TA_VCENTER | GUI_TA_LEFT); LISTVIEW_AddColumn(hItem, 55, "Duration", GUI_TA_VCENTER | GUI_TA_RIGHT); LISTVIEW_SetGridVis(hItem, 0); LISTVIEW_SetAutoScrollV(hItem, 1); LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_UNSEL, GUI_BLACK); LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_UNSEL, GUI_CYAN); /* Title Initialization in play list */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TITLE_CAPTION); TEXT_SetText(hItem, "TITLE:"); TEXT_SetTextColor(hItem, GUI_CYAN); /* Title Initialization in play list */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TITLE); TEXT_SetTextColor(hItem, GUI_CYAN); /* Duration */ hItem = WM_GetDialogItem(pMsg->hWin, ID_ELAPSED_TIME); TEXT_SetText(hItem, "00:00"); TEXT_SetFont(hItem, GUI_FONT_20B_1); TEXT_SetTextColor(hItem, GUI_LIGHTGRAY); /* Author initialization */ hItem = WM_GetDialogItem(pMsg->hWin, ID_AUTHOR_CAPTION); TEXT_SetText(hItem, "AUTHOR:"); TEXT_SetTextColor(hItem, GUI_CYAN); /* Author */ hItem = WM_GetDialogItem(pMsg->hWin, ID_AUTHOR); TEXT_SetText(hItem, ""); TEXT_SetTextColor(hItem, GUI_CYAN); /* Sampling Rate */ hItem = WM_GetDialogItem(pMsg->hWin, ID_SAMPLING_CAPTION); TEXT_SetText(hItem, "SAMPLING:"); TEXT_SetTextColor(hItem, GUI_CYAN); /* Sampling Rate Value */ hItem = WM_GetDialogItem(pMsg->hWin, ID_SAMPLING_VALUE); TEXT_SetText(hItem, ""); TEXT_SetTextColor(hItem, GUI_CYAN); /* Duration */ hItem = WM_GetDialogItem(pMsg->hWin, ID_TOTAL_TIME); TEXT_SetText(hItem, "00:00"); TEXT_SetTextColor(hItem, GUI_CYAN); /* Initialization of 'WAV' Button */ hItem = WM_GetDialogItem(pMsg->hWin, ID_WAV_BUTTON); BUTTON_SetFont(hItem, GUI_FONT_24_1); /* Initialization of 'Play List' Button */ hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_LIST_BUTTON); BUTTON_SetFont(hItem, GUI_FONT_24_1); /* Initialization of 'Add' Button */ hItem = WM_GetDialogItem(pMsg->hWin, ID_ADD_BUTTON); BUTTON_SetFont(hItem, GUI_FONT_24_1); volume = AUDIOPLAYER_GetVolume(); hItem = WM_GetDialogItem(pMsg->hWin, ID_VOLUME_SLIDER); SLIDER_SetValue(hItem, volume); hItem = WM_GetDialogItem(pMsg->hWin, ID_DURATION_SLIDER); SLIDER_SetNumTicks(hItem, 25); PlayerSettings.d32 = k_BkupRestoreParameter(CALIBRATION_AUDIOPLAYER_SETTING_BKP); PlayerSettings.b.mute = MUTE_OFF; PlayerSettings.b.pause = PLAY_ACTIVE; hItem = BUTTON_CreateEx(25, 100, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_REPEAT_BUTTON); WM_SetCallback(hItem, _cbButton_repeat); hItem = BUTTON_CreateEx(100, 95, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_MUTE_BUTTON); WM_SetCallback(hItem, _cbButton_speaker); hItem = BUTTON_CreateEx(22, 147, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_STOP_BUTTON); WM_SetCallback(hItem, _cbButton_stop); hItem = BUTTON_CreateEx(89, 147, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_PREVIOUS_BUTTON); WM_SetCallback(hItem, _cbButton_previous); hItem = BUTTON_CreateEx(148, 140, 50, 50, pMsg->hWin, WM_CF_SHOW, 0, ID_PLAY_BUTTON); WM_SetCallback(hItem, _cbButton_play); hItem = BUTTON_CreateEx(222, 147, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_NEXT_BUTTON); WM_SetCallback(hItem, _cbButton_next); hItem = WM_GetClientWindow(pMsg->hWin); hItem = BUTTON_CreateEx(20, 205, 50, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_WAV_BUTTON); WM_SetCallback(hItem, _cbButton_open); hItem = BUTTON_CreateEx(80, 205, 50, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_ADD_BUTTON); WM_SetCallback(hItem, _cbButton_add); hItem = BUTTON_CreateEx(235, 205, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_CLOSE_BUTTON); WM_SetCallback(hItem, _cbButton_close); hTimerWin = WM_CreateWindowAsChild(0, 100, 10, 10, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbAudioProcess, 0); hItem = WM_CreateWindowAsChild(15, 75, 255, 20, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND, _cbDrawProgressSlider, 0); hItem = WM_CreateWindowAsChild(145, 105, 125, 20, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND, _cbDrawVolumeSlider, 0); WM_CreateWindowAsChild(479, 250, 1, 1, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMediaConnection , 0); break; case WM_PAINT: GUI_SetBkColor(GUI_BLACK); GUI_ClearRect(15, 6, 270, 70); DrawRect3D(15, 135, 255, 60); DrawRect3D(15, 200, 255, 40); break; case WM_DELETE: AUDIOPLAYER_DeInit(); k_free(pWavList); k_free(pFileInfo); pWavList->ptr = 0; PlayerSettings.b.mute = MUTE_OFF; PlayerSettings.b.pause = PLAY_ACTIVE; k_BkupSaveParameter(CALIBRATION_AUDIOPLAYER_SETTING_BKP, PlayerSettings.d32); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { /* Notification sent by "Button_Close" */ case ID_CLOSE_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: GUI_EndDialog(pMsg->hWin, 0); break; } break; /* Notifications sent by 'Repeat' Button */ case ID_REPEAT_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_REPEAT_BUTTON); if(PlayerSettings.b.repeat == REPEAT_NONE) { PlayerSettings.b.repeat = REPEAT_ONCE; } else if(PlayerSettings.b.repeat == REPEAT_ONCE) { PlayerSettings.b.repeat = REPEAT_ALL; } else if(PlayerSettings.b.repeat == REPEAT_ALL) { PlayerSettings.b.repeat = REPEAT_NONE; } } break; /* Notifications sent by 'Mute' Button */ case ID_MUTE_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_MUTE_BUTTON); if(PlayerSettings.b.mute == MUTE_OFF) { AUDIOPLAYER_Mute(MUTE_ON); PlayerSettings.b.mute = MUTE_ON; } else { AUDIOPLAYER_Mute(MUTE_OFF); PlayerSettings.b.mute = MUTE_OFF; } } break; /* Notifications sent by 'Volume' Slider */ case ID_VOLUME_SLIDER: if(NCode == WM_NOTIFICATION_VALUE_CHANGED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_VOLUME_SLIDER); AUDIOPLAYER_SetVolume(SLIDER_GetValue(hItem)); if(PlayerSettings.b.mute == MUTE_ON) { AUDIOPLAYER_Mute(MUTE_OFF); PlayerSettings.b.mute = MUTE_OFF; } } break; /* Notifications sent by 'progress' Slider */ case ID_DURATION_SLIDER: if(NCode == WM_NOTIFICATION_CLICKED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_DURATION_SLIDER); AUDIOPLAYER_SetPosition(SLIDER_GetValue(hItem)); if(PlayerSettings.b.mute == MUTE_ON) { AUDIOPLAYER_Mute(MUTE_ON); } } break; /* Notifications sent by 'ListView' Slider */ case ID_WAVFILE_LIST: if(NCode == WM_NOTIFICATION_CLICKED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST); index = LISTVIEW_GetSel(hItem); if(index < pWavList->ptr) { if(playlist_select == 0) { hPlaylistTimer = WM_CreateTimer(hTimerWin, ID_PLAYLIST_TIMER, 500, 0); playlist_select = (index + 1); } else if(playlist_select == (index + 1)) { WM_DeleteTimer(hPlaylistTimer); hPlaylistTimer = 0; playlist_select = 0; if(index < pWavList->ptr) { if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { AUDIOPLAYER_Stop(); } PlayerSettings.b.pause = PLAY_ACTIVE; hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); file_pos = index; _PlayFile((char *)pWavList->file[index].name); } } } } break; /* Notifications sent by 'Play' Button */ case ID_PLAY_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { if(AUDIOPLAYER_GetState() == AUDIOPLAYER_STOP) { if(pWavList->ptr > 0) { _PlayFile((char *)pWavList->file[file_pos].name); LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos); } else { pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_audio; hItem = CHOOSEFILE_Create(pMsg->hWin, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Open an audio file", 0, pFileInfo); WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { if((strstr(pFileInfo->pRoot, ".wav")) || (strstr(pFileInfo->pRoot, ".WAV"))) { if(AUDIOPLAYER_GetFileInfo(pFileInfo->pRoot, &WavInfo) == 0) { if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { /* Stop current audio sample */ AUDIOPLAYER_Stop(); } pWavList->ptr = 0; file_pos = 0; strcpy((char *)pWavList->file[pWavList->ptr].name, pFileInfo->pRoot); FILEMGR_GetFileOnly (tmp, pFileInfo->pRoot); hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST); /* Update Play list */ strcpy((char *)pWavList->file[pWavList->ptr].name, pFileInfo->pRoot); ItemNbr = LISTVIEW_GetNumRows(hItem); while(ItemNbr--) { LISTVIEW_DeleteRow(hItem, ItemNbr); } LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, pWavList->ptr, tmp); duration = WavInfo.FileSize / WavInfo.ByteRate; sprintf((char *)tmp , "%02d:%02d", duration/60, duration%60 ); LISTVIEW_SetItemText(hItem, 1, pWavList->ptr, tmp); pWavList->ptr++; LISTVIEW_SetSel(hItem, 0); _PlayFile(pFileInfo->pRoot); } } } } } else if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { PlayerSettings.b.pause = (PlayerSettings.b.pause == PLAY_ACTIVE ? PAUSE_ACTIVE : PLAY_ACTIVE); if(PlayerSettings.b.pause == PAUSE_ACTIVE) { AUDIOPLAYER_Pause(); } else if(PlayerSettings.b.pause == PLAY_ACTIVE) { AUDIOPLAYER_Resume(); } } } break; /* Notifications sent by 'STOP' Button */ case ID_STOP_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { if(PlayerSettings.b.pause == PAUSE_ACTIVE) { PlayerSettings.b.pause = PLAY_ACTIVE; } AUDIOPLAYER_Stop(); hItem = WM_GetDialogItem(pMsg->hWin, ID_ELAPSED_TIME); TEXT_SetText(hItem, "00:00"); hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); } } break; /* Notifications sent by 'Next' Button */ case ID_NEXT_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { if( pWavList->ptr > 0) { if(file_pos < (pWavList->ptr - 1)) { file_pos++; } else if(PlayerSettings.b.repeat == REPEAT_ALL) { file_pos = 0; } LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos); if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { if(PlayerSettings.b.pause == PAUSE_ACTIVE) { PlayerSettings.b.pause = PLAY_ACTIVE; hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); } AUDIOPLAYER_Stop(); _PlayFile((char *)pWavList->file[file_pos].name); } } } break; /* Notifications sent by 'Previous' Button */ case ID_PREVIOUS_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { if( pWavList->ptr > 0) { if(file_pos > 0) { file_pos--; } else if(PlayerSettings.b.repeat == REPEAT_ALL) { file_pos = (pWavList->ptr - 1); } LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos); if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { if(PlayerSettings.b.pause == PAUSE_ACTIVE) { PlayerSettings.b.pause = PLAY_ACTIVE; hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); } AUDIOPLAYER_Stop(); _PlayFile((char *)pWavList->file[file_pos].name); } } } break; /* Notifications sent by 'Open' Button */ case ID_WAV_BUTTON: switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_dir; hItem = CHOOSEFILE_Create(pMsg->hWin, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Add a folder", 0, pFileInfo); WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { _AddEntireFolder(pFileInfo->pRoot); } break; } break; /* Notifications sent by 'Add' Button */ case ID_ADD_BUTTON: switch(NCode) { case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_audio; hItem = CHOOSEFILE_Create(pMsg->hWin, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Add to playlist", 0, pFileInfo); WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { if((strstr(pFileInfo->pRoot, ".wav")) || (strstr(pFileInfo->pRoot, ".WAV"))) { if(pWavList->ptr < FILEMGR_LIST_DEPDTH) { strcpy((char *)pWavList->file[pWavList->ptr].name, pFileInfo->pRoot); FILEMGR_GetFileOnly (tmp, pFileInfo->pRoot); hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST); if(AUDIOPLAYER_GetFileInfo(pFileInfo->pRoot, &WavInfo) == 0) { LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, pWavList->ptr, tmp); duration = WavInfo.FileSize / WavInfo.ByteRate; sprintf((char *)tmp , "%02d:%02d", duration/60, duration%60 ); LISTVIEW_SetItemText(hItem, 1, pWavList->ptr, tmp); pWavList->ptr++; } } } } } break; } break; default: WM_DefaultProc(pMsg); break; } }
static void myListViewListener(WM_MESSAGE* pMsg) { const WM_KEY_INFO* pInfo; WM_HWIN thisListView = pMsg->hWin; WM_MESSAGE myMsg; int selectedRow = -1; long selectedMMSI = 0; int i = 0; Bool isAdded = FALSE; switch(pMsg->MsgId) { case WM_SET_FOCUS: if(pMsg->Data.v) { LV_Page = 0; LV_turnPage(thisListView, LV_Page); LISTVIEW_SetSel(thisListView, 0); WM_InvalidateRect(subWins[2], &lvIndicate); } else { WM_InvalidateRect(subWins[2], &lvIndicate); WM_InvalidateRect(subWins[2], &infoRect); } LISTVIEW_Callback(pMsg); break; case WM_KEY: pInfo = (WM_KEY_INFO*)pMsg->Data.p; switch(pInfo->Key) { case GUI_KEY_UP: selectedRow = LISTVIEW_GetSel(thisListView); if(selectedRow == 0) { if(LV_Page) { LV_Page--; LV_turnPage(thisListView, LV_Page); LISTVIEW_SetSel(thisListView, LV_PAGE_SIZE-1); } } else { LISTVIEW_SetSel(thisListView, selectedRow-1); } WM_InvalidateRect(subWins[2],&lvRect); WM_InvalidateRect(subWins[2],&lvIndicate); break; case GUI_KEY_DOWN: selectedRow = LISTVIEW_GetSel(thisListView); if(selectedRow == LV_PAGE_SIZE-1) { if(LV_Page < (N_boat-1)/LV_PAGE_SIZE) { LV_Page++; LV_turnPage(thisListView, LV_Page); LISTVIEW_SetSel(thisListView, 0); } } else if(LV_Page*LV_PAGE_SIZE+selectedRow+1 < N_boat) { LISTVIEW_SetSel(thisListView, selectedRow+1); } WM_InvalidateRect(subWins[2],&lvRect); WM_InvalidateRect(subWins[2],&lvIndicate); break; case GUI_KEY_RIGHT: if(LV_Page < (N_boat-1)/LV_PAGE_SIZE) { LV_Page++; LV_turnPage(thisListView, LV_Page); LISTVIEW_SetSel(thisListView, 0); } WM_InvalidateRect(subWins[2],&lvRect); WM_InvalidateRect(subWins[2],&lvIndicate); break; case GUI_KEY_LEFT: if(LV_Page > 0) { LV_Page--; LV_turnPage(thisListView, LV_Page); LISTVIEW_SetSel(thisListView, 0); } WM_InvalidateRect(subWins[2],&lvRect); WM_InvalidateRect(subWins[2],&lvIndicate); break; case GUI_KEY_BACKSPACE: // OSSchedLock(); for(i=N_boat-1;i>=0;i--) { if(MNTState_Choosen == SimpBerthes[i].pBerth->mntState) { // SimpBerthes[i].pBerth->mntState = MNTState_Add; isAdded = MNT_add(SimpBerthes[i].pBerth); if( isAdded ) { SimpBerthes[i].pBerth->mntState = MNTState_Monitored ; } else { break; } } } // OSSchedUnlock(); myMsg.hWin = WM_GetClientWindow(menuWin); myMsg.MsgId = USER_MSG_DFULT_CNT; myMsg.Data.v = MNT_getDefaultNum(); //INFO("default num:%d",myMsg.Data.v); WM_SendMessage(myMsg.hWin, &myMsg); WM_SetFocus(menuWin); break; case GUI_KEY_MONITORING: selectedRow = LISTVIEW_GetSel(thisListView); LISTVIEW_GetItemText(thisListView, LV_AllList_Col_MMSI, selectedRow, pStrBuf, 11); selectedMMSI = strtoi(pStrBuf); if(selectedMMSI <= 0) break; for(i=N_boat;i>0;i--) { if(SimpBerthes[i-1].pBerth->Boat.user_id == selectedMMSI) { break; } } if(i) i--; else { INFO("Err!"); break; } if(SimpBerthes[i].pBerth->mntState == MNTState_None) { SimpBerthes[i].pBerth->mntState = MNTState_Choosen; LISTVIEW_SetItemText(thisListView, LV_AllList_Col_STT, selectedRow, "吖"); } break; case GUI_KEY_CANCEL: selectedRow = LISTVIEW_GetSel(thisListView); LISTVIEW_GetItemText(thisListView, LV_AllList_Col_MMSI, selectedRow, pStrBuf, 11); selectedMMSI = strtoi(pStrBuf); if(selectedMMSI <= 0) break; for(i=N_boat;i>0;i--) { if(SimpBerthes[i-1].pBerth->Boat.user_id == selectedMMSI) { break; } } if(i) i--; else { INFO("Err!"); break; } if(MNTState_Choosen == SimpBerthes[i].pBerth->mntState) { SimpBerthes[i].pBerth->mntState = MNTState_None; LISTVIEW_SetItemText(thisListView, LV_AllList_Col_STT, selectedRow, "啊"); } else if(MNTState_Monitored <= SimpBerthes[i].pBerth->mntState) { MMSI = SimpBerthes[i].pBerth->Boat.user_id; myMsg.hWin = WM_GetClientWindow(confirmWin); myMsg.hWinSrc = thisListView; myMsg.MsgId = USER_MSG_CHOOSE; myMsg.Data.v = CANCEL_MONITED; WM_SendMessage(myMsg.hWin, &myMsg); WM_BringToTop(confirmWin); WM_SetFocus(WM_GetDialogItem (confirmWin,GUI_ID_BUTTON0)); } break; case GUI_KEY_ENTER: selectedRow = LISTVIEW_GetSel(thisListView); LISTVIEW_GetItemText(thisListView, LV_AllList_Col_MMSI, selectedRow, pStrBuf, 11); selectedMMSI = strtoi(pStrBuf); if(selectedMMSI <= 0) break; for(i=0; i<N_boat; i++) { if(SimpBerthes[i].pBerth->Boat.user_id == selectedMMSI) { break; } } if(MNTState_None == SimpBerthes[i].pBerth->mntState) { SimpBerthes[i].pBerth->mntState = MNTState_Choosen; LISTVIEW_SetItemText(thisListView, LV_AllList_Col_STT, selectedRow, "吖"); } else if(MNTState_Choosen == SimpBerthes[i].pBerth->mntState) { SimpBerthes[i].pBerth->mntState = MNTState_None; LISTVIEW_SetItemText(thisListView, LV_AllList_Col_STT, selectedRow, "啊"); } else if(MNTState_Monitored == SimpBerthes[i].pBerth->mntState) { MMSI = SimpBerthes[i].pBerth->Boat.user_id; myMsg.hWin = WM_GetClientWindow(confirmWin); myMsg.hWinSrc = thisListView; myMsg.MsgId = USER_MSG_CHOOSE; myMsg.Data.v = CANCEL_MONITED; WM_SendMessage(myMsg.hWin, &myMsg); WM_BringToTop(confirmWin); WM_SetFocus(WM_GetDialogItem (confirmWin,GUI_ID_BUTTON0)); } break; default: LISTVIEW_Callback(pMsg); break; } break; case USER_MSG_REPLY: switch(pMsg->Data.v) { case REPLY_OK: LISTVIEW_SetItemText(thisListView, LV_AllList_Col_STT, LISTVIEW_GetSel(thisListView), "啊"); if(MNT_removeById(MMSI)) { for(i=N_boat-1;i>=0;i--) { if(SimpBerthes[i].pBerth->Boat.user_id == MMSI) { SimpBerthes[i].pBerth->mntState = MNTState_None; break; } } WM_SetFocus(subWins[2]); } else { INFO("Error!"); WM_SetFocus(menuWin); } break; case REPLY_CANCEL: WM_SetFocus(pMsg->hWin); break; default: INFO("Something err!"); break; } break; default: LISTVIEW_Callback(pMsg); break; } }
/********************************************************************* * * LISTVIEW_IncSel */ void LISTVIEW_IncSel(LISTVIEW_Handle hObj) { int Sel = LISTVIEW_GetSel(hObj); LISTVIEW_SetSel(hObj, Sel + 1); }
/********************************************************************* * * LISTVIEW_DecSel */ void LISTVIEW_DecSel(LISTVIEW_Handle hObj) { int Sel = LISTVIEW_GetSel(hObj); if (Sel) { LISTVIEW_SetSel(hObj, Sel - 1); } }
static void updateListViewContent(WM_HWIN thisHandle) { WM_HWIN thisListView = thisHandle; int i = 0; int selRow = -1; long selectedMMSI = 0; if(N_boat <= 0) { // modifided by Bill LISTVIEW_GetItemText(thisListView, LV_AllList_Col_MMSI, 0, pStrBuf, 11); selectedMMSI = strtoi(pStrBuf); PRINT("SelMMSI:%d", selectedMMSI); if(selectedMMSI) { for(i=0; i<9; i++) { LISTVIEW_SetItemText(thisListView, LV_AllList_Col_DIST, i, ""); LISTVIEW_SetItemText(thisListView, LV_AllList_Col_MMSI, i, ""); LISTVIEW_SetItemText(thisListView, LV_AllList_Col_STT, i, ""); } LISTVIEW_SetSel(thisListView, 0); WM_InvalidateRect(subWins[2], &lvIndicate); return ; } return ; } selRow = LISTVIEW_GetSel(thisListView); LISTVIEW_GetItemText(thisListView, LV_AllList_Col_MMSI, selRow, pStrBuf, 11); selectedMMSI = strtoi(pStrBuf); PRINT("-SelMMSI:%ld", selectedMMSI); if(selectedMMSI) { for(i=0; i<N_boat; i++) { if(SimpBerthes[i].pBerth->Boat.user_id == selectedMMSI) { LV_Page = i/LV_PAGE_SIZE; selRow = i%LV_PAGE_SIZE; break; } } /// Selected boat has gone if(i >= N_boat ){ PRINT("sel has gone"); if(N_boat > LV_Page * LV_PAGE_SIZE + selRow){ selRow = 0; } else{ LV_Page = (N_boat-1) /LV_PAGE_SIZE; selRow = 0; } } } else { LV_Page = (N_boat-1) / LV_PAGE_SIZE; selRow = (N_boat-1) % LV_PAGE_SIZE; } LV_turnPage(thisListView, LV_Page); LISTVIEW_SetSel(thisListView, selRow); WM_InvalidateRect(subWins[2], &lvIndicate); }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int SelectedRow = -1; long SelectedMMSI = 0; int i; switch (pMsg->MsgId) { case USER_MSG_LV_UPDATE: updateListViewContent(WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0)); break; case USER_MSG_SKIN: pSkin = &(lvWinSkins[pMsg->Data.v]); INFO("case skin:%s",pMsg->Data.v==SKIN_Day?"Day":"Night"); WINDOW_SetBkColor(pMsg->hWin,pSkin->bkColor); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0); TEXT_SetTextColor(hItem, pSkin->ttl_Text); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); TEXT_SetTextColor(hItem, pSkin->ttl_Text); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2); TEXT_SetTextColor(hItem, pSkin->inf_Label); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3); TEXT_SetTextColor(hItem, pSkin->inf_Label); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4); TEXT_SetTextColor(hItem, pSkin->inf_Label); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_5); TEXT_SetTextColor(hItem, pSkin->inf_Label); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_6); TEXT_SetTextColor(hItem, pSkin->inf_Label); hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0); LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_UNSEL, pSkin->itm_bkUnsel); LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_SEL, pSkin->itm_bkSel); LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_SELFOCUS, pSkin->itm_bkFocus); LISTVIEW_SetTextColor(hItem,LISTVIEW_CI_UNSEL, pSkin->itm_txUnsel); LISTVIEW_SetTextColor(hItem,LISTVIEW_CI_SEL, pSkin->itm_txSel); LISTVIEW_SetTextColor(hItem,LISTVIEW_CI_SELFOCUS, pSkin->itm_txFocus); hItem = LISTVIEW_GetHeader(hItem); HEADER_SetBkColor(hItem,pSkin->Header_Bk); HEADER_SetTextColor(hItem,pSkin->Header_Text); break; case WM_INIT_DIALOG: pSkin = &(lvWinSkins[SysConf.Skin]); hItem = pMsg->hWin; WINDOW_SetBkColor(hItem, pSkin->bkColor); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0); TEXT_SetTextColor(hItem, pSkin->ttl_Text); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); TEXT_SetTextColor(hItem, pSkin->ttl_Text); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2); TEXT_SetTextColor(hItem, pSkin->inf_Label); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3); TEXT_SetTextColor(hItem, pSkin->inf_Label); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4); TEXT_SetTextColor(hItem, pSkin->inf_Label); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_5); TEXT_SetTextColor(hItem, pSkin->inf_Label); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_6); TEXT_SetTextColor(hItem, pSkin->inf_Label); hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0); WM_SetCallback(hItem, &myListViewListener); LISTVIEW_AddColumn(hItem, LV_AllList_Col_0_WIDTH, "距离", GUI_TA_HCENTER | GUI_TA_VCENTER); LISTVIEW_AddColumn(hItem, LV_AllList_Col_2_WIDTH, "MMSI", GUI_TA_HCENTER | GUI_TA_VCENTER); LISTVIEW_AddColumn(hItem, LV_AllList_Col_3_WIDTH, "状态", GUI_TA_HCENTER | GUI_TA_VCENTER); LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetGridVis(hItem, 1); LISTVIEW_SetHeaderHeight(hItem,LV_MoniteList_Header_HEIGHT); LISTVIEW_SetRowHeight(hItem,LV_MoniteList_Row_HEIGHT); LISTVIEW_SetFont(hItem,&GUI_Font30); LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_UNSEL, pSkin->itm_bkUnsel); LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_SEL, pSkin->itm_bkSel); LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_SELFOCUS, pSkin->itm_bkFocus); LISTVIEW_SetTextColor(hItem,LISTVIEW_CI_UNSEL, pSkin->itm_txUnsel); LISTVIEW_SetTextColor(hItem,LISTVIEW_CI_SEL, pSkin->itm_txSel); LISTVIEW_SetTextColor(hItem,LISTVIEW_CI_SELFOCUS, pSkin->itm_txFocus); for(i=LV_PAGE_SIZE; i>0; i--) { LISTVIEW_AddRow(hItem, NULL); } LISTVIEW_SetSel(hItem, 0); hItem = LISTVIEW_GetHeader(hItem); HEADER_SetBkColor(hItem,pSkin->Header_Bk); HEADER_SetTextColor(hItem,pSkin->Header_Text); isSub2Inited = 1; break; case WM_PAINT: GUI_SetColor(pSkin->inf_bkColor); GUI_FillRectEx(&infoRect); GUI_SetTextMode(GUI_TM_TRANS); GUI_SetFont(&GUI_Font24); GUI_SetColor(pSkin->inf_Label); GUI_DispStringAt("按确定键选择或取消选择监控的网位仪", LV_AllList_WIDTH+20, LV_AllList_Y+240); GUI_SetFont(&GUI_Font24_1); GUI_SetColor(pSkin->inf_txColor); hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0); if(WM_HasFocus(hItem) == FALSE) { sprintf(pStrBuf, " 0/%3d", N_boat); GUI_DispStringAt(pStrBuf,LV_AllList_WIDTH-80,LV_AllList_Y-20); break; } // if( N_boat <= 0 ){ // sprintf(pStrBuf, " 0/ 0"); // GUI_DispStringAt(pStrBuf, LV_AllList_WIDTH-80, LV_AllList_Y-20); // break; // } SelectedRow = LISTVIEW_GetSel(hItem); LISTVIEW_GetItemText(WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0), LV_AllList_Col_MMSI, SelectedRow, pStrBuf, 11); SelectedMMSI = strtoi(pStrBuf); if(SelectedMMSI <= 0) { sprintf(pStrBuf," 0/%3d", N_boat); GUI_DispStringAt(pStrBuf,LV_AllList_WIDTH-80,LV_AllList_Y-20); break; } for(i=0; i<N_boat ; i++) { if(SimpBerthes[i].pBerth->Boat.user_id == SelectedMMSI) { break; } } if(i<N_boat) { sprintf(pStrBuf,"%3d/%3d", i+1 ,N_boat); GUI_DispStringAt(pStrBuf,LV_AllList_WIDTH-80,LV_AllList_Y-20); GUI_DispStringAt(SimpBerthes[i].pBerth->Boat.name,LV_AllList_WIDTH+80,85); lltostr(SimpBerthes[i].latitude,pStrBuf); GUI_DispStringAt(pStrBuf,LV_AllList_WIDTH+80,125); lltostr(SimpBerthes[i].longitude,pStrBuf); GUI_DispStringAt(pStrBuf,LV_AllList_WIDTH+80,165); // if(SysConf.Unit == UNIT_km) // { // int sog = SimpBerthes[i].pBerth->Boat.SOG *18; // sprintf(pStrBuf, "%3d.%02dkm",sog/100, sog%100); // } // else // { // sprintf(pStrBuf, "%2d.%dkt", SimpBerthes[i].pBerth->Boat.SOG/10, // SimpBerthes[i].pBerth->Boat.SOG%10); // } sprintf(pStrBuf, "%2d.%dkt", SimpBerthes[i].pBerth->Boat.SOG/10, SimpBerthes[i].pBerth->Boat.SOG%10); GUI_DispStringAt(pStrBuf, LV_AllList_WIDTH+80,205); sprintf(pStrBuf, "%3d", SimpBerthes[i].pBerth->Boat.COG/10); pStrBuf[3] = 194; pStrBuf[4] = 176; pStrBuf[5] = '\0'; GUI_DispStringAt(pStrBuf,LV_AllList_WIDTH+80,245); } break; default: WM_DefaultProc(pMsg); break; } }
/** * @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; int NCode; int Id, Index, newpos; GUI_RECT r; int ItemNbr; int result; static char tmp[FILEMGR_FILE_NAME_SIZE]; switch (pMsg->MsgId) { case WM_INIT_DIALOG: pVideoList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef)); pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO)); pVideoList->ptr = 0; PlayerSettings.d32 = k_BkupRestoreParameter(CALIBRATION_VIDEOPLAYER_SETTING_BKP); /* Initialization of 'Listview' */ hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST); LISTVIEW_AddColumn(hItem, 165, "Video", GUI_TA_VCENTER | GUI_TA_LEFT); LISTVIEW_SetGridVis(hItem, 0); LISTVIEW_SetAutoScrollV(hItem, 1); LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_UNSEL, GUI_BLACK); LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_UNSEL, GUI_CYAN); hItem = BUTTON_CreateEx( 240, 202, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_STOP_BUTTON); WM_SetCallback(hItem, _cbButton_stop); hItem = BUTTON_CreateEx(92, 202, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_PREVIOUS_BUTTON); WM_SetCallback(hItem, _cbButton_previous); hItem = BUTTON_CreateEx(137, 195, 50, 45, pMsg->hWin, WM_CF_SHOW, 0, ID_PLAY_BUTTON); WM_SetCallback(hItem, _cbButton_play); hItem = BUTTON_CreateEx(195, 202, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_NEXT_BUTTON); WM_SetCallback(hItem, _cbButton_next); hItem = BUTTON_CreateEx(47, 205, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_REPEAT_BUTTON); WM_SetCallback(hItem, _cbButton_repeat); hItem = BUTTON_CreateEx(315, 205, 70, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_OPEN_BUTTON); WM_SetCallback(hItem, _cbButton_open); hItem = BUTTON_CreateEx(375, 205, 70, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_ADD_BUTTON); WM_SetCallback(hItem, _cbButton_add); hItem = BUTTON_CreateEx(440, 202, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_CLOSE_BUTTON); WM_SetCallback(hItem, _cbButton_close); hItem = BUTTON_CreateEx(281, 172, 25, 25, pMsg->hWin, WM_CF_SHOW, 0, ID_FULL_SCREEN_BUTTON); WM_SetCallback(hItem, _cbButton_fullscreen); hClient = WM_GetClientWindow(pMsg->hWin); WM_GetClientRectEx(hClient, &r); hFrame = WM_CreateWindowAsChild(r.x0 + 5, r.y0 + 5, r.x1 - 179, r.y1 - 75, hClient, WM_CF_SHOW, _cbVideoWindow , 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON); hItem = WM_GetDialogItem(pMsg->hWin, ID_PROGRESS_SLIDER); SLIDER_SetNumTicks(hItem, 25); hItem = WM_CreateWindowAsChild(05, 163, 275, 20, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND, _cbDrawProgressSlider, 0); WM_CreateWindowAsChild(479, 250, 1, 1, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMediaConnection , 0); break; case WM_PAINT: DrawRect3D(05, 193, 300, 50); DrawRect3D(310, 193, 165, 50); break; case WM_TIMER: Id = WM_GetTimerId(pMsg->Data.v); if (Id == ID_PLAYLIST_TIMER) { playlist_select = 0; } break; case WM_DELETE: k_BkupSaveParameter(CALIBRATION_VIDEOPLAYER_SETTING_BKP, PlayerSettings.d32); WM_DeleteTimer(hPlaylistTimer); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { /* Notification sent by "Close Button" */ case ID_FULL_SCREEN_BUTTON: switch (NCode) { case WM_NOTIFICATION_RELEASED: if( VideoPlayer_State != VIDEO_IDLE) { _ShowFullScreen(); } break; } break; /* Notifications sent by 'Add' Button */ case ID_ADD_BUTTON: switch(NCode) { case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_video; hItem = CHOOSEFILE_Create(pMsg->hWin, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Add video file to playlist", 0, pFileInfo); if(VideoPlayer_State == VIDEO_PLAY) { GUI_MOVIE_Pause(hMovie); } WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { if((strstr(pFileInfo->pRoot, ".emf")) || (strstr(pFileInfo->pRoot, ".EMF"))) { if(pVideoList->ptr < FILEMGR_LIST_DEPDTH) { strcpy((char *)pVideoList->file[pVideoList->ptr].name, pFileInfo->pRoot); FILEMGR_GetFileOnly ((char *)tmp, (char *)pFileInfo->pRoot); hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST); LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, pVideoList->ptr, tmp); pVideoList->ptr++; } } WM_InvalidateWindow(hFrame); } if(VideoPlayer_State == VIDEO_PLAY) { GUI_MOVIE_Play(hMovie); } break; } break; /* Notifications sent by 'Open' Button */ case ID_OPEN_BUTTON: switch(NCode) { case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_dir; hItem = CHOOSEFILE_Create(pMsg->hWin, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Add a folder", 0, pFileInfo); if(VideoPlayer_State == VIDEO_PLAY) { GUI_MOVIE_Pause(hMovie); } WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { _AddEntireFolder(pFileInfo->pRoot); WM_InvalidateWindow(hFrame); } if(VideoPlayer_State == VIDEO_PLAY) { GUI_MOVIE_Play(hMovie); } break; } break; /* Notification sent by "Full Screen button" */ case ID_CLOSE_BUTTON: switch (NCode) { case WM_NOTIFICATION_RELEASED: k_free(pVideoList); k_free(pFileInfo); _StopPlay(); GUI_EndDialog(pMsg->hWin, 0); break; } break; /* Notification sent by "Play Button" */ case ID_PLAY_BUTTON: switch(NCode) { case WM_NOTIFICATION_RELEASED: if(VideoPlayer_State == VIDEO_IDLE) { if (pVideoList->ptr > 0) { _StartPlay((char *)pVideoList->file[file_pos].name); LISTVIEW_SetSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST), file_pos); } else { pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_video; hItem = CHOOSEFILE_Create(pMsg->hWin, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Open a video file", 0, pFileInfo); WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { if((strstr(pFileInfo->pRoot, ".emf")) || (strstr(pFileInfo->pRoot, ".EMF"))) { pVideoList->ptr = 0; strcpy((char *)pVideoList->file[pVideoList->ptr].name, pFileInfo->pRoot); FILEMGR_GetFileOnly (tmp, pFileInfo->pRoot); hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST); /* Update Play list */ strcpy((char *)pVideoList->file[pVideoList->ptr].name, pFileInfo->pRoot); ItemNbr = LISTVIEW_GetNumRows(hItem); while(ItemNbr--) { LISTVIEW_DeleteRow(hItem, ItemNbr); } LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, pVideoList->ptr, tmp); pVideoList->ptr++; file_pos = 0; LISTVIEW_SetSel(hItem, 0); _StartPlay((char *)pVideoList->file[file_pos].name); WM_InvalidateWindow(hFrame); } } } } else if(VideoPlayer_State == VIDEO_PLAY) { _PausePlay(); } else if(VideoPlayer_State == VIDEO_PAUSE) { _ResumePlay(); } break; } break; case ID_REPEAT_BUTTON: if(NCode == WM_NOTIFICATION_RELEASED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_REPEAT_BUTTON); if(PlayerSettings.b.repeat == REPEAT_NONE) { PlayerSettings.b.repeat = REPEAT_ONCE; } else if(PlayerSettings.b.repeat == REPEAT_ONCE) { PlayerSettings.b.repeat = REPEAT_ALL; } else if(PlayerSettings.b.repeat == REPEAT_ALL) { PlayerSettings.b.repeat = REPEAT_NONE; } } break; case ID_STOP_BUTTON: _StopPlay(); hItem = WM_GetDialogItem(VIDEOPLAYER_hWin, ID_PROGRESS_SLIDER); SLIDER_SetValue(hItem, 0); WM_InvalidateWindow(hFrame); break; case ID_NEXT_BUTTON: switch(NCode) { case WM_NOTIFICATION_RELEASED: if(file_pos < (pVideoList->ptr - 1)) { /* Play Next */ file_pos++; LISTVIEW_IncSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST)); } else if(PlayerSettings.b.repeat == REPEAT_ALL) { file_pos = 0; LISTVIEW_SetSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST), file_pos); } if(VideoPlayer_State == VIDEO_PLAY) { _StopPlay(); _StartPlay((char *)pVideoList->file[file_pos].name); WM_InvalidateWindow(hFrame); } break; } break; case ID_PREVIOUS_BUTTON: switch(NCode) { case WM_NOTIFICATION_RELEASED: if( pVideoList->ptr > 0) { if(file_pos > 0) { file_pos--; LISTVIEW_DecSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST)); } else if(PlayerSettings.b.repeat == REPEAT_ALL) { file_pos = (pVideoList->ptr - 1); LISTVIEW_SetSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST), file_pos); } if(VideoPlayer_State == VIDEO_PLAY) { _StopPlay(); _StartPlay((char *)pVideoList->file[file_pos].name); WM_InvalidateWindow(hFrame); } } break; } break; /* Notifications sent by 'progress' Slider */ case ID_PROGRESS_SLIDER: if(NCode == WM_NOTIFICATION_CLICKED) { if(VideoPlayer_State != VIDEO_IDLE) { GUI_MOVIE_Pause(hMovie); hItem = WM_GetDialogItem(pMsg->hWin, ID_PROGRESS_SLIDER); newpos = (SLIDER_GetValue(hItem) * Video_Info.NumFrames)/100; GUI_MOVIE_GotoFrame(hMovie, newpos); if(VideoPlayer_State == VIDEO_PLAY) { GUI_MOVIE_Play(hMovie); } } } break; /* Notifications sent by 'ListView' Slider */ case ID_VIDEO_LIST: if(NCode == WM_NOTIFICATION_CLICKED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST); Index = LISTVIEW_GetSel(hItem); if(Index < pVideoList->ptr) { file_pos = Index; if(playlist_select == 0) { hPlaylistTimer = WM_CreateTimer(pMsg->hWin, ID_PLAYLIST_TIMER, 500, 0); playlist_select = (Index + 1); } else if(playlist_select == (Index + 1)) { WM_DeleteTimer(hPlaylistTimer); hPlaylistTimer = 0; playlist_select = 0; if(Index < pVideoList->ptr) { if(VideoPlayer_State != VIDEO_IDLE) { _StopPlay(); } _StartPlay((char *)pVideoList->file[Index].name); hItem = WM_GetDialogItem(VIDEOPLAYER_hWin, ID_PLAY_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); WM_InvalidateWindow(hFrame); } } } } break; } break; default: WM_DefaultProc(pMsg); break; } }
// // Buttoncallback; // void mybutton (WM_MESSAGE *pMsg) { WM_HWIN hWin; WM_KEY_INFO *pInfo; int column,row,row_index,del_row; int i; hWin = pMsg->hWin; switch (pMsg->MsgId) { case USER_MSG_LANGUAGE: //更改语言 pLanguage = &Lgumainwin[Language]; if (Language == 0) { BUTTON_SetFont(hButton,&GUI_Font30); TEXT_SetFont(mainwinText[5],&GUI_Font30); HEADER_SetFont(hListhead,&GUI_Font24); } else { BUTTON_SetFont(hButton,&GUI_Font20_1); TEXT_SetFont(mainwinText[5],&GUI_Font24_1); HEADER_SetFont(hListhead,&GUI_Font16_1); LISTVIEW_SetHeaderHeight(hListview,29); } DisPage(); BUTTON_SetText(hButton,pLanguage->ButtonInfo[0]); for(i = 0; i<7; i++) HEADER_SetItemText(hListhead,i,pLanguage->ListHead[i]); break; case WM_SET_FOCUS: if (pMsg->Data.v) { BUTTON_SetBkColor(hButton,BUTTON_CI_UNPRESSED,GUI_GRAY); BUTTON_SetTextColor(hButton,BUTTON_CI_UNPRESSED,GUI_WHITE); BUTTON_SetFocusColor(hButton,GUI_GRAY); } else { BUTTON_SetBkColor(hButton,BUTTON_CI_UNPRESSED,GUI_WHITE);//BUTTON_SetTextColor (hButton,BUTTON_CI_UNPRESSED,GUI_BLACK); BUTTON_SetTextColor(hButton,BUTTON_CI_UNPRESSED,GUI_BLACK); BUTTON_SetFocusColor(hButton,GUI_WHITE); } BUTTON_Callback(pMsg); break; case WM_KEY: pInfo = (WM_KEY_INFO*)pMsg->Data.p; switch (pInfo->Key) { case GUI_KEY_ENTER: break; case GUI_KEY_PRINT: WM_BringToTop(PrintWin); WM_SetFocus(WM_GetDialogItem(PrintWin,ID_PrintMenu)); break; case GUI_KEY_MENU: WM_BringToTop(Menuwin); WM_SetFocus (WM_GetDialogItem(Menuwin,ID_MENU)); MENU_SetSel (WM_GetDialogItem(Menuwin,ID_MENU),0); MenuSel = 0; break; case GUI_KEY_LOC1: pCannel = " 490 横"; WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1)); break; case GUI_KEY_LOC2: pCannel = "4209.5横"; WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1)); break; case GUI_KEY_CHS: pCannel = " 486 横"; WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1)); break; case GUI_KEY_UP: break; case GUI_KEY_DOWN: if (LISTVIEW_GetNumRows(hListview)) { thispage = 1; WM_SetFocus(hListview); LISTVIEW_SetSel(hListview,0); DisPage(); //WM_InvalidateRect(mainwin,&PageRect); //刷新页数提示 } break; case GUI_KEY_LEFT: if(InfoType > 0) InfoType--; else InfoType = 3; switch (InfoType) { case 0: BUTTON_SetText(hWin,pLanguage->ButtonInfo[0]); LISTVIEW_DeleteAllRows(hListview); InfoSel(0,1); break; case 1: BUTTON_SetText(hWin,pLanguage->ButtonInfo[1]); LISTVIEW_DeleteAllRows(hListview); InfoSel(1,1); break; case 2: BUTTON_SetText(hWin,pLanguage->ButtonInfo[2]); LISTVIEW_DeleteAllRows(hListview); InfoSel(2,1); break; case 3: BUTTON_SetText(hWin,pLanguage->ButtonInfo[3]); LISTVIEW_DeleteAllRows(hListview); InfoSel(3,1); break; } if (rowindex<8) { pageNum = 1; } else if (rowindex%8 == 0) pageNum = rowindex/8; else pageNum = rowindex/8+1; thispage = 1; DisPage(); //WM_InvalidateRect(mainwin,&PageRect);//刷新页数提示 break; case GUI_KEY_RIGHT: InfoType++; if(InfoType == 4) InfoType = 0; switch (InfoType) { case 0: BUTTON_SetText(hWin,pLanguage->ButtonInfo[0]); LISTVIEW_DeleteAllRows(hListview); InfoSel(0,1); break; case 1: BUTTON_SetText(hWin,pLanguage->ButtonInfo[1]); LISTVIEW_DeleteAllRows(hListview); InfoSel(1,1); break; case 2: BUTTON_SetText(hWin,pLanguage->ButtonInfo[2]); LISTVIEW_DeleteAllRows(hListview); InfoSel(2,1); break; case 3: BUTTON_SetText(hWin,pLanguage->ButtonInfo[3]); LISTVIEW_DeleteAllRows(hListview); InfoSel(3,1); break; } if (rowindex<8) pageNum = 1; else if (rowindex%8 == 0) pageNum = rowindex/8; else pageNum = rowindex/8+1; thispage = 1; DisPage(); //WM_InvalidateRect(mainwin,&PageRect);//刷新页数提示 break; } break; default : BUTTON_Callback(pMsg); break; } }
static void mylistview(WM_MESSAGE *pMsg) { WM_HWIN hWin; CHAR RowNum; CHAR RowLineIndex; const WM_KEY_INFO *pInfo; int16_t i = 0; static char addrow = 0; hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_KEY: pInfo = (WM_KEY_INFO*)pMsg->Data.p; switch (pInfo->Key) { case GUI_KEY_MENU: WM_BringToTop(Menuwin); WM_SetFocus(WM_GetDialogItem(Menuwin,ID_MENU)); MENU_SetSel(WM_GetDialogItem(Menuwin,ID_MENU),0); MenuSel = 0; break; case GUI_KEY_PRINT: WM_BringToTop(PrintWin); WM_SetFocus(WM_GetDialogItem(PrintWin,ID_PrintMenu)); break; case GUI_KEY_LOC1: pCannel = " 490 横"; WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1)); break; case GUI_KEY_LOC2: pCannel = "4209.5横"; WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1)); break; case GUI_KEY_CHS: pCannel = " 486 横"; WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1)); break; case GUI_KEY_LOCK: SelRow = LISTVIEW_GetSel(hListview); LISTVIEW_GetItemText(hListview,0,SelRow,pStrBuf,5); InfoId = atoi(pStrBuf); Info = pInfoHeader; if (pInfoHeader) do { if (Info->ID == InfoId) { if (Info->isLocked == 0) { LISTVIEW_SetItemText(hListview,6,SelRow," 锁"); Info->isLocked = 1; } else if (Info->isLocked == 1) { LISTVIEW_SetItemText(hListview,6,SelRow,""); Info->isLocked = 0; } break; } }while (Info = Info->pNext); break; case GUI_KEY_DOWN: SelRow = LISTVIEW_GetSel(hListview); if (thispage < pageNum) { if (SelRow == 7) { thispage++; InfoSel(InfoType,thispage); DisPage(); //WM_InvalidateRect(mainwin,&PageRect); } } break; case GUI_KEY_UP: SelRow = LISTVIEW_GetSel(hListview); if(SelRow == 0 && thispage == 1) WM_SetFocus(hButton); if (thispage>1) { if(SelRow == 0) { SelBottom = 1; thispage--; InfoSel(InfoType,thispage); DisPage(); GUI_StoreKeyMsg(GUI_KEY_RIGHT,1); //选择列表中最后一行 } } break; case GUI_KEY_RIGHT: if (SelBottom == 1) { LISTVIEW_SetSel(hListview,7); SelBottom = 0; } break; case GUI_KEY_ESCAPE: SelRow = LISTVIEW_GetSel(hListview); WM_SetFocus(hButton); break; case GUI_KEY_ENTER: SelRow = LISTVIEW_GetSel(hListview); LISTVIEW_GetItemText(hListview,0,SelRow,pStrBuf,5); InfoId = atoi(pStrBuf); Info = pInfoHeader; if (pInfoHeader) do { if (Info->ID == InfoId) { if (Info->state == INFO_STT_New) LISTVIEW_SetItemBitmap(hListview,6,SelRow,10,7,NULL); if (Info->isLocked == 0) TEXT_SetText(WM_GetDialogItem(InfoText,ID_TEXT_0),""); else TEXT_SetText(WM_GetDialogItem(InfoText,ID_TEXT_0),"锁"); Info->state = INFO_STT_Choosen; sprintf(pStrBuf,"%s",pStrBuf); BUTTON_SetText(WM_GetDialogItem(InfoText,ID_BUTTON_0),pStrBuf); MULTIEDIT_SetText(WM_GetDialogItem(InfoText, ID_MULTIEDIT_0),Info->pContent); break; } }while (Info = Info->pNext); WM_BringToTop (InfoText); WM_SetFocus (InfoText); break; } case WM_POST_PAINT: //行分割线 RowNum = LISTVIEW_GetNumRows(hListview); GUI_SetColor(GUI_BLACK); for (RowLineIndex = 0; RowLineIndex<RowNum; RowLineIndex++) GUI_DrawLine(0,(68+40*(RowLineIndex)),720,(68+40*(RowLineIndex))); default : LISTVIEW_Callback(pMsg); break; } }
/**监控设置 LISTVIEW 的监听器(回调函数) * */ static void myListViewListener(WM_MESSAGE* pMsg) { const WM_KEY_INFO * pInfo; WM_HWIN thisListView = pMsg->hWin; int selectedRow = -1; int index = -1; switch(pMsg->MsgId) { case WM_SET_FOCUS: if(LISTVIEW_GetNumRows(pMsg->hWin) && (LISTVIEW_GetSel(pMsg->hWin)<0)) LISTVIEW_SetSel(pMsg->hWin, 0); updateListViewContent(thisListView); LISTVIEW_Callback(pMsg); break; case WM_KEY: pInfo = (WM_KEY_INFO*)pMsg->Data.p; switch(pInfo->Key) { case GUI_KEY_UP: case GUI_KEY_DOWN: LISTVIEW_Callback(pMsg); //showSelectedBoatInfo(thisListView); break; case GUI_KEY_LEFT: WM_SetFocus(menuWin); break; case GUI_KEY_RIGHT: WM_SetFocus(etWin); break; case GUI_KEY_ENTER: // selectedRow = LISTVIEW_GetSel(thisListView); // index = getSelectedBoatIndex(thisListView, 1, selectedRow); index = LISTVIEW_GetSel(thisListView); if(index >= 0) { // if( mntBoats[index].MNTState == MNTState_Default ) // { // mntBoats[index].MNTState = MNTState_None; // LISTVIEW_SetItemText(thisListView, 2, index, "x"); // } // else if(mntBoats[index].MNTState == MNTState_Monite) // { // mntBoats[index].MNTState = MNTState_Choosen; // LISTVIEW_SetItemText(thisListView, 2, index, "o"); // } // switch(mntBoats[index].MNTState) // { // case MNTState_Choosen: // mntBoats[index].MNTState = MNTState_Monite; // LISTVIEW_SetItemText(thisListView, 2, index, "x"); // break; // case MNTState_Default: // mntBoats[index].MNTState = MNTState_None; // LISTVIEW_SetItemText(thisListView, 2, index, "x"); // break; // case MNTState_Monite: // mntBoats[index].MNTState = MNTState_Choosen; // LISTVIEW_SetItemText(thisListView, 2, index, "o"); // break; // case MNTState_None: // mntBoats[index].MNTState = MNTState_Default; // LISTVIEW_SetItemText(thisListView, 2, index, "o"); // break; // } } break; case GUI_KEY_BACKSPACE: INFO("case backspace"); WM_BringToTop(confirmWin); WM_SetFocus(confirmWin); break; case GUI_KEY_MENU: WM_BringToTop(hDlg_FishMap); WM_SetFocus(hDlg_FishMap); break; default: LISTVIEW_Callback(pMsg); break; } break; default: LISTVIEW_Callback(pMsg); break; } }
/********************************************************************* * * MainTask */ void MainTask(void) { WM_HWIN hScrollbar, hDlgOptions; GUI_RECT RectDlg, RectClient; int Cnt = 0, IndexEffect = 0, ButtonState = 0, DropdownState = 0; int ProgbarValue = 0, ProgbarInc = 1; int SliderValue = 0, SliderInc = 1; int ScrollbarValue = 0, ScrollbarInc = 1; int ListViewInc = 1; int ListBoxInc = 1; int MultiEditInc = 1; int Vz = 1; const WIDGET_EFFECT * _apEffect[] = {&WIDGET_Effect_3D, /* Array of effects */ &WIDGET_Effect_Simple, &WIDGET_Effect_None}; const char * _apEffects[] = {"Widget effect: 3D", "Widget effect: Simple", "Widget effect: None"}; GUI_Init(); GUI_CURSOR_Show(); WM_SetCallback(WM_HBKWIN, _cbBkWindow); WM_SetCreateFlags(WM_CF_MEMDEV); /* Use memory devices on all windows to avoid flicker */ WM_EnableMemdev(WM_HBKWIN); /* Enable use of memory devices for desktop windows */ /* Create framewindow and set its properties */ _hFrameWin = FRAMEWIN_CreateEx(0, 0, 640, 480, 0, WM_CF_SHOW, 0, 0, "", &_cbCallbackFramewin); FRAMEWIN_SetMoveable(_hFrameWin, 1); FRAMEWIN_SetText(_hFrameWin, _apEffects[0]); FRAMEWIN_SetFont(_hFrameWin, &GUI_Font13B_ASCII); /* Create main dialog window as child from framewindows client window */ _hDlg = GUI_CreateDialogBox(_aDlgWidgets, GUI_COUNTOF(_aDlgWidgets), &_cbCallbackWidgets, WM_GetClientWindow(_hFrameWin), 0, 0); /* Attach scrollbar to framewindows client window and set its properties */ hScrollbar = SCROLLBAR_CreateAttached(WM_GetClientWindow(_hFrameWin), 0); WM_GetWindowRectEx(_hDlg, &RectDlg); WM_GetClientRectEx(WM_GetClientWindow(_hFrameWin), &RectClient); SCROLLBAR_SetNumItems(hScrollbar, RectDlg.x1); SCROLLBAR_SetPageSize(hScrollbar, RectClient.x1); /* Create options dialog with 'stay on top' and 'moveable' attribute */ hDlgOptions = GUI_CreateDialogBox(_aDlgOptions, GUI_COUNTOF(_aDlgOptions), &_cbCallbackOptions, WM_HBKWIN, 0, 0); FRAMEWIN_SetMoveable(hDlgOptions, 1); WM_SetStayOnTop(hDlgOptions, 1); /* Main loop for modifying the widgets */ while (1) { if (_AutoMode) { Cnt++; /* Modify progbar */ if ((Cnt % 2) == 0) { ProgbarValue += ProgbarInc; if ((ProgbarValue == 110) || (ProgbarValue == -10)) { ProgbarInc *= -1; } PROGBAR_SetValue(_ahWin[PROGBAR0], ProgbarValue); } /* Modify slider */ if ((Cnt % 2) == 0) { int j; SliderValue += SliderInc; if ((SliderValue == 100) || (SliderValue == 0)) { SliderInc *= -1; } for (j = 0; j < 3; j++) { SLIDER_SetValue(_ahWin[SLIDER0 + j], SliderValue); } } /* Modify scrollbar */ if ((Cnt % 3) == 0) { int j; ScrollbarValue += ScrollbarInc; if ((ScrollbarValue == 90) || (ScrollbarValue == 0)) { ScrollbarInc *= -1; } for (j = 0; j < 3; j++) { SCROLLBAR_SetValue(_ahWin[SCROLLBAR0 + j], ScrollbarValue); } } /* Modify multipage */ if ((Cnt % 120) == 0) { MULTIPAGE_SelectPage(_ahWin[MULTIPAGE0], MULTIPAGE_GetSelection(_ahWin[MULTIPAGE0]) ^ 1); } /* Modify dropdown */ if ((Cnt % 120) == 0) { DropdownState ^= 1; if (DropdownState) { DROPDOWN_Expand(_ahWin[DROPDOWN0]); } else { DROPDOWN_Collapse(_ahWin[DROPDOWN0]); } } /* Modify button */ if ((Cnt % 40) == 0) { ButtonState ^= 1; BUTTON_SetPressed(_ahWin[BUTTON0], ButtonState); } /* Modify listbox */ if ((Cnt % 30) == 0) { int Sel; Sel = LISTBOX_GetSel(_ahWin[LISTBOX0]); if (Sel < 0) { Sel = 0; } LISTBOX_SetSel(_ahWin[LISTBOX0], Sel + ListBoxInc); Sel = LISTBOX_GetSel(_ahWin[LISTBOX0]); if ((Sel == (int)LISTBOX_GetNumItems(_ahWin[LISTBOX0]) - 1) || (Sel == 0)) { ListBoxInc *= -1; } } /* Modify listview */ if ((Cnt % 50) == 0) { int Sel; Sel = LISTVIEW_GetSel(_ahWin[LISTVIEW0]); if (Sel < 0) { Sel = 0; } LISTVIEW_SetSel(_ahWin[LISTVIEW0], Sel + ListViewInc); Sel = LISTVIEW_GetSel(_ahWin[LISTVIEW0]); if ((Sel == (int)LISTVIEW_GetNumRows(_ahWin[LISTVIEW0]) - 1) || (Sel == 0)) { ListViewInc *= -1; } } /* Modify multiedit */ if ((Cnt % 5) == 0) { int Sel, Len; char acBuffer[100]; MULTIEDIT_SetCursorOffset(_ahWin[MULTIEDIT0], MULTIEDIT_GetCursorCharPos(_ahWin[MULTIEDIT0]) + MultiEditInc); MULTIEDIT_GetText(_ahWin[MULTIEDIT0], acBuffer, sizeof(acBuffer)); Sel = MULTIEDIT_GetCursorCharPos(_ahWin[MULTIEDIT0]); Len = strlen(acBuffer); if ((Sel == (Len - 1)) || (Sel == 0)) { MultiEditInc *= -1; } if (!DropdownState) { WM_SetFocus(_ahWin[MULTIEDIT0]); } } /* Modify graph */ _AddValues(_ahWin[GRAPH0], 95); /* Move window */ if ((Cnt % 1200) == 0) { int Inc; WM_HWIN hScroll; WM_SCROLL_STATE ScrollState; hScroll = WM_GetScrollbarH(WM_GetClientWindow(_hFrameWin)); WM_GetScrollState(hScroll, &ScrollState); Inc = (ScrollState.NumItems - ScrollState.PageSize) / 2; ScrollState.v += Inc * Vz; if ((ScrollState.v >= Inc * 2) || (ScrollState.v <= 0)) { Vz *= -1; } SCROLLBAR_SetValue(hScroll, ScrollState.v); } /* Change effect */ if ((Cnt % 400) == 0) { int Index; WM_HWIN hWin; IndexEffect++; Index = IndexEffect % GUI_COUNTOF(_apEffect); _SetEffect(Index); hWin = WM_GetDialogItem(hDlgOptions, GUI_ID_RADIO0); RADIO_SetValue(hWin, Index); } } /* Wait a while */ GUI_Delay(10); } }