home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
PROG_C
/
WINCPP.ZIP
/
WINDOW.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-25
|
3KB
|
128 lines
#include "window.h"
int Window::Initialized = FALSE;
WindowList Window::List;
int Window::CursorHidden = FALSE;
Window::Window(int row, int col, int width, int height, uchar attr) :
Buffer(), SavedBuffer()
{
ScreenRows = 25;
ScreenCols = 80;
if (!Initialized) {
vc = IdentifyVideoCard();
SetVideoMem();
Cls();
Initialized = TRUE;
}
Row = row;
Col = col;
Width = width;
Height = height;
WindowAttr = attr;
CursorCol = CursorRow = 0;
WallpaperAttr = (BLACK<<4|LGRAY);
WallpaperSymbol = '\xb1';
List.Add(this);
SavedBuffer.SetSize(Height, Width);
SaveScreen();
Buffer.SetSize(Height, Width);
Buffer.Fill(attr, ' ');
DrawBorder(DOUBLE_BORDER);
Display();
}
Window::~Window()
{
RestoreScreen();
List.Delete(this);
}
void Window::DrawBorder(int BorderType)
{
register i;
if (BorderType == DOUBLE_BORDER) {
Buffer.Put(0, 0, WindowAttr, ULD);
Buffer.Put(0, Width-1, WindowAttr, URD);
Buffer.Put(Height-1, 0, WindowAttr, LLD);
Buffer.Put(Height-1, Width-1, WindowAttr, LRD);
for (i=1; i<(Width-1); i++) {
Buffer.Put(0, i, WindowAttr, HD);
Buffer.Put(Height-1, i, WindowAttr, HD);
}
for (i=1; i<(Height-1); i++) {
Buffer.Put(i, 0, WindowAttr, VD);
Buffer.Put(i, Width-1, WindowAttr, VD);
}
}
else {
Buffer.Put(0, 0, WindowAttr, UL);
Buffer.Put(0, Width, WindowAttr, UR);
Buffer.Put(Height-1, 0, WindowAttr, LL);
Buffer.Put(Height-1, Width-1, WindowAttr, LR);
for (i=1; i<(Width-1); i++) {
Buffer.Put(0, i, WindowAttr, H);
Buffer.Put(Height-1, i, WindowAttr, H);
}
for (i=1; i<(Height-1); i++) {
Buffer.Put(i, 0, WindowAttr, V);
Buffer.Put(i, Width-1, WindowAttr, V);
}
}
}
void Window::Display()
{
register r, c;
for (r=0; r<Height; r++)
for(c=0; c<Width; c++)
VPut(Row+r, Col+c, Buffer.Get(r,c));
}
void Window::Cls()
{
register r, c;
for (r=0; r<ScreenRows; r++)
for (c=0; c<ScreenCols; c++)
VPut(r, c, (BLACK<<4|WHITE), ' ');
}
void Window::SaveScreen()
{
register r,c;
for (r=Row; r<Row+Height; r++)
for (c=Col; c<Col+Width; c++)
SavedBuffer.Put(r-Row, c-Col, VGet(r,c));
}
void Window::RestoreScreen()
{
register r, c;
for (r=0; r<Height; r++)
for(c=0; c<Width; c++)
VPut(Row+r, Col+c, SavedBuffer.Get(r,c));
}
void Window::ResetWindows()
{
Window *w;
w = List.AtBottom();
while (w != NULL) {
w->Display();
w->List.NextWindow();
}
}