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

📄 demo.cpp

📁 这是一个C++编程文档
💻 CPP
字号:
/* -------------------------------------------------------------------- */
/* Mouse++ Version 4.0             demo.cpp            Revised 10/05/92 */
/*                                                                      */
/* General mouse class for Turbo C++/Borland C++.                       */
/* Copyright 1991, 1992 by Carl W. Moreland                             */
/* -------------------------------------------------------------------- */
/* Demonstration of Mouse++ in text mode and graphics mode.             */
/* -------------------------------------------------------------------- */

#include <dos.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <graphics.h>
#include "mouse.h"
#include "cursor.h"

void textdemo(void);
int  textscreen(void);
void alttextscreen(void);
void nexttdemo(char *);
void graphicdemo(void);
int  graphicscreen(void);
void nextgdemo(char *);

int maxx, maxy;
int text_width, text_height;
struct text_info t_info;
int done = 0;

MouseEventHandler myHandler(MB_PRESSED|MB_RELEASED, MouseHandler);

main()
{
  if(mouse.Exists())	    		// check for mouse
  {
    mouse.InstallHandler(0xFF);		// install event handler
    mouse.Enable();			// enable mouse
    textdemo();				// run text mode demo

    mouse.SetRepeatRate(CENTERBUTTON,	// set the center button to repeat
                        500, 200);
    graphicdemo();			// run graphics mode demo
    return(0);				// normal termination
  }
  return(1);				// abnormal termination
}

/* ----- text mode demo ----------------------------------------------- */

void textdemo()				// main routine for text mode demo
{
  textmode(C80);			// 80x25 color text mode
  if(textscreen() == 0)			// draw the screen
  {
    alttextscreen();			// draw the alt screen
    textcolor(13);
    gotoxy(1,3);

    if(mouse.Info.type == 1) cprintf(" Bus mouse found\n");
    if(mouse.Info.type == 2) cprintf(" Serial mouse found\n");
    if(mouse.Info.type == 3) cprintf(" InPort mouse found\n");
    if(mouse.Info.type == 4) cprintf(" PS/2 mouse found\n");
    if(mouse.Info.type == 5) cprintf(" HP mouse found\n");
    gotoxy(1,4);
    cprintf(" Software version is %d.%d\n", (int)mouse.Info.majorvers,
    	      (int)mouse.Info.minorvers);

    mouse.yLimit(0, 199);		// set y limit
    mouse.Show();			// initial turn-on

    if(!done) { mouse.SetCursor(tdef); nexttdemo("     Default Cursor      "); }
    if(!done) { mouse.SetCursor(txt1); nexttdemo(" 0000h 0E0Fh Soft Cursor "); }
    if(!done) { mouse.SetCursor(txt2); nexttdemo(" 7000h 0E0Fh Soft Cursor "); }
    if(!done) { mouse.SetCursor(txt3); nexttdemo(" 7F00h FF0Fh Soft Cursor "); }
    mouse.xLimit(16, 623);
    if(!done) { mouse.SetCursor(txt4); nexttdemo(" 00FFh 0FD4h Soft Cursor "); }

    mouse.Hide();
    textmode(C4350);			// 43/50 line mode
    _setcursortype(_NOCURSOR);		// turn the hardware cursor off
    mouse.xLimit(0, 639);		// set x limit
    gettextinfo(&t_info);
    if(t_info.screenheight == 43)
      mouse.yLimit(0, 349);		// set y limit to EGA 43 line
    else
      mouse.yLimit(0, 399);		// set y limit to VGA 50 line
    mouse.Show();
    if(!done) { mouse.SetCursor(txt4); nexttdemo("     Default Cursor      "); }
  }
}

int textscreen(void)			// draws screen for demo
{
  register int i, j;
  char far *video = (char far *)MK_FP(0xB800, 0x0000);

  _setcursortype(_NOCURSOR);		// turn the hardware cursor off

  for(i=0; i<50; i++)			// draw the text screen background
  {
    for(j=0; j<80; j++)
    {
      *video++ = 0xDB+2*(j/10);		// write the character to video memory
      *video++ = 16*(j/10)+j/10+1;	// write the color
    }
  }

  gotoxy(27,1);
  textattr(4);
  cprintf(" Text Mode Demonstration ");

  textattr(LIGHTGRAY);
  for(i=5; i<13; i++)
  {
    gotoxy(5, i);
    cprintf("圹圹圹圹圹");
  }
  textattr(DARKGRAY);
  for(i=6; i<8; i++)
  {
    gotoxy(6, i);
    cprintf("圹");
    gotoxy(9, i);
    cprintf("圹");
    gotoxy(12, i);
    cprintf("圹");
  }
  textattr(WHITE);
  gotoxy(6,9);
  cprintf("Position");

  textattr(LIGHTBLUE);
  gotoxy(37,22); cprintf("赏屯屯突");
  gotoxy(37,23); cprintf("

⌨️ 快捷键说明

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