home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_11 / 1011052b < prev    next >
Text File  |  1992-09-08  |  695b  |  50 lines

  1.  
  2. ******************************************************
  3.  
  4. // REGION.CPP (Listing 8)
  5. // Screen region package -- Williams
  6. #include "region.h"
  7. region::region(int x0,int y0, int x1, int y1,int save)
  8.    {
  9.    left=x0;
  10.    top=y0;
  11.    right=x1;
  12.    bot=y1;
  13.    buf=NULL;
  14.    if (save)
  15.    reinit();
  16.    }
  17.  
  18. void region::reinit(void)
  19.    {
  20.    if (buf) delete buf;
  21.    buf=new char[2*(1+right-left)*(1+bot-top)];
  22.    gettext(left,top,right,bot,buf);
  23.    }
  24.  
  25. void region::restore(void)
  26.    {
  27.    if (buf)
  28.      {
  29.      puttext(left,top,right,bot,buf);
  30.      destroy();
  31.      }
  32.    }
  33.  
  34.  
  35. region::~region()
  36.    {
  37.    restore();
  38.    }
  39.  
  40. void region::destroy(void)
  41.    {
  42.    if (buf)
  43.      {
  44.      delete buf;
  45.      buf=NULL;
  46.      }
  47.    }
  48.  
  49.  
  50.