home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / CTECHAPP.ZIP / WINDOWS.ZIP / SCREEN.HPP < prev    next >
C/C++ Source or Header  |  1990-03-01  |  3KB  |  101 lines

  1. //  Header:     Screen  (MS-DOS Text Video Display Class)
  2. //  Version:    1.10
  3. //
  4. //  Language:   C++ 2.0
  5. //  Environ:    MS-DOS w/monochrome or color text display
  6. //
  7. //  Purpose:    Provides a class for manipulating a text display.
  8. //
  9. //  WARNING!    To drastically improve the speed of this class, NO RANGE
  10. //              CHECKING is done! Invalid line/column values may cause
  11. //              portions of non-video memory to be corrupted!
  12. //
  13. //  Written by: Scott Robert Ladd
  14.  
  15. #if !defined(__SCREEN_HPP)
  16. #define __SCREEN_HPP 1
  17.  
  18. #include "Str.hpp"
  19.  
  20. extern "C"
  21.     {
  22.     #include "peekpoke.h"
  23.     #include "stddef.h"
  24.     }
  25.  
  26. enum BoxType {BT_NONE, BT_SINGLE, BT_DOUBLE, BT_SOLID};
  27.  
  28. class Screen
  29.     {
  30.     protected:
  31.         static unsigned int  Width;        // width of the screen in characters
  32.         static unsigned int  Length;       // length of the screen in characters
  33.  
  34.         static unsigned int  BaseAdr;      // base address of character memory
  35.  
  36.         static unsigned int  CursorShape;  // stored shape of the cursor
  37.         static int           CursorHidden; // non-zero if cursor has been hidden
  38.  
  39.         static unsigned int  HowMany;      // How many screens instantiated?
  40.  
  41.     public:
  42.         // constructor
  43.         Screen();
  44.  
  45.         // destructor
  46.         ~Screen();
  47.  
  48.         // retrieve screen size method
  49.         static void Dimensions(unsigned int & wid, unsigned int & len);
  50.  
  51.         // cursor methods
  52.         static void CursorHide();
  53.         static void CursorUnhide();
  54.  
  55.         static void CursorSetPos(unsigned int line, unsigned int col);
  56.         static void CursorGetPos(unsigned int & line, unsigned int & col);
  57.  
  58.         // data display methods
  59.         static void PutChar(unsigned int line, unsigned int col,
  60.                             unsigned char attr, char ch);
  61.  
  62.         static void PutStr(unsigned int line, unsigned int col,
  63.                            unsigned char attr, String & str);
  64.  
  65.         // data retrieval methods
  66.         static void GetChar(unsigned int line, unsigned int col,
  67.                             unsigned char & attr, char & ch);
  68.  
  69.         // box display method
  70.         static void DrawBox(unsigned int topLine, unsigned int leftCol,
  71.                             unsigned int btmLine, unsigned int rightCol,
  72.                             unsigned char attr, BoxType typeBox);
  73.  
  74.         // screen clearing methods
  75.         static void Clear();
  76.         static void ClearLine(unsigned int line, unsigned int col = 0);
  77.     };
  78.  
  79. // character display method
  80. inline void Screen::PutChar(unsigned int line, unsigned int col,
  81.                             unsigned char attr, char ch)
  82.     {
  83.     unsigned int v = ((unsigned int)attr << 8) | (unsigned char)ch;
  84.  
  85.     Poke(BaseAdr, (line * Width * 2) + (2 * col), v);
  86.     }
  87.  
  88. // data retrieval methods
  89. inline void Screen::GetChar(unsigned int line, unsigned int col,
  90.                             unsigned char & attr, char & ch)
  91.     {
  92.     unsigned int v = Peek(BaseAdr, (line * Width * 2) + (2 * col));
  93.  
  94.     attr = v >> 8;
  95.     ch   = v & 0xFF;
  96.     }
  97.  
  98. extern Screen Display;
  99.  
  100. #endif
  101.