home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 19
/
CD_ASCQ_19_010295.iso
/
dos
/
prg
/
pas
/
ktools
/
source
/
ohelpwin.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1994-10-31
|
5KB
|
225 lines
Unit OHelpWin;
{ fenêtre d'aide }
{ K.B. juin-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,
OFHelp,
OGenView,OTxtView;
Const
cmHelpOk=100;
Type
PHelpWin=^THelpWin;
THelpWin=object(TWindow)
Fichier:PHelpFile;
Choix:Integer;
Index:Boolean;
Constructor Init(NomFichier:PathStr);
Destructor Done;virtual;
Procedure HandleEvent(Var Event:TEvent);virtual;
Procedure DrawInterior;virtual;
Procedure DrawIndex;
Procedure DrawItem;
Function GetErrorMsg:String; virtual;
End;
IMPLEMENTATION
Constructor THelpWin.Init(NomFichier:PathStr);
Begin
TWindow.Init(1,2,62,18,' AIDE ');
PalOffset:=pCyan;
Fichier:=New(PHelpFile,Init(NomFichier));
if not Fichier^.IsValid
then ErrorFlag:=2;
Choix:=1;
Index:=true;
End;
Destructor THelpWin.Done;
Begin
dispose(Fichier,Done);
TWindow.Done;
End;
Procedure THelpWin.HandleEvent(Var Event:TEvent);
Var P:TPoint;
n:Integer;
Begin
TWindow.HandleEvent(Event);
if Etat and stSelected=0
then exit;
case Event.What of
evCommand:
case Event.Command of
cmHelpOk:
begin
Index:=not Index;
end;
else exit;
end;
evKeyDown:
case Event.KeyCode of
Ret : SetCommand(cmHelpOk);
CsRg: if Index
then begin
if Choix<Fichier^.NombreItems
then inc(Choix);
end;
CsLf: if Index
then begin
if Choix>1
then dec(Choix);
end;
CsUp: if Index
then begin
if Choix>=4
then dec(Choix,3);
end;
CsDn: if Index
then begin
if Choix<=Fichier^.NombreItems-3
then inc(Choix,3);
end;
else exit;
end;
evMouseLDown:
begin
if not Index
then begin
repeat
GetMouseEvent(Event);
until Event.What=evMouseLUp;
SetCommand(cmHelpOk);
end
else begin
if MouseInView and not SurCadre(Event.Where)
then begin
repeat
GetMouseEvent(Event)
until Event.What=evMouseLUp;
MakeLocal(Event.Where,P);
n:=3*(P.Y-6)+P.X div 20 +1;
if n=Choix
then SetCommand(cmHelpOk)
else if (n>0) and (n<=Fichier^.NombreItems)
then Choix:=n
else exit;
end
else exit;
end;
end;
else exit;
end;
DrawInterior;
Event.What:=evNothing;
End;
Procedure THelpWin.DrawIndex;
Var i:Integer;
x,y:Byte;
S:String;
Begin
S:=' ';
Ajuste(S,largeur);
Ecrire(S,1,1,0);
Ecrire(S,1,3,0);
S:=Fichier^.FName+Fichier^.FExt;
while length(S)<largeur do S:=' '+S+' ';
Ajuste(S,largeur);
Ecrire(S,1,2,0);
x:=1;
y:=4;
For i:=1 to Fichier^.NombreItems do
begin
S:=Fichier^.Titre(i);
Ajuste(S,20);
if i=Choix
then Ecrire(S,x,y,1)
else Ecrire(S,x,y,0);
x:=x+20;
if x>largeur
then begin
x:=1;
inc(y);
if y>hauteur then exit;
end;
end;
if x<largeur
then begin
S:=' ';
Ajuste(S,largeur-x);
Ecrire(S,x,y,0);
inc(y);
end;
S:=' ';
Ajuste(S,largeur);
while y<=hauteur do
begin
Ecrire(S,1,y,0);
inc(y);
end;
End;
Procedure THelpWin.DrawItem;
Var y:Byte;
S:String;
fini:Boolean;
Begin
with Fichier^ do
begin
y:=1;
if FindItem(Titre(Choix))
then repeat
S:=GetLine;
fini:=S[1]='#';
if not fini
then begin
Ajuste(S,Largeur);
Ecrire(S,1,y,0);
inc(y);
if y>hauteur
then fini:=true;
end;
until fini;
end;
S:=' ';
Ajuste(S,largeur);
while y<=hauteur do
begin
Ecrire(S,1,y,0);
inc(y);
end;
End;
Procedure THelpWin.DrawInterior;
Begin
DrawBegin;
if Index
then DrawIndex
else DrawItem;
DrawEnd;
End;
Function THelpWin.GetErrorMsg:String;
Begin
case ErrorFlag of
2: GetErrorMsg:=Fichier^.GetErrorMsg;
else GetErrorMsg:=TWindow.GetErrorMsg;
end;
End;
END.
{ Fin du fichier OHelpWin.Pas }