Ejemplo n.º 1
0
/*********************************************************************
*
*       GUIDEMO_Dialog
*/
void GUIDEMO_Dialog(void) {
  int i;
  WM_HWIN hWin;
  GUI_COLOR DesktopColorOld;
  GUIDEMO_ShowIntro("Dialog boxes", "\nDialog boxes\ncan easily be created");
  GUIDEMO_HideInfoWin();
  DesktopColorOld = WM_SetDesktopColor(GUI_RED);  /* Automatically update desktop window */
  hWin = GUI_CreateDialogBox(aDialogCreate, GUI_COUNTOF(aDialogCreate), _cbCallback, 0, 0, 0);
  for (i = 0; i < GUI_COUNTOF(_aID); i++) {
    GUIDEMO_Delay(_aID[i].Time);
    GUI_SendKeyMsg(_aID[i].Id, 1);
  }
  #if !(GUIDEMO_TINY)
    #if !(GUIDEMO_LARGE)
      if (LCD_GetYSize() < 120) {
      } else
    #endif
    {
      GUIDEMO_Delay(1000);
      for (i = 0; i <= 100; i += 10) {
        if (WM_IsWindow(hWin)) {
          SLIDER_SetValue(WM_GetDialogItem(hWin, GUI_ID_SLIDER0), i);
        }
        GUIDEMO_Delay(100);
      }
    }
  #endif
  GUIDEMO_Delay(800);
  if (WM_IsWindow(hWin)) {
    WM_MoveTo(hWin, 20, 20);
    GUIDEMO_Delay(500);
  }
  if (WM_IsWindow(hWin)) {
    WM_MoveTo(hWin, 60, 20);
    GUIDEMO_Delay(800);
  }
  /* Cleanup ... */
  if (WM_IsWindow(hWin)) {
    WM_DeleteWindow(hWin);
  }
  GUIDEMO_NotifyStartNext();
  WM_SetDesktopColor(DesktopColorOld);   /* Restore old settings */
}
Ejemplo n.º 2
0
/*******************************************************************************************************
 *
 *         函数名称: 
 *
 *         函数功能: 
 *
 *         入口参数: 
 *
 *         出口参数: 无
 *
 *             说明:
 *
 *******************************************************************************************************/
void _cbKBDlgCallback1(WM_MESSAGE * pMsg) 
{
    int NCode;
    int id;
    int i;
    
    char str_buff[10];
      
    WM_HWIN hWin = pMsg->hWin;
    
    switch (pMsg->MsgId) 
    {
        case WM_PAINT:
            //TextNumPaintDialog(pMsg);
            break;        
        case WM_INIT_DIALOG:
            InitKBDlg(pMsg);
            break;        
        case WM_KEY:
            break;            
        case WM_NOTIFY_PARENT:
            id = WM_GetId(pMsg->hWinSrc); 
            NCode = pMsg->Data.v;        
            switch (NCode) 
            {
				case WM_NOTIFICATION_RELEASED:
                    switch (id)
                    {                
                        case GUI_ID_OK:
                            GUI_EndDialog(hWindKB, 0);
                            break;
                        case GUI_ID_CANCEL:
                            GUI_EndDialog(hWindKB, 0);
                        
                            break;
                    }  
                    break;  
                                 
                case WM_NOTIFICATION_CLICKED:
                    switch(id)
                    {  
                        case GUI_ID_BUTTON_CLR:  //清除
                            EDIT_SetText(WM_GetDialogItem(hWin,GUI_ID_EDIT_KB_INPUT),"0");
                            break;
                        case GUI_ID_BUTTON_BK_SPC: //退格
                            WM_SetFocus(WM_GetDialogItem(hWin,GUI_ID_EDIT_KB_INPUT));
                            GUI_SendKeyMsg(GUI_KEY_BACKSPACE,1);
                            break;
                        case GUI_ID_BUTTON_OK:
                            EDIT_AddKey(WM_GetDialogItem(hWin,GUI_ID_EDIT_KB_INPUT),'\0');
                            EDIT_GetText(WM_GetDialogItem(hWin,GUI_ID_EDIT_KB_INPUT),str_buff,sizeof(str_buff));
                            GUI_EndDialog(hWin, atoi(str_buff));
                            break;
                        case GUI_ID_BUTTON_CANCEL:
                            GUI_EndDialog(hWin, -1);
                            break;
                        default:
                            for (i = 0; i < 10; i++) //10个数字
                            {
                                if (NumBtn09ID[i] == id)
                                {
                                    EDIT_AddKey(WM_GetDialogItem(hWin,GUI_ID_EDIT_KB_INPUT),'0' + i);
                                    break;             
                                }
                            }                             
                          
                   } 
                   break;
               }
               
               break;
               
         default:
            WM_DefaultProc(pMsg);      
    }      
          
        
    
}
Ejemplo n.º 3
0
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN                hItem;
	WM_MESSAGE             Msg;
	WM_HWIN                hIteminfo;
	int 									  i;
	int 	     					sel;
	uint8_t     					items;
	FRESULT res;
 // FILINFO fno;
  //DIR dir;
  // USER START (Optionally insert additional variables)
  // USER END
	hItem = pMsg->hWin;
	WINDOW_SetBkColor(hItem, GUI_LIGHTGRAY);
	
	hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
	//WM_SetFocus(hItem);
	
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetFont(hItem,&GUI_FontHZ_Song_12);
    TEXT_SetText(hItem, "自学习文件选择");  
	
		hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
    TEXT_SetFont(hIteminfo,&GUI_FontHZ_Song_12);
		TEXT_SetTextColor(hIteminfo,GUI_RED);
		TEXT_SetText(hIteminfo, (char *)"打开文件……");
		WM_HideWindow(hIteminfo);
	  //
    // Initialization of 'Dropdown'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		DROPDOWN_SetFont(hItem,&GUI_FontHZ_Song_12);
    DROPDOWN_AddString(hItem, "U盘");
    DROPDOWN_AddString(hItem, "SD卡");
		if(k_StorageGetStatus(MSD_DISK_UNIT) != 0)
		DROPDOWN_SetSel(hItem,1);
		else DROPDOWN_SetSel(hItem,0);
	//
    // Initialization of 'Treeview'
    //
		store_dev=DROPDOWN_GetSel(hItem);
		WT_TestFolder_Init();
	  hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		for(i=0;i<TestFolder.number_TotalFile;i++)
		{
			LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]);
		}
		LISTBOX_SetFont(hItem,GUI_FONT_20_1);
		LISTBOX_SetSel(hItem,TestFolder.number_CurrentFile);
    
		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OK);
		BUTTON_SetFont(hItem,&GUI_FontHZ_Song_12);
		BUTTON_SetSkinClassic(hItem);
		BUTTON_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
		BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED, GUI_GREEN);
		BUTTON_SetFocussable(hItem,0);//不接收焦点
		
		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CANCEL);
		BUTTON_SetFont(hItem,&GUI_FontHZ_Song_12);
		BUTTON_SetSkinClassic(hItem);
		BUTTON_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
		BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED, GUI_RED);
		BUTTON_SetFocussable(hItem,0);//不接收焦点
    // USER START (Optionally insert additional code for further widget initialization)
    // USER END
    break;
	case MY_MESSAGE_CLICK:
		GUI_SendKeyMsg(GUI_KEY_TAB, 1);//改变输入焦点
		break;
	case MY_MESSAGE_DOWN:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		if(WM_HasFocus(hItem))
		{
			LISTBOX_IncSel(hItem);
		}
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		if(WM_HasFocus(hItem))
		{
			sel=DROPDOWN_GetSel(hItem);
			if(sel<1)
			{
				DROPDOWN_IncSel(hItem);
			}					
			else //sel>=1 
			{
				DROPDOWN_SetSel(hItem,0);		
			}	

			store_dev=DROPDOWN_GetSel(hItem);
			WT_TestFolder_Init();
			hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
			items = LISTBOX_GetNumItems(hItem);
			for(i=0;i<items;i++)
			{
				LISTBOX_DeleteItem(hItem,0);
			}
			for(i=0;i<TestFolder.number_TotalFile;i++)
			{
				LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]);
			}
		}	
		break;
	case MY_MESSAGE_UP:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		if(WM_HasFocus(hItem))
		{
			LISTBOX_DecSel(hItem);
		}
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		if(WM_HasFocus(hItem))
		{
			sel=DROPDOWN_GetSel(hItem);
			if(sel>0)
			{
				DROPDOWN_DecSel(hItem);
			}					
			else //sel>=1 
			{
				DROPDOWN_SetSel(hItem,1);		
			}	

			store_dev=DROPDOWN_GetSel(hItem);
			WT_TestFolder_Init();
			hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
			items = LISTBOX_GetNumItems(hItem);
			for(i=0;i<items;i++)
			{
				LISTBOX_DeleteItem(hItem,0);
			}
			for(i=0;i<TestFolder.number_TotalFile;i++)
			{
				LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]);
			}
		}
		break;
	case MY_MESSAGE_CANCEL://取消
		GUI_EndDialog(pMsg->hWin,0);
		break;
	case MY_MESSAGE_OK:
		hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
		TEXT_SetText(hIteminfo, (char *)"打开文件中……");
		WM_ShowWindow(hIteminfo);
	  GUI_Exec();
		hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		TestFolder.number_CurrentFile=LISTBOX_GetSel(hItem);
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		store_dev=DROPDOWN_GetSel(hItem);
		WT_TestItem_Init((char *)TestFolder.FilesName[TestFolder.number_CurrentFile]);
		//WT_TestFile_Write2Flash((char *)TestFolder.FilesName[TestFolder.number_CurrentFile]);//将文件内容复制到Flash
	  //WT_TestFiles_Write2card((char *)TestFolder.FilesName[TestFolder.number_CurrentFile]);//将文件内容复制到SD card

	  if(TestFile.file_status == 1)//文件读取OK
		{
			Msg.MsgId = MY_MESSAGE_BUTTONOK;
			WM_SendMessage(pMsg->hWinSrc,&Msg);
			GUI_EndDialog(pMsg->hWin,0);
		}
		else
		{
			TEXT_SetText(hIteminfo, (char *)"读取文件错误!");
			WM_ShowWindow(hIteminfo);
		}
		Msg.MsgId = MY_MESSAGE_BUTTONOK;
		WM_SendMessage(pMsg->hWinSrc,&Msg);
		GUI_EndDialog(pMsg->hWin,0);

		break;
	case MY_MESSAGE_BUTTONDELETE:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		store_dev=DROPDOWN_GetSel(hItem);
		if(store_dev==0) //usb
		strcpy(filename,path_testfile);
		//f_opendir(&dir, path_testfile);
		if(store_dev==1) //sd
		strcpy(filename,path_testfile_sd);
		//f_opendir(&dir, path_testfile_sd);
		//res = f_opendir(&dir, "1:/LZY_WireTester/Test Files");
		hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		strcat(filename,"/");
		sel = LISTBOX_GetSel(hItem);
		if(sel < 0) break;
		strcat(filename,(char *)TestFolder.FilesName[LISTBOX_GetSel(hItem)]);
		res=f_unlink((const TCHAR*)filename);
		if(res == FR_OK)
		{
			hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
			store_dev=DROPDOWN_GetSel(hItem);
			WT_TestFolder_Init();
			hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
			items = LISTBOX_GetNumItems(hItem);
			for(i=0;i<items;i++)
			{
				LISTBOX_DeleteItem(hItem,0);
			}
			for(i=0;i<TestFolder.number_TotalFile;i++)
			{
				LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]);
			}
			WM_SetFocus(hItem);
			if(sel > 0) LISTBOX_SetSel(hItem,sel - 1);
			else LISTBOX_SetSel(hItem,0);
		}
		break;
	case WM_PAINT://绘制标题栏
		GUI_SetColor(GUI_DARKBLUE);
		GUI_FillRect(0,0,380,22);
		GUI_SetColor(GUI_DARKGRAY);
		GUI_SetPenSize(8);
		GUI_DrawRect(0,0,378,220);
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Ejemplo n.º 4
0
/*********************************************************************
*
*       Dialog callback routine
*/
static void _cbBk_Frame(WM_MESSAGE * pMsg) 
{
    int NCode, Id;
    WM_HWIN hWin = pMsg->hWin;
    switch (pMsg->MsgId) 
    {
        case WM_PAINT:
            PaintDialog(pMsg);
            break;
        case WM_INIT_DIALOG:
            InitDialog(pMsg);
            break;
        case WM_KEY:
            switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) 
            {
                case GUI_KEY_ESCAPE:
                    GUI_EndDialog(hWin, 1);
                    break;
                case GUI_KEY_ENTER:
                    GUI_EndDialog(hWin, 0);
                    break;						
            }
            break;
        case WM_NOTIFY_PARENT:
						GUI_DispStringAt("Frame",10,220);
            Id = WM_GetId(pMsg->hWinSrc); 
            NCode = pMsg->Data.v;        
    
						switch(NCode)
						{
								 case WM_NOTIFICATION_RELEASED: 
								 {																			
											if(Id == GUI_ID_BUTTON0)
											{
													EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'0');
											}
											if(Id == GUI_ID_BUTTON1)
											{
													EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'1');													
											}
											if(Id == GUI_ID_BUTTON2)
											{
													EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'2');													
											}
											if(Id == GUI_ID_BUTTON3)
											{
													EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'3');
											}
											if(Id == GUI_ID_BUTTON4)
											{
													EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'4');													
											}
											if(Id == GUI_ID_BUTTON5)
											{
													EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'5');													
											}
											if(Id == GUI_ID_BUTTON6)
											{
													EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'6');													
											}
											if(Id == GUI_ID_BUTTON7)
											{
													EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'7');													
											}
											if(Id == GUI_ID_BUTTON8)
											{
													EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'8');
											}
											if(Id == GUI_ID_BUTTON9)
											{
													EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'9');							
											}
											if(Id == GUI_ID_BUTTON10)
											{
													EDIT_AddKey(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT),'.');										
											}
											
											/* BackSpace */
											if(Id == GUI_ID_BUTTON11)
											{
												 //EDIT_SetText(WM_GetDialogItem(hWin,GUI_ID_EDIT0),NULL);//清空输入框,挨个删除用下面两行
												 WM_SetFocus(WM_GetDialogItem(hWN_Dialog_PID_Frame,PID_EDIT));
												 GUI_SendKeyMsg(GUI_KEY_BACKSPACE,1);  
																				
												 GPIO_ResetBits(GPIOF,GPIO_Pin_7);												
											}
											
											/* PID Parameter Edit choese*/
											{
													if(Id == GUI_ID_BUTTON12 || Id == GUI_ID_EDIT0)
													{
														PID_Para_Edit_Flag = Kp;
														PID_EDIT = PID_Para_Edit_Flag + GUI_ID_EDIT0;
														
													}											
													if(Id == GUI_ID_BUTTON13 || Id == GUI_ID_EDIT1)
													{
														PID_Para_Edit_Flag = Ki;
														PID_EDIT = PID_Para_Edit_Flag + GUI_ID_EDIT0;												
													}
													if(Id == GUI_ID_BUTTON14 || Id == GUI_ID_EDIT2)
													{
														PID_Para_Edit_Flag = Kd;
														PID_EDIT = PID_Para_Edit_Flag + GUI_ID_EDIT0; //GUI_ID_EDIT2													
													}											
													if(Id == GUI_ID_BUTTON15 || Id == GUI_ID_EDIT3)
													{
														PID_Para_Edit_Flag = E;
														PID_EDIT = PID_Para_Edit_Flag + GUI_ID_EDIT0;																											
													}
													if(Id == GUI_ID_BUTTON17 || Id == GUI_ID_EDIT4)
													{
														PID_Para_Edit_Flag = Set;
														PID_EDIT = PID_Para_Edit_Flag + GUI_ID_EDIT0; //GUI_ID_EDIT2												
													}	
													
													/* OK Key */
													if(Id == GUI_ID_BUTTON16)
													{														
															/* Store the last array(5) */
															value_PID[CounterPID].Proportion = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT0) );
														 	value_PID[CounterPID].Integral   = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT1) );
															value_PID[CounterPID].Derivative = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT2) );
															value_PID[CounterPID].SetPoint 	 = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT4) );

															BK_Light = SLIDER_GetValue(WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_SLIDER0));
															SetPWM(BK_Light,PWM_BACK_LIGHT);	
														
															//!< Not the PID configuration Period
															PID_CFG_Flag = 0;
															
															WM_DeleteWindow(hWN_Dialog_PID_Frame);
															
															WM_ShowWindow(hWM_HBKWIN_CURVE);
															WM_HideWindow(hWM_HBKWIN_CFG_PID);
													}																										
													
											}
											
											/* Up and down of the order of the PID Array */
											{
												if(Id == GUI_ID_BUTTON18)
												{
														value_PID[CounterPID].Proportion = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT0) );
														value_PID[CounterPID].Integral   = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT1) );
														value_PID[CounterPID].Derivative = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT2) );
														value_PID[CounterPID].SetPoint 	 = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT4) );
													
														/* Get the E_Percent */
														{
															if(0 == CounterPID)
															{
																E_Percent[0] = EDIT_GetFloatValue ( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT3) );
																E_Percent[1] = 1 - E_Percent[0];
															 }
														}
														
														CounterPID++;
																																							
														if(6 == CounterPID)
														{
																CounterPID = 0;
														}
														
														itoa(CounterPID,bufTextOrder,10);												
														TEXT_SetText( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_TEXT0),bufTextOrder);
														
														if(1 == CounterPID)
														{
																EDIT_SetFloatValue ( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT3), E_Percent[1]);
														}
												
														/* Set the same value to edit */
														if( 2 == CounterPID || 4 == CounterPID)
														{																																
																EDIT_SetFloatValue(WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT3),E_Percent[0]);
																EDIT_SetFloatValue(WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT4),value_PID[0].SetPoint);
														}
														else if( 3 == CounterPID || 5 == CounterPID)
														{
																EDIT_SetFloatValue(WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT3),E_Percent[1]);
																EDIT_SetFloatValue(WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT4),value_PID[1].SetPoint);
														}											
												}
												
												/** Previous button **/
												if(Id == GUI_ID_BUTTON19)
												{
														value_PID[CounterPID].Proportion = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT0) );
														value_PID[CounterPID].Integral   = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT1) );
														value_PID[CounterPID].Derivative = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT2) );
														value_PID[CounterPID].SetPoint 	 = EDIT_GetFloatValue( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_EDIT4) );
													
														CounterPID--;
																																																
														if(-1 == CounterPID)
														{
																CounterPID = 5;
														}
														
														itoa(CounterPID,bufTextOrder,10);												
														TEXT_SetText( WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_TEXT0),bufTextOrder);
												}
											}
											
											if(Id == GUI_ID_SLIDER0)
											{												
													BK_Light = SLIDER_GetValue(WM_GetDialogItem(hWN_Dialog_PID_Frame,GUI_ID_SLIDER0));
													SetPWM(BK_Light,PWM_BACK_LIGHT);																									
											}
									
								 }
									break;				
						}														
        default:
            WM_DefaultProc(pMsg);
    }
}
Ejemplo n.º 5
0
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN                hItem;
	WM_MESSAGE             Msg;
	WM_HWIN                hIteminfo;
	int 									  i;
	uint8_t     					sel;
	uint8_t     					items;
//	int  										wheelval=0;
  // USER START (Optionally insert additional variables)
  // USER END
	hItem = pMsg->hWin;
	WINDOW_SetBkColor(hItem, GUI_LIGHTGRAY);
	
	hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
	//WM_SetFocus(hItem);
	
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetFont(hItem,&GUI_FontHZ_Song_12);
    TEXT_SetText(hItem, "测试文件选择");  
	
		hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
    TEXT_SetFont(hIteminfo,&GUI_FontHZ_Song_12);
		TEXT_SetTextColor(hIteminfo,GUI_RED);
		TEXT_SetText(hIteminfo, (char *)"打开测试文件……");
		WM_HideWindow(hIteminfo);
	
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_LOCKINFO);
    TEXT_SetFont(hItem,&GUI_FontHZ_Song_12);
		TEXT_SetTextColor(hItem,GUI_RED);
		TEXT_SetText(hItem, "系统被锁定,请解锁!");
		WM_HideWindow(hItem);
	  //
    // Initialization of 'Dropdown'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		DROPDOWN_SetFont(hItem,&GUI_FontHZ_Song_12);
		//if(k_StorageGetStatus(USB_DISK_UNIT) != 0)
    DROPDOWN_AddString(hItem, "U盘");
		//if(k_StorageGetStatus(MSD_DISK_UNIT) != 0)
    DROPDOWN_AddString(hItem, "SD卡");
		if(k_StorageGetStatus(MSD_DISK_UNIT) != 0)
		DROPDOWN_SetSel(hItem,1);
		else DROPDOWN_SetSel(hItem,0);
		//
    // Initialization of 'Listview'
    //
		store_dev=DROPDOWN_GetSel(hItem);
		WT_TestFolder_Init();
		
	  hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		for(i=0;i<TestFolder.number_TotalFile;i++)
		{
			LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]);
		}
		LISTBOX_SetFont(hItem,GUI_FONT_20_1);
		LISTBOX_SetSel(hItem,TestFolder.number_CurrentFile);

		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OK);
		BUTTON_SetFont(hItem,&GUI_FontHZ_Song_12);
		BUTTON_SetSkinClassic(hItem);
		BUTTON_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
    BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED, GUI_GREEN);
		BUTTON_SetFocussable(hItem,0);//不接收焦点
		
		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CANCEL);
		BUTTON_SetFont(hItem,&GUI_FontHZ_Song_12);
		BUTTON_SetSkinClassic(hItem);
		BUTTON_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
    BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED, GUI_RED);
		BUTTON_SetFocussable(hItem,0);//不接收焦点
    // USER START (Optionally insert additional code for further widget initialization)
    // USER END
    break;
	case MY_MESSAGE_CLICK:
		GUI_SendKeyMsg(GUI_KEY_TAB, 1);//改变输入焦点
		hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		if(WM_HasFocus(hItem))
		{
			LISTBOX_SetSel(hItem,0);
		}
		break;
	case MY_MESSAGE_DOWN:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		if(WM_HasFocus(hItem))
		{
			LISTBOX_IncSel(hItem);
		}
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		if(WM_HasFocus(hItem))
		{
			sel=DROPDOWN_GetSel(hItem);
			if(sel<1)
			{
				DROPDOWN_IncSel(hItem);
			}					
			else //sel>=1 
			{
				DROPDOWN_SetSel(hItem,0);		
			}	

			store_dev=DROPDOWN_GetSel(hItem);
			WT_TestFolder_Init();
			hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
			items = LISTBOX_GetNumItems(hItem);
			for(i=0;i<items;i++)
			{
				LISTBOX_DeleteItem(hItem,0);
			}
			for(i=0;i<TestFolder.number_TotalFile;i++)
			{
				LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]);
			}
		}	

		break;
		case MY_MESSAGE_UP:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		if(WM_HasFocus(hItem))
		{
			LISTBOX_DecSel(hItem);
		}
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		if(WM_HasFocus(hItem))
		{
			sel=DROPDOWN_GetSel(hItem);
			if(sel>0)
			{
				DROPDOWN_DecSel(hItem);
			}					
			else //sel>=1 
			{
				DROPDOWN_SetSel(hItem,1);		
			}	

			store_dev=DROPDOWN_GetSel(hItem);
			WT_TestFolder_Init();
			hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
			items = LISTBOX_GetNumItems(hItem);
			for(i=0;i<items;i++)
			{
				LISTBOX_DeleteItem(hItem,0);
			}
			for(i=0;i<TestFolder.number_TotalFile;i++)
			{
				LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]);
			}
		}

		break;
	case MY_MESSAGE_CANCEL://取消
		TestFile.command=2;//test cancel
		TestFile.item_total=0;
		GUI_EndDialog(pMsg->hWin,0);
		break;
	case MY_MESSAGE_OK:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
		if(LISTBOX_GetNumItems(hItem) ==0 ) break;
			TestFolder.number_CurrentFile=LISTBOX_GetSel(hItem);
	
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		store_dev=DROPDOWN_GetSel(hItem);
		TestFile.command = 0;
		hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
		TEXT_SetText(hIteminfo, (char *)"读取测试文件!");
		WM_ShowWindow(hIteminfo);
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_LOCKINFO);
		WM_HideWindow(hItem);
		GUI_Exec();
		WT_TestItem_Init((char *)TestFolder.FilesName[TestFolder.number_CurrentFile]);
	  if(TestFile.file_status == 1)//文件读取OK
		{
			Msg.MsgId = MY_MESSAGE_BUTTONOK;
			WM_SendMessage(pMsg->hWinSrc,&Msg);
			GUI_EndDialog(pMsg->hWin,0);
		}
		else
		{
			TEXT_SetText(hIteminfo, (char *)"读取测试文件错误!");
			WM_ShowWindow(hIteminfo);
		}


//		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CANCEL);
//		if(WM_HasFocus(hItem))//取消
//		{
//			TestFolder.number_CurrentFile=0;
//			TestFile.command = 0;
//			WT_TestItem_Init(TestFolder.FilesName[0]);
//			Msg.MsgId = MY_MESSAGE_BUTTONCANCEL;
//			WM_SendMessage(pMsg->hWinSrc,&Msg);
//			GUI_EndDialog(pMsg->hWin,0);
//		}
		//GUI_EndDialog(pMsg->hWin,0);
		//Number_Windos = 0;
		break;
	case MY_MESSAGE_LOCK:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
		WM_HideWindow(hItem);
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_LOCKINFO);
		TEXT_SetText(hItem, "系统被锁定,请解锁!");
		WM_ShowWindow(hItem);
		GUI_Exec();
		break;
	case MY_MESSAGE_UNLOCK:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_LOCKINFO);
		WM_HideWindow(hItem);
		break;
	case WM_PAINT://绘制标题栏
		GUI_SetColor(GUI_DARKBLUE);
		GUI_FillRect(0,0,480,22);
		GUI_SetColor(GUI_DARKGRAY);
		GUI_SetPenSize(8);
		GUI_DrawRect(0,0,478,220);
//		GUI_DrawRoundedFrame(0, 0, 480, 222, 0, 4);
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Ejemplo n.º 6
0
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN                hItem;

	int cursorpos=0;
  int index=0;
	uint8_t res=0;
	uint8_t sel=0;
	char str[60];
	uint8_t filename[110];
  uint8_t NumChars=0;
	hItem = pMsg->hWin;
	WINDOW_SetBkColor(hItem, GUI_LIGHTGRAY);
	
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetFont(hItem,&GUI_FontHZ_Song_16);
		TEXT_SetTextAlign(hItem, TEXT_CF_HCENTER | TEXT_CF_VCENTER);
    TEXT_SetText(hItem, (char *)"保存自学习文件");  
	
	  hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
    TEXT_SetFont(hItem,&GUI_FontHZ_Song_16);
		TEXT_SetText(hItem, (char *)"文件名称:"); 
		
	
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
    TEXT_SetFont(hItem,&GUI_FontHZ_Song_16);
		TEXT_SetText(hItem, (char *)"文件类型:WTR"); 
	
		hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3);
    TEXT_SetFont(hItem,&GUI_FontHZ_Song_16);
		TEXT_SetText(hItem, (char *)"保存路径:"); 
	
	  hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		DROPDOWN_SetFont(hItem,&GUI_FontHZ_Song_16);
    DROPDOWN_AddString(hItem, (char *)"U盘");
    DROPDOWN_AddString(hItem, (char *)"SD卡");
		if(k_StorageGetStatus(MSD_DISK_UNIT) != 0)
		DROPDOWN_SetSel(hItem,1);
		else DROPDOWN_SetSel(hItem,0);
	
		hItemwarn = WM_GetDialogItem(pMsg->hWin, ID_TEXT_WARNING);
    TEXT_SetFont(hItemwarn,&GUI_FontHZ_Song_12);
		TEXT_SetTextColor(hItemwarn,GUI_RED);
		TEXT_SetText(hItemwarn, (char *)"警告:文件名不能为空!");
		WM_HideWindow(hItemwarn);
	
		hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_INFO);
    TEXT_SetFont(hIteminfo,&GUI_FontHZ_Song_12);
		TEXT_SetTextColor(hIteminfo,GUI_RED);
		TEXT_SetText(hIteminfo, (char *)"文件保存成功!");
		WM_HideWindow(hIteminfo);
		
		
		hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH);
		//EDIT_SetDecMode(hItem, 24, 1,256, 0, 0);
		EDIT_SetFont(hItem,GUI_FONT_32_1);
		EDIT_SetMaxLen(hItem, 50);
		EDIT_EnableBlink(hItem, 600, 1);
		EDIT_SetInsertMode(hItem,1);
		//strcpy ((char*)str,(char *)path_studyfile);
		//strcat ((char*)str,"/");
		//strcat ((char*)str,"A.wtr");
    EDIT_SetText(hItem,"A");
		cursorindex=EDIT_GetCursorCharPos(hItem);
		WM_SetFocus(hItem);
    
		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OK);
		BUTTON_SetFont(hItem,&GUI_FontHZ_Song_12);
		BUTTON_SetSkinClassic(hItem);
		BUTTON_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
		BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED, GUI_GREEN);
		BUTTON_SetFocussable(hItem,0);//不接收焦点
		
		hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CANCEL);
		BUTTON_SetFont(hItem,&GUI_FontHZ_Song_12);
		BUTTON_SetSkinClassic(hItem);
		BUTTON_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
		BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED, GUI_RED);
		BUTTON_SetFocussable(hItem,0);//不接收焦点
		
    break;
  // USER START (Optionally insert additional message handling)
  // USER END
	case WM_KEY:
		//GUI_SendKeyMsg(GUI_KEY_TAB, 1);//改变输入焦点
	
		break;
	case MY_MESSAGE_CLICK:
		GUI_SendKeyMsg(GUI_KEY_TAB, 1);//改变输入焦点
		break;
	case MY_MESSAGE_OK:
		hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH);
		if(EDIT_GetNumChars(hItem)==0)
		{
			hItemwarn = WM_GetDialogItem(pMsg->hWin, ID_TEXT_WARNING);
			WM_ShowWindow(hItemwarn);
			break;
		}
		else 
		{
			hItemwarn = WM_GetDialogItem(pMsg->hWin, ID_TEXT_WARNING);
			WM_HideWindow(hItemwarn);		
		}
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		store_dev=DROPDOWN_GetSel(hItem);
		
		hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH);
		EDIT_GetText(hItem, str, 51);
		if(store_dev == 0)//usb
		{
			if(sizeof(path_studyfile) < 50) strcpy ((char*)filename,(char *)path_studyfile);
			else														strcpy ((char*)filename,(char *)path_Default);
		}
		if(store_dev == 1)//sd
		{
			if(sizeof(path_studyfile) < 50) strcpy ((char*)filename,(char *)path_studyfile_sd);
			else														strcpy ((char*)filename,(char *)path_Default_sd);
		}
		strcat ((char*)filename,"/");
		strcat ((char*)filename,str);
		strcat ((char*)filename,".wtr");
		hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_INFO);
		TEXT_SetText(hIteminfo, "正在保存自学习文件!");
		WM_ShowWindow(hIteminfo);
		GUI_Exec();
		res=WT_StudyFiles_Write(filename);//0-ok, 1-hardware error, 2-file operate error, 
		if(res==0)
		{
			hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_INFO);
			TEXT_SetText(hIteminfo, (char *)"文件保存成功!");
			WM_ShowWindow(hIteminfo);
		}
		else
		{
			hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_INFO);
			TEXT_SetText(hIteminfo, "警告:保存失败,未检测到存储设备!");
			WM_ShowWindow(hIteminfo);
			break;
		}

		GUI_EndDialog(pMsg->hWin,0);

		break;
	case MY_MESSAGE_DOWN://向右移动光标
		hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
		if(WM_HasFocus(hItem))//选择存储路径
		{
			sel=DROPDOWN_GetSel(hItem);
			if(sel<1)
			{
				DROPDOWN_IncSel(hItem);
			}					
			else //sel>=2 
			{
				DROPDOWN_SetSel(hItem,0);		
			}						
		}
		hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH);	
		cursorpos=EDIT_GetCursorCharPos(hItem);
		NumChars = EDIT_GetNumChars(hItem);
		if(cursorpos <= (NumChars-1) )
		{
			EDIT_SetCursorAtChar(hItem,cursorpos+1);
			EDIT_SetSel(hItem,cursorpos+1,cursorpos+1);
			cursorindex=EDIT_GetCursorCharPos(hItem);
		}
		//KeyLed_State.wheel=0;
		break;
	case MY_MESSAGE_UP://向左移动光标
		hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH);
		cursorpos=EDIT_GetCursorCharPos(hItem);
		EDIT_SetCursorAtChar(hItem,cursorpos-1);
		EDIT_SetSel(hItem,cursorpos-1,cursorpos-1);
		cursorindex=EDIT_GetCursorCharPos(hItem);
		break;
	case	MY_MESSAGE_WHEEL://处理滚轮事件
		hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH);
		EDIT_SetCursorAtChar(hItem,cursorindex);
		index=KeyLed_State.wheel;

		if(KeyLed_State.wheel>=65 && KeyLed_State.wheel <130) index=KeyLed_State.wheel-65;
		if(KeyLed_State.wheel>=130 && KeyLed_State.wheel <195) index=KeyLed_State.wheel-130;
		if(KeyLed_State.wheel>=195) index=64;
		if(KeyLed_State.wheel<0 && KeyLed_State.wheel >= -65) index=KeyLed_State.wheel+65;
		if(KeyLed_State.wheel<-65 && KeyLed_State.wheel >= -130) index=KeyLed_State.wheel+130;
		if(KeyLed_State.wheel<-130) index=0;
		if(cursorindex==EDIT_GetCursorCharPos(hItem))
		{
			EDIT_AddKey(hItem,GUI_KEY_DELETE);
			EDIT_AddKey(hItem,input_char[index]);
			cursorpos=EDIT_GetCursorCharPos(hItem);
			EDIT_SetSel(hItem,cursorpos-1,cursorpos-1);
		}

		break;
	case MY_MESSAGE_BUTTONDELETE://删除字符
		hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH);
		if(WM_HasFocus(hItem))
		{
			EDIT_AddKey(hItem,GUI_KEY_BACKSPACE);
			cursorindex=EDIT_GetCursorCharPos(hItem);
		}
		break;
	case WM_PAINT://绘制标题栏
		GUI_SetColor(GUI_DARKBLUE);
		GUI_FillRect(0,0,480,22);
		GUI_SetColor(GUI_DARKGRAY);
		GUI_SetPenSize(6);
		GUI_DrawRect(0,0,480-2,222-2);
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}