home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / CTECHAPP.ZIP / WINDOWS.ZIP / WINDOW.CPP < prev   
C/C++ Source or Header  |  1990-03-26  |  3KB  |  143 lines

  1. //  Header:     Window  (Window Class)
  2. //  Version:    2.11
  3. //
  4. //  Language:   C++ 2.0
  5. //  Environ:    IBM-PC MS-DOS
  6. //
  7. //  Purpose:    Provides the definition of the stacked Windows module
  8. //
  9. //  Written by: Scott Robert Ladd
  10.  
  11. #if !defined(__WINDOW_HPP)
  12. #define __WINDOW_HPP 1
  13.  
  14. #include "Screen.hpp"
  15. #include "Str.hpp"
  16. #include "WorkList.hpp"
  17.  
  18. extern "C"
  19.     {
  20.     #include "stddef.h"
  21.     }
  22.  
  23. class Window
  24.     {
  25.     protected:
  26.         static WorkList  WdwList;
  27.         static Window ** ScrnOwner;
  28.         static int       Initialized;
  29.         static Window *  TopWindow;
  30.  
  31.         static unsigned int MaxLength;
  32.         static unsigned int MaxWidth;
  33.  
  34.         unsigned int HomeLine;
  35.         unsigned int HomeCol;
  36.         unsigned int Length;
  37.         unsigned int Width;
  38.         unsigned int CrsLine;
  39.         unsigned int CrsCol;
  40.  
  41.         unsigned char InsideColor;
  42.         unsigned char BorderColor;
  43.  
  44.         BoxType Border;
  45.  
  46.         // header text
  47.         String Header;
  48.  
  49.         // flags
  50.         int Wrapped;
  51.         int Concealed;
  52.  
  53.         // buffer for this window
  54.         struct WindowWord
  55.             {
  56.             unsigned char Attribute;
  57.             char Symbol;
  58.             };
  59.  
  60.         WindowWord * BufferSW;
  61.  
  62.         // private methods
  63.         static void FirstTime();
  64.  
  65.         void Display(int line, int col,
  66.                      unsigned char attr, char ch);
  67.  
  68.         static void Restack();
  69.  
  70.         void PlotOwnership();
  71.  
  72.         static void (* ErrorHandler)();
  73.  
  74.     public:
  75.         // constructor
  76.         Window(unsigned int  line, unsigned int  col,
  77.                unsigned int  len,  unsigned int  wid,
  78.                unsigned char iattr, unsigned char battr,
  79.                BoxType bord,
  80.                String & heading, int wrapMode = 0);
  81.  
  82.         // copy constructor
  83.         Window(const Window & w);
  84.  
  85.         // assignment operator
  86.         void operator = (const Window & w);
  87.  
  88.         // destructor
  89.         ~Window();
  90.  
  91.         // assign an exception handler
  92.         static void SetErrorHandler(void (* userHandler)());
  93.  
  94.         // paint a window
  95.         void Paint();
  96.  
  97.         // paint a line
  98.         void PaintLine(unsigned int line);
  99.  
  100.         // change position
  101.         void Move(unsigned int line, unsigned int col);
  102.  
  103.         // make this the top window
  104.         void Hoist();
  105.  
  106.         // conceal this window
  107.         void Conceal();
  108.  
  109.         // reveal this window
  110.         void Reveal();
  111.  
  112.         // turn wrap on
  113.         void WrapOn();
  114.  
  115.         // turn wrap off
  116.         void WrapOff();
  117.  
  118.         // change headings
  119.         void SetHead(String & heading);
  120.  
  121.         // set the cursor position
  122.         void SetCursor(unsigned int line, unsigned int col);
  123.  
  124.         // get the cursor position
  125.         void GetCursor(unsigned int & line, unsigned int & col);
  126.  
  127.         // store a character
  128.         void PutChar(unsigned int  line, unsigned int col,
  129.                      unsigned char attr, char c);
  130.  
  131.         // store a string
  132.         void PutStr(unsigned int line, unsigned int col,
  133.                     unsigned char attr, String & s);
  134.  
  135.         // clear entire window
  136.         void ClearAll();
  137.  
  138.         // clear one line of window
  139.         void ClearLine(unsigned int line, unsigned int col = 0);
  140.     };
  141.  
  142. #endif
  143.