home *** CD-ROM | disk | FTP | other *** search
-
-
-
- Function SaveWindow(XLow: XTCoord; YLow: YTCoord;
- XHigh: XTCoord; YHigh:YTCoord): WindowPtr;
- { Allocate a WindowRec of the precise size needed to save the window, then
- fill it with the text that is in the window XLow..XHigh, YLow..YHigh.
- Return a pointer to this WindowRec. }
-
-
- Var
- SW: WindowPtr;
- I: Integer;
- XS: XTCoord;
- YS: YTCoord;
-
- Begin
- XS:=XHigh-XLow+1;
- YS:=YHigh-YLow+1;
- GetMem(SW,2*XS*YS + 4);
- { Allocate 2 bytes for each screen position, + 4 for size and position }
- With SW^ Do
- Begin
- XSize:=XS;
- YSize:=YS;
- XPosn:=XLow;
- YPosn:=YLow;
- For I:=0 To YSize-1 Do
- MoveFromScreen(Mem[ScrSeg:((YPosn+I-1)*80+XPosn-1) Shl 1],
- Contents[I*XSize],XSize Shl 1);
- { For each line of the window,
- Move XSize*2 bytes (1 for char, 1 for attribute) into the Contents
- array. Leave no holes in the array. }
- End;
- SaveWindow:=SW;
- End;
-
-
- Procedure RestoreWindow(WP: WindowPtr; XPos: XTCoord0; YPos: YTCoord0);
- { Given a pointer to a WindowRec, restore the contents of the window. If
- XPos or YPos is 0, use the XPosn or YPosn that the window was originally
- saved with. If either is nonzero, use it. Thus a window can be restored
- exactly with RestoreWindow(wp,0,0); or its upper left corner can be
- placed at (2,3) with RestoreWindow(wp,2,3); }
-
-
- Var
- I: Integer;
-
- Begin
- With WP^ Do
- Begin
- If XPos=0 Then XPos:=XPosn;
- If YPos=0 Then YPos:=YPosn;
- For I:=0 To YSize-1 Do
- MoveToScreen(Contents[I*XSize],
- Mem[ScrSeg:2*((YPos+I-1)*80+XPos-1)],XSize*2);
- { For each line of the window,
- Move XSize*2 bytes (1 for char, 1 for attribute) from the Contents
- array onto the screen. }
- End;
- End;
-
-
- Procedure DisposeWindow(Var WP: WindowPtr);
- { Dispose of a WindowPtr. The built in procedure Dispose cannot be used,
- because it will deallocate SizeOf(WindowRec) bytes, even though less may
- have been allocated. }
-
-
- Begin
- With WP^ Do FreeMem(WP,2*XSize*YSize+4);
- WP:=Nil;
- End;
-
-
- Procedure DRestoreWindow(Var WP: WindowPtr; XPos: XTCoord0; YPos: YTCoord0);
- { Restore the contents of a window, then dispose of the saved image }
-
-
- Begin
- RestoreWindow(WP, XPos, YPos);
- DisposeWindow(WP);
- End;