Source code for /engineering/SERIAL-TEST/CONSOLE.HOriginal file CONSOLE.H
   1 // --------------------------------------------------------------------------
   2 // --
   3 // -- CONSOLE -- Main cosole handler.
   4 // --
   5 // --
   6 // --------------------------------------------------------------------------
   7 
   8 // --------------------------------------------------------------------------
   9 // -- Includes
  10 // --------------------------------------------------------------------------
  11 
  12 // --------------------------------------------------------------------------
  13 // -- Definitions
  14 // --------------------------------------------------------------------------
  15 
  16 // -- Basic types
  17 typedef int			  ColorT;   // stupid weak typing...
  18 typedef unsigned char ColorTB;  // these must be different types
  19 
  20 // -- Absolutes
  21 #define CON_MAX_X_SIZE	80
  22 #define CON_MAX_Y_SIZE  80
  23 
  24 #define CON_START_X		1
  25 #define CON_END_X		80
  26 #define CON_START_Y		1
  27 
  28 // --------------------------------------------------------------------------
  29 // -- Classes
  30 // --------------------------------------------------------------------------
  31 
  32 // ---------------- Console windows -----------------------------------------
  33 
  34 // -- The basic window
  35 class ConWindow  {
  36 
  37    int  startY;
  38    int  endY;
  39 
  40    void use(void)   { window(CON_START_X, startY, CON_END_X, endY); };
  41    void clear(void) { use(); clrscr(); };
  42 
  43  public:
  44 
  45    ConWindow(int Y, int sizeY);
  46 
  47    void putit(int X, int Y, char character   );
  48    void putit(int X, int Y, char *text       );
  49    void putit(int X, int Y, char *text, Boolean lineBased	 );
  50 
  51    void up(void);
  52    void down(void);
  53 
  54    virtual void reset(void);
  55 
  56 };
  57 
  58 
  59 // -- Color control
  60 class ConColorControl {
  61 
  62    ColorT   defaultTextColor;
  63    ColorTB  defaultBkgColor;
  64 
  65  protected:
  66    void assertText(void) { textcolor(defaultTextColor);     };
  67    void assertBack(void) { textbackground(defaultBkgColor); };
  68 
  69    void assertText(ColorT  textColor) {textcolor(textColor);      };
  70    void assertBack(ColorTB textColor) {textbackground(textColor); };
  71 
  72  public:
  73 
  74    ConColorControl( ColorT textColor, ColorTB bkgColor );
  75 
  76    void setTextColor( ColorT textColor)  { defaultTextColor = textColor; };
  77    void setBackgroundColor( ColorTB backgroundColor)
  78 							 { defaultBkgColor = backgroundColor; };
  79 
  80    void colAssert(void);
  81 };
  82 
  83 
  84 // -- Line based scrolling window.
  85 class ConLBSWindow : ConWindow, public ConColorControl {
  86 
  87    int      cursorY;  // must be saved at end of every public method
  88 
  89  public:
  90 
  91    ConLBSWindow( int yStart, int ySize );
  92    
  93    void put(char *text);
  94    void put(char *text, ColorT  textColor);
  95    void put(char *text, ColorTB backgroundColor);
  96    void put(char *text, ColorT  textColor,  ColorTB backgroundColor);
  97 
  98    void reset(void);
  99 
 100    void scrollUp(char *text);
 101    void scrollUp(char *text, ColorT  textColor,  ColorTB backgroundColor);
 102 
 103 };
 104 
 105 
 106 // -- Character based chaser window
 107 class ConCBCWindow : ConWindow, public ConColorControl  {
 108    
 109    int   sizeY;
 110 
 111    int   cursorX;  // must be saved at end of every public method
 112    int   cursorY;  // must be saved at end of every public method
 113 
 114    void  puntCursor( int &X, int &Y);
 115 
 116  public:
 117 
 118    ConCBCWindow( int yStart, int ySize );
 119 
 120    void reset(void);
 121    void put(char theCharacter);
 122    void put(char theCharacter, ColorT  textColor,  ColorTB backgroundColor);
 123 
 124 };
 125 
 126 
 127 // -- Freestyle window
 128 class ConFreeWindow : ConWindow, public ConColorControl  {
 129 
 130    int startX;
 131 
 132  public:
 133 
 134    ConFreeWindow( int yStart, int xStart, int ySize );
 135 
 136    void reset(void);
 137 
 138    void put( int  atX, int  atY, char   character );
 139    void put( int  atX, int  atY, char  *text );
 140    void put( int  atX, int  atY, char   character,
 141 			 ColorT  textColor, ColorTB backgroundColor	);
 142    void put( int  atX, int  atY, char  *text,
 143 			 ColorT  textColor, ColorTB backgroundColor	 );
 144 
 145 
 146 };
 147 
 148 
 149 // -- Separator line
 150 class ConSepLine : ConColorControl {
 151 
 152    int	Y;
 153 
 154  public:
 155 
 156    ConSepLine( int  atY, ColorT  textColor,  ColorTB backgroundColor );
 157 
 158    void reset(void);
 159 };
 160 
 161 
 162 // -------- Console Objects -----------------------------------------------
 163 
 164 class Console {
 165 
 166  public:
 167 
 168    Console(void);
 169   ~Console();
 170 
 171 };