📄 wmredraw.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
----------------------------------------------------------------------
*/
#ifndef DEMOCHOICE
#include "headers.h"
#include "GUI.H"
#include "graphics.h"
void DrawInit (void)
{
int driver=DETECT,graphmode;
registerfarbgidriver (EGAVGA_driver_far);
initgraph (&driver,&graphmode,"");
}
#endif
/*******************************************************************
*
* Callback routine for background window
*
********************************************************************
*/
static void cbBackgroundWin(WM_MESSAGE* pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
GUI_Clear();
default:
WM_DefaultProc(pMsg);
}
}
/*******************************************************************
*
* Callback routine for foreground window
*
********************************************************************
*/
static void cbForegroundWin(WM_MESSAGE* pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
GUI_SetBkColor(GUI_GREEN);
GUI_Clear();
GUI_DispString("Foreground window");
break;
default:
WM_DefaultProc(pMsg);
}
}
/*******************************************************************
*
* Demonstrates the redraw mechanism of emWinGSC
*
********************************************************************
*/
#define DELAY 200
void DemoRedraw(void *pData) {
GUI_HWIN hWnd;
GUI_Init();
while(1) {
/* Create foreground window */
hWnd = WM_CreateWindow(10, 10, 100, 100, WM_CF_SHOW, cbForegroundWin, 0);
/* Show foreground window */
GUI_Delay(DELAY);
/* Delete foreground window */
WM_DeleteWindow(hWnd);
GUI_DispStringAt("Background of window has not been redrawn", 10, 10);
/* Wait a while, background will not be redrawn */
GUI_Delay(DELAY);
//GUI_Clear();
/* Set callback for Background window */
//WM_SetCallback(WM_HBKWIN, cbBackgroundWin);
/* Create foreground window */
hWnd = WM_CreateWindow(50, 50, 150, 150,WM_CF_SHOW, cbForegroundWin, 0);
/* Show foreground window */
GUI_Delay(DELAY);
/* Delete foreground window */
WM_DeleteWindow(hWnd);
/* Wait a while, background will be redrawn */
GUI_Delay(DELAY);
/* Delete callback for Background window */
//WM_SetCallback(WM_HBKWIN, 0);
GUI_Delay(DELAY);
}
}
/*******************************************************************
*
* main
*
********************************************************************
*/
#ifndef DEMOCHOICE
void main(void) {
DrawInit ();
OSInit(); /* Initialize uC/OS-II */
PC_DOSSaveReturn(); /* Save environment to return to DOS */
PC_VectSet(uCOS, OSCtxSw); /* Install uC/OS-II's context switch vector */
OS_ENTER_CRITICAL();
PC_VectSet(0x08, OSTickISR); /* Install uC/OS-II's clock tick ISR */
PC_SetTickRate(OS_TICKS_PER_SEC); /* Reprogram tick rate */
OS_EXIT_CRITICAL();
OSTaskCreateExt(DemoRedraw,(void *)1,&TestTask1Stk[TaskStkLeath-1],1,0,&TestTask1Stk[0],10*1024,(void *)0,OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
OSTaskCreateExt(TestTask2,(void *)2,&TestTask2Stk[TaskStkLeath-1],2,0,&TestTask2Stk[0],1024,(void *)0,OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
OSStart();
while (1);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -