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

  1. //  Module:     Wdw_ctdt  (Window Class)
  2. //  Version:    2.11
  3. //
  4. //  Language:   C++ 2.0
  5. //  Environ:    IBM-PC MS-DOS
  6. //
  7. //  Purpose:    Constructor / destructor
  8. //
  9. //  Written by: Scott Robert Ladd
  10.  
  11. #include "Str.hpp"
  12. #include "Window.hpp"
  13.  
  14. extern "C"
  15.     {
  16.     #include "string.h"
  17.     #include "stddef.h"
  18.     }
  19.  
  20. // constructor
  21. Window::Window(unsigned int line, unsigned int col,
  22.                unsigned int len,  unsigned int wid,
  23.                unsigned char iattr, unsigned char battr,
  24.                BoxType bord, String & heading, int wrapMode)
  25.     : Header(heading)
  26.     {
  27.     if (!Initialized)
  28.         FirstTime();
  29.  
  30.     // make sure window is created on the scree
  31.     if ((line > MaxLength) || (col > MaxWidth))
  32.         {
  33.         line = 0;
  34.         col  = 0;
  35.         }
  36.  
  37.     // set instance variables
  38.     HomeLine = line;
  39.     HomeCol  = col;
  40.     Length   = len;
  41.     Width    = wid;
  42.     CrsLine  = 0;
  43.     CrsCol   = 0;
  44.  
  45.     InsideColor = iattr;
  46.     BorderColor = battr;
  47.  
  48.     Border = bord;
  49.  
  50.     Wrapped   = wrapMode;
  51.     Concealed = 0;
  52.  
  53.     // no border, no heading
  54.     if (Border == BT_NONE)
  55.         Header = "";
  56.  
  57.     // add the window to the list
  58.     WdwList.Store(this);
  59.  
  60.     // allocate buffer to store window contents
  61.     BufferSW = new WindowWord [Length * Width];
  62.  
  63.     if (BufferSW == NULL)
  64.         ErrorHandler();
  65.  
  66.     // make the new window the top window
  67.     TopWindow = this;
  68.  
  69.     PlotOwnership();
  70.  
  71.     // clear the window
  72.     ClearAll();
  73.  
  74.     // and display it
  75.     Paint();
  76.     }
  77.  
  78. // destructor
  79. Window::~Window()
  80.     {
  81.     // remove window from list
  82.     WdwList.Delete(this);
  83.  
  84.     // get a new top window
  85.     WdwList.GoToHead();
  86.  
  87.     TopWindow = (Window *)WdwList.Examine();
  88.  
  89.     // free buffer space
  90.     delete BufferSW;
  91.  
  92.     // restack all windows
  93.     Restack();
  94.     return;
  95.     }
  96.