📄 guidemo.c
字号:
/*********************************************************************************************************** uC/GUI* Universal graphic software for embedded applications** (c) Copyright 2002, Micrium Inc., Weston, FL* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH** 礐/GUI is protected by international copyright laws. Knowledge of the* source code may not be used to write a similar product. This file may* only be used in accordance with a license and should not be redistributed* in any way. We appreciate your understanding and fairness.*----------------------------------------------------------------------File : GUIDEMO.cPurpose : Several GUIDEMO routines----------------------------------------------------------------------*/#include <stddef.h>#include "..\gui\core\GUI.h"#include "..\gui\widget\Progbar.h"#include "..\gui\widget\LISTBOX.h"#include "..\gui\widget\FrameWin.h"#include "..\gui\widget\BUTTON.H"#include "..\Target\44blib.h"#include "GUIDEMO.H"//#include "..\ucos-ii\os_cpu.h"/*********************************************************************** Static variables************************************************************************/#if GUI_WINSUPPORT static BUTTON_Handle _ahButton[2]; static FRAMEWIN_Handle _ahFrameWin[2]; static FRAMEWIN_Handle _ahInfoWin[2]; static int _FrameWinPosX[2], _FrameWinPosY[2]; static int _FrameWinSizeX[2], _FrameWinSizeY[2]; static int _ButtonSizeX, _ButtonSizeY;// static unsigned char guidemo_flg=0;#endifstatic int _iTest, _iTestMinor;static char _CmdNext;static const char* _sInfo;static const char* _sExplain;unsigned char guidemo_flg=0;#define countof(Obj) (sizeof(Obj)/sizeof(Obj[0]))/*********************************************************************** Routine table*********************************************************************** The routines to be called are listed here. The advantage to calling directly is that we can execute some code before and after.*/typedef void fVoidVoid(void);/*static fVoidVoid * _apfTest[] = { GUIDEMO_HardwareInfo, GUIDEMO_Speed, #if GUI_SUPPORT_MEMDEV GUIDEMO_Graph, #endif GUIDEMO_Bitmap, GUIDEMO_ShowInternationalFonts, GUIDEMO_Dialog, GUIDEMO_ShowColorBar, GUIDEMO_ShowColorList, //GUIDEMO_DemoLUT, GUIDEMO_DemoPolygon, GUIDEMO_Circle, GUIDEMO_ShowMemoryDevice, GUIDEMO_Automotive, GUIDEMO_Navigation, #if GUI_WINSUPPORT GUIDEMO_DemoProgBar, GUIDEMO_DemoFrameWin, #if GUI_SUPPORT_TOUCH GUIDEMO_Touch, #endif #endif 0 };*//*********************************************************************** Static routines***********************************************************************static void _UpdateCmdWin(void) { #if GUI_WINSUPPORT && GUIDEMO_LARGE//&&guidemo_flg // Update info in command window if(guidemo_flg){ WM_HWIN hWin; GUI_CONTEXT ContextOld; GUI_SaveContext(&ContextOld); hWin = WM_SelectWindow(_ahInfoWin[1]); GUI_SetDefault(); GUI_SetBkColor(GUI_GRAY); GUI_Clear(); GUI_DispStringAt("Demo ", 0, 0); GUI_DispDecMin(_iTest + 1); GUI_DispString("."); GUI_DispDecMin(_iTestMinor); GUI_DispString("/"); GUI_DispDecMin(countof(_apfTest)); WM_SelectWindow(hWin); GUI_RestoreContext(&ContextOld); } #endif}*/static void _UpdateInfoWin(void) { #if GUI_WINSUPPORT && GUIDEMO_LARGE if(guidemo_flg){ GUI_RECT rClient; WM_HWIN hWin; GUI_CONTEXT ContextOld; GUI_SaveContext(&ContextOld); // Update info window WM_ShowWindow(_ahInfoWin[0]); WM_ShowWindow(_ahFrameWin[0]); hWin = WM_SelectWindow(_ahInfoWin[0]); GUI_GetClientRect(&rClient); GUI_SetBkColor(GUI_WHITE); GUI_Clear(); GUI_SetColor(GUI_BLACK); GUI_SetFont(&GUI_Font13_1); //GUI_SetFont(&GUI_FontHZ12); GUI_SetTextAlign(GUI_TA_HCENTER); GUI_DispStringHCenterAt(_sInfo, (rClient.x1 - rClient.x0) / 2, 0); GUI_SetTextAlign(GUI_TA_LEFT); GUI_SetFont(&GUI_Font8_ASCII); GUI_DispStringAt(_sExplain, 0, 20); WM_SelectWindow(hWin); GUI_RestoreContext(&ContextOld); } #endif}/*********************************************************************** Exported routines************************************************************************/int GUIDEMO_Delay(int t) { int r = 0; #if GUI_WINSUPPORT int tRem, tEnd = GUI_GetTime() + t; if(guidemo_flg==1) { PROGBAR_Handle hProg; WM_SetForegroundWindow(_ahButton[0]); hProg = (t >100) ? PROGBAR_Create(_FrameWinPosX[1] + 10, _FrameWinPosY[1] + 25, _FrameWinSizeX[1] - 20, 7, WM_CF_SHOW|WM_CF_STAYONTOP) : 0; #if GUI_SUPPORT_MEMDEV PROGBAR_EnableMemdev(hProg); #endif PROGBAR_SetMinMax(hProg, 0, t); for (; tRem = tEnd - GUI_GetTime(), (tRem > 0) && !GUIDEMO_CheckCancel();) { PROGBAR_SetValue(hProg, t - tRem); WM_ExecIdle(); GUI_Delay(20); } PROGBAR_Delete(hProg); //_UpdateCmdWin(); WM_ExecIdle(); } else { GUI_Delay(t); } #else GUI_Delay(t); #endif return r;}void GUIDEMO_Wait(void) { GUIDEMO_Delay(3000); GUIDEMO_NotifyStartNext();}int GUIDEMO_CheckCancel(void) { int c = GUI_GetKey(); GUI_TOUCH_Exec(); //GUI_TOUCH_Exec(); #if GUI_WINSUPPORT WM_ExecIdle(); #endif if ((c == 'n') || (c=='N')) _CmdNext =1; if ((c == 's') || (c=='S')) { GUI_Delay(500); do { GUI_Delay(10); #if GUI_WINSUPPORT WM_ExecIdle(); #endif c = GUI_GetKey(); GUI_TOUCH_Exec(); } while (!c); } return _CmdNext;}void GUIDEMO_ShowInfo(const char* s) { _sExplain = s; _UpdateInfoWin();}void GUIDEMO_HideInfoWin(void) { #if GUI_WINSUPPORT //if(guidemo_flg==1) WM_HideWindow(_ahFrameWin[0]); #endif}void GUIDEMO_NotifyStartNext(void) { _CmdNext = 0; //_UpdateCmdWin(); _iTestMinor++;}int GUIDEMO_WaitKey(void) { int r = 0; int tMax = GUI_GetTime() + 4000; int tDiff; /*#if GUI_WINSUPPORT PROGBAR_Handle hProg = PROGBAR_Create(LCD_GetXSize() - 70, LCD_GetYSize() - 40, 80, 5, WM_CF_SHOW); #endif*/ while (tDiff = tMax-GUI_GetTime(), (tDiff > 0) && !GUIDEMO_CheckCancel()) { if ((r = GUI_GetKey()) != 0) break; GUI_Delay(100); } #if GUI_WINSUPPORT //PROGBAR_Delete(hProg); if (r != 0) WM_ExecIdle(); #endif return r;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -