Example #1
0
/* 更新监控设置的 LISTVIEW 条目
*
*/
static void updateListViewContent(WM_HWIN thisHandle)
{
 	WM_HWIN thisListView  = thisHandle;
	
  int Cnt = 0;
  int NumOfRows  = 0;
  MNT_BERTH * pIterator  = NULL;
 // MNT_BERTH * pIterator  = pMntHeader;

  NumOfRows  = LISTVIEW_GetNumRows(thisListView);

 // MNT_resetIterator();
  pIterator  = pMntHeader;
  while(pIterator)
  {
     if(pIterator->chsState != MNTState_Cancel)
     {
        Cnt++;  
        if(Cnt > NumOfRows)
        {
           LISTVIEW_AddRow(thisListView, NULL);
           NumOfRows  = LISTVIEW_GetNumRows(thisListView);
        }
        
        sprintf(pStrBuf, "%s", pIterator->mntBoat.name);
        LISTVIEW_SetItemText(thisListView, 0, Cnt-1, pStrBuf);
      
        sprintf(pStrBuf, "%09ld", pIterator->mntBoat.mmsi);
        LISTVIEW_SetItemText(thisListView, 1, Cnt-1, pStrBuf);
        
        LISTVIEW_SetItemText(thisListView, 2, Cnt-1, (MNTState_Default==pIterator->chsState)?"吖":"啊");  
//        if(pIterator->chsState == MNTState_Choosen  ||  pIterator->chsState == MNTState_Default)
//        {
//           
//        }
     }
     pIterator  = pIterator->pNext;
  }
  while(NumOfRows > Cnt)
  {
     LISTVIEW_DeleteRow(thisListView, NumOfRows-1);
     NumOfRows  = LISTVIEW_GetNumRows(thisListView);
  }
  
  if(NumOfRows == 0)
  {
     LISTVIEW_AddRow(thisListView, NULL);
  }
}
Example #2
0
 void OnButtonDelectClicked(WM_MESSAGE * pMsg)
 {
	char buf[3];
	char act_row;
	int row,row_number,i,j;
	if((get_data.e_work_state != START_TEST)&&(get_data.e_work_state != GET_V1))
	{
	row_number = LISTVIEW_GetNumRows(WM_GetDialogItem(pMsg->hWin,GUI_ID_LISTVIEW_RESULT_T));
	
	row = LISTVIEW_GetSel(WM_GetDialogItem(pMsg->hWin,GUI_ID_LISTVIEW_RESULT_T));
	
	LISTVIEW_DeleteRow(WM_GetDialogItem(pMsg->hWin,GUI_ID_LISTVIEW_RESULT_T),row);
	
	for(i=0;i<row_number-1;i++)
	 {
	    j = row_number-1-i;
	    sprintf(buf,"%d",j);
		LISTVIEW_SetItemText(WM_GetDialogItem(current_handle,GUI_ID_LISTVIEW_RESULT_T),0,i,buf);
	 }
	
	record.test_times--;

	act_row = row_number - row - 1;
	
	record.v1[act_row] = 0;
	record.v2[act_row] = 0;
	 }

 }
Example #3
0
/**
  * @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);

  }
}
Example #4
0
/**
  * @brief  Add entire folder to play list.
  * @param  Foldername: pointer to folder name.
  * @retval None
  */
static void _AddEntireFolder(char *Foldername)
{
  FRESULT res;
  FILINFO fno;
  DIR dir;
  char *fn;
  char tmp[FILEMGR_FULL_PATH_SIZE]; 
  WM_HWIN hItem;  
  
#if _USE_LFN
  static char lfn[_MAX_LFN];
  fno.lfname = lfn;
  fno.lfsize = sizeof(lfn);
#endif
  
  res = f_opendir(&dir, Foldername);
  
  if (res == FR_OK)
  {
    
    while (1)
    {
      res = f_readdir(&dir, &fno);
      
      if (res != FR_OK || fno.fname[0] == 0)
      {
        break;
      }
      if (fno.fname[0] == '.')
      {
        continue;
      }
#if _USE_LFN
      fn = *fno.lfname ? fno.lfname : fno.fname;
#else
      fn = fno.fname;
#endif
      
      if (pVideoList->ptr < FILEMGR_LIST_DEPDTH)
      {
        if ((fno.fattrib & AM_DIR) == 0)
        {
          if(((strstr(fn, ".emf")) || (strstr(fn, ".EMF"))) && (VIDEOPLAYER_hWin != 0))
          {
            strcpy(tmp, Foldername);
            strcat(tmp, "/");
            strcat(tmp, fn);
            strncpy((char *)pVideoList->file[pVideoList->ptr].name, (char *)tmp, FILEMGR_FILE_NAME_SIZE);
            hItem = WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST);
            LISTVIEW_AddRow(hItem, NULL);  
            FILEMGR_GetFileOnly (tmp, fn);
            LISTVIEW_SetItemText(hItem, 0, pVideoList->ptr, fn);
            pVideoList->ptr++;
          }
        }
      }   
    }
  }
  f_closedir(&dir);
}
Example #5
0
/**
  * @brief  Update process manager view.
  * @param  hItem: pointer to window handle
  * @retval None
  */
static void _UpdateProcessManagerView(WM_HWIN  hItem) {
  int      Idx;
  char     str[3];
  int16_t  tasks_nbr;
  
  tasks_nbr = uxTaskGetSystemState( ProcessStatus, 16, NULL );
  
  /*Limit view size */
  if(tasks_nbr > 16)
  {
    tasks_nbr = 16;
  }
  
  for (Idx = 0; Idx < tasks_nbr ; Idx ++)
  {
    LISTVIEW_SetItemText(hItem, 0, Idx, (char *)(ProcessStatus[Idx].pcTaskName)); 
    sprintf(str, "%lu", ProcessStatus[Idx].uxCurrentPriority);
    LISTVIEW_SetItemText(hItem, 1, Idx, str);
    
    switch (ProcessStatus[Idx].eCurrentState)
    {
    case eReady:
      LISTVIEW_SetItemText(hItem, 2, Idx, "Ready"); 
      break;
      
    case eBlocked:
      LISTVIEW_SetItemText(hItem, 2, Idx, "Blocked"); 
      break;
      
    case eDeleted:
      LISTVIEW_SetItemText(hItem, 2, Idx, "Deleted"); 
      break;
      
    case eSuspended:
      LISTVIEW_SetItemText(hItem, 2, Idx, "Suspended"); 
      break;
      
    case eRunning:
      LISTVIEW_SetItemText(hItem, 2, Idx, "Running"); 
      break;        
      
    default:
      LISTVIEW_SetItemText(hItem, 2, Idx, "Unknown"); 
      break;        
    }
  }
  LISTVIEW_SetSort(hItem, 1, 0);
}
/**
  * @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();  
  chooser_openfile = 0;
  chooser_add2playlist = 0;
  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);              
    }
  }
}
Example #7
0
static void LV_turnPage(WM_HWIN thisListView, int page)
{
   int viewNumRows  = 0;
   int orgIndex     = 0;
   int i            = 0;
PRINT("turn to page:%d", page);   
   if( (N_boat-1)/LV_PAGE_SIZE == page)
   {
      viewNumRows  = (N_boat-1) % LV_PAGE_SIZE + 1;
   }
   else
   {
      viewNumRows  = LV_PAGE_SIZE;
   }
   
   orgIndex  = page * LV_PAGE_SIZE;
   
   for(i=0; i<viewNumRows; i++)
   {
      disttostr(pStrBuf, SimpBerthes[orgIndex+i].Dist);
      LISTVIEW_SetItemText(thisListView, LV_AllList_Col_DIST,  i, pStrBuf);
      
      sprintf(pStrBuf, "%09ld", SimpBerthes[orgIndex+i].pBerth->Boat.user_id);
      LISTVIEW_SetItemText(thisListView, LV_AllList_Col_MMSI,  i, pStrBuf);
      
      if(MNTState_None == SimpBerthes[orgIndex+i].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_SetItemText(thisListView, LV_AllList_Col_DIST, i, "");
      LISTVIEW_SetItemText(thisListView, LV_AllList_Col_MMSI, i, "");
      LISTVIEW_SetItemText(thisListView, LV_AllList_Col_STT,  i, "");
   }
}
Example #8
0
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);
}
Example #9
0
/**
  * @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;
  }
}
Example #10
0
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;
	}
}
/**
  * @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;
  }
}
/**
  * @brief  Add entire folder to play list.
  * @param  Foldername: pointer to folder name.
  * @retval None
  */
static void _AddEntireFolder(char *Foldername)
{
  FRESULT res;
  uint32_t duration;
  FILINFO fno;
  DIR dir;
  char *fn;
  char tmp[FILEMGR_FULL_PATH_SIZE]; 
  WM_HWIN hItem;  
  
#if _USE_LFN
  static char lfn[_MAX_LFN];
  fno.lfname = lfn;
  fno.lfsize = sizeof(lfn);
#endif
  
  res = f_opendir(&dir, Foldername);
  
  if (res == FR_OK)
  {
    
    while (1)
    {
      res = f_readdir(&dir, &fno);
      
      if (res != FR_OK || fno.fname[0] == 0)
      {
        break;
      }
      if (fno.fname[0] == '.')
      {
        continue;
      }
#if _USE_LFN
      fn = *fno.lfname ? fno.lfname : fno.fname;
#else
      fn = fno.fname;
#endif
      
      if (pWavList->ptr < FILEMGR_LIST_DEPDTH)
      {
        if ((fno.fattrib & AM_DIR) == 0)
        {
          if(((strstr(fn, ".wav")) || (strstr(fn, ".WAV"))) && (AUDIOPLAYER_hWin != 0))
          {
            strcpy(tmp, Foldername);
            strcat(tmp, "/");
            strcat(tmp, fn);
            if(AUDIOPLAYER_GetFileInfo(tmp, &WavInfo) == 0)
            {
              
              strncpy((char *)pWavList->file[pWavList->ptr].name, (char *)tmp, FILEMGR_FILE_NAME_SIZE);
              hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST);
              LISTVIEW_AddRow(hItem, NULL);  
              FILEMGR_GetFileOnly (tmp, fn);
              
              LISTVIEW_SetItemText(hItem, 0, pWavList->ptr, fn);
              
              duration = WavInfo.FileSize / WavInfo.ByteRate; 
              sprintf((char *)tmp , "%02lu:%02lu", duration/60, duration%60 );
              LISTVIEW_SetItemText(hItem, 1, pWavList->ptr, tmp);
            
              pWavList->ptr++;
            }
          }
        }
      }   
    }
  }
  f_closedir(&dir);
}
Example #13
0
/*********************************************************************
*
*       _Demo
*/
static void _Demo(void) {
  unsigned int i, j;
  int Key = 0;
  int Cnt = 15;
  char acInfoText[] = "-- sec to play with header control";
  HEADER_Handle hHeader;
  hHeader = LISTVIEW_GetHeader(_hListView);
  WM_SetFocus(_hListView);
  _ChangeInfoText("LISTVIEW_AddColumn");
  LISTVIEW_AddColumn(_hListView, 100, "EAN",         GUI_TA_CENTER);
  GUI_Delay(SPEED / 2);
  LISTVIEW_AddColumn(_hListView,  50, "Order #\0x0", GUI_TA_CENTER);
  GUI_Delay(SPEED / 2);
  LISTVIEW_AddColumn(_hListView, 100, "Description", GUI_TA_CENTER);
  GUI_Delay(SPEED / 2);
  _ChangeInfoText("SCROLLBAR_CreateAttached");
  SCROLLBAR_CreateAttached(_hListView, SCROLLBAR_CF_VERTICAL);
  GUI_Delay(SPEED / 2);
  _ChangeInfoText("LISTVIEW_AddRow");
  for (i = 0; i < GUI_COUNTOF(_aTable_1); i++) {
    LISTVIEW_AddRow(_hListView, _aTable_1[i]);
    GUI_Delay(SPEED / 3);
  }
  _ChangeInfoText("LISTVIEW_IncSel");
  for (i = 0; i < LISTVIEW_GetNumRows(_hListView); i++) {
    LISTVIEW_IncSel(_hListView);
    GUI_Delay(SPEED / 4);
  }
  GUI_Delay(SPEED / 4);
  _ChangeInfoText("LISTVIEW_DecSel");
  for (i = 0; i < LISTVIEW_GetNumRows(_hListView); i++) {
    LISTVIEW_DecSel(_hListView);
    GUI_Delay(SPEED / 4);
  }
  GUI_Delay(SPEED / 4);
  _ChangeInfoText("LISTVIEW_SetTextAlign");
  LISTVIEW_SetTextAlign(_hListView, 0, GUI_TA_RIGHT);
  GUI_Delay(SPEED * 0.7);
  _ChangeInfoText("LISTVIEW_SetColumnWidth");
  LISTVIEW_SetColumnWidth(_hListView, 1, 70);
  GUI_Delay(SPEED * 0.7);
  _ChangeInfoText("HEADER_SetTextColor");
  HEADER_SetTextColor(hHeader, GUI_BLUE);
  GUI_Delay(SPEED * 0.7);
  _ChangeInfoText("LISTVIEW_SetItemText");
  for (i = 0; i < GUI_COUNTOF(_aTable_2); i++) {
    for (j = 0; j < GUI_COUNTOF(_aTable_2[i]); j++) {
      LISTVIEW_SetItemText(_hListView, j, i, _aTable_2[i][j]);
    }
  }
  GUI_Delay(SPEED / 2);
  _ChangeInfoText("LISTVIEW_SetBkColor");
  LISTVIEW_SetBkColor(_hListView, 0, GUI_YELLOW);
  GUI_Delay(SPEED * 0.7);
  _ChangeInfoText("LISTVIEW_SetGridVis");
  LISTVIEW_SetGridVis(_hListView, 1);
  GUI_Delay(SPEED * 0.7);
  _ChangeInfoText("HEADER_SetHeight");
  HEADER_SetHeight(hHeader, 30);
  GUI_Delay(SPEED * 0.7);
  _ChangeInfoText("HEADER_SetBitmapEx");
  HEADER_SetBitmap(hHeader, 0, &bmBarCode);
  GUI_Delay(SPEED * 0.7);
  while ((Key != GUI_KEY_ENTER) && (Cnt > 0)) {
    acInfoText[0] = '0' + (Cnt / 10);
    acInfoText[1] = '0' + (Cnt-- % 10);
    _ChangeInfoText(acInfoText);
    GUI_Delay(1000);
    Key = GUI_GetKey();
  }
}
void Listview_Set_Item_Text(WM_HWIN hWin, int id, uint16_t column, uint16_t row, char *str)
{
    WM_HWIN hItem;
    hItem = WM_GetDialogItem(hWin, id);
    LISTVIEW_SetItemText(hItem, column, row, str);
}
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int     NCode;
  int     Id;
  // USER START (Optionally insert additional variables)
  int i;
  int j;
  int k;
  int slave_column;
  char buffer[10];

  new_GUI_value.BUTTON_value.send_button= FALSE;
  
  // USER END

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of 'id_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetText(hItem, "slave id:");
    //
    // Initialization of 'function_radio'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO_0);
    RADIO_SetText(hItem, "read holding registers", 0);
    RADIO_SetText(hItem, "write single register", 1);
    RADIO_SetText(hItem, "read single coil", 2);
    RADIO_SetText(hItem, "write single coil", 3);
    RADIO_SetText(hItem, "read multiple coils", 4);
    //
    // Initialization of 'multiple_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
    TEXT_SetText(hItem, "MULTIPLE REGISTER REQUEST");
    //
    // Initialization of 'from_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
    TEXT_SetText(hItem, "from:");
    //
    // Initialization of 'to_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3);
    TEXT_SetText(hItem, "to:");
    //
    // Initialization of 'single_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4);
    TEXT_SetText(hItem, "SINGLE REGISTER REQUEST");
    //
    // Initialization of 'number_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_5);
    TEXT_SetText(hItem, "number:");
    //
    // Initialization of 'send_button'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
    BUTTON_SetText(hItem, "SEND");
    //
    // Initialization of 'response_view'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0);
    LISTVIEW_AddColumn(hItem, 60, "address", GUI_TA_HCENTER | GUI_TA_VCENTER);
    LISTVIEW_AddColumn(hItem, 80, "slave 1", GUI_TA_HCENTER | GUI_TA_VCENTER);
    LISTVIEW_AddColumn(hItem, 80, "slave 2", GUI_TA_HCENTER | GUI_TA_VCENTER);
    LISTVIEW_AddRow(hItem, NULL);
    LISTVIEW_SetGridVis(hItem, 1);
    LISTVIEW_AddColumn(hItem, 30, "Col", GUI_TA_LEFT | GUI_TA_VCENTER);
    LISTVIEW_SetAutoScrollV(hItem, 1);
    //
    // Initialization of 'status_view'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1);
    LISTVIEW_AddColumn(hItem, 129, "status", GUI_TA_HCENTER | GUI_TA_VCENTER);
    LISTVIEW_SetGridVis(hItem, 1);
    LISTVIEW_SetItemText(hItem, 0, 0, "0");
    LISTVIEW_SetItemText(hItem, 0, 0, "0");
    LISTVIEW_SetRowHeight(hItem, 20);
    LISTVIEW_SetHeaderHeight(hItem, 20);
    //
    // Initialization of 'exit_button'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
    BUTTON_SetText(hItem, " X");
    //
    // Initialization of 'write_req_text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_6);
    TEXT_SetText(hItem, "WRITE REGISTER REQUEST");
    //
    // Initialization of 'value_txt'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_7);
    TEXT_SetText(hItem, "value:");
    // USER START (Optionally insert additional code for further widget initialization)

    //aggiungo casella Status
    hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1);
    LISTVIEW_AddRow(hItem, NULL);
    LISTVIEW_SetItemText(hItem, 0, 0, "Ready");

    //aggiungo caselle di risposta
    hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0);
    for (i = 0; i < 60; i++)
       LISTVIEW_AddRow(hItem, NULL);


    // USER END
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
    case ID_RADIO_0: // Notifications sent by 'function_radio'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        PlayAudio(150, 20);				
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)

          hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO_0);
          new_GUI_value.RADIO_value.radio_selection = RADIO_GetValue(pMsg->hWinSrc);

        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_0: // Notifications sent by 'send_button'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        PlayAudio(600, 20);				
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)

        modbus_task();

        hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1);

        if (modbus_rx.error != 0)
        {
					GUI_Delay(100);
					modbus_task();
				}
				
				hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1);
					
				if (modbus_rx.error != 0)
				{

					LISTVIEW_SetItemBkColor(hItem, 0,0,0, GUI_RED);
					GUI_Delay(100);
					LISTVIEW_SetItemText(hItem, 0, 0, "No Response");
					PlayAudio(50, 60);				
					PlayAudio(0, 20);				
					PlayAudio(50, 100);				
				}
					
				 else if (modbus_rx.func & 0x80)
				{
					LISTVIEW_SetItemBkColor(hItem, 0,0,0, GUI_YELLOW);
					GUI_Delay(100);
					LISTVIEW_SetItemText(hItem, 0, 0, "R: Wrong Message");
					PlayAudio(90, 60);				
					PlayAudio(90, 20);				
					PlayAudio(90, 100);				

				}

				else
				{
					//cancello vecchi valori
					hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0);
					LISTVIEW_DeleteAllRows(hItem);
					GUI_Delay(100);
					for (i = 0; i < 60; i++)
						LISTVIEW_AddRow(hItem, NULL);
					GUI_Delay(100);
					
					hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1);

					LISTVIEW_SetItemBkColor(hItem, 0,0,0, GUI_GREEN);
					GUI_Delay(100);
					LISTVIEW_SetItemText(hItem, 0, 0, "R: Message Accepted");
					PlayAudio(600, 20);				
					PlayAudio(600, 20);				
					PlayAudio(200, 20);
					
					
					//se ho fatto una richiesta read
					if(new_GUI_value.RADIO_value.radio_selection == 0 || new_GUI_value.RADIO_value.radio_selection == 2 || new_GUI_value.RADIO_value.radio_selection == 4)
					{
						if(new_GUI_value.SPINBOX_value.slave_id == 1)
							slave_column = 1;
						else
							slave_column = 2;

						//scrivo sul listview 0
						hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0);

						
						//mi prendo la sezione dati effettivi

						//ho chiesto gli holding?
						if(new_GUI_value.RADIO_value.radio_selection == 0){
							for(i = 0; i < modbus_rx.len; i++)
							{
								//se leggo holdings
								sprintf(buffer, "%d", new_GUI_value.SPINBOX_value.multiple_register_from + i +2000);
								
								LISTVIEW_SetItemText(hItem, 0, i, buffer);
				
								sprintf(buffer, "%d", modbus_rx.data_converted[i]);
								LISTVIEW_SetItemText(hItem, slave_column, i, buffer);

							}
						}							


						//ho chiesto i coils?
						else if(new_GUI_value.RADIO_value.radio_selection == 4 ){
							for(i = 0; i < modbus_rx.len; i++)
							{
								sprintf(buffer, "%d", new_GUI_value.SPINBOX_value.multiple_register_from + i );
								
								LISTVIEW_SetItemText(hItem, 0, i, buffer);

								if(modbus_rx.data_converted[i] != 0)
									sprintf(buffer, "%s", "ON");
								else
									sprintf(buffer, "%s", "OFF");
								
								LISTVIEW_SetItemText(hItem, slave_column, i, buffer);

							}							
						}	

						//ho chiesto 1 coil?
						else if(new_GUI_value.RADIO_value.radio_selection == 2){
							
								sprintf(buffer, "%d", new_GUI_value.SPINBOX_value.single_register_number);
								LISTVIEW_SetItemText(hItem, 0, 0, buffer);
							
								if(modbus_rx.data_converted[0] != 0)
									sprintf(buffer, "%s", "ON");
								else
									sprintf(buffer, "%s", "OFF");
								
								LISTVIEW_SetItemText(hItem, slave_column, 0, buffer);
							
							
						}
						
					}						
				}

        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_LISTVIEW_0: // Notifications sent by 'response_view'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        PlayAudio(150, 20);				
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_SEL_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_LISTVIEW_1: // Notifications sent by 'status_view'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_SEL_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_1: // Notifications sent by 'exit_button'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        PlayAudio(600, 20);				
        PlayAudio(600, 20);				
        PlayAudio(200, 20);				
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        new_GUI_value.SPINBOX_value.slave_id = 0;
        new_GUI_value.SPINBOX_value.multiple_register_from = 0;
        new_GUI_value.SPINBOX_value.multiple_register_to = 0;
        new_GUI_value.SPINBOX_value.single_register_number = 0;
        new_GUI_value.SPINBOX_value.write_value = 0;
        new_GUI_value.RADIO_value.radio_selection = 0;

        PlayAudio(900, 20);				
        PlayAudio(1000, 20);				
        PlayAudio(1100, 20);				

        hItem = pMsg->hWin;
        GUI_EndDialog(hItem, 0);


        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_SPINBOX_0: // Notifications sent by 'slave_id_spinbox'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        PlayAudio(150, 20);				
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_MOVED_OUT:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)

        hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_0);
        new_GUI_value.SPINBOX_value.slave_id = SPINBOX_GetValue(pMsg->hWinSrc);

        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_SPINBOX_1: // Notifications sent by 'from_spinbox'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        PlayAudio(150, 20);				
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_MOVED_OUT:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)

        hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_1);
        new_GUI_value.SPINBOX_value.multiple_register_from = SPINBOX_GetValue(pMsg->hWinSrc);

        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_SPINBOX_2: // Notifications sent by 'to_spinbox'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        PlayAudio(150, 20);				
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_MOVED_OUT:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)

        hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_2);
        new_GUI_value.SPINBOX_value.multiple_register_to = SPINBOX_GetValue(pMsg->hWinSrc);

        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_SPINBOX_3: // Notifications sent by 'number_spinbox'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        PlayAudio(150, 20);				
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_MOVED_OUT:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)

        hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_3);
        new_GUI_value.SPINBOX_value.single_register_number = SPINBOX_GetValue(pMsg->hWinSrc);

        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_SPINBOX_4: // Notifications sent by 'write_value_spinbox'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        PlayAudio(150, 20);				
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_MOVED_OUT:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)

        hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_4);
        new_GUI_value.SPINBOX_value.write_value = SPINBOX_GetValue(pMsg->hWinSrc);

        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    // USER START (Optionally insert additional code for further Ids)
    // USER END
    }
    break;
  // USER START (Optionally insert additional message handling)
  // USER END
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Example #16
0
/**监控设置 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;
  }
}
Example #17
0
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;
	}
}
Example #18
0
const void Infoinit(INFO *Info,char i)  //填充行信息
{
		static int Year=0,day=0,month=0,hour=0,minute=0;
		
		LISTVIEW_AddRow(hListview,NULL);	
		sprintf(pStrBuf, (Info->ID)<10?"00%d":(Info->ID)<100?"0%d":"%d", Info->ID);
		LISTVIEW_SetItemText (hListview,0,i,pStrBuf);		  //序号
		sprintf(pStrBuf, "%s", Info->codeFormat);
		LISTVIEW_SetItemText (hListview,1,i,pStrBuf);	  //编码
	 
		Year = Info->date/10000;
		month = ((Info->date)%10000)/100;
		day = (Info->date)%100;
		sprintf (pStrBuf,month<10?"%d/0%d/%d":day<10?"%d/%d/0%d":"%d/%d/%d",Year,month,day);
		LISTVIEW_SetItemText (hListview,2,i,pStrBuf);  //年月日
		hour = (Info->time)/100;
		minute = (Info->time)%100;
		sprintf(pStrBuf,(hour<10 && minute<10)?"0%d:0%d":hour<10?"0%d:%d":minute<10?"%d:0%d":"%d:%d",hour,minute);
		LISTVIEW_SetItemText(hListview, 3, i,  pStrBuf); //时间
		LISTVIEW_SetItemText(hListview, 4, i, Info->chnl==INT?"518KHz":Info->chnl==LOC1?"490KHz":Info->chnl==LOC2?"4209.5KHz":"486KHz"); //频道
	 if (Info->type == INFO_Type_None)  //信息类型
		{
			 LISTVIEW_SetItemBitmap(hListview,5,i,25,7,NULL);
		}
		else if (Info->type == INFO_Type_VIP)
		{
			 if (Language == 0)
			    LISTVIEW_SetItemBitmap(hListview,5,i,25,7,&bmzhongyao);
				else LISTVIEW_SetItemBitmap(hListview,5,i,25,7,&bmIM_E);
		}
		else if (Info->type == INFO_Type_Rscue)
		{
			  if (Language == 0)
							LISTVIEW_SetItemBitmap(hListview,5,i,25,7,&bmsar);
					else LISTVIEW_SetItemBitmap(hListview,5,i,25,7,&bmSAR_E);
		}
			
	 if (Info->isLocked == 0)  //信息状态
		{
				if (Info->state == INFO_STT_New)
				{
					  if (Language == 0) //
									LISTVIEW_SetItemBitmap(hListview,6,i,10,7,&bmnewmsg);
							else LISTVIEW_SetItemBitmap(hListview,6,i,10,7,&bmNEW_E);
				}
				else LISTVIEW_SetItemText(hListview,6,i,"");
		}
		else if(Info->isLocked == 1)
		{
				if (Info->state == INFO_STT_New)
				{
					 if (Language == 0)
						{
						  LISTVIEW_SetItemBitmap(hListview,6,i,10,7,&bmnewmsg);
						}
						else LISTVIEW_SetItemBitmap(hListview,6,i,10,7,&bmNEW_E);
						LISTVIEW_SetItemText(hListview,6,i,"          锁");
				}
				else LISTVIEW_SetItemText(hListview,6,i,"          锁");
		}
}
Example #19
0
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int Id, NCode;
  // USER START (Optionally insert additional variables)
  // USER END

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of '_dFileType'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
    DROPDOWN_AddString(hItem, "(.Prj) Project");
    //
    // Initialization of 'Name'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetTextAlign(hItem, GUI_TA_RIGHT | GUI_TA_VCENTER);
    //
    // Initialization of '_bOK'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
    BUTTON_SetText(hItem, "Conform");
    //
    // Initialization of '_bDiscard'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
    BUTTON_SetText(hItem, "Discard");
    //
    // Initialization of 'Listview'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0);
    LISTVIEW_SetGridVis(hItem, 1);
    LISTVIEW_SetAutoScrollV(hItem, 1);
    LISTVIEW_AddColumn(hItem, 50, "Date", GUI_TA_HCENTER | GUI_TA_VCENTER);
    LISTVIEW_AddColumn(hItem, 100, "FileName", GUI_TA_HCENTER | GUI_TA_VCENTER);
    LISTVIEW_AddColumn(hItem, 80, "Type", GUI_TA_HCENTER | GUI_TA_VCENTER);
    LISTVIEW_AddRow(hItem, NULL);
    LISTVIEW_SetItemText(hItem, 0, 0, "13/12/21");
    LISTVIEW_SetItemText(hItem, 1, 0, "Default.Prj");
    LISTVIEW_SetItemText(hItem, 2, 0, ".Prj Project");
    //
    // Initialization of '_eFilename'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
    EDIT_SetText(hItem, "Default.prj");
    // USER START (Optionally insert additional code for further widget initialization)
    // USER END
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
    case ID_DROPDOWN_0: // Notifications sent by '_dFileType'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_SEL_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_0: // Notifications sent by '_bOK'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_1: // Notifications sent by '_bDiscard'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_LISTVIEW_0: // Notifications sent by 'Listview'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_SEL_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_EDIT_0: // Notifications sent by '_eFilename'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    // USER START (Optionally insert additional code for further Ids)
    // USER END
    }
    break;
  // USER START (Optionally insert additional message handling)
  // USER END
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
/*********************************************************************
*
*       _cbCallbackWidgets
*
* Purpose:
*   Initializes the widgets of the main dialog box
*/
static void _cbCallbackWidgets(WM_MESSAGE * pMsg) {
  GRAPH_SCALE_Handle hScaleH, hScaleV;
  int i;
  WM_HWIN hDlg, hMenu;
  hDlg = pMsg->hWin;
  switch (pMsg->MsgId) {
    case WM_INIT_DIALOG:
      /* Get handles of widgets */
      for (i = 0; i < NUM_WIDGETS; i++) {
        _ahWin[i] = WM_GetDialogItem(hDlg, _aID[i]);
      }
      /* Init dropdown widget */
      for (i = 0; i < 8; i++) {
        char acBuffer[] = {"Item x"};
        int Len = strlen(acBuffer);
        acBuffer[Len - 1] = '1' + i;
        DROPDOWN_AddString(_ahWin[DROPDOWN0], acBuffer);
      }
      /* Init edit widget */
      EDIT_SetText(_ahWin[EDIT0], "Edit");
      /* Init listbox widget */
      LISTBOX_SetAutoScrollV(_ahWin[LISTBOX0], 1);
      for (i = 0; i < 4; i++) {
        char acBuffer[] = {"Item x"};
        int Len = strlen(acBuffer);
        acBuffer[Len - 1] = '1' + i;
        LISTBOX_AddString(_ahWin[LISTBOX0], acBuffer);
      }
      /* Init listview widget */
      for (i = 0; i < 2; i++) {
        char acBuffer[] = {"Col. x"};
        int Len = strlen(acBuffer);
        acBuffer[Len - 1] = '1' + i;
        LISTVIEW_AddColumn(_ahWin[LISTVIEW0], 60, acBuffer, GUI_TA_CENTER);
      }
      for (i = 0; i < 9; i++) {
        int j;
        LISTVIEW_AddRow(_ahWin[LISTVIEW0], NULL);
        for (j = 0; j < (int)LISTVIEW_GetNumColumns(_ahWin[LISTVIEW0]); j++) {
          char acBuffer[] = {"Rx/Cx"};
          acBuffer[1] = '1' + i;
          acBuffer[4] = '1' + j;
          LISTVIEW_SetItemText(_ahWin[LISTVIEW0], j, i, acBuffer);
        }
      }
      LISTVIEW_SetGridVis(_ahWin[LISTVIEW0], 1);
      SCROLLBAR_CreateAttached(_ahWin[LISTVIEW0], SCROLLBAR_CF_VERTICAL);
      /* Init multiedit widget */
      MULTIEDIT_SetText(_ahWin[MULTIEDIT0], "This text could be modified by the MULTIEDIT widget");
      MULTIEDIT_SetWrapWord(_ahWin[MULTIEDIT0]);
      MULTIEDIT_SetAutoScrollV(_ahWin[MULTIEDIT0], 1);
      /* Init progbar widget */
      WIDGET_SetEffect(_ahWin[PROGBAR0], &WIDGET_Effect_3D);
      /* Init graph widget */
      for (i = 0; i < GUI_COUNTOF(_aColor); i++) {
        _aValue[i] = rand() % 95;
        _ahData[i] = GRAPH_DATA_YT_Create(_aColor[i], 500, 0, 0);
        GRAPH_AttachData(_ahWin[GRAPH0], _ahData[i]);
      }
      GRAPH_SetGridDistY(_ahWin[GRAPH0], 25);
      GRAPH_SetGridVis(_ahWin[GRAPH0], 1);
      GRAPH_SetGridFixedX(_ahWin[GRAPH0], 1);
      GRAPH_SetBorder(_ahWin[GRAPH0], 20, 4, 5, 4);
      /* Create and add vertical scale of graph widget */
      hScaleV = GRAPH_SCALE_Create(18, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25);
      GRAPH_SCALE_SetTextColor(hScaleV, GUI_RED);
      GRAPH_AttachScale(_ahWin[GRAPH0], hScaleV);
      /* Create and add horizontal scale of graph widget */
      hScaleH = GRAPH_SCALE_Create(46, GUI_TA_HCENTER | GUI_TA_VCENTER, GRAPH_SCALE_CF_HORIZONTAL, 50);
      GRAPH_SCALE_SetTextColor(hScaleH, GUI_DARKGREEN);
      GRAPH_AttachScale(_ahWin[GRAPH0], hScaleH);
      /* Init multipage widget */
      MULTIPAGE_AddPage(_ahWin[MULTIPAGE0],
                        GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), &_cbDialogPage, WM_UNATTACHED, 0, 0), 
                        "Page 1");
      MULTIPAGE_AddPage(_ahWin[MULTIPAGE0],
                        GUI_CreateDialogBox(_aDialogCreate2, GUI_COUNTOF(_aDialogCreate2), &_cbDialogPage, WM_UNATTACHED, 0, 0), 
                        "Page 2");
      /* Create and attach menu */
      hMenu = _CreateMenu(hDlg);/**/
      break;
    default:
      WM_DefaultProc(pMsg);
  }
}
Example #21
0
/**
  * @brief  Callback routine of Info dialog
  * @param  pMsg: pointer to data structure of type WM_MESSAGE 
  * @retval None
  */
static void _cbPlaylistDialog(WM_MESSAGE * pMsg) {
  int     NCode;
  int     Id;
  int     r;
  WM_HWIN hItem;

  static char tmp[64];
  uint32_t i = 0;
  
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OKPL);
    WM_SetCallback(hItem, _cbButton_okPL);
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_ADDPL);
    WM_SetCallback(hItem, _cbButton_add2PL);   
    
    
    hItem = LISTVIEW_CreateEx(60, 30, 300, 250, pMsg->hWin, WM_CF_SHOW, 0, ID_VIDEO_LIST);

    LISTVIEW_SetFont(hItem, &GUI_Font16_1);
    LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_UNSEL, 0x00DCA939);
    LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_SEL, GUI_WHITE);
    LISTVIEW_SetHeaderHeight(hItem, 0);
    LISTVIEW_AddColumn(hItem, 300, "", GUI_TA_VCENTER | GUI_TA_LEFT);
    LISTVIEW_SetGridVis(hItem, 0);
    LISTVIEW_SetAutoScrollV(hItem, 1);  
    WIDGET_SetEffect(hItem, &WIDGET_Effect_None);
    LISTVIEW_SetTextAlign(hItem, 0, GUI_TA_HCENTER); 
    
    if(VideoList.ptr > 0)
    {
      for(i=0; i<VideoList.ptr; i++)
      {
        strcpy(FileInfo.pRoot, (char *)VideoList.file[i].name);
        FILEMGR_GetFileOnly ((char *)tmp, (char *)FileInfo.pRoot);
        hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST);
        
        LISTVIEW_AddRow(hItem, NULL);         
        LISTVIEW_SetItemText(hItem, 0, i, (char *)tmp);
      }
    }     
    break;
    
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;   
    switch(Id) {
    case ID_BUTTON_OKPL: /* Notifications sent by 'OK' */
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        GUI_EndDialog(pMsg->hWin, 0); 
        break;
      }
      break;
      
    case ID_BUTTON_ADDPL: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        FileInfo.pfGetData = k_GetData;
        FileInfo.pMask = acMask_video;     
        hItem = CHOOSEFILE_Create(pMsg->hWin, 48, 30, 330, 240, apDrives, GUI_COUNTOF(apDrives), 0, "Video files", 0, &FileInfo);
        WM_MakeModal(hItem);
        r = GUI_ExecCreatedDialog(hItem);
        if (r == 0) 
        {
          if((strstr(FileInfo.pRoot, ".emf")) || (strstr(FileInfo.pRoot, ".EMF")))
          {
            if(VideoList.ptr < FILEMGR_LIST_DEPDTH)
            {
              strcpy((char *)VideoList.file[VideoList.ptr].name, FileInfo.pRoot);
              FILEMGR_GetFileOnly ((char *)tmp, (char *)FileInfo.pRoot);
              hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST);
              
              LISTVIEW_AddRow(hItem, NULL);         
              LISTVIEW_SetItemText(hItem, 0, VideoList.ptr, (char *)tmp);
              VideoList.ptr++;
            }
          }
          WM_InvalidateWindow(pMsg->hWin);
        }
        
        break;
      }
      break;        
      
    }
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
/**
  * @brief  Callback function of the media connection status
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbMediaConnection(WM_MESSAGE * pMsg) 
{
  static WM_HTIMER      hStatusTimer;  
  static uint8_t        prev_usb_status = 0;
  WM_HWIN hItem = 0;

  static char tmp[64];
  uint32_t i = 0;
  
  switch (pMsg->MsgId) 
  {
  case WM_CREATE:
    prev_usb_status = k_StorageGetStatus(USB_DISK_UNIT);    
    hStatusTimer = WM_CreateTimer(pMsg->hWin, ID_TIMER_CONNECTION, 500, 0);      
    break;
    
  case WM_TIMER:
  if(prev_usb_status != k_StorageGetStatus(USB_DISK_UNIT))
    {
      prev_usb_status = k_StorageGetStatus(USB_DISK_UNIT);
      if(prev_usb_status == 0)
      { 
        if(VideoPlayer_State != VIDEO_IDLE)
        {
          _StopPlay(&hvideo, &Video_File);
        }
        
        VideoList.ptr = 0;
        if(playbackwin)
        {
          GUI_EndDialog(playbackwin, 0);
          playbackwin = 0;
          
          SelLayer = 0;
          GUI_SetLayerVisEx (1, 0);
          GUI_SelectLayer(0);
          WM_InvalidateWindow(VideoWin);
        }
        if(hFrame)
        {
          WM_HideWindow(hFrame);        
          WM_Exec();        
          WM_DeleteWindow(hFrame);
          hFrame = 0;
        }
        if(hPlaylistWin)
        {
          hItem = WM_GetDialogItem(hPlaylistWin, ID_VIDEO_LIST);
          i = LISTVIEW_GetNumRows(hItem);
          while(i--)
          {
            LISTVIEW_DeleteRow(hItem, i);
          }
        }
      }
      else
      {
        VideoList.ptr = 0;
        _AddEntireFolder("0:");
        _AddEntireFolder("0:/Video");
        
        if(hPlaylistWin)
        {
          if(VideoList.ptr > 0)
          {
            for(i=0; i<VideoList.ptr; i++)
            {
              strcpy(FileInfo.pRoot, (char *)VideoList.file[i].name);
              FILEMGR_GetFileOnly ((char *)tmp, (char *)FileInfo.pRoot);
              hItem = WM_GetDialogItem(hPlaylistWin, ID_VIDEO_LIST);
              
              LISTVIEW_AddRow(hItem, NULL);         
              LISTVIEW_SetItemText(hItem, 0, i, (char *)tmp);
            }
            WM_InvalidateWindow(hItem);
            WM_Update(hItem); 
          } 
        }
        
      }
    }
    WM_RestartTimer(pMsg->Data.v, 500);
    break;
    
  case WM_DELETE:
    if(hStatusTimer != 0)
    {
      WM_DeleteTimer(hStatusTimer);
      hStatusTimer = 0;
    }
    break;   
    
  default:
    WM_DefaultProc(pMsg);
  }
}
Example #23
0
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);  
}