home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / TPPROC19.ZIP / WINDOW.INC < prev   
Encoding:
Text File  |  1985-02-05  |  3.2 KB  |  123 lines

  1. const
  2.      maxwin = 5;
  3.  
  4. type
  5.     imagetype = array[1..4096] of char;
  6.     windimtype = record
  7.                  x1,y1,x2,y2: integer
  8.                  end;
  9.  
  10. var
  11.    win          :            {global variable package}
  12.         record
  13.               dim: windimtype; {current window dimensions}
  14.               depth: integer;
  15.               stack: array[1..maxwin] of
  16.                      record
  17.                            image : imagetype;   {saved screen image}
  18.                            dim   : windimtype;  {saved window dimensions}
  19.                            x,y   : integer      {saved cursor position}
  20.                      end
  21.         end;
  22.     crtmode     :     byte       absolute $0040:$0049;
  23.     crtwidth    :     byte       absolute $0040:$004A;
  24.     monobuffer  :     imagetype  absolute $B000:$0000;
  25.     colorbuffer :     imagetype  absolute $B800:$0000;
  26.  
  27. procedure initwin;
  28.          {records initial window dimension}
  29. begin
  30.      with win.dim do
  31.           begin x1:=1; y1:=1; x2:=crtwidth; y2:=25 end;
  32.           win.depth:=0
  33. end;
  34.  
  35. procedure boxwin(x1,y1,x2,y2:integer);
  36.  
  37. {  Draws a box, fills it with blanks, and makes it the current window.   }
  38. {  Dimensions given are for the box;  actual window is one unit smaller  }
  39. {  in each direction.  This routine can be used seperately from the      }
  40. {  rest of the removable window package.                                 }
  41.  
  42. var
  43.    x,y : integer;
  44.  
  45. begin
  46.      window(1,1,80,25);
  47.  
  48.      {top}
  49.      gotoxy(x1,y1);
  50.      write(chr(213));
  51.      for x:=x1+1 to x2-1 do write(chr(205));
  52.      write(chr(184));
  53.  
  54.     {sides}
  55.     for y:=y1+1 to y2-1 do
  56.         begin
  57.              gotoxy(x1,y);
  58.              write(chr(179),' ':x2-x1-1, chr(179))
  59.         end;
  60.  
  61.     {bottom}
  62.     gotoxy(x1,y2);
  63.     write(chr(212));
  64.     for x:=x1+1 to x2-1 do write(chr(205));
  65.     write(chr(190));
  66.  
  67.     {make it the current window}
  68.     window(x1+1,y1+1,x2-1,y2-2);
  69.     gotoxy(1,1)
  70.  
  71. end;
  72.  
  73. procedure mkwin(x1,y1,x2,y2:integer);
  74. {create a removable window}
  75. begin
  76. {increment stack pointer}
  77.     with win do depth:=depth+1;
  78.     if win.depth > maxwin then
  79.     begin
  80.          writeln(^G'windows nested too deep');
  81.          halt
  82.     end;
  83.  
  84.   {save contents of the screen}
  85.   if crtmode = 7 then
  86.     win.stack[win.depth].image := monobuffer
  87.   else
  88.     win.stack[win.depth].image := colorbuffer;
  89.  
  90.   win.stack[win.depth].dim  :=  win.dim;
  91.   win.stack[win.depth].x    :=  wherex;
  92.   win.stack[win.depth].y    :=  wherey;
  93.  
  94.   {create the window}
  95.   boxwin(x1,y1,x2,y2);
  96.   win.dim.x1          := x1+1;
  97.   win.dim.y1          := y1+1;    {allow for margins}
  98.   win.dim.x2          := x2-1;
  99.   win.dim.y2          := y2-1;
  100.  
  101. end;
  102.  
  103. procedure rmwin;
  104. {  Remove the most recently created removable window.  Restore the screen    }
  105. {  contents, window dimensions, and position of the cursor.                  }
  106.  
  107. begin
  108.      if crtmode = 7 then
  109.         monobuffer  := win.stack[win.depth].image
  110.      else
  111.         colorbuffer := win.stack[win.depth].image;
  112.  
  113.    with win do
  114.         begin
  115.              dim := stack[depth].dim;
  116.              window(dim.x1,dim.y1,dim.x2,dim.y2);
  117.              gotoxy(stack[depth].x,stack[depth].y);
  118.              depth := depth - 1
  119.         end
  120. end;
  121.  
  122.  
  123.