/********************************************************************* * * GUIDEMO_ShowIntro * * This function has to be called by every sample */ void GUIDEMO_ShowIntro(const char * acTitle, const char * acDescription) { int xSize, ySize, xCenter, yCenter, FontDistY, TimeWait, i; xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); xCenter = xSize >> 1; yCenter = ySize >> 1; GUIDEMO_HideInfoWin(); GUIDEMO_ShowControlWin(); GUI_Exec(); GUIDEMO_DrawBk(1); GUI_SetColor(GUI_WHITE); // // Title // GUI_SetTextMode(GUI_TM_TRANS); GUI_SetFont(&GUI_FontRounded22); GUI_DispStringHCenterAt(acTitle, xCenter, 60); // // Description // GUI_SetFont(&GUI_FontSouvenir18); FontDistY = GUI_GetFontDistY(); GUI_DispStringHCenterAt(acDescription, xCenter, yCenter - FontDistY + 10); // // Determine time to wait // i = 0; while (acDescription[i]) { i++; } TimeWait = i * 80; GUIDEMO_Wait(TimeWait); }
void GUIDEMO_ShowIntro(const char * s, const char * sExp) { GUI_CONTEXT ContextOld; GUI_SaveContext(&ContextOld); _sInfo = s; _sExplain = sExp; GUI_SetDefault(); GUIDEMO_HideInfoWin(); GUI_SetBkColor(GUI_BLUE); GUI_SetColor(GUI_WHITE); GUI_Clear(); //GUI_SetFont(&GUI_FontComic18B_ASCII); GUI_SetFont(&GUI_FontHZ12); GUI_DispStringHCenterAt(s, LCD_GET_XSIZE() / 2, LCD_GET_YSIZE() / 3 - 10); if (_sExplain) { GUI_SetFont(&GUI_Font8_ASCII); GUI_DispStringHCenterAt(_sExplain, LCD_GET_XSIZE() / 2, LCD_GET_YSIZE() / 2 - 10); } GUIDEMO_Delay(_sExplain ? 2000 : 4000); #if GUI_WINSUPPORT _UpdateInfoWin(); _UpdateCmdWin(); #endif GUI_RestoreContext(&ContextOld); #if GUI_WINSUPPORT WM_ExecIdle(); #endif GUIDEMO_NotifyStartNext(); GUI_SetBkColor(GUI_RED); GUI_Clear(); }
void GUIDEMO_WM(void) { /* Show message */ /* GUIDEMO_ShowIntro("Windows Manager", "\nExamples for the" "\nWindows manager"); */ GUIDEMO_NotifyStartNext(); GUI_SetBkColor(GUI_BLACK); GUI_Clear(); WM_SetCreateFlags(WM_CF_MEMDEV); WM_EnableMemdev(WM_HBKWIN); GUIDEMO_HideInfoWin(); _DemoSetDesktopColor(); _DemoCreateWindow(); _DemoCreateWindowAsChild(); _DemoInvalidateWindow(); _DemoBringToTop(); _DemoMoveTo(); _DemoBringToBottom(); _DemoMoveWindow(); _DemoHideShowParent(); _DemoHideShowChild(); //_DemoClipping(); _DemoRedrawing(); _DemoResizeWindow(); _DemoSetCallback(); _DemoDeleteWindow(); }
void GUIDEMO_Touch(void) { #define ID_KEYBOARD 1 #define ID_TESTCAL 2 #define ID_CALIBRATE 3 int i, r; int XSize = LCD_GetXSize(); int YSize = LCD_GetYSize(); int XMid = XSize / 2; int YMid = YSize / 2; //GUIDEMO_NotifyStartNext(); GUIDEMO_HideInfoWin(); do { GUI_RECT rText;/*= {0, 80, XSize, 120};*/ BUTTON_Handle ahButton[3]; rText.x0=0; rText.y0=50; rText.x1=XSize; rText.y1=90; GUI_SetBkColor(GUI_BLUE); GUI_Clear(); GUI_DrawBitmap(&bmMicriumLogo, (XSize - 1 - bmMicriumLogo.XSize) / 2, 15); GUI_SetFont(&GUI_Font16B_1); GUI_DispStringInRect("µC/GUI Touch screen demo", &rText, GUI_TA_HCENTER | GUI_TA_VCENTER); ahButton[0] = BUTTON_Create( XMid - 50, YMid - 30, 100, 50, ID_CALIBRATE,BUTTON_CF_SHOW ); ahButton[1] = BUTTON_Create( XMid - 90, YMid + 30, 80, 30, ID_KEYBOARD, BUTTON_CF_SHOW ); ahButton[2] = BUTTON_Create( XMid + 10, YMid + 30, 80, 30, ID_TESTCAL,BUTTON_CF_SHOW ); BUTTON_SetText (ahButton[0], "Calibrate"); BUTTON_SetBkColor(ahButton[0], 0, GUI_RED); BUTTON_SetText (ahButton[1], "Keyboard"); BUTTON_SetText (ahButton[2], "Test calibration"); BUTTON_SetFont(ahButton[0], &GUI_FontComic18B_ASCII); r = GUIDEMO_WaitKey(); if (r==0) { r = ID_KEYBOARD; BUTTON_SetState(ahButton[1],BUTTON_STATE_PRESSED); GUIDEMO_Delay(500); } for (i=0; i< countof(ahButton); i++) { BUTTON_Delete(ahButton[i]); } switch (r) { case ID_KEYBOARD: init_uart0(); send_press_key(); break; case ID_CALIBRATE: _ExecCalibration(); break; case ID_TESTCAL: _TestCalibration(); break; } } while (r && (r!='n') && (r!='N')); }
/********************************************************************* * * 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); /* 把消息发送至指定键,把键盘数据发送到输入焦点所在窗口,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)) { /* 确定指定句柄是否是有效的窗口句柄,0:句柄不是有效的窗口句柄,1:句柄是有效的窗口句柄 */ 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 */ }
/********************************************************************* * * 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 = GUIDEMO_SetBkColor(GUI_RED); DesktopColorOld = WM_SetDesktopColor(DesktopColorOld); /* 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 */ }