home *** CD-ROM | disk | FTP | other *** search
- { MSWINDOW.INC
- MS 4.0
- Copyright (c) 1985, 87 by Borland International, Inc. }
-
- procedure EdDrawBox(Border : BorderChars;
- XPosn, YPosn, XSize, YSize : Byte;
- BoxAttr : BoxType);
- {-Draw a box frame on the screen}
- var
- L, R, T, B, I, Attr : Byte;
- HorizBar : VarString;
-
- begin {EdDrawBox}
-
- L := XPosn;
- R := Pred(XPosn+XSize);
- T := YPosn;
- B := Pred(YPosn+YSize);
- Attr := FrameAttr[BoxAttr];
-
- {Draw horizontal segments}
- HorizBar[0] := Chr(XSize);
- FillChar(HorizBar[1], Length(HorizBar), Border[Horiz]);
- HorizBar[1] := Border[TopLeft];
- HorizBar[Length(HorizBar)] := Border[TopRight];
- {Draw top bar}
- EdFastWrite(HorizBar, T, L, Attr);
- {Fix bottom bar}
- HorizBar[1] := Border[BotLeft];
- HorizBar[Length(HorizBar)] := Border[BotRight];
- EdFastWrite(HorizBar, B, L, Attr);
-
- {Vertical segments}
- for I := Succ(T) to Pred(B) do begin
- EdFastWrite(Border[Vert], I, L, Attr);
- EdFastWrite(Border[Vert], I, R, Attr);
- end;
- end; {EdDrawBox}
-
- procedure EdClearWindow(XPosn, YPosn, XSize, YSize, Attr : Byte);
- {-Clear screen region to a specified attribute}
- var
- S : VarString;
- I : Integer;
-
- begin {EdClearWindow}
- S[0] := Chr(XSize-2);
- FillChar(S[1], Length(S), Blank);
- for I := 1 to YSize-2 do
- EdFastWrite(S, YPosn+I, Succ(XPosn), Attr);
- end; {EdClearWindow}
-
- function EdSetupWindow(Border : BorderChars;
- XLow, YLow, XHigh, YHigh : Byte;
- BoxAttr : BoxType) : WindowPtr;
- {-Save current screen and set up a new window}
- var
- W : WindowPtr;
- Xs, Ys, I : Byte;
-
- begin {EdSetupWindow}
-
- Xs := Succ(XHigh-XLow);
- Ys := Succ(YHigh-YLow);
-
- {Allocate 2 bytes for each screen position}
- GetMem(W, (Xs*Ys) shl 1);
-
- {Save the existing contents}
- for I := 0 to Pred(Ys) do
- EdMoveFromScreen(Mem[ScreenAdr: (PhyScrCols*Pred(YLow+I)+Pred(XLow)) shl 1], W^[I*Xs], Xs);
-
- {Draw box around window}
- EdDrawBox(Border, XLow, YLow, Xs, Ys, BoxAttr);
-
- {Clear out the window}
- EdClearWindow(XLow, YLow, Xs, Ys, TextAttr[BoxAttr]);
-
- {Return the pointer}
- EdSetupWindow := W;
-
- end; {EdSetupWindow}
-
- procedure EdRestoreWindow(var W : WindowPtr;
- XPosn, YPosn, XSize, YSize : Byte);
- {-Given a pointer to a screen buffer, restore the contents of the window}
- var
- I : Integer;
-
- begin {EdRestoreWindow}
- {Restore the contents}
- for I := 0 to Pred(YSize) do
- EdMoveToScreen(W^[I*XSize],
- Mem[ScreenAdr: (PhyScrCols*Pred(YPosn+I)+Pred(XPosn)) shl 1], XSize);
- {Free the memory}
- FreeMem(W, (XSize*YSize) shl 1);
- EdSetPtrNil(W);
- end; {EdRestoreWindow}
-
- procedure EdSaveTextWindow(Border : BorderChars;
- Title : VarString;
- XLow, YLow, XHigh, YHigh : Byte;
- var W : WindowRec);
- {-Save existing screen and set up a new text window}
-
- begin {EdSaveTextWindow}
- with W do begin
- XSize := Succ(XHigh-XLow);
- YSize := Succ(YHigh-YLow);
- XPosn := XLow;
- YPosn := YLow;
- Overlap := EdSetupWindow(Border, XLow, YLow, XHigh, YHigh, NormalBox);
-
- {Set up Turbo window}
- EdWindow(Succ(XLow), Succ(YLow), Pred(XHigh), Pred(YHigh));
- GoToXY(1, 1);
-
- {Write a title}
- if Length(Title) <> 0 then
- EdFastWrite(Title, YPosn, XPosn+(XSize-Length(Title)) shr 1, ScreenAttr[MfColor]);
-
- {Turn off cursor}
- EdSetCursor(CursorOff);
- end;
- end; {EdSaveTextWindow}
-
- procedure EdRestoreTextWindow(W : WindowRec);
- {Given a pointer to a WindowRec, restore the contents of the window}
-
- begin {EdRestoreTextWindow}
- with W do
- {Restore the contents}
- EdRestoreWindow(Overlap, XPosn, YPosn, XSize, YSize);
- {Reset Turbo window to full screen}
- EdWindow(1, 1, PhyScrCols, PhyscrRows);
- {Restore cursor if menus are not on screen}
- if EdPtrIsNil(CurrMenu) then
- EdUpdateCursor;
- end; {EdRestoreTextWindow}
-