#ifndef INCLUDE_WINDOW #define INCLUDE_WINDOW // // WINDOW.H // ======== enum color { BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY, DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE, NO_COLOR=-1 }; enum frame_t { NO_FRAME, FRAME_222, FRAME_111 }; // // CLASS WINDOW // ============ class Window { private: static int initialized; // Window system initialized static unsigned scrwid; // Screen size static unsigned scrhig; static char *videoadr; unsigned x1,y1; // Upper-left corner unsigned x2,y2; // Bottom-right corner unsigned w,h; // Window size unsigned cx,cy; // Cursor position int x0,y0; // Plotting offset int cursortype; // Cursor type int showcursor; // Cursor shown or not char *title; // Titlebar text char attrib; // Attribute character (colors and flashing) frame_t frame; // Borders void Initialize(); void FramePlot(int x,int y,char c); public: Window(unsigned x,unsigned y,unsigned w,unsigned h,color fg=BLACK,color bg=BLACK,frame_t=NO_FRAME,char *title=0); inline void Bg(color c) {attrib &= 0x8f; attrib += (c&7)<<4;}; inline void Fg(color c) {attrib &= 0xf0; attrib += (c&15);}; inline void Color(color fg,color bg) {Bg(bg);Fg(fg);}; inline void Goto(unsigned x,unsigned y) {cx=x;cy=y;}; inline int X() {return x1;} inline int Y() {return y1;} inline int W() {return w;} inline int H() {return h;} void SetOrigin(int x,int y) {x0=x;y0=y;} void PlotAt(unsigned x,unsigned y,char c); void Plot(char c); void DrawFrames(); void SetTitle(char *t); void Fill(color fcol=NO_COLOR); void PrintAt(unsigned x,unsigned y,char *str); void Print(char *str); int GetKey(); void ShowCursor(); void HideCursor(); }; #endif