⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demoport.c

📁 nucleus 文件系统,内核和彩色图形系统,在小系统上非常好用
💻 C
字号:
#define byte unsigned char
#define word unsigned short
#include "metawndo.h"      /* master MetaWINDOW include file */

/* special stack size declaration if using Turbo or Borland C++ */
#ifdef      TurboC
extern unsigned _stklen = 14336U;  /* stack size 14K */
#endif

void Waiting(int a);

void  nxt(void), Port2(int,int), Port1(int,int); 

void demoport( )
{
//	int	i,j;
	int 	x,y;
   char  msgstr[80];
   rect  scrnR;
//   rect moveR;
   int   GrafixCard = 2;

   /* init the system */
//   i = InitGraphics( GrafixCard );

   ScreenRect(&scrnR);
//	SetDisplay( GrafPg0 );
	BackColor(0);
	EraseRect( &scrnR );
	x = scrnR.Xmax/20;
	y = scrnR.Ymax/10;

   /* print something on default port */
	PenColor(-1);
	MoveTo(x*2,y);
	sprintf(msgstr,"Display has %d by %d pixels, and %ld colors."
			 			,scrnR.Xmax,scrnR.Ymax, QueryColors()+1 );
	DrawString(msgstr);
	PenSize(10,8);
	FrameRect(&scrnR);
	MoveTo(x*2,y*3);
	DrawString(" This is the default Port. ");
	nxt();               /* wait for a key */

	Port1(x*4,y*4);

	MoveTo(x*2,y*7);
	DrawString(" Full screen port after port1. ");
	nxt();               /* wait for a key */

	Port2(x*12,y*3);
	
	MoveTo(x*2,y*7);
	DrawString(" Full screen port after port2. ");
	nxt();               /* wait for a key */

	return;
}


/* build a port */
void Port1( int x, int y )
{

	grafPort  *entryPort;   /* pointer for entry port */
   grafPort Port1Rcd;		/* This ports record      */
	rect		PortR;

	GetPort(&entryPort);    /* get pointer to current port */
	InitPort(&Port1Rcd);    /* init and make active Port1  */   

	MovePortTo(x,y);        /* position this port in global coordinates */

	PortSize(200,100);      /* size this port in global coordinates */

   ScreenRect(&PortR);     /* get the port rectangle */

                           /* draw something */
	PenColor(Green);
	BackColor(LtGray);
   FillRect(&PortR,12);
	PenColor(-1);

	MoveTo(10,20);				/* note that this is port relative */
	DrawString("Port1");

	MoveTo(10,40);				
	DrawString(" I will be clipped, 'cuz I'm too long to fit. ");

	SetPort(entryPort);     /* restore original port context */
}

/* son of build a port */
void Port2( int x, int y)
{
	grafPort  *entryPort;   /* pointer for entry port address */
   grafPort Port2Rcd;		/* This ports record */
	rect     PortR;

	GetPort(&entryPort);    /* get pointer to current port  */
	InitPort(&Port2Rcd);    /* init and make active this port */

	MovePortTo(x,y);        /* position this port in global coordinates */

	PortSize(100,100);      /* size this port in global coordinates */
               
   ScreenRect(&PortR);     /* get the port rectangle */

	PenColor(LtBlue);       /* draw something */
	BackColor(LtMagenta);
	EraseRect(&PortR);
	MoveTo(10,20);				/* note that this is port relative */
	DrawString("Port 2");
	MoveTo(10,40);				
	DrawString("I'm too long to fit here.");

	SetPort(entryPort);    /* restore original port context */
}


/* print this message along the bottom of the screen        */
/* uses active port	  									            */

void nxt()
{
	void quit(void);
	mwEvent waitEvent;
   rect  scrnR;

   ScreenRect(&scrnR);
    PenSize(penThin);
	
#ifndef CYCLE
	PenColor(-1);
	MoveTo( 0,scrnR.Ymax - 20 );
	DrawString( "Press 'x' to exit" );
	MoveTo( 0,scrnR.Ymax - 10 );
	DrawString( "any other key to continue" );
	  while(!KeyEvent(1, &waitEvent));
	  if((waitEvent.eventChar == 'x') || (waitEvent.eventChar == 'X')) quit();
#else
#ifdef _MNT_
	  KeyEvent(0, &waitEvent);
	  if((waitEvent.eventChar == 'x') || (waitEvent.eventChar == 'X')) quit();
#endif
   Waiting(150);
#endif

}





					  	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -