Exemple #1
0
/*******************************************************************
*
*       _DemoHideShowParent

  Demonstrates the use of WM_HideWindow and WM_ShowWindow
*/
static void _DemoHideShowParent(void) {
  _ChangeInfoText("WM_HideWindow(Parent)");
  GUI_Delay(SPEED);
  WM_HideWindow(_hWindow2);
  GUI_Delay(SPEED/3);
  WM_HideWindow(_hWindow1);
  GUI_Delay(SPEED);
  _ChangeInfoText("WM_ShowWindow(Parent)");
  GUI_Delay(SPEED);
  WM_ShowWindow(_hWindow1);
  GUI_Delay(SPEED/3);
  WM_ShowWindow(_hWindow2);
  GUI_Delay(SPEED);
}
/*********************************************************************
*
*       _MinimizeFramewin
*/
static void _MinimizeFramewin(FRAMEWIN_Handle hObj, FRAMEWIN_Obj* pObj) {
  _RestoreMaximized(hObj, pObj);
  /* When window is not minimized, minimize it */
  if ((pObj->Flags & FRAMEWIN_SF_MINIMIZED) == 0) {
    int OldHeight = pObj->Widget.Win.Rect.y1 - pObj->Widget.Win.Rect.y0 + 1;
    int NewHeight = FRAMEWIN__CalcTitleHeight(pObj) + pObj->Widget.pEffect->EffectSize * 2 + 2;    
    pObj->rRestore = pObj->Widget.Win.Rect;
    WM_HideWindow(pObj->hClient);
    WM_HideWindow(pObj->hMenu);
    WM_ResizeWindow(hObj, 0, NewHeight - OldHeight);
    FRAMEWIN__UpdatePositions(pObj);
    pObj->Flags |= FRAMEWIN_SF_MINIMIZED;
    _InvalidateButton(pObj, GUI_ID_MINIMIZE);
  }
}
/*******************************************************************
*
*       _DemoHideShowParent

  Demonstrates the use of WM_HideWindow and WM_ShowWindow
*/
static void _DemoHideShowParent(void) {
  _ChangeInfoText("WM_HideWindow(Parent)");
//  GUIDEMO_Delay(SPEED);
  WM_HideWindow(_hWindow2);
  GUIDEMO_Delay(SPEED/3);
  WM_HideWindow(_hWindow1);
  GUIDEMO_Delay(SPEED);
  _ChangeInfoText("WM_ShowWindow(Parent)");
  GUIDEMO_Delay(SPEED);
  WM_ShowWindow(_hWindow1);
  GUIDEMO_Delay(SPEED/3);
  WM_ShowWindow(_hWindow2);
  GUIDEMO_Delay(SPEED);
  GUIDEMO_NotifyStartNext();
}
Exemple #4
0
/*********************************************************************
*
*       MainTask
*
**********************************************************************
*/
void customer(WM_MESSAGE * pMsg) 
{ 
	current_interface = PORTABLE_CUSTOMER;
	if(pMsg)
	{
		WM_DeleteWindow(pMsg->hWin);
#if 0
		WM_HideWindow(pMsg->hWin);
#endif
	}

    WM_SetDesktopColor(GUI_WHITE);      /* Automacally update desktop window */
    WM_SetCreateFlags(WM_CF_MEMDEV);  /* Use memory devices on all windows to avoid flicker */
    //PROGBAR_SetDefaultSkin(PROGBAR_SKIN_FLEX);
    //FRAMEWIN_SetDefaultSkin(FRAMEWIN_SKIN_FLEX);
    //PROGBAR_SetDefaultSkin(PROGBAR_SKIN_FLEX);
    //BUTTON_SetDefaultSkin(BUTTON_SKIN_FLEX);
    //CHECKBOX_SetDefaultSkin(CHECKBOX_SKIN_FLEX);
    //DROPDOWN_SetDefaultSkin(DROPDOWN_SKIN_FLEX);
    //SCROLLBAR_SetDefaultSkin(SCROLLBAR_SKIN_FLEX);
    //SLIDER_SetDefaultSkin(SLIDER_SKIN_FLEX);
    //HEADER_SetDefaultSkin(HEADER_SKIN_FLEX);
    //RADIO_SetDefaultSkin(RADIO_SKIN_FLEX);
    current_handle = GUI_CreateDialogBox(_aDialogCreate_Cus, GUI_COUNTOF(_aDialogCreate_Cus), &_cbCallback_Cus, 0, 0, 0);
	h_cus = current_handle;
}
U8 TopDistortionScreen(WM_HWIN hPreWin)
{
	WM_HideWindow(hPreWin);
	WM_ShowWindow(hDistortion);
	//WM_BringToTop(hDistortion);
	SetWindowToUpdateIfPresetModified(hDistortion);
	return 0;
}
/*********************************************************************
*
*       _cbBk
*/
static void _cbBk(WM_MESSAGE * pMsg) 
{
	static unsigned int GirdFlag = 0;
	int NCode, Id;
  switch (pMsg->MsgId) {
  case WM_PAINT:
		GUI_SetBkColor(GUI_LIGHTBLUE);
	  GUI_Clear();
    GUI_DispStringAt("Temperature Curve ", 80, 0);
  // GUIDEMO_DrawBk(1);
    break;
	case WM_TOUCH:
		GirdFlag++;
		GRAPH_SetGridVis(hGraph,GirdFlag%3);  //!< Display the  if touch the screen
		break;

	/*******************/
	case WM_NOTIFY_PARENT:
      Id    = WM_GetId(pMsg->hWinSrc);    /* Id of widget */
      NCode = pMsg->Data.v;               /* Notification code */
      switch (NCode) {
        case WM_NOTIFICATION_RELEASED:    /* React only if released */
          if (Id == ID_CURVE_BTN_SWTITCH_2_PARA)  /* ID =210 btn Button */  
					{                   	
							ClosePWM = ! ClosePWM;
						
							if(1 == ClosePWM)
							{
									BUTTON_SetText(btn,"Closed");
							}
							else
							{
									BUTTON_SetText(btn,"Running");
							}
							
          } 	
					if (Id == 202)  /* ID =210 btn Button */  
					{                   	
						BUTTON_SetText(btnClear,"PID_Set");
						GPIO_SetBits(GPIOF,GPIO_Pin_8);
						
						PID_CFG_Flag = 1;
						
						WM_HideWindow(hWM_HBKWIN_CURVE);
				  	WM_ShowWindow(hWM_HBKWIN_CFG_PID);

          } 
        break;      
        default:          
				{
				}
      }
	break;
	
  default:
    WM_DefaultProc(pMsg);
  }
}
U8 TopSynthScreen(WM_HWIN hPreWin)
{
	UpdateSynthSettingEx(MISAMODULE_SYNTH); //MZ
	WM_HideWindow(hPreWin);
	WM_ShowWindow(hSynth);
	//WM_BringToTop(hSynth);
	SetWindowToUpdateIfPresetModified(hSynth);
	return 0;
}
Exemple #8
0
/*********************************************************************
*
*       _HideWindow
*/
static void _HideWindow(void) {
  unsigned i;
  for (i = 0; i < MAX_WINDOWS; i++) {
    if (WM_IsVisible(_ahWin[i])) {
      WM_HideWindow(_ahWin[i]);
      break;
    }
  }
}
Exemple #9
0
/*******************************************************************
*
*       _DemoHideShowChild

  Demonstrates the use of WM_HideWindow and WM_ShowWindow
*/
static void _DemoHideShowChild(void) {
  _ChangeInfoText("WM_HideWindow(Child)");
  GUI_Delay(SPEED);
  WM_HideWindow(_hChild);
  GUI_Delay(SPEED);
  _ChangeInfoText("WM_ShowWindow(Child)");
  GUI_Delay(SPEED);
  WM_ShowWindow(_hChild);
  GUI_Delay(SPEED);
}
Exemple #10
0
/*********************************************************************
*
*       _Main
*/
static void _Main(void) {
  int xSize;
  int ySize;

  WM_SelectWindow(WM_HBKWIN);
  GUI_Clear();
  #if (GUI_SUPPORT_CURSOR | GUI_SUPPORT_TOUCH)
//    GUI_CURSOR_Show();
  #endif
  //
  // Create and configure Control and Information window
  //
  xSize           = LCD_GetXSize();
  ySize           = LCD_GetYSize();
  _hDialogControl = GUI_CreateDialogBox(_aFrameWinControl, GUI_COUNTOF(_aFrameWinControl), &_cbFrameWinControl, WM_HBKWIN, xSize - CONTROL_SIZE_X, ySize - CONTROL_SIZE_Y);
  _hDialogInfo    = GUI_CreateDialogBox(_aFrameWinInfo,    GUI_COUNTOF(_aFrameWinInfo),    &_cbFrameWinInfo,    WM_HBKWIN, (xSize >> 1) - 1,       0);
  WM_HideWindow(_hDialogInfo);
  //
  // Show Intro
  //
  WM_InvalidateWindow(_hDialogControl);
  WM_DisableMemdev(WM_HBKWIN);
  GUI_Exec();
  WM_EnableMemdev(WM_HBKWIN);
  
  GUI_SetBkColor(GUI_RED);
  GUI_Clear();
  GUI_SetBkColor(GUI_GREEN);
  GUI_Clear();
  GUI_SetBkColor(GUI_BLUE);
  GUI_Clear();
  
  GUIDEMO_Intro();
  //
  // Run the demos
  //
  for (_iDemo = 0; _GUIDemoConfig.apFunc[_iDemo]; _iDemo++) {
    _ClearHalt();
    GUIDEMO_UpdateControlText();
    (*_GUIDemoConfig.apFunc[_iDemo])();
    _iDemoMinor = 0;
    _Pressed    = 0;
    
   
  }
  _iDemo = 0;
  //
  // Cleanup
  //
  WM_DeleteWindow(_hDialogControl);
  WM_DeleteWindow(_hDialogInfo);
  #if (GUI_SUPPORT_CURSOR | GUI_SUPPORT_TOUCH)
    GUI_CURSOR_Hide();
  #endif
}
/*******************************************************************
*
*       _DemoHideShowChild

  Demonstrates the use of WM_HideWindow and WM_ShowWindow
*/
static void _DemoHideShowChild(void) {
  _ChangeInfoText("WM_HideWindow(Child)");
//  GUIDEMO_Delay(SPEED);
  WM_HideWindow(_hChild);
  GUIDEMO_Delay(SPEED);
  _ChangeInfoText("WM_ShowWindow(Child)");
  GUIDEMO_Delay(SPEED);
  WM_ShowWindow(_hChild);
  GUIDEMO_Delay(SPEED);
  GUIDEMO_NotifyStartNext();
}
/**
  * @brief  Callback function of the performance dialog
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbPerformanceDialog(WM_MESSAGE * pMsg) {
  int NCode;
  int Id;
  WM_HWIN hGraph;

  GUI_RECT Rect;

  switch (pMsg->MsgId) 
  {
    
  case WM_INIT_DIALOG:

    FRAMEWIN_SetTitleVis(pMsg->hWin, 0);
    hGraph = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_CPU);
    hData = GRAPH_DATA_YT_Create(GUI_LIGHTGREEN, 500, 0, 20);
    GRAPH_SetGridVis(hGraph, 1);
    GRAPH_SetBorder(hGraph, 30, 2, 2, 2); 
    GRAPH_AttachData(hGraph, hData);
    hScale = GRAPH_SCALE_Create(20, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25);
    GRAPH_AttachScale(hGraph, hScale);  
    GRAPH_SCALE_SetTextColor(hScale, GUI_YELLOW);
    GRAPH_SetGridDistX(hGraph, 25);
    GRAPH_SetGridDistY(hGraph, 25);
    WM_GetClientRect(&Rect);
    WM_CreateWindowAsChild(470, 0, 10, 10, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbCpuWindow , 0); 
    
    break;
    
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
      
    case ID_BUTTON_HIDE: /* Notifications sent by Hide Button */
      switch(NCode) 
      {
      case WM_NOTIFICATION_RELEASED:
        
        if(hPerformance != 0)
        {
          WM_HideWindow(hPerformance);
        }
        break;
      }
      break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Exemple #13
0
/*********************************************************************
*
*       _ForEach
*
* Purpose:
*   This routine hides/shows all windows except the button, graph and scroll bar widgets
*/
static void _ForEach(WM_HWIN hWin, void * pData) {
  int Id, FullScreenMode;
  FullScreenMode = *(int *)pData;
  Id = WM_GetId(hWin);
  if ((Id == GUI_ID_GRAPH0) || (Id == GUI_ID_BUTTON0) || (Id == GUI_ID_VSCROLL) || (Id == GUI_ID_HSCROLL)) {
    return;
  }
  if (FullScreenMode) {
    WM_HideWindow(hWin);
  } else {
    WM_ShowWindow(hWin);
  }
}
/**
  * @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;
   
  switch (pMsg->MsgId) 
  {
  case WM_CREATE:
    prev_usb_status = k_StorageGetStatus(USB_DISK_UNIT);    
    hStatusTimer = WM_CreateTimer(pMsg->hWin, 0, 500, 0);      
    break;
    
  case WM_TIMER:
  if(prev_usb_status != k_StorageGetStatus(USB_DISK_UNIT))
    {
      prev_usb_status = k_StorageGetStatus(USB_DISK_UNIT);
      if(VideoList.file[file_pos].name[0] == '0')
      { 
        if(VideoPlayer_State != VIDEO_IDLE)
        {
          _StopPlay(&hvideo, &Video_File);
        }
        
        VideoList.ptr = 0;
        
        GUI_EndDialog(playbackwin, 0);
        SelLayer = 0;
        GUI_SetLayerVisEx (1, 0);
        GUI_SelectLayer(0); 
        WM_HideWindow(hFrame);        
        WM_Exec();        
        WM_DeleteWindow(hFrame);
        WM_InvalidateWindow(VideoWin);
        break; 
      }
    }
    WM_RestartTimer(pMsg->Data.v, 500);
    break;
    
  case WM_DELETE:
    if(hStatusTimer != 0)
    {
      WM_DeleteTimer(hStatusTimer);
      hStatusTimer = 0;
    }
    break;   
    
  default:
    WM_DefaultProc(pMsg);
  }
}
static void OpenFileProcess(int sel_num,char* record_file)
{
	result = f_open (&listfile, FILE_LIST_PATH, FA_READ|FA_OPEN_EXISTING); //打开索引文件
	if(result != FR_OK)
	  return ;
	result = f_lseek (&listfile, sel_num*BROWSER_FILE_NAME_LEN);
	if(result != FR_OK)
	  return ;
	result = f_read (&listfile, curentopenfile, BROWSER_FILE_NAME_LEN, &bw);	
	if(result != FR_OK)
	  return ;
	//printf("\nfileItem=:%s",openfile);
	f_close (&listfile);
    
    if(strstr(curentopenfile,".gcode")||strstr(curentopenfile,".GCODE")
        ||strstr(curentopenfile,".g")||strstr(curentopenfile,".G")) //判断是否是gcode文件,可以执行打印指令
    {
        //对话框显示是否打印该文件
        _ChooseFrame = CreatePrintFileWaring();
        WM_MakeModal(_ChooseFrame);
    }
#if 0    
	else if(strstr(openfile,".txt")||strstr(openfile,".TXT")
			||strstr(openfile,".c")||strstr(openfile,".c")
				||strstr(openfile,".cpp")||strstr(openfile,".CPP")
						||strstr(openfile,".h")||strstr(openfile,".h"))//判断是否可以使用txt格式打开
	{
		//printf("\ntxt file");
		WM_HideWindow(hDialog);
		hOpenfile=FRAMEWIN_CreateEx(0,0,320,240,WM_HBKWIN,WM_CF_SHOW,0,0,0,_cbOpenfile);
		FRAMEWIN_SetTextColor(hOpenfile,GUI_DARKGRAY);
		FRAMEWIN_SetTitleHeight(hOpenfile, 20);
		FRAMEWIN_SetText(hOpenfile,framename);
		FRAMEWIN_SetTextAlign(hOpenfile, GUI_TA_LEFT | GUI_TA_VCENTER);
		FRAMEWIN_AddCloseButton(hOpenfile,FRAMEWIN_BUTTON_RIGHT,0);
		hWin=MULTIEDIT_CreateEx(5,22,295,230,hOpenfile,
							WM_CF_SHOW,MULTIEDIT_CF_AUTOSCROLLBAR_V|MULTIEDIT_CF_READONLY,0,0,0);
		MULTIEDIT_SetBkColor(hWin,MULTIEDIT_CI_READONLY,GUI_WHITE);
		MULTIEDIT_SetWrapWord(hWin);
		MULTIEDIT_AddText(hWin,txtBuffer);
	}
#endif
	else
	{				
		GUI_MessageBox("Sorry,do not support open the file!","Sorry",GUI_MESSAGEBOX_CF_MODAL);
	}
    
}
Exemple #16
0
/*********************************************************************
*
*       MainTask
*
**********************************************************************
*/
void home(WM_MESSAGE * pMsg) 
{ 
	current_interface = HOME; 

	if(pMsg)
	{
	WM_DeleteWindow(pMsg->hWin);
#if 0
	WM_HideWindow(pMsg->hWin);
#endif 
	}
    WM_SetDesktopColor(GUI_WHITE);      /* Automacally update desktop window */
    WM_SetCreateFlags(WM_CF_MEMDEV);  /* Use memory devices on all windows to avoid flicker */

    current_handle = GUI_CreateDialogBox(_aDialogCreate_Home, GUI_COUNTOF(_aDialogCreate_Home), &_cbCallback_Home, 0, 0, 0);

	h_home = current_handle;
}
Exemple #17
0
/*********************************************************************
*
*       _ShowPage
*/
static void _ShowPage(MULTIPAGE_Obj* pObj, unsigned Index) {
  WM_HWIN hWin = 0;
  WM_HWIN hChild;
  WM_Obj* pChild;
  WM_Obj* pClient = WM_H2P(pObj->hClient);
  if ((int)Index < pObj->Handles.NumItems) {
    MULTIPAGE_PAGE* pPage;
    pPage = (MULTIPAGE_PAGE*) GUI_ARRAY_GetpItem(&pObj->Handles, Index);
    hWin = pPage->hWin;
  }
  for (hChild = pClient->hFirstChild; hChild; hChild = pChild->hNext) {
    pChild = WM_H2P(hChild);
    if (hChild == hWin) {
      WM_ShowWindow(hChild);
      WM_SetFocus(hChild);
    } else {
      WM_HideWindow(hChild);
    }
  }
}
 /*---------------------------------------------------------------------------*/
static void IHideButtonsAndText(WM_MESSAGE * pMsg)
{
    WM_HWIN hItem;

    hItem = WM_GetDialogItem(pMsg->hWin, ID_TITLE_TEXT);
    WM_HideWindow(hItem);
    hItem = WM_GetDialogItem(pMsg->hWin, ID_SETTINGS_BUTTON);
    WM_HideWindow(hItem);
    hItem = WM_GetDialogItem(pMsg->hWin, ID_REVERSE_BUTTON);
    WM_HideWindow(hItem);
    hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_PAUSE_BUTTON);
    WM_HideWindow(hItem);
    hItem = WM_GetDialogItem(pMsg->hWin, ID_FORWARD_BUTTON);
    WM_HideWindow(hItem);
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TIMEDATE_TEXT);
    WM_HideWindow(hItem);
}
Exemple #19
0
/*********************************************************************
*
*       _cbBk
*/
static void _cbBk(WM_MESSAGE * pMsg) {
  static WM_HWIN hEdit    = 0;
  static U8      ShowText = 0;
  char           aBuffer[TEXT_MAXLEN];

  switch (pMsg->MsgId) {
  case WM_PAINT:
    GUI_SetBkColor(GUI_DARKGRAY);
    GUI_Clear();
    GUI_SetFont(&GUI_Font24_ASCII);
    GUI_DispStringHCenterAt("WIDGET_Edit - Sample", 160, 5);
    GUI_SetFont(&GUI_Font8x16);
    if (ShowText) {
      GUI_DispStringHCenterAt("The string you have modified is:", 160, 90);
      EDIT_GetText(hEdit, aBuffer, TEXT_MAXLEN);
      GUI_DispStringHCenterAt(aBuffer, 160, 110);
    } else {
      GUI_DispStringHCenterAt("Use keyboard to modify string...", 160, 90);
    }
    break;
  case WM_APP_SHOW_TEXT:
    if (hEdit == 0) {
      hEdit = pMsg->hWinSrc;
    }
    WM_HideWindow(hEdit);
    ShowText = 1;
    WM_InvalidateWindow(WM_HBKWIN);
    WM_CreateTimer(WM_HBKWIN, 0, 3000, 0);
    break;
  case WM_TIMER:
    ShowText = 0;
    WM_InvalidateWindow(WM_HBKWIN);
    WM_ShowWindow(hEdit);
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}
/**
  * @brief  Callback routine of the Benchmark dialog
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int Id, NCode;
  WM_HWIN hGraph;
  int cpu_speed = 0;
  char temp[50];
  WM_CALLBACK  *_cb;

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:

    /* Initialization of 'CPU' */
    hItem = pMsg->hWin;
    FRAMEWIN_SetFont(hItem, GUI_FONT_13HB_ASCII);
    FRAMEWIN_AddCloseButton(hItem, FRAMEWIN_BUTTON_RIGHT,  0);

    hItem = TEXT_CreateEx(10, 20, 100, 25, pMsg->hWin, WM_CF_SHOW,0, 0x123,"");
    TEXT_SetFont(hItem, GUI_FONT_13B_1);
    TEXT_SetTextColor(hItem, 0x00804000);
    TEXT_SetText(hItem, "CPU Usage %:");

    hItem = WM_GetDialogItem(pMsg->hWin, ID_BENCH_CPU);
    TEXT_SetFont(hItem, GUI_FONT_16B_ASCII);
    TEXT_SetTextColor(hItem, GUI_DARKRED);


    hItem = WM_GetDialogItem(pMsg->hWin, ID_CPU_GRAPH);
    FRAMEWIN_SetBarColor(hItem, 0, GUI_DARKGRAY);
    FRAMEWIN_SetBarColor(hItem, 1, GUI_DARKGRAY);

    hGraph = GRAPH_CreateEx(10, 35, 300, 95, pMsg->hWin, WM_CF_SHOW, 0, GUI_ID_GRAPH0);
    hData = GRAPH_DATA_YT_Create(GUI_LIGHTGREEN, 500, 0, 20);
    GRAPH_SetGridVis(hGraph, 1);
    GRAPH_SetBorder(hGraph, 20, 4, 5, 4);
    GRAPH_AttachData(hGraph, hData);

    hScale = GRAPH_SCALE_Create(20, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25);
    GRAPH_AttachScale(hGraph, hScale);
    GRAPH_SCALE_SetTextColor(hScale, GUI_YELLOW);
    GRAPH_SetGridDistX(hGraph, 25);
    GRAPH_SetGridDistY(hGraph, 25);

    WM_CreateWindowAsChild(80, 45, 354, 23, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbCpuWindow , 0);

    break;

  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);    /* Id of widget */
    NCode = pMsg->Data.v;               /* Notification code */
    switch (NCode) {
    case WM_NOTIFICATION_RELEASED:      /* React only if released */
      switch (Id) {

      case ID_BENCH_CPU:
        Stop_Test = 0;

        WM_HideWindow(pMsg->hWin);

        _cb = WM_GetCallback(WM_HBKWIN);
        WM_SetCallback(WM_HBKWIN, _ClearDesktop);
        cpu_speed = Run_SpeedTest();

        WM_ShowWindow(pMsg->hWin);
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BENCH_CPU);
        sprintf (temp, "%d  Pixels/s ", cpu_speed);
        TEXT_SetText(hItem, temp);
        WM_SetCallback(WM_HBKWIN, _cb);
        hItem = WM_GetDialogItem(WM_HBKWIN, ID_BUTTON_BKGND);
        WM_InvalidateWindow(hItem);
        WM_InvalidateWindow(WM_HBKWIN);
        WM_Paint(WM_HBKWIN);
        break;
      }
      break;

    case WM_NOTIFICATION_CHILD_DELETED:
      Stop_Test = 1;
      break;
    }
    break;

  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Exemple #21
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;
  }
}
void GUIDEMO_HideInfoWin(void) {
  #if GUI_WINSUPPORT
    WM_HideWindow(_ahFrameWin[0]);
  #endif
}
Exemple #23
0
/*********************************************************************
*
*       GUIDEMO_HideInfoWin
*/
void GUIDEMO_HideInfoWin(void) {
  WM_HideWindow(_hDialogInfo);
  WM_ValidateWindow(WM_HBKWIN);
}
Exemple #24
0
/*********************************************************************
*
*       GUIDEMO_HideControlWin
*/
void GUIDEMO_HideControlWin(void) {
  WM_HideWindow(_hDialogControl);
  WM_ValidateWindow(WM_HBKWIN);
}
Exemple #25
0
/*********************************************************************
*
*       _HideProgress
*/
static void _HideProgress(void) {
  PROGBAR_Handle hProg;

  hProg = WM_GetDialogItem(_hDialogControl, GUI_ID_PROGBAR0);
  WM_HideWindow(hProg);
}
/**
  * @brief  Callback routine of desktop window.
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbBk(WM_MESSAGE * pMsg) {
  
  MENU_MSG_DATA* pData;
  uint32_t NCode, Id;
  static uint8_t sel = 0;
  
  switch (pMsg->MsgId) 
  {

  case WM_MENU:
    /* Process the menu message */
    pData = (MENU_MSG_DATA*)pMsg->Data.p;
    switch (pData->MsgType) 
    {
    case MENU_ON_ITEMSELECT:
      /* A menu item has been selected */
      switch (pData->ItemId) 
      {  
        
      case ID_MENU_LOG:
        if (hLog == 0)
        {
          hLog = GUI_CreateDialogBox(_aKernelLogDialogCreate, 
                                     GUI_COUNTOF(_aProcessManagerDialogCreate), 
                                     _cbKernelLogDialog, 
                                     pMsg->hWin, 
                                     FRAMEWIN_CF_MOVEABLE | WM_CF_FGND | WM_CF_STAYONTOP, 
                                     50);  
        }
        else
        {
          WM_ShowWindow(hLog);
          WM_BringToTop(hLog);
        }        
        break;
        
      case ID_MENU_PMGR:
        if(hProcess == 0)
        {
          hProcess = GUI_CreateDialogBox(_aProcessManagerDialogCreate, 
                                         GUI_COUNTOF(_aProcessManagerDialogCreate), 
                                         _cbProcessManagerDialog, 
                                         pMsg->hWin, 
                                         FRAMEWIN_CF_MOVEABLE | WM_CF_FGND | WM_CF_STAYONTOP, 
                                         50);  
        }
        else
        {
          WM_ShowWindow(hProcess);
          WM_BringToTop(hProcess);
        }
        break;
        
      case ID_MENU_PERF:
        if(hPerformance == 0)
        {
          hPerformance = GUI_CreateDialogBox(_aPerformanceDialogCreate, 
                                             GUI_COUNTOF(_aPerformanceDialogCreate), 
                                             _cbPerformanceDialog, 
                                             pMsg->hWin, 
                                             FRAMEWIN_CF_MOVEABLE | WM_CF_FGND | WM_CF_STAYONTOP, 
                                             50);
        }
        else
        {
          WM_ShowWindow(hPerformance);
          WM_BringToTop(hPerformance);
        }
        break;
        
      case ID_MENU_EXIT:
        break;
      }
    }
    break;
      
  case WM_PAINT:
    GUI_SetBkColor(GUI_TRANSPARENT);
    GUI_Clear();
    if(hIcon)
    {
      WM_BringToBottom(hIcon);
    }
    break;
    
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);     
    NCode = pMsg->Data.v;  
    
    switch (NCode) 
    {  
      
    case WM_NOTIFICATION_CHILD_DELETED:
      SpriteDisabled = 0;
      GUI_SPRITE_Show(_aSprite[0].hSprite);
      break;
      
    case WM_NOTIFICATION_CLICKED:   
      if (Id == ID_ICONVIEW_MENU)
      { 
        
        sel = ICONVIEW_GetSel(pMsg->hWinSrc);
        
        if(hPerformance != 0)
        {
          WM_HideWindow(hPerformance);
        } 
        
        if(sel < k_ModuleGetNumber())
        {    
          if(sel < 8)
          {
            ICONVIEW_SetSel(pMsg->hWinSrc, -1);
          }
          else
          {
            ICONVIEW_SetSel(pMsg->hWinSrc, k_ModuleGetNumber() + 1); 
          }
        }
      }    
      break;
      
    case WM_NOTIFICATION_RELEASED:
      if (Id == ID_ICONVIEW_MENU)
      {
        
        if(sel < k_ModuleGetNumber())
        { 
          SpriteDisabled = 1;
          GUI_SPRITE_Hide(_aSprite[0].hSprite);
          module_prop[sel].module->startup(pMsg->hWin, 0, 26);
          sel = 0;
        }
      }
      else if (Id == ID_BUTTON_BKGND)
      {
        /* Create popup menu after touching the display */
        _OpenPopup(WM_HBKWIN, _aMenuItems, GUI_COUNTOF(_aMenuItems),0 , 25);  
      }
      break;
    
    default:
      break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int Id, NCode;
  
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    
    hItem = BUTTON_CreateEx(420, 0, 60, 60, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_EXIT);
    WM_SetCallback(hItem, _cbButton_exit);   
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_VNC_CONNECTION);
    IMAGE_SetBitmap(hItem, &bmconnection_ko);
    
    hItem = BUTTON_CreateEx(315, 195, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, START_VNC);
    WM_SetCallback(hItem, _cbButton_start);
    
    hItem = BUTTON_CreateEx(380, 195, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, GO_BACKGROUND);
    WM_SetCallback(hItem, _cbButton_bg);
    
    hItem = BUTTON_CreateEx(245, 195, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_LOCK);
    WM_SetCallback(hItem, _cbButton_lock); 
    
    hItem = WM_GetDialogItem(pMsg->hWin, GO_BACKGROUND);
    BUTTON_SetFont(hItem, &GUI_FontLubalGraph16B);    
    
    break;     
    
  case WM_PAINT:
    
    GUI_SetColor(GUI_STCOLOR_LIGHTBLUE);
    GUI_SetPenSize(5);
    GUI_DrawBitmap(&bmconnect, 7, 45);
    GUI_DrawCircle(332, 215, 40);
    GUI_AA_FillCircle(332, 215, 45);
    
    GUI_AA_FillRoundedRect(230, 182, 440, 250, 20);
    
    GUI_SetColor(GUI_WHITE);
    GUI_AA_FillCircle(332, 215, 42);
    GUI_SetBkColor(GUI_WHITE);
    GUI_AA_FillRoundedRect(233, 185, 437, 247, 20);
    
    GUI_SetColor(GUI_STCOLOR_LIGHTBLUE);
    GUI_AA_FillCircle(332, 215, 33);
    
    break;    

  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);    /* Id of widget */
    NCode = pMsg->Data.v;               /* Notification code */
    
    
    switch(Id) {  
      
    case START_VNC: /* Notifications sent by 'Start' */
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        
        if((VNC_GetState() == VNC_IDLE)||
          (VNC_GetState() == VNC_INIT))
        {
          VNC_SERVER_LogMessage("Starting VNC connection...");
          hItem = WM_GetDialogItem(pMsg->hWin, ID_VNC_CONNECTION);
          IMAGE_SetBitmap(hItem, &bmno_connection);
          
          VNC_SetState (VNC_INIT);
          WM_Exec();
          VNC_SERVER_Start();
        }     
        else
        {
          VNC_SERVER_Stop();
        }
        break;
        
      case WM_NOTIFICATION_CLICKED:
        hItem = WM_GetDialogItem(pMsg->hWin, START_VNC);
        WM_InvalidateWindow(hItem);
        WM_Update(hItem);   
        break;
      }
      break;
    case GO_BACKGROUND: /* Notifications sent by 'Background' */
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        WM_HideWindow(pMsg->hWin);
        module_prop[k_ModuleGetIndex(&vnc_server)].win_state = 1;
        ST_AnimatedIconView_SetItemText(hIcon,k_ModuleGetIndex(&vnc_server),"vnc server[B]");
        ST_AnimatedIconView_SetDualTextColor(hIcon, ICONVIEW_CI_SEL, GUI_STCOLOR_LIGHTBLUE, GUI_STCOLOR_DARKBLUE    ); 
        break;
      }
      break;
      
    case ID_BUTTON_EXIT: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        if(VNC_GetState() != VNC_IDLE)
        {
          VNC_SERVER_Stop();
        }
        GUI_EndDialog(pMsg->hWin, 0);
        break;
      }
      break; 
      
    case ID_LOCK: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        if(VNC_GetState() == VNC_IDLE)
        {
          if(VNC_GetLockState())
          {
            VNC_SetLockState(0);
          }
          else
          {
            VNC_SetLockState(1);
          }
        }
        break;
      }
      break; 
    }
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }      
}
/**
  * @brief  Callback routine of the video main dialog
  * @param  pMsg: pointer to a data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN  hItem;
  int Id, NCode;

  static uint8_t sel = 0;
  
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:

    memset(Video_Path, 0, 256);   
    
    hItem = BUTTON_CreateEx(700, 0, 100, 100, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_EXIT);
    WM_SetCallback(hItem, _cbButton_exit); 
    
    hItem = ST_AnimatedIconView_CreateEx(120, 
                                         50, 
                                         LCD_GetXSize() - 220, 
                                         LCD_GetYSize() - 150, 
                                         pMsg->hWin, 
                                         WM_CF_SHOW | WM_CF_HASTRANS ,
                                         0,
                                         ID_ICONVIEW_SUBMENU, 
                                         240, 
                                         300, 100, 5);    
    
    
    ST_AnimatedIconView_SetDualFont(hItem, &GUI_FontLubalGraph24, &GUI_FontLubalGraph24);
    
    ST_AnimatedIconView_SetSpace(hItem, GUI_COORD_Y, 5);
    ST_AnimatedIconView_SetSpace(hItem, GUI_COORD_X, 25);
    ST_AnimatedIconView_SetFrame(hItem, GUI_COORD_Y, 10);
    ST_AnimatedIconView_SetFrame(hItem, GUI_COORD_X, 5);
    
    ST_AnimatedIconView_SetSel(hItem, -1);
    
    ST_AnimatedIconView_SetTextColor(hItem, ICONVIEW_CI_UNSEL, GUI_STCOLOR_LIGHTBLUE);
    ST_AnimatedIconView_SetBkColor(hItem, ICONVIEW_CI_UNSEL, GUI_WHITE);
    ST_AnimatedIconView_SetBkColor(hItem, ICONVIEW_CI_SEL, GUI_WHITE);
    
    ST_AnimatedIconView_SetDualTextColor(hItem, ICONVIEW_CI_SEL, GUI_STCOLOR_LIGHTBLUE, GUI_STCOLOR_DARKBLUE);  
    
    ST_AnimatedIconView_AddIcon(hItem, open_file, 0, "Play video");   
    ST_AnimatedIconView_AddIcon(hItem, add_video, 0, "Open playlist");    
    
    break;     

  case WM_PAINT: 
    GUI_SetColor(GUI_BLACK);
    GUI_DrawLine(799, 0, 799, 480);   

    break;
    
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);    /* Id of widget */
    NCode = pMsg->Data.v;               /* Notification code */   
    
    switch(Id) {
    case ID_BUTTON_EXIT: 
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        /* avoid icon view animation */
        hItem = WM_GetDialogItem(pMsg->hWin, ID_ICONVIEW_SUBMENU);
        WM_HideWindow(hItem);
        break;
        
      case WM_NOTIFICATION_MOVED_OUT:
        hItem = WM_GetDialogItem(pMsg->hWin, ID_ICONVIEW_SUBMENU);
        WM_ShowWindow(hItem);        
        break;
        
      case WM_NOTIFICATION_RELEASED:
        GUI_EndDialog(pMsg->hWin, 0);
        break;
      }
      break; 
      
      
    case ID_ICONVIEW_SUBMENU: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:      
        sel = ST_AnimatedIconView_GetSel(pMsg->hWinSrc);
        
        if(sel == 0)
        {
          if(VNC_IsRunning() == 0)
          {
            /* Playlist not empty, so start play first item */
            if(VideoList.ptr > 0)
            {  
              GUI_SetLayerVisEx (1, 1);
              GUI_SelectLayer(1); 
              playbackwin = WM_CreateWindowAsChild(0, 0, 800, 480, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbplaybackwin , 0);
              WM_CreateWindowAsChild(100, 100, 600, 280, WM_GetDesktopWindowEx(1), WM_CF_SHOW | WM_CF_HASTRANS, _cbTouch , 0);             
              GUI_SelectLayer(0);
              _StartPlay(&hvideo, (char *)VideoList.file[0].name, &Video_File, 0, 0);
              VideoPlayer_State = VIDEO_PLAY;
              hFrame = WM_CreateWindowAsChild(0, 0, 800, 480,pMsg->hWin, WM_CF_SHOW, _cbVideoWindow , 0);    
              GUI_SelectLayer(1);
              
            }
            else 
            {/* There is no item yet in the playlist: Show hint message */
              hItem = GUI_CreateDialogBox(_aFileInfoDialogCreate, 
                                          GUI_COUNTOF(_aFileInfoDialogCreate), 
                                          _cbFileInfoDialog, 
                                          pMsg->hWin, 
                                          100, 50);
              WM_MakeModal(hItem);            
            }
          }
          else
          {
              hItem = GUI_CreateDialogBox(_aFileErrorDialogCreate, 
                                          GUI_COUNTOF(_aFileErrorDialogCreate), 
                                          _cbFileInfoDialog, 
                                          pMsg->hWin, 
                                          100, 50);
              WM_MakeModal(hItem);
          }
        }
        else if(sel == 1)
        {
            hPlaylistWin = GUI_CreateDialogBox(_aPlaylistDialogCreate, 
                                GUI_COUNTOF(_aPlaylistDialogCreate), 
                                _cbPlaylistDialog, 
                                pMsg->hWin, 
                                100, 50);
            WM_MakeModal(hPlaylistWin);
        }
        break;
      }
      break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }    
}
/**
  * @brief  Callback function of the media connection status
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbMediaConnection(WM_MESSAGE * pMsg) 
{
  static WM_HTIMER      hStatusTimer;  
  static uint8_t        prev_usb_status = 0;
  WM_HWIN hItem = 0;

  static char tmp[64];
  uint32_t i = 0;
  
  switch (pMsg->MsgId) 
  {
  case WM_CREATE:
    prev_usb_status = k_StorageGetStatus(USB_DISK_UNIT);    
    hStatusTimer = WM_CreateTimer(pMsg->hWin, ID_TIMER_CONNECTION, 500, 0);      
    break;
    
  case WM_TIMER:
  if(prev_usb_status != k_StorageGetStatus(USB_DISK_UNIT))
    {
      prev_usb_status = k_StorageGetStatus(USB_DISK_UNIT);
      if(prev_usb_status == 0)
      { 
        if(VideoPlayer_State != VIDEO_IDLE)
        {
          _StopPlay(&hvideo, &Video_File);
        }
        
        VideoList.ptr = 0;
        if(playbackwin)
        {
          GUI_EndDialog(playbackwin, 0);
          playbackwin = 0;
          
          SelLayer = 0;
          GUI_SetLayerVisEx (1, 0);
          GUI_SelectLayer(0);
          WM_InvalidateWindow(VideoWin);
        }
        if(hFrame)
        {
          WM_HideWindow(hFrame);        
          WM_Exec();        
          WM_DeleteWindow(hFrame);
          hFrame = 0;
        }
        if(hPlaylistWin)
        {
          hItem = WM_GetDialogItem(hPlaylistWin, ID_VIDEO_LIST);
          i = LISTVIEW_GetNumRows(hItem);
          while(i--)
          {
            LISTVIEW_DeleteRow(hItem, i);
          }
        }
      }
      else
      {
        VideoList.ptr = 0;
        _AddEntireFolder("0:");
        _AddEntireFolder("0:/Video");
        
        if(hPlaylistWin)
        {
          if(VideoList.ptr > 0)
          {
            for(i=0; i<VideoList.ptr; i++)
            {
              strcpy(FileInfo.pRoot, (char *)VideoList.file[i].name);
              FILEMGR_GetFileOnly ((char *)tmp, (char *)FileInfo.pRoot);
              hItem = WM_GetDialogItem(hPlaylistWin, ID_VIDEO_LIST);
              
              LISTVIEW_AddRow(hItem, NULL);         
              LISTVIEW_SetItemText(hItem, 0, i, (char *)tmp);
            }
            WM_InvalidateWindow(hItem);
            WM_Update(hItem); 
          } 
        }
        
      }
    }
    WM_RestartTimer(pMsg->Data.v, 500);
    break;
    
  case WM_DELETE:
    if(hStatusTimer != 0)
    {
      WM_DeleteTimer(hStatusTimer);
      hStatusTimer = 0;
    }
    break;   
    
  default:
    WM_DefaultProc(pMsg);
  }
}
/**
  * @brief  callback for video window
  * @param  pMsg: pointer to a data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbplaybackwin(WM_MESSAGE * pMsg) 
{
  WM_HWIN hItem;
  int Id, NCode;
  char tmp[64];
  
  switch (pMsg->MsgId) 
  {
  case WM_CREATE:
    SelLayer = 1;    
   
    hItem = BUTTON_CreateEx(398 - 160, 442, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_BACK);
    WM_SetCallback(hItem, _cbButton_back);
    
    hItem = BUTTON_CreateEx(449 - 160, 442, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_STOP);
    WM_SetCallback(hItem, _cbButton_stop); 

    hItem = BUTTON_CreateEx(495 - 160, 441, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, PLAY_VIDEO_ID);
    WM_SetCallback(hItem, _cbButton_play);
        
    hItem = BUTTON_CreateEx(540 - 160, 442, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_FORE);
    WM_SetCallback(hItem, _cbButton_fore);
    
    hItem = SLIDER_CreateEx(72, 420, 510, 13, pMsg->hWin, WM_CF_SHOW, 0, ID_SLIDER_DURATION);
    SLIDER_SetBkColor(hItem, GUI_TRANSPARENT);
    SLIDER_SetFocusColor (hItem, 0x00DCA939);
    SLIDER_SetValue(hItem, 0);
    SLIDER_SetWidth(hItem, 0);
    SLIDER_SetSTSkin(hItem);    
       
    hItem = BUTTON_CreateEx(568, 0, 70, 70, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_MENU);
    WM_SetCallback(hItem, _cbButton_menu);     
    
    hItem = BUTTON_CreateEx(0, 410, 70, 70, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_EXIT_FROM_VIDEO);
    WM_SetCallback(hItem, _cbButton_exit1);   
    
    /* Title Initialization in play list */   
    hItem = TEXT_CreateEx(10, 20, 100, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_ELAPSED_TIME, "00:00");
    TEXT_SetFont(hItem, GUI_FONT_20B_1);
    TEXT_SetTextColor(hItem, GUI_WHITE);     
    
    /* Title Initialization in play list */   
    hItem = TEXT_CreateEx(50, 40, 50, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_TIME, "00:00");
    TEXT_SetFont(hItem, GUI_FONT_16B_1);
    TEXT_SetTextColor(hItem, GUI_WHITE);  
    
    hItem = TEXT_CreateEx(150, 20, 350, 30, pMsg->hWin, WM_CF_SHOW, TEXT_CF_HCENTER, ID_VIDEO_NAME, "File Name");
    TEXT_SetFont(hItem, GUI_FONT_20B_1);
    TEXT_SetTextColor(hItem, GUI_WHITE); 
    
    hItem = TEXT_CreateEx(150, 48, 350, 30, pMsg->hWin, WM_CF_SHOW, TEXT_CF_HCENTER, ID_VIDEO_FORMAT, "Format : MJPEG");
    TEXT_SetFont(hItem, GUI_FONT_13B_1);
    TEXT_SetTextColor(hItem, GUI_WHITE);
    
    hItem = TEXT_CreateEx(548, 200, 260, 20, pMsg->hWin, WM_CF_SHOW, TEXT_CF_LEFT, ID_FPS, "Rate : 20 fps");
    TEXT_SetFont(hItem, GUI_FONT_13B_1);
    TEXT_SetTextColor(hItem, GUI_WHITE);   
    
    hItem = TEXT_CreateEx(548, 220, 260, 20, pMsg->hWin, WM_CF_SHOW, TEXT_CF_LEFT, ID_FEATURES_FPU, "FPU : ON");
    TEXT_SetFont(hItem, GUI_FONT_13B_1);
    TEXT_SetTextColor(hItem, GUI_WHITE); 
    
    hItem = TEXT_CreateEx(548, 240, 260, 20, pMsg->hWin, WM_CF_SHOW, TEXT_CF_LEFT, ID_FEATURES_IC, "I-Cache : ON");
    TEXT_SetFont(hItem, GUI_FONT_13B_1);
    TEXT_SetTextColor(hItem, GUI_WHITE);     
    
    hItem = TEXT_CreateEx(548, 260, 260, 20, pMsg->hWin, WM_CF_SHOW, TEXT_CF_LEFT, ID_FEATURES_DC, "D-Cache : ON");
    TEXT_SetFont(hItem, GUI_FONT_13B_1);
    TEXT_SetTextColor(hItem, GUI_WHITE);  

    hItem = TEXT_CreateEx(548, 280, 260, 20, pMsg->hWin, WM_CF_SHOW, TEXT_CF_LEFT, ID_FEATURES_CPU, "MCU Load : 0%");
    TEXT_SetFont(hItem, GUI_FONT_13B_1);
    TEXT_SetTextColor(hItem, GUI_WHITE);       
    
    break;
    
  case WM_TIMER:
    { 
      WM_RestartTimer(pMsg->Data.v, 1000);
      /* show elapsed time */
      hItem = WM_GetDialogItem(pMsg->hWin, ID_ELAPSED_TIME);
      elapsed_time++;
      sprintf((char *)tmp , "%02lu:%02lu", elapsed_time/60, elapsed_time%60 );
      TEXT_SetText(hItem, tmp);
      sprintf((char *)tmp , "MCU Load : %d%%", ((osGetCPUUsage() > 90) ? (osGetCPUUsage() - 10) : osGetCPUUsage()));
      hItem = WM_GetDialogItem(pMsg->hWin, ID_FEATURES_CPU);
      TEXT_SetText(hItem, tmp);
      
      hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_DURATION);
      SLIDER_SetValue(hItem, (GUI_MOVIE_GetFrameIndex(hvideo)* 100)/ Video_Info.NumFrames);
      
      if(step == 0)
      {
        step = ((GUI_MOVIE_GetFrameIndex(hvideo)* 100)/ Video_Info.NumFrames);
      }

      if(((GUI_MOVIE_GetFrameIndex(hvideo)* 100)/ Video_Info.NumFrames) > (100 - 2*step - 1))
      {
        SLIDER_SetValue(hItem, 100);
        GUI_Exec();
      }
      
    }
    break;
    
  case WM_DELETE:
    if(hTimer != 0)
    {
      WM_DeleteTimer(hTimer);
      hTimer = 0;
    }
    
  case WM_PAINT: 
    GUI_SetColor(0xFF000000 | GUI_BLACK);
    GUI_SetBkColor(GUI_TRANSPARENT);
    GUI_Clear();

    GUI_SetColor(GUI_BLACK);
    GUI_DrawHLine(0, 0, 640);
    GUI_DrawHLine(479, 0, 640);
    GUI_DrawLine(639, 0, 639, 480);   
    GUI_DrawLine(0, 0, 0, 480);

    /* Background for total time */
    GUI_SetColor(0x00DCA939);
    GUI_AA_FillRoundedRect((-30), 5, 90, 65, 30);
    
    /*Video Information */
    GUI_AA_FillRoundedRect(150, 5, 500, 65, 30);
    
    /*H/W Information */
    GUI_AA_FillRoundedRect(538, 180, 780, 320, 30);    
    
    break;
    
    
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);    /* Id of widget */
    NCode = pMsg->Data.v;               /* Notification code */
 
    
    switch(Id) {
      
    case ID_BUTTON_EXIT_FROM_VIDEO: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:

        if(VideoPlayer_State != VIDEO_IDLE)
        {
          _StopPlay(&hvideo, &Video_File);
        }
        
        GUI_EndDialog(pMsg->hWin, 0);
        SelLayer = 0;
        GUI_SetLayerVisEx (1, 0);
        GUI_SelectLayer(0); 
        WM_HideWindow(hFrame);        
        WM_Exec();        
        WM_DeleteWindow(hFrame);
        WM_InvalidateWindow(VideoWin);
        break;
      }
      break;

    case ID_BUTTON_MENU: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:

        if(VideoPlayer_State != VIDEO_IDLE)
        {
          _StopPlay(&hvideo, &Video_File);
        }
        
        GUI_EndDialog(pMsg->hWin, 0);
        SelLayer = 0;
        GUI_SetLayerVisEx (1, 0);
        GUI_SelectLayer(0); 
        WM_DeleteWindow(hFrame);
        WM_HideWindow(VideoWin);        
        WM_Exec();
        WM_DeleteWindow(VideoWin);
        break;
      }
      break;
      
    case ID_BUTTON_STOP: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        if(VideoPlayer_State != VIDEO_IDLE)
        {
          VideoPlayer_State = VIDEO_STOP;
          _StopPlay(&hvideo, &Video_File);
        }
         WM_InvalidateWindow(pMsg->hWin);
        break;
      }
      break;
     
    case ID_BUTTON_FORE: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        if(VideoPlayer_State == VIDEO_PLAY)
        {
          if(file_pos < (VideoList.ptr - 1))
          {
            file_pos++;
          }
          else 
          {        
            file_pos = 0; 
          }  
          _StopPlay(&hvideo, &Video_File);
          _StartPlay(&hvideo, (char *)VideoList.file[file_pos].name, &Video_File, 0, 0);

        }
        break;
      }
      break;
      
    /* Notifications sent by 'progress' Slider */
    case ID_SLIDER_DURATION: 
      if(NCode == WM_NOTIFICATION_CLICKED)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_DURATION);
        int32_t newpos;
        if(VideoPlayer_State == VIDEO_PLAY)
        {
          GUI_MOVIE_Pause(hvideo);
          hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_DURATION);
          newpos = (SLIDER_GetValue(hItem) * Video_Info.NumFrames)/100;
          GUI_MOVIE_GotoFrame(hvideo, newpos);
          GUI_MOVIE_Play(hvideo);
          elapsed_time = (Video_Info.msPerFrame * newpos)/ 1000;
          hItem = WM_GetDialogItem(playbackwin, ID_ELAPSED_TIME);
          sprintf((char *)tmp , "%02lu:%02lu", elapsed_time/60, elapsed_time%60 );
          TEXT_SetText(hItem, tmp); 
          WM_InvalidateWindow(hItem);
          WM_Paint(hItem);
        }
        
      }
      break;
      
      
    case ID_BUTTON_BACK: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        if(VideoPlayer_State == VIDEO_PLAY)
        {
          if(file_pos > 0)
          {   
            file_pos--;
          }
          else 
          {        
            file_pos = VideoList.ptr - 1; 
          }  
          
          _StopPlay(&hvideo, &Video_File);
          _StartPlay(&hvideo, (char *)VideoList.file[file_pos].name, &Video_File, 0, 0); 
        }
        break;
      }
      break;
      
    case PLAY_VIDEO_ID: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
          if((VideoPlayer_State == VIDEO_IDLE) || (VideoPlayer_State == VIDEO_PAUSE))
          {
            hTimer = WM_CreateTimer(playbackwin, 0, 1000, 0);  
            GUI_MOVIE_Play(hvideo); 
            VideoPlayer_State = VIDEO_PLAY;
          }
          else if(VideoPlayer_State == VIDEO_STOP)
          {
            _StartPlay(&hvideo, (char *)VideoList.file[file_pos].name, &Video_File, 0, 0);             
            VideoPlayer_State = VIDEO_PLAY;
          }
          else
          {
            GUI_MOVIE_Pause(hvideo);
            VideoPlayer_State = VIDEO_PAUSE; 
            if(hTimer != 0)
            {
              WM_DeleteTimer(hTimer);
              hTimer = 0;
            }            
          }
        break;
      }
      break;       
    }
    break;

  default:
    WM_DefaultProc(pMsg);
    break;
  }
}