home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 19
/
CD_ASCQ_19_010295.iso
/
dos
/
prg
/
pas
/
ktools
/
source
/
ocrtwin.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1994-10-31
|
4KB
|
183 lines
Unit OCrtWin;
{ Fenêtre simulant un écran DOS. }
{ KB mai-novembre 1994 }
{$IFDEF debug}
{$A+,B-,D+,E-,F-,I+,L+,N-,R+,S+,V-,W+,X+}
{$ELSE}
{$A+,B-,D-,E-,F-,I+,L-,N-,R-,S-,V-,W+,X+}
{$ENDIF}
INTERFACE
Uses UDrivers,UTextScr,OGenView,OTxtView;
Type
PCrtWin=^TCrtWin;
TCrtWin=object(TWindow)
XPos,YPos:Byte;
TAttr:Word;
ReadStr:String;
Constructor Init(xi,yi,l,h:Integer);
Procedure DrawInterior;virtual;
Procedure WinWriteChar(c:Char);
Procedure WinWrite(S:String);
Procedure WinWriteln(S:String);
Procedure EndRead;virtual;
Procedure HandleEvent(Var Event:TEvent);virtual;
Procedure Select; virtual;
Procedure Scroll;
Procedure GotoNextPos;
Procedure GotoPrevPos;
Procedure GotoNextLine;
Procedure WinGotoXY(x,y:Byte);
Procedure SetColor(c:Byte);
End;
IMPLEMENTATION
{ objet TCrtWin }
Constructor TCrtWin.Init(xi,yi,l,h:Integer);
Begin
TWindow.Init(xi,yi,l,h,'');
Etat:=Etat or stCurseur;
XPos:=1;
YPos:=1;
ReadStr:='';
TAttr:=GetColor(0);
End;
Procedure TCrtWin.DrawInterior;
Var P : TPoint;
Begin
MakeGlobal(Origin,P);
SetCursorPos(P.X+xpos,P.Y+ypos);
End;
Procedure TCrtWin.Select;
Var P : TPoint;
Begin
TWindow.Select;
MakeGlobal(Origin,P);
SetCursorPos(P.X+xpos,P.Y+ypos);
End;
Procedure TCrtWin.WinWriteChar(c:Char);
Begin
DrawInterior;
case c of
#13 : gotonextline;
#10 :;
#8 : begin
gotoprevpos;
PutCharAttrib(32+256*TAttr,1);
end;
else begin
PutCharAttrib(ord(c)+256*TAttr,1);
GotoNextPos;
end;
end;
End;
Procedure TCrtWin.WinWrite(S:String);
Var i:Byte;
Begin
if S=''
then exit;
for i:=1 to length(S) do
WinWriteChar(S[i]);
End;
Procedure TCrtWin.WinWriteln(S:String);
Begin
WinWrite(S);
gotonextline;
End;
Procedure TCrtWin.EndRead;
Begin
gotonextline;
End;
Procedure TCrtWin.HandleEvent(Var Event:TEvent);
Begin
TWindow.HandleEvent(Event);
if Etat and stSelected = 0
then exit;
if Event.What=evKeyDown
then case Event.KeyCode of
8: WinWriteChar(chr(Event.KeyCode));
13: begin
EndRead;
ReadStr:='';
end;
32..255: begin
ReadStr:=ReadStr+chr(Event.KeyCode);
WinWriteChar(chr(Event.KeyCode));
end;
else exit;
end;
Event.What:=evNothing;
Event.InfoPtr:=@self;
End;
Procedure TCrtWin.Scroll;
Var P : TPoint;
Begin
MakeGlobal(Origin,P);
ScrollWindowUp(1,TAttr,P.X+1,P.Y+1,
P.X+Size.X-2,P.Y+Size.Y-2);
End;
Procedure TCrtWin.GotoNextPos;
Begin
if XPos=Largeur
then GotoNextLine
else begin
inc(XPos);
DrawInterior;
end;
End;
Procedure TCrtWin.GotoNextLine;
Begin
XPos:=1;
if YPos=Hauteur
then Scroll
else inc(YPos);
DrawInterior;
End;
Procedure TCrtWin.GotoPrevPos;
Begin
if XPos=1
then begin
if YPos>1
then begin
dec(YPos);
XPos:=Largeur;
end;
end
else dec(XPos);
DrawInterior;
End;
Procedure TCrtWin.WinGotoXY(x,y:Byte);
Begin
if (x>0) and (x<=Largeur)
then xpos:=x;
if (y>0) and (y<=Hauteur)
then ypos:=y;
DrawInterior;
End;
Procedure TCrtWin.SetColor(c:Byte);
Begin
TAttr:=c;
End;
END.
{ Fin du fichier OCrtWin.Pas }