Ejemplo n.º 1
0
/**监控列表 LISTVIEW 条目更新
*
*/
static void updateListViewContent(WM_HWIN thisHandle)
{
	WM_HWIN  thisListView  = thisHandle;
	int i  = 0;
	int Cnt  = 0;
  int NumOfRows  = 0;
	
	NumOfRows  = LISTVIEW_GetNumRows(thisListView);
  
	for(i=0;i<N_boat;i++)
	{
//		if(boat_list_p[i]->isVisible )
//		{	
			Cnt++;
			
			if(Cnt > NumOfRows)
			{
				LISTVIEW_AddRow(thisListView, NULL);
				NumOfRows  = LISTVIEW_GetNumRows(thisListView);
			}
			
			sprintf(pStrBuf, "%ld", boat_list_p[i]->user_id);
			LISTVIEW_SetItemText(thisListView, 1, i, pStrBuf);
			
			sprintf(pStrBuf, "%d", boat_list_p[i]->true_heading);
			LISTVIEW_SetItemText(thisListView, 2, i, pStrBuf);
//		}
	}
	NumOfRows  = LISTVIEW_GetNumRows(thisListView);
	while(NumOfRows > Cnt)
	{
		LISTVIEW_DeleteRow(thisListView, NumOfRows-1);
		NumOfRows  = LISTVIEW_GetNumRows(thisListView);
	}
}
Ejemplo n.º 2
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);
  }
}
Ejemplo n.º 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);

  }
}
Ejemplo n.º 4
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;
	 }

 }
Ejemplo n.º 5
0
/*********************************************************************
*
*       _AddListviewItem
*/
static void _AddListviewItem(LISTVIEW_Handle hObj, const char* pMake, const char* pModel) {
  unsigned NumItems;
  NumItems = LISTVIEW_GetNumRows(hObj);
  LISTVIEW_AddRow(hObj, NULL);
  LISTVIEW_SetItemText(hObj, 0, NumItems, pMake);
  LISTVIEW_SetItemText(hObj, 1, NumItems, pModel);  
}
Ejemplo n.º 6
0
 void TestCom(WM_MESSAGE * pMsg,ETestMode etest_mode_in)
 {
	 int lenth;
	 char buf[10];
	 etest_mode = etest_mode_in;

     if(etest_mode == TEST_MODE_COM)
	 {
	 _ListBox[1]="C";
	 }else if(etest_mode == TEST_MODE_T)
	 {
	 _ListBox[1]="T";
	 }else{
	 _ListBox[1]="S";
	 }

	  if(ttpars.dir == 2)
	  {
	  _ListBox[2] = "D";
	   }else{
	  _ListBox[2] = "R";
	   }
	  

	 if((get_data.e_work_state != START_TEST)&&(get_data.e_work_state != GET_V1))
	 {
	  lenth = LISTVIEW_GetNumRows(WM_GetDialogItem(pMsg->hWin,GUI_ID_LISTVIEW_RESULT_T));
	  if(lenth < TEST_TIMES)
	  {
		record.test_times++;
	  
		sprintf(buf,"%d",lenth+1);

		_ListBox[0]= buf;
		LISTVIEW_InsertRow(WM_GetDialogItem(pMsg->hWin,GUI_ID_LISTVIEW_RESULT_T),0,_ListBox);

		if(ttpars.dir !=2)
		{
		BUTTON_SetText(WM_GetDialogItem(pMsg->hWin,GUI_ID_BUTTON_TRT),"正转中");
		ttpars.dir = 1;
		}else {
		BUTTON_SetText(WM_GetDialogItem(pMsg->hWin,GUI_ID_BUTTON_TRT),"反转中");	
		}
		motor_dir(ttpars.dir);

		BUTTON_SetText(WM_GetDialogItem(pMsg->hWin,GUI_ID_BUTTON_TSTOP),"运行中");
		start_test_init();

		if(!disp_mult)
		{
		draw_clear(&tdraw);
		}
		tdraw.draw_color = _aColor[record.test_times%5];
		tdraw.data_size = 0;
	  }
	  all_button(0,GUI_ID_BUTTON_TMAIN);
	  botton_able(1,GUI_ID_BUTTON_TSTOP);
	}
 }
Ejemplo n.º 7
0
void OnxxxClicked_SAVE(WM_MESSAGE * pMsg,ESaveState save_state)
{
	int i,j,k;
	LISTVIEW_Handle hObj;
	char buf[10];
	hObj = WM_GetDialogItem(pMsg->hWin,GUI_ID_LISTVIEW_RESULT);
	tget_record.act_record_lenth = LISTVIEW_GetNumRows(hObj);
	for(i=0;i<LISTVIEW_GetNumRows(hObj);i++)
		{

	LISTVIEW_GetItemText(hObj,0,i,tget_record.sig_record[i].order,4);

	LISTVIEW_GetItemText(hObj,1,i,tget_record.sig_record[i].V1,5);

	LISTVIEW_GetItemText(hObj,2,i,tget_record.sig_record[i].V2,5);

	LISTVIEW_GetItemText(hObj,3,i,tget_record.sig_record[i].result_r_e,5);
	
	LISTVIEW_GetItemText(hObj,4,i,tget_record.sig_record[i].state,8);

	LISTVIEW_GetItemText(hObj,5,i,tget_record.sig_record[i].time,6);

	LISTVIEW_GetItemText(hObj,6,i,tget_record.sig_record[i].dir,3);

	
		
		}

	if(save_state == RemberToSd)
	{
	tget_record.year = Tim.year;
	tget_record.month = Tim.month;
	tget_record.date = Tim.date;

	
	file_clear();
    save_custormer();
	save_parameters();
	save_get_record();
	}
	

	
}
Ejemplo n.º 8
0
/* 更新监控设置的 LISTVIEW 条目
*
*/
static void updateListViewContent(WM_HWIN thisHandle)
{
	WM_HWIN thisListView  = thisHandle;
	
	int i  = 0;
	int NumOfRows  = 0;
	
	NumOfRows  = LISTVIEW_GetNumRows(thisListView);
//	for(i=0;i<N_boat;i++)
//	{
//		// LISTVIEW 行数小于要显示的船的数量,添加行
//		if(i+1 > NumOfRows)
//		{
//			LISTVIEW_AddRow(thisListView, NULL);
//			NumOfRows  = LISTVIEW_GetNumRows(thisListView);
//		}
//		
//    if(boat_list_p[i]->name[0] != '\0')
//		   LISTVIEW_SetItemText(thisListView, 0, i, boat_list_p[i]->name);
//		
////		sprintf(pStrBuf, "%ld", test[i].user_id);
////		LISTVIEW_SetItemText(thisListView, 1, i, pStrBuf);
//		sprintf(pStrBuf, "%ld", boat_list_p[i]->user_id);
//		LISTVIEW_SetItemText(thisListView, 1, i, pStrBuf);
//		
//		if(boat_list_p[i]->mntState)
//			LISTVIEW_SetItemText(thisListView, 2, i, "o");
//		else
//			LISTVIEW_SetItemText(thisListView, 2, i, "x");
//	}

	
	// LISTVIEW 行数大于要显示的船的数量,删除行
//  NumOfRows  = LISTVIEW_GetNumRows(thisListView);
	while(NumOfRows > N_boat)
	{
		LISTVIEW_DeleteRow(thisListView, NumOfRows-1);
		NumOfRows  = LISTVIEW_GetNumRows(thisListView);
	}
}
Ejemplo n.º 9
0
/**监控列表 LISTVIEW 的监听器(回调函数)
*
*/
static void myListViewListener(WM_MESSAGE* pMsg)
{
	 const WM_KEY_INFO * pInfo;
	 WM_HWIN thisListView  = pMsg->hWin; 
   
	switch(pMsg->MsgId)
	{
//		case WM_PAINT:
//			
//		GUI_SetColor(GUI_BLACK);
//		GUI_SetFont(&GUI_Font24_1);
//		GUI_DispStringAt("egg",330,160);
//		GUI_DispStringAt("eggg",400,450);
//			LISTVIEW_Callback(pMsg);
//	  	break;
		case WM_SET_FOCUS:

      if(LISTVIEW_GetNumRows(pMsg->hWin) && (LISTVIEW_GetSel(pMsg->hWin)<0))
         LISTVIEW_SetSel(pMsg->hWin, 0);
      LISTVIEW_Callback(pMsg);
      break;
		case WM_KEY:
			pInfo  = (WM_KEY_INFO*)pMsg->Data.p;
		
		  switch(pInfo->Key)
			{
				case GUI_KEY_UP:
				case GUI_KEY_DOWN:
					LISTVIEW_Callback(pMsg);	
   				showSelectedBoatInfo(thisListView);			
					break;
				
				case GUI_KEY_LEFT:				
					WM_SetFocus(menuWin);
					break;
				case GUI_KEY_MENU:
//         WM_BringToBottom(thisListView);
					WM_BringToTop(hDlg_FishMap);
				  WM_SetFocus(hDlg_FishMap);
					break;
				default:
					LISTVIEW_Callback(pMsg);
					break;
			}
			break;
		
		default:
			LISTVIEW_Callback(pMsg);
			break;
	}
}
Ejemplo n.º 10
0
 void OnButtonTSaveClicked(WM_MESSAGE * pMsg,ESaveState save_state)
 {
	int i,j,k;
	LISTVIEW_Handle hObj;
	char buf[10];
	hObj = WM_GetDialogItem(pMsg->hWin,GUI_ID_LISTVIEW_RESULT_T);
	tget_record.act_record_lenth = LISTVIEW_GetNumRows(hObj);
	for(i=0;i<LISTVIEW_GetNumRows(hObj);i++)
		{
	LISTVIEW_GetItemText(hObj,0,i,tget_record.sig_record[i].order,4);

	LISTVIEW_GetItemText(hObj,1,i,tget_record.sig_record[i].V1,5);

	LISTVIEW_GetItemText(hObj,2,i,tget_record.sig_record[i].V2,5);

	LISTVIEW_GetItemText(hObj,3,i,tget_record.sig_record[i].result_r_e,5);
	
	LISTVIEW_GetItemText(hObj,4,i,tget_record.sig_record[i].state,8);

	LISTVIEW_GetItemText(hObj,5,i,tget_record.sig_record[i].time,6);

	LISTVIEW_GetItemText(hObj,6,i,tget_record.sig_record[i].dir,3);
		}

	if(save_state == RemberToSd)
	{
	tget_record.year = Tim.year;
	tget_record.month = Tim.month;
	tget_record.date = Tim.date;

	file_clear();

	save_data_to_file( "speedt.lt", (TCustormer*)&custormer,sizeof(TCustormer));
    save_data_to_file( "speedt.lt", (TTPars*)&ttpars,sizeof(TTPars));
	save_data_to_file( "speedt.lt", (TGetRecord*)&tget_record,sizeof(TGetRecord));
	}
 }
/*********************************************************************
*
*       _AddRow
*
* Function description
*   Inserts or adds a new row of data to the given LISTVIEW
*
* Parameter:
*   hItem  - Handle of LISTVIEW widget
*   Insert - 1 for inserting a row,0 for adding a row
*/
static int _AddRow(WM_HWIN hItem, int Insert) {
  int    i;
  int    r;
  int    Len;
  int    NumRows;
  char * apText[3];
  char   acText[3][10] = {{0}};
  char   acBuffer[6];
  
  //
  // Create contents of name field
  //
  strcpy(acText[0], "Name ");
  NumRows = LISTVIEW_GetNumRows(hItem);
  _IntToStr(acBuffer, NumRows);
  Len = strlen(acBuffer);
  for (i = Len; i < 4; i++) {
    strcat(acText[0], " ");
  }
  strcat(acText[0], acBuffer);
  //
  // Create contents of code field
  //
  for (i = 0; i < 5; i++) {
    acText[1][i] = rand() % 26 + 'A';
  }
  //
  // Create contents of balance field
  //
  _IntToStr(acText[2], ((rand() % 10000) - 5000));
  //
  // Fill pointer array
  //
  for (i = 0; i < 3; i++) {
    apText[i] = acText[i];
  }
  //
  // Add/Insert row
  //
  if (Insert) {
    r = LISTVIEW_InsertRow(hItem, 0, (const GUI_ConstString *)apText);
  } else {
    r = LISTVIEW_AddRow(hItem, (const GUI_ConstString *)apText);
  }
  return r;
}
Ejemplo n.º 12
0
/*********************************************************************
*
*       _GetVehicle
*/
static int _GetVehicle(WM_HWIN hWin) {
  WM_HWIN hItem;
  int CurSel, NumItems;
  hItem = WM_GetDialogItem(hWin, GUI_ID_LISTVIEW0);
  NumItems = LISTVIEW_GetNumRows(hItem);
  CurSel   = LISTVIEW_GetSel(hItem);
  if ((CurSel >= 0) && (CurSel < NumItems)) {
    strcpy(_acVehicle, _acItems[CurSel][0]);
    strcat(_acVehicle, " ");
    strcat(_acVehicle, _acItems[CurSel][1]);

    hItem = WM_GetDialogItem(hWin, GUI_ID_EDIT0);
    EDIT_SetText(hItem, _acVehicle);
    return 1;
  }
  return 0;
}
Ejemplo n.º 13
0
/*********************************************************************
*
*       LISTVIEW_SetItemText
*/
void LISTVIEW_SetItemText(LISTVIEW_Handle hObj, unsigned Column, unsigned Row, const char * s) {
  if (hObj) {
    if ((Column < LISTVIEW_GetNumColumns(hObj)) && (Row < LISTVIEW_GetNumRows(hObj))) {
      int NumBytes;
      LISTVIEW_ITEM * pItem;
      LISTVIEW_Obj  * pObj;
      WM_LOCK();
      pObj = LISTVIEW_H2P(hObj);
      NumBytes = GUI__strlen(s) + 1;
      pItem = (LISTVIEW_ITEM *)GUI_ARRAY_ResizeItem((GUI_ARRAY *)GUI_ARRAY_GetpItem(&pObj->RowArray, Row), Column, sizeof(LISTVIEW_ITEM) + NumBytes);
      if (NumBytes > 1) {
        strcpy(pItem->acText, s);
      }
      LISTVIEW__InvalidateRow(hObj, pObj, Row);
      WM_UNLOCK();
    }
  }
}
Ejemplo n.º 14
0
/*********************************************************************
*
*       LISTVIEW_AddColumn
*/
void LISTVIEW_AddColumn(LISTVIEW_Handle hObj, int Width, const char * s, int Align) {
  if (hObj) {
    LISTVIEW_Obj* pObj;
    unsigned NumRows;
    WM_LOCK();
    pObj = LISTVIEW_H2P(hObj);
    HEADER_AddItem(pObj->hHeader, Width, s, Align);   /* Modify header */
    GUI_ARRAY_AddItem(&pObj->AlignArray, &Align, sizeof(int));
    NumRows = LISTVIEW_GetNumRows(hObj);
    if (NumRows) {
      GUI_ARRAY* pRow;
      unsigned i;
      for (i = 0; i < NumRows; i++) {
        pRow = (GUI_ARRAY*) GUI_ARRAY_GetpItem(&pObj->RowArray, i);
        GUI_ARRAY_AddItem(pRow, NULL, sizeof(LISTVIEW_ITEM) + 1);
      }
    }
    LISTVIEW__UpdateScrollParas(hObj, pObj);
    LISTVIEW__InvalidateInsideArea(hObj, pObj);
    WM_UNLOCK();
  }
}
Ejemplo n.º 15
0
//
// Buttoncallback;
//
void mybutton (WM_MESSAGE *pMsg) 
{
	WM_HWIN hWin;
	WM_KEY_INFO *pInfo;
	int column,row,row_index,del_row;
	int i;
	hWin = pMsg->hWin;
	switch (pMsg->MsgId)
	{
		
		 case USER_MSG_LANGUAGE: //更改语言
				    pLanguage = &Lgumainwin[Language];
			     if (Language == 0)
								{
									  BUTTON_SetFont(hButton,&GUI_Font30);
									  TEXT_SetFont(mainwinText[5],&GUI_Font30);
									  HEADER_SetFont(hListhead,&GUI_Font24);
								}
								else
								{
									  BUTTON_SetFont(hButton,&GUI_Font20_1);
									  TEXT_SetFont(mainwinText[5],&GUI_Font24_1);
									  HEADER_SetFont(hListhead,&GUI_Font16_1);			
           LISTVIEW_SetHeaderHeight(hListview,29);									
								}
								DisPage();
			     BUTTON_SetText(hButton,pLanguage->ButtonInfo[0]);
			     for(i = 0; i<7; i++)
											HEADER_SetItemText(hListhead,i,pLanguage->ListHead[i]);
				    break;
			
			case WM_SET_FOCUS:
								if (pMsg->Data.v)
								{
											BUTTON_SetBkColor(hButton,BUTTON_CI_UNPRESSED,GUI_GRAY);
											BUTTON_SetTextColor(hButton,BUTTON_CI_UNPRESSED,GUI_WHITE);
											BUTTON_SetFocusColor(hButton,GUI_GRAY);
								}
								else 	
								{
									BUTTON_SetBkColor(hButton,BUTTON_CI_UNPRESSED,GUI_WHITE);//BUTTON_SetTextColor (hButton,BUTTON_CI_UNPRESSED,GUI_BLACK);
									BUTTON_SetTextColor(hButton,BUTTON_CI_UNPRESSED,GUI_BLACK);
									BUTTON_SetFocusColor(hButton,GUI_WHITE);
								}
								BUTTON_Callback(pMsg);
								break;
		
			case WM_KEY:
				    pInfo = (WM_KEY_INFO*)pMsg->Data.p;
							switch (pInfo->Key)
							{ 
								
								 case GUI_KEY_ENTER:
										    break;
									
								 case GUI_KEY_PRINT:
														WM_BringToTop(PrintWin);
														WM_SetFocus(WM_GetDialogItem(PrintWin,ID_PrintMenu));
										    break;
									case GUI_KEY_MENU:
										    WM_BringToTop(Menuwin);
										    WM_SetFocus  (WM_GetDialogItem(Menuwin,ID_MENU));
									     MENU_SetSel (WM_GetDialogItem(Menuwin,ID_MENU),0);
									     MenuSel = 0;
										    break;
				
				     case GUI_KEY_LOC1:
							       pCannel = "  490 横";
							       WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1));
							       break;
									
				     case GUI_KEY_LOC2:
							       pCannel = "4209.5横";
						       	WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1));
							       break;
									
				     case GUI_KEY_CHS:
							       pCannel = "  486 横";
							       WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1));
					         break;
				  
		     		case GUI_KEY_UP:
						       	break;
									
				     case GUI_KEY_DOWN:
					         if (LISTVIEW_GetNumRows(hListview))
				         	{
																	thispage = 1;
																	WM_SetFocus(hListview);
																	LISTVIEW_SetSel(hListview,0);
																	DisPage();			
																	//WM_InvalidateRect(mainwin,&PageRect);  //刷新页数提示
														}
														break;
				
									case GUI_KEY_LEFT:
										    if(InfoType > 0)
											     InfoType--;
										    else InfoType = 3;
					         switch (InfoType)
														{
																case 0:
																					BUTTON_SetText(hWin,pLanguage->ButtonInfo[0]);
																					LISTVIEW_DeleteAllRows(hListview);
																					InfoSel(0,1);
																					break;
																
																case 1:
																					BUTTON_SetText(hWin,pLanguage->ButtonInfo[1]);
																				 LISTVIEW_DeleteAllRows(hListview);
																					InfoSel(1,1);
																	    break;
																
																case 2:
																				BUTTON_SetText(hWin,pLanguage->ButtonInfo[2]);
																			 LISTVIEW_DeleteAllRows(hListview);
																				InfoSel(2,1);
																			 break;
																
																case 3:
																					BUTTON_SetText(hWin,pLanguage->ButtonInfo[3]);
																					LISTVIEW_DeleteAllRows(hListview);
																					InfoSel(3,1);					
																					break;
													}
													if (rowindex<8)
													{	
														pageNum = 1;
													}
													else if (rowindex%8 == 0)
														pageNum = rowindex/8;
													else pageNum = rowindex/8+1;
													thispage = 1;
													DisPage();			
													//WM_InvalidateRect(mainwin,&PageRect);//刷新页数提示
													break;
													
								case GUI_KEY_RIGHT:
												InfoType++;
												if(InfoType == 4)
													  InfoType = 0;
												switch (InfoType)
												{
														case 0:
																			BUTTON_SetText(hWin,pLanguage->ButtonInfo[0]);
																			LISTVIEW_DeleteAllRows(hListview);
																			InfoSel(0,1);
																		 break;
														
														case 1:
																			BUTTON_SetText(hWin,pLanguage->ButtonInfo[1]);
																			LISTVIEW_DeleteAllRows(hListview);
																			InfoSel(1,1);
																		 break;
														
														case 2:
																			BUTTON_SetText(hWin,pLanguage->ButtonInfo[2]);
																			LISTVIEW_DeleteAllRows(hListview);
																			InfoSel(2,1);
																	 	break;
														 
														case 3:
																			BUTTON_SetText(hWin,pLanguage->ButtonInfo[3]);
																			LISTVIEW_DeleteAllRows(hListview);
																			InfoSel(3,1);		
																			break;
												}
												if (rowindex<8)
												  	pageNum = 1;
												else if (rowindex%8 == 0)
													  pageNum = rowindex/8;
												else pageNum = rowindex/8+1;
												thispage = 1;				
												DisPage();												
												//WM_InvalidateRect(mainwin,&PageRect);//刷新页数提示
												break;
							}
				   break;
							
			default :
			    BUTTON_Callback(pMsg);
		     break;
	}
}
Ejemplo n.º 16
0
/**
  * @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;
  }
}
Ejemplo n.º 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;
	}
}
Ejemplo n.º 18
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();
  }
}
Ejemplo n.º 19
0
/**监控设置 LISTVIEW 的监听器(回调函数)
*
*/
static void myListViewListener(WM_MESSAGE* pMsg)
{
	 const WM_KEY_INFO * pInfo;
	 WM_HWIN thisListView  = pMsg->hWin; 
	
	 int selectedRow  = -1;
  int index  = -1;
	
	switch(pMsg->MsgId)
	{
		case WM_SET_FOCUS:

      if(LISTVIEW_GetNumRows(pMsg->hWin) && (LISTVIEW_GetSel(pMsg->hWin)<0))
         LISTVIEW_SetSel(pMsg->hWin, 0);
      updateListViewContent(thisListView);
      LISTVIEW_Callback(pMsg);
      break;		
    case WM_KEY:
			pInfo  = (WM_KEY_INFO*)pMsg->Data.p;
		
		  switch(pInfo->Key)
			{
				case GUI_KEY_UP:
				case GUI_KEY_DOWN:
					LISTVIEW_Callback(pMsg);
				  //showSelectedBoatInfo(thisListView);
					break;
				
				case GUI_KEY_LEFT:				
					WM_SetFocus(menuWin);
					break;
				
				case GUI_KEY_RIGHT:
					WM_SetFocus(etWin);
					break;
				
				
				case GUI_KEY_ENTER:
//      selectedRow  = LISTVIEW_GetSel(thisListView);
//				 	index  = getSelectedBoatIndex(thisListView, 1, selectedRow);
      index  = LISTVIEW_GetSel(thisListView);
				  if(index >= 0)
      {
//         if( mntBoats[index].MNTState == MNTState_Default )
//         {
//            mntBoats[index].MNTState  = MNTState_None;
//            LISTVIEW_SetItemText(thisListView, 2, index, "x");
//         } 
//         else if(mntBoats[index].MNTState == MNTState_Monite)           
//         {
//            mntBoats[index].MNTState  = MNTState_Choosen;
//            LISTVIEW_SetItemText(thisListView, 2, index, "o");
//         }
//         switch(mntBoats[index].MNTState)
//         {
//            case MNTState_Choosen:
//                 mntBoats[index].MNTState  = MNTState_Monite;
//                 LISTVIEW_SetItemText(thisListView, 2, index, "x");
//                 break;
//            case MNTState_Default:  
//                 mntBoats[index].MNTState  = MNTState_None;
//                 LISTVIEW_SetItemText(thisListView, 2, index, "x");
//                 break;
//            case MNTState_Monite:
//                 mntBoats[index].MNTState  = MNTState_Choosen;
//                 LISTVIEW_SetItemText(thisListView, 2, index, "o");
//                 break;
//            case MNTState_None:
//                 mntBoats[index].MNTState  = MNTState_Default;
//                 LISTVIEW_SetItemText(thisListView, 2, index, "o");
//                 break;
//         }
       
      }
      
					break;
					
				case GUI_KEY_BACKSPACE:
INFO("case backspace");    
					WM_BringToTop(confirmWin);
				  WM_SetFocus(confirmWin);
          break;					
				
				case GUI_KEY_MENU:
					WM_BringToTop(hDlg_FishMap);
				  WM_SetFocus(hDlg_FishMap);
					break;
			
				default:
					LISTVIEW_Callback(pMsg);
					break;
			}
			break;
		
		default:
			LISTVIEW_Callback(pMsg);
			break;
	}
}
Ejemplo n.º 20
0
/*********************************************************************
*
*       _Action
*
* Purpose:
*   Does some action with the widget
*/
static void _Action(WM_HWIN hList) {
  unsigned ColoredCol   = 0;
  unsigned ColoredRow   = 0;
  unsigned NumRows;
  unsigned Index;
  unsigned i;
  int      SortedColumn = -1;
  int      ColorIndex   = 0;
  int      Reverse      = 0;

  Index = 0;
  do {
    if (_aAction[Index].pDescription) {
      GUIDEMO_ShowInfo(_aAction[Index].pDescription);
    }
    switch (_aAction[Index].Job) {
    case JOB_COLOR:
      NumRows = LISTVIEW_GetNumRows(hList);
      for (i = 0; i < NumRows; i++) {
        LISTVIEW_SetItemBkColor(hList, ColoredCol, ColoredRow, LISTVIEW_CI_UNSEL, _aColor[ColorIndex]);
        if (++ColorIndex == GUI_COUNTOF(_aColor)) {
          ColorIndex = 0;
        }
        if (++ColoredCol == LISTVIEW_GetNumColumns(hList)) {
          ColoredCol = 0;
        }
        if (++ColoredRow == NumRows) {
          ColoredRow = 0;
        }
      }
      break;
    case JOB_INCSEL:
      LISTVIEW_IncSel(hList);
      break;
    case JOB_DECSEL:
      LISTVIEW_DecSel(hList);
      break;
    case JOB_REVERSE:
      Reverse ^= 1;
      LISTVIEW_SetSort(hList, SortedColumn, Reverse);
      break;
    case JOB_ADDROWS:
      for (i = 0; i < 40; i++) {
        _AddRow(hList, 0);
      }
      break;
    case JOB_SETSORT:
      if (SortedColumn == -1) {
        SortedColumn = 0;
      } else {
        SortedColumn++;
        if (SortedColumn == (int)LISTVIEW_GetNumColumns(hList)) {
          SortedColumn = 0;
        }
      }
      LISTVIEW_SetSort(hList, SortedColumn, Reverse);
      break;
    }
    GUI_Delay(_aAction[Index].Delay);
  } while ((++Index < GUI_COUNTOF(_aAction)) && (GUIDEMO_CheckCancel() == 0));
}
Ejemplo n.º 21
0
void OnxxxClicked_Start(WM_MESSAGE * pMsg)
{

	  int lenth;
	  char buf[5];
	
	  GUI_ConstString _ListBox[] = {"1", "0", "0","E", "", "","R"};

	if(!disp_muit && !exist[0])// 如果单曲线显示
	  {

#ifdef DISP_YT
	_ahData[0] = GRAPH_DATA_YT_Create(_aColor[0], 500, 0, 0);//YT
	
#endif

#ifdef DISP_XY

	_ahData[0]  = GRAPH_DATA_XY_Create(_aColor[0],DISP_XY_X_LENTH,0, 0);
     
#endif
	 
    GRAPH_AttachData(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), _ahData[0]);//attaches  data object to graph object
    exist[0] = 1;
	GRAPH_SetUserDraw(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), _UserDraw); /* Enable user draw */
			
    GRAPH_SetGridVis(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), 6);
	GRAPH_SetVSizeY(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), 1000);
    _hScaleV = GRAPH_SCALE_Create( 35, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 10);
    GRAPH_SCALE_SetTextColor(_hScaleV, GUI_YELLOW);
    GRAPH_AttachScale(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), _hScaleV);
	  }

	  if((get_data.e_work_state != START_TEST)&&(get_data.e_work_state != GET_V1))
	  	{
	
	  lenth = LISTVIEW_GetNumRows(WM_GetDialogItem(pMsg->hWin,GUI_ID_LISTVIEW_RESULT));
	  
	  if(lenth < TEST_TIMES)
	  {
	  record.test_times++;
	  
	  sprintf(buf,"%d",lenth+1);
	  _ListBox[0]= buf;
	  LISTVIEW_InsertRow(WM_GetDialogItem(pMsg->hWin,GUI_ID_LISTVIEW_RESULT),0,_ListBox);
	
	  if(disp_muit)
	  	{
	  	if(!exist[lenth])
	  		{
		_ahData[lenth] = GRAPH_DATA_YT_Create(_aColor[lenth%3], 500, 0, 0);//YT
	 
     	GRAPH_AttachData(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), _ahData[lenth]);//attaches  data object to graph object
     	exist[lenth] = 1;
		
			if(lenth == 0)
			{
			GRAPH_SetUserDraw(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), _UserDraw); /* Enable user draw */	
    		GRAPH_SetGridVis(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), 6);
			GRAPH_SetVSizeY(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), 1000);
    		_hScaleV = GRAPH_SCALE_Create( 35, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 10);
    		GRAPH_SCALE_SetTextColor(_hScaleV, GUI_YELLOW);
    		GRAPH_AttachScale(WM_GetDialogItem(pMsg->hWin, GUI_ID_GRAPH0), _hScaleV);
			}

	    }
	  }
      
	  BUTTON_SetText(WM_GetDialogItem(pMsg->hWin,GUI_ID_BUTTON_CR),"正转");
	  button_cr_state = 1;

	  pars.dir = 1;
	  
	  start_test_init();
	  	}
	}
}
Ejemplo n.º 22
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;
  }
}
Ejemplo n.º 23
0
/**
  * @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);
  }
}
Ejemplo n.º 24
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;
  }
}
Ejemplo n.º 25
0
/*********************************************************************
*
*       MainTask
*/
void MainTask(void) {
  WM_HWIN hScrollbar, hDlgOptions;
  GUI_RECT RectDlg, RectClient;
  int Cnt = 0, IndexEffect = 0, ButtonState = 0, DropdownState = 0;
  int ProgbarValue   = 0, ProgbarInc   = 1;
  int SliderValue    = 0, SliderInc    = 1;
  int ScrollbarValue = 0, ScrollbarInc = 1;
  int ListViewInc  = 1;
  int ListBoxInc   = 1;
  int MultiEditInc = 1;
  int Vz = 1;
  const WIDGET_EFFECT * _apEffect[] = {&WIDGET_Effect_3D,     /* Array of effects */
                                      &WIDGET_Effect_Simple, 
                                      &WIDGET_Effect_None};
  const char * _apEffects[] = {"Widget effect: 3D", "Widget effect: Simple", "Widget effect: None"};
  GUI_Init();
  GUI_CURSOR_Show();
  WM_SetCallback(WM_HBKWIN, _cbBkWindow);
  WM_SetCreateFlags(WM_CF_MEMDEV);  /* Use memory devices on all windows to avoid flicker */
  WM_EnableMemdev(WM_HBKWIN);       /* Enable use of memory devices for desktop windows */
  /* Create framewindow and set its properties */
  _hFrameWin = FRAMEWIN_CreateEx(0, 0, 640, 480, 0, WM_CF_SHOW, 0, 0, "", &_cbCallbackFramewin);
  FRAMEWIN_SetMoveable(_hFrameWin, 1);
  FRAMEWIN_SetText(_hFrameWin, _apEffects[0]);
  FRAMEWIN_SetFont(_hFrameWin, &GUI_Font13B_ASCII);
  /* Create main dialog window as child from framewindows client window */
  _hDlg = GUI_CreateDialogBox(_aDlgWidgets,
                              GUI_COUNTOF(_aDlgWidgets), 
                              &_cbCallbackWidgets, 
                              WM_GetClientWindow(_hFrameWin), 0, 0);
  /* Attach scrollbar to framewindows client window and set its properties */
  hScrollbar = SCROLLBAR_CreateAttached(WM_GetClientWindow(_hFrameWin), 0);
  WM_GetWindowRectEx(_hDlg, &RectDlg);
  WM_GetClientRectEx(WM_GetClientWindow(_hFrameWin), &RectClient);
  SCROLLBAR_SetNumItems(hScrollbar, RectDlg.x1);
  SCROLLBAR_SetPageSize(hScrollbar, RectClient.x1);
  /* Create options dialog with 'stay on top' and 'moveable' attribute */
  hDlgOptions = GUI_CreateDialogBox(_aDlgOptions, 
                                    GUI_COUNTOF(_aDlgOptions), 
                                    &_cbCallbackOptions, 
                                    WM_HBKWIN, 0, 0);
  FRAMEWIN_SetMoveable(hDlgOptions, 1);
  WM_SetStayOnTop(hDlgOptions, 1);
  /* Main loop for modifying the widgets */
  while (1) {
    if (_AutoMode) {
      Cnt++;
      /* Modify progbar */
      if ((Cnt % 2) == 0) {
        ProgbarValue += ProgbarInc;
        if ((ProgbarValue == 110) || (ProgbarValue == -10)) {
          ProgbarInc *= -1;
        }
        PROGBAR_SetValue(_ahWin[PROGBAR0], ProgbarValue);
      }
      /* Modify slider */
      if ((Cnt % 2) == 0) {
        int j;
        SliderValue += SliderInc;
        if ((SliderValue == 100) || (SliderValue == 0)) {
          SliderInc *= -1;
        }
        for (j = 0; j < 3; j++) {
          SLIDER_SetValue(_ahWin[SLIDER0 + j], SliderValue);
        }
      }
      /* Modify scrollbar */
      if ((Cnt % 3) == 0) {
        int j;
        ScrollbarValue += ScrollbarInc;
        if ((ScrollbarValue == 90) || (ScrollbarValue == 0)) {
          ScrollbarInc *= -1;
        }
        for (j = 0; j < 3; j++) {
          SCROLLBAR_SetValue(_ahWin[SCROLLBAR0 + j], ScrollbarValue);
        }
      }
      /* Modify multipage */
      if ((Cnt % 120) == 0) {
        MULTIPAGE_SelectPage(_ahWin[MULTIPAGE0], MULTIPAGE_GetSelection(_ahWin[MULTIPAGE0]) ^ 1);
      }
      /* Modify dropdown */
      if ((Cnt % 120) == 0) {
        DropdownState ^= 1;
        if (DropdownState) {
          DROPDOWN_Expand(_ahWin[DROPDOWN0]);
        } else {
          DROPDOWN_Collapse(_ahWin[DROPDOWN0]);
        }
      }
      /* Modify button */
      if ((Cnt % 40) == 0) {
        ButtonState ^= 1;
        BUTTON_SetPressed(_ahWin[BUTTON0], ButtonState);
      }
      /* Modify listbox */
      if ((Cnt % 30) == 0) {
        int Sel;
        Sel = LISTBOX_GetSel(_ahWin[LISTBOX0]);
        if (Sel < 0) {
          Sel = 0;
        }
        LISTBOX_SetSel(_ahWin[LISTBOX0], Sel + ListBoxInc);
        Sel = LISTBOX_GetSel(_ahWin[LISTBOX0]);
        if ((Sel == (int)LISTBOX_GetNumItems(_ahWin[LISTBOX0]) - 1) || (Sel == 0)) {
          ListBoxInc *= -1;
        }
      }
      /* Modify listview */
      if ((Cnt % 50) == 0) {
        int Sel;
        Sel = LISTVIEW_GetSel(_ahWin[LISTVIEW0]);
        if (Sel < 0) {
          Sel = 0;
        }
        LISTVIEW_SetSel(_ahWin[LISTVIEW0], Sel + ListViewInc);
        Sel = LISTVIEW_GetSel(_ahWin[LISTVIEW0]);
        if ((Sel == (int)LISTVIEW_GetNumRows(_ahWin[LISTVIEW0]) - 1) || (Sel == 0)) {
          ListViewInc *= -1;
        }
      }
      /* Modify multiedit */
      if ((Cnt % 5) == 0) {
        int Sel, Len;
        char acBuffer[100];
        MULTIEDIT_SetCursorOffset(_ahWin[MULTIEDIT0], MULTIEDIT_GetCursorCharPos(_ahWin[MULTIEDIT0]) + MultiEditInc);
        MULTIEDIT_GetText(_ahWin[MULTIEDIT0], acBuffer, sizeof(acBuffer));
        Sel = MULTIEDIT_GetCursorCharPos(_ahWin[MULTIEDIT0]);
        Len = strlen(acBuffer);
        if ((Sel == (Len - 1)) || (Sel == 0)) {
          MultiEditInc *= -1;
        }
        if (!DropdownState) {
          WM_SetFocus(_ahWin[MULTIEDIT0]);
        }
      }
      /* Modify graph */
      _AddValues(_ahWin[GRAPH0], 95);
      /* Move window */
      if ((Cnt % 1200) == 0) {
        int Inc;
        WM_HWIN hScroll;
        WM_SCROLL_STATE ScrollState;
        hScroll = WM_GetScrollbarH(WM_GetClientWindow(_hFrameWin));
        WM_GetScrollState(hScroll, &ScrollState);
        Inc = (ScrollState.NumItems - ScrollState.PageSize) / 2;
        ScrollState.v += Inc * Vz;
        if ((ScrollState.v >= Inc * 2) || (ScrollState.v <= 0)) {
          Vz *= -1;
        }
        SCROLLBAR_SetValue(hScroll, ScrollState.v);
      }
      /* Change effect */
      if ((Cnt % 400) == 0) {
        int Index;
        WM_HWIN hWin;
        IndexEffect++;
        Index = IndexEffect % GUI_COUNTOF(_apEffect);
        _SetEffect(Index);
        hWin = WM_GetDialogItem(hDlgOptions, GUI_ID_RADIO0);
        RADIO_SetValue(hWin, Index);
      }
    }
    /* Wait a while */
    GUI_Delay(10);
  }
}