home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
PROG_C
/
WINCPP.ZIP
/
WINDOW.H
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-27
|
3KB
|
167 lines
#ifndef __WINDOW__
#define WINDOW
#include <stdio.h>
#include <string.h>
#define FALSE 0
#define TRUE 1
// Line drawing symbols
#define UL 218
#define UR 191
#define LL 192
#define LR 217
#define H 196
#define V 179
#define ULD 201
#define URD 187
#define LLD 200
#define LRD 188
#define HD 205
#define VD 186
// Border Types
#define SINGLE_BORDER 1
#define DOUBLE_BORDER 2
// Colors (Foreground & Background)
#define BLACK 0 // Background & Foreground
#define BLUE 1
#define GREEN 2
#define CYAN 3
#define RED 4
#define MAGENTA 5
#define BROWN 6
#define LGRAY 7
#define DGRAY 8 // Foreground only
#define LBLUE 9
#define LGREEN 10
#define LCYAN 11
#define LRED 12
#define LMAGENTA 13
#define YELLOW 14
#define WHITE 15
typedef unsigned char uchar;
enum ScrMode {
SCR_MODE_UNKNOWN = -1,
SCR_MODE_25x40 = 0, // all except monochrome
SCR_MODE_25x80 = 1, // all (default)
SCR_MODE_30x80 = 2, // VGA and MCGA
SCR_MODE_43x80 = 3, // EGA
SCR_MODE_50x80 = 4 // VGA and MCGA
};
enum VideoCardType {
TYPE_UNKNOWN = -1,
TYPE_MDA = 0,
TYPE_CGA = 1,
TYPE_HGC = 2,
TYPE_EGA = 3,
TYPE_MCGA = 4,
TYPE_VGA = 5
};
class Window;
// Cell class - defines a position as an attribute & caharcter
class Cell {
public:
Cell();
void Put(uchar attr, uchar c);
void Put(short word);
void Get(uchar &attr, uchar &c);
short Get();
private:
uchar Character;
uchar Attribute;
};
// Buffer that holds contents of window
class WindowBuffer {
public:
WindowBuffer();
WindowBuffer(const WindowBuffer &wb);
~WindowBuffer();
void SetSize(int rows, int cols);
void Fill(uchar attr, uchar c);
void Put(int row, int col, uchar attr, uchar c);
void Put(int row, int col, short word);
void Get(int row, int col, uchar &attr, uchar &c);
short Get(int row, int col);
protected:
Cell *Buffer;
int RowSize;
int ColSize;
};
// Window list class - linked list of windows
struct WindowListNode {
WindowListNode *Prev;
WindowListNode *Next;
Window *WindowPtr;
};
class WindowList {
public:
WindowList();
~WindowList();
void Add(Window *w);
void Delete(Window *w);
void MoveTop(Window *w);
void MoveBottom(Window *w);
short IsTop(Window *w);
Window *AtBottom();
Window *NextWindow();
private:
WindowListNode *Bottom;
WindowListNode *Top;
WindowListNode *Current;
};
// Window class
class Window {
public:
Window(int row, int col, int width, int height, uchar attr);
~Window();
void DrawBorder(int BorderType);
void ResetWindows();
int Getch();
void VPut(int row, int col, uchar attr, uchar c);
void VPut(int row, int col, short word);
void VGet(int row, int col, uchar &attr, uchar &c);
short VGet(int row, int col);
void Cls();
void HideCursor();
void ShowCursor();
protected:
static short far *Video;
static VideoCardType vc;
static int Initialized;
static WindowList List;
static int CursorHidden;
int Row;
int Col;
int Width;
int Height;
int ScreenRows;
int ScreenCols;
uchar WindowAttr;
int CursorRow;
int CursorCol;
uchar WallpaperAttr;
uchar WallpaperSymbol;
WindowBuffer Buffer;
WindowBuffer SavedBuffer;
unsigned short CursorShape;
private:
VideoCardType IdentifyVideoCard();
void SetVideoMem();
void Display();
void SaveScreen();
void RestoreScreen();
};
// function prototypes
void Error(char *msg);
#endif