home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_01 / 1001128b < prev    next >
Text File  |  1991-11-19  |  820b  |  43 lines

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