home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 19
/
CD_ASCQ_19_010295.iso
/
dos
/
prg
/
pas
/
ktools
/
source
/
oedwin.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1994-11-12
|
4KB
|
169 lines
Unit OEdWin;
{ fenêtre éditeur }
{ K.B. 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 Dos,UDrivers,UTextScr,OGenView,OTxtView,OTEdit;
Const erEdObj = 50;
Type
PEdWin=^TEdWin;
TEdWin=object(TWindow)
EdObj : PEdObj;
Constructor Init(x1,y1,l,h:Integer);
Constructor Load(x1,y1,l,h:Integer; NomDeFichier:PathStr);
Destructor Done; virtual;
Procedure Select; virtual;
Procedure DrawInterior; virtual;
Procedure HandleEvent(var Event:TEvent); virtual;
Function GetErrorMsg:String; virtual;
End;
IMPLEMENTATION
{ objet TEdWin }
Constructor TEdWin.Init(x1,y1,l,h:Integer);
Begin
TWindow.Init(x1,y1,l,h,' sans nom ');
Ident:='EDWIN';
Etat:=Etat or stCurseur;
EdObj:=New(PEdObj,Init(h-2,l-2));
if not EdObj^.IsValid
then ErrorFlag:=erEdObj;
End;
Constructor TEdWin.Load(x1,y1,l,h:Integer;NomDeFichier:PathStr);
Begin
TWindow.Init(x1,y1,l,h,'');
Ident:='EDWIN';
Titre:=NomDeFichier;
Etat:=Etat or stCurseur;
EdObj:=New(PEdObj,Load(h-2,l-2,NomDeFichier));
if not EdObj^.IsValid
then ErrorFlag:=erEdObj;
End;
Destructor TEdWin.Done;
Begin
dispose(EdObj,Done);
TWindow.Done;
End;
Procedure TEdWin.Select;
Var P : TPoint;
Begin
TWindow.Select;
if EdObj<>nil
then begin
MakeGlobal(Origin,P);
SetCursorPos(P.X+EdObj^.NrScreenColumn,P.Y+EdObj^.NrScreenLine);
end;
End;
Function TEdWin.GetErrorMsg:String;
Var S : String;
Begin
case ErrorFlag of
erEdObj : S:=EdObj^.GetErrorMsg;
else S:=TWindow.GetErrorMsg;
end;
GetErrorMsg:=S;
End;
Procedure TEdWin.DrawInterior;
Var i,ALine : Integer;
S : String;
P : TPoint;
Begin
ALine:=EdObj^.FirstScreenLine;
For i:=1 to Hauteur do
begin
if ALine<=EdObj^.NombreItems
then begin
S:=EdObj^.Ligne(ALine);
S:=copy(S,EdObj^.FirstTextCol,EdObj^.NbCols);
inc(ALine);
end
else S:='';
Ajuste(S,EdObj^.NbCols);
Ecrire(S,1,i,0);
end;
{ mise à jour du curseur }
MakeGlobal(Origin,P);
SetCursorPos(P.X+EdObj^.NrScreenColumn,P.Y+EdObj^.NrScreenLine);
End;
Procedure TEdWin.HandleEvent(var Event:TEvent);
Var P : TPoint;
Begin
TWindow.HandleEvent(Event);
case Event.What of
evKeyDown :
begin
with EdObj^ do
case Event.KeyCode of
CsLf: CharLeft;
CsRg: CharRight;
Home: StartLine;
Fin: EndLine;
CsUp: CharUp;
CsDn: CharDown;
PgUp: PageUp;
PgDn: PageDown;
CPgUp: StartText;
CPgDn: EndText;
Inser: ChangeInsertMode;
Suppr: DelChar;
BSP: DelPrevChar;
Tab: CharTab;
Ret: NewLine;
CtrlY: DelLine;
else begin
if (Event.KeyCode<32) or (Event.KeyCode>255)
then exit
else InsertChar(Chr(Event.KeyCode));
end;
end;
end;
evMouseAuto :
begin
MakeGlobal(Origin,P);
if Event.LButton and SurCadre(Event.Where)
then begin
if Event.Where.Y>P.Y+hauteur div 2
then EdObj^.CharDown
else EdObj^.CharUp;
end
else exit;
end;
evMouseLUp :
begin
if not MouseInView or (Etat and stSelected=0)
then exit;
if not SurCadre(Event.Where)
then begin
MakeLocal(Origin,P);
P.X:=Event.Where.X-P.X;
P.Y:=Event.Where.Y-P.Y;
EdObj^.NewPos(P.X,P.Y);
end
else exit;
end;
else exit;
end;
DrawInterior;
End;
END.
{ Fin du fichier OEdWin.Pas }