home *** CD-ROM | disk | FTP | other *** search
- Unit InterWin;
- { Interface window used as support for mickey mouse programs
- INTERWIN revision history
- v1.0 - Started November 21, 1989
- - First generation used by MICKEY v1.1
-
- }
-
- INTERFACE
- {$I MICKEY11.INC}
- Procedure NiErrorWindow(TextMsg:StringVar); { Non Interactive ERROR window }
- Function YnErrorWindow(TextMsg:StringVar) : Boolean;
- { Returns True for 'Yes' and False for 'no'}
-
-
- IMPLEMENTATION
- USES Crt,WritBox,Mouse;
-
-
- CONST
- ROWSTART = 6;
- ROWEND = 12;
- COLSTART = 6;
- COLEND = 50;
- SCRSEG = $B800;
- SCROFF = (ROWSTART-1)*160 + (COLSTART-1)*2;
- TEXTROWSTART = 8;
- TEXTCOLSTART = 7;
- TEXTCOLEND = 49;
- TITLEROWSTART= 7;
- TITLECOLSTART= 7;
- TITLECOLEND = 49;
- CHROWSTART = 9;
- CHROWEND = 11;
- LCHCOLSTART = 7;
- LCHCOLEND = 24;
- RCHCOLSTART = 32;
- RCHCOLEND = 49;
- BOXCOLOR = green;
- BOXLEN = 7;
-
- Type
- MchoiceLines = array [1..3] of StringVar; { Mouse choices displayed }
-
- Var
- Box : Array [1..BOXLEN] Of StringVar;
- ScreenSave : Array [1..BOXLEN] of
- array [1..(COLEND-COLSTART+1)] of Word;
- OldTextAttr : Word;
- OldMrow, OldMcol : Word;
-
-
- Procedure SaveScreen;
- Var
- I,O,L : Word;
- Begin
- GetTextMouseLocation(OldMrow,OldMcol);
- O := SCROFF; { Start Here }
- L := (COLEND-COLSTART+1)*2;
- For I := 1 to BOXLEN do
- begin
- Move(Ptr(SCRSEG,O)^,ScreenSave[I],L);
- Inc(O,160); { Add to next area 80*2 }
- end;
- OldTextAttr := TextAttr;
- TextAttr := BOXCOLOR;
- WriteBox(BOX,BOXLEN,ROWSTART,COLSTART);
- End;
-
-
- Procedure RestoreScreen;
- Var
- I,O,L : Word;
- Begin
- L := (COLEND-COLSTART+1)*2;
- O := SCROFF;
- For I := 1 to BOXLEN do
- begin
- Move(ScreenSave[I],Ptr(SCRSEG,O)^,L);
- Inc(O,160);
- end;
- TextAttr := OldTextAttr;
- SetTextMouseLocation(OldMrow,OldMcol);
- End;
-
-
- Function StartCol(StartY, StrLen : Word) : Word; { Centers string }
- Begin
- StartCol := ((COLEND-COLSTART+1) div 2) -
- (StrLen div 2) +
- (StartY - 1);
- End;
-
-
- Procedure MouseChoices(Lines : MchoiceLines);
- Begin
- Box[4] := Lines[1];
- Box[5] := Lines[2];
- Box[6] := Lines[3];
- End;
-
-
- Procedure WriteMsg(TextMsg : StringVar);
- Var
- OldColor : Word;
- Wstart : Word;
- Begin
- Wstart := StartCol(TEXTCOLSTART,Length(TextMsg));
- GotoXY(Wstart,TEXTROWSTART);
- OldColor := TextAttr;
- TextAttr := BOXCOLOR;
- WriteLn(TextMsg);
- TextAttr := OldColor;
- End;
-
-
-
- Procedure NiErrorWindow(TextMsg : StringVar);
- Const
- ErrorTitle : StringVar = ' ERROR ';
- SelectCh : MchoiceLines = (
- '│ ░░░░░░░░░░░░░░░░░░░░░░ │',
- '│ ░░░░░░░Continue░░░░░░░ │',
- '│ ░░░░░░░░░░░░░░░░░░░░░░ │');
- TitleColor = red;
- DefaultRow = 10;
- DefaultCol = 28;
-
- Var
- TWriteStart : Word;
- MWriteStart : Word;
- Prs : MouseButtons;
- Begin
- MouseChoices(SelectCh); { Register screen def with possible choices }
- SaveScreen;
- TWriteStart := StartCol(TITLECOLSTART,Length(ErrorTitle));
- GotoXY(TWriteStart,TITLEROWSTART);
- TextAttr := TitleColor;
- Write(ErrorTitle);
- WriteMsg(TextMsg);
- SetTextMouseLocation(DefaultRow,DefaultCol);
- GotoXY(DefaultCol,DefaultRow);
- Repeat
- Prs := GetMouseButtonStatus; { Get this }
- Until Prs in [LeftPressed,RightPressed];
- RestoreScreen;
- End;
-
-
- Function YnErrorWindow(TextMsg : StringVar) : Boolean;
- Const
- SelectCh : MchoiceLines = (
- '│░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░│',
- '│░░░░░░░Yes░░░░░░░░ ░░░░░░░░░No░░░░░░░│',
- '│░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░│');
- CrowStart = 9;
- CrowEnd = 12;
- YcolStart = 7;
- YcolEnd = 24;
- NcolStart = 32;
- NcolEnd = 49;
- DefRow = 10;
- DefCol = 15;
- Var
- Prs : MouseButtons;
- R, C : Word;
- L : Byte;
- Begin
- MouseChoices(SelectCh); { Register screen def with possible choices }
- SaveScreen;
- WriteMsg(TextMsg);
- SetTextMouseLocation(DefRow,DefCol);
- GotoXy(DefCol,DefRow);
- Repeat
- Repeat
- Prs := GetMouseButtonStatus;
- Until Prs in [LeftPressed,RightPressed];
- GetTextMouseLocation(R,C);
- If R in [CrowStart..CrowEnd]
- then begin
- case C of
- YcolStart..YcolEnd : L := 1;
- NcolStart..NcolEnd : L := 2;
- else L := 0;
- end;
- end
- else L := 0;
- Until (L <> 0);
- RestoreScreen;
- YnErrorWindow := (L = 1);
- End;
-
-
-
-
- Begin { INTERWIN initialization }
- Box[1] := '┌───────────────────────────────────────────┐';
- Box[2] := '├───────────────────────────────────────────┤';
- Box[3] := '│ │';
- Box[4] := '│ │';
- Box[5] := '│ │';
- Box[6] := '│ │';
- Box[7] := '└───────────────────────────────────────────┘';
- End. { INTERWIN initialization }