
******************************************************

// REGION.CPP (Listing 8)
// Screen region package -- Williams
#include "region.h"
region::region(int x0,int y0, int x1, int y1,int save)
   {
   left=x0;
   top=y0;
   right=x1;
   bot=y1;
   buf=NULL;
   if (save)
   reinit();
   }

void region::reinit(void)
   {
   if (buf) delete buf;
   buf=new char[2*(1+right-left)*(1+bot-top)];
   gettext(left,top,right,bot,buf);
   }

void region::restore(void)
   {
   if (buf)
     {
     puttext(left,top,right,bot,buf);
     destroy();
     }
   }


region::~region()
   {
   restore();
   }

void region::destroy(void)
   {
   if (buf)
     {
     delete buf;
     buf=NULL;
     }
   }


