📄 wm_redraw.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 : WM_Redraw.c
Purpose : Demonstrates the redrawing mechanism of the window manager
----------------------------------------------------------------------
*/
#include "GUI.h"
#include "WM.h"
/*******************************************************************
*
* static code
*
********************************************************************
*/
/*******************************************************************
*
* _cbBkWindow
*/
static void _cbBkWindow(WM_MESSAGE* pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
GUI_ClearRect(0, 50, 319, 239);
default:
WM_DefaultProc(pMsg);
}
}
/*******************************************************************
*
* _cbWindow
*/
static void _cbWindow(WM_MESSAGE* pMsg) {
GUI_RECT Rect;
switch (pMsg->MsgId) {
case WM_PAINT:
WM_GetInsideRect(&Rect);
GUI_SetBkColor(GUI_RED);
GUI_SetColor(GUI_YELLOW);
GUI_ClearRectEx(&Rect);
GUI_DrawRectEx(&Rect);
GUI_SetColor(GUI_BLACK);
GUI_SetFont(&GUI_Font8x16);
GUI_DispStringHCenterAt("Foreground window", 75, 40);
break;
default:
WM_DefaultProc(pMsg);
}
}
/*******************************************************************
*
* _MoveWindow
*/
static void _MoveWindow(const char* pText) {
WM_HWIN hWnd;
int i;
/* Create foreground window */
hWnd = WM_CreateWindow(10, 50, 150, 100, WM_CF_SHOW, _cbWindow, 0);
GUI_Delay(500);
/* Move foreground window */
for (i = 0; i < 40; i++) {
WM_MoveWindow(hWnd, 2, 2);
GUI_Delay(10);
}
/* Show text before deleting window if we have one */
if (pText) {
GUI_DispStringAt(pText, 5, 50);
GUI_Delay(2500);
}
/* Delete foreground window */
WM_DeleteWindow(hWnd);
WM_Invalidate(WM_HBKWIN);
GUI_Exec();
}
/*******************************************************************
*
* _DemoRedraw
*/
static void _DemoRedraw(void) {
WM_CALLBACK* _cbOldBk;
GUI_SetBkColor(GUI_BLACK);
GUI_Clear();
GUI_SetColor(GUI_WHITE);
GUI_SetFont(&GUI_Font24_ASCII);
GUI_DispStringHCenterAt("WM_Redraw - Sample", 160, 5);
GUI_SetFont(&GUI_Font8x16);
while(1) {
/* Move a window over background */
_MoveWindow("Background has not been redrawn");
/* Clear background */
GUI_ClearRect(0, 50, 319, 239);
GUI_Delay(1000);
/* Set callback for background window */
_cbOldBk = WM_SetCallback(WM_HBKWIN, _cbBkWindow);
/* Move a window over background */
_MoveWindow("Background has been redrawn");
/* Delete callback for Background window */
WM_SetCallback(WM_HBKWIN, _cbOldBk);
}
}
/*******************************************************************
*
* MainTask
*
* Demonstrates redrawing
*
********************************************************************
*/
void MainTask(void) {
GUI_Init();
_DemoRedraw();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -