Quelle Frame11.pas
Sprache: Delphi
//-----------------------------------------------------------------
//ToDo
//
//1. .....
//
//-------------------------------------------------------------------
unit Frame11;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
interface
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
uses
//----------------------------------------------------------------------------
//locals
//----------------------------------------------------------------------------
OwnUtils,GenDefs,Utilities,OptionClass,MDIClass,
//----------------------------------------------------------------------------
//globals
//----------------------------------------------------------------------------
Forms,ComCtrls,ExtCtrls,Classes,Controls,Types,ImgList;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
type
TFrame1= class (TFrame)
Navigator:TTreeView;
Semantik:TTreeView;
Explorer:TTreeView;
PageControl1:TPageControl;
NavigatorTab:TTabSheet;
SemantikTab:TTabSheet;
ExplorerTab:TTabSheet;
Inspector:TListView;
SplitterInspector:TSplitter;
StatusBar1:TStatusBar;
PageControl2:TPageControl;
TabSheet1:TTabSheet;
constructor Create(Owner:TComponent);override;
destructor Destroy;override;
procedure Loader(Froot:JString;ImgL:TImageList);
procedure SetHints();
procedure PrintIt;
procedure FindText(TS:TTreeView;Tx:JString);
procedure FindPosition(var TS:TTreeView;Pos:TPoint);
procedure positbyText(Find:JString);
procedure positbyNode(SN:JString;Sender:TObject);
procedure positbyPoint(P:TPoint;Fnr:integer );
procedure positbyIndex(Nr:integer );
function CreateSem(CSem:PAnsiChar):PLongTexts;
function CreateNav(CNav:PAnsiChar):PLongTexts;
procedure TreeClick(Sender:TObject);
procedure ScanSources(var T:TTreeView);
procedure ShowErrorMessages();
procedure PrintInspector(var RE:TRichEdit);
private
public
RootFile:JString;
KeyFound:boolean ;
LastText:JString;
LastIndex:integer ;
LastNavSelected:TTreeNode;
LastSemSelected:TTreeNode;
FileCount:integer ;
Key:JString;
end ;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
implementation
uses
//----------------------------------------------------------------------------
//specific
//----------------------------------------------------------------------------
Windows,Messages,SysUtils,Variants,Graphics,Dialogs,StdCtrls,Grids,
Math,Printers,StrUtils;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
{$R *.dfm}
//------------------------------------------------------------------ }
//- - }
//- construct - }
//- - }
//------------------------------------------------------------------ }
constructor TFrame1.Create(Owner:TComponent);
begin
inherited Create(Owner);
LastText:='' ;
LastIndex:=0;
FileCount:=0;
Inspector.columns[1].MaxWidth:=Width-Inspector.columns[0].MaxWidth;
LastNavSelected:=nil ;
LastSemSelected:=nil ;
end ;
//------------------------------------------------------------------ }
//- - }
//- construct - }
//- - }
//------------------------------------------------------------------ }
destructor TFrame1.Destroy;
begin
inherited Free;
end ;
//------------------------------------------------------------------ }
//- - }
//- Loader - }
//- - }
//------------------------------------------------------------------ }
procedure TFrame1.Loader(Froot:JString;ImgL:TImageList);
begin
Im_Root:=62;
Im_Branch:=62;
Im_Level:=62;
Im_State:=62;
im_Error:=0;
Navigator.Images:=nil ;
Navigator.StateImages:=nil ;
Navigator.Font.Color:=opt.R.FontColor;
Navigator.Font.Style:=opt.R.FontStyle;
FileCount:=0;
Explorer.Items.Clear;
PageControl1.ActivePage:=opt.R.Explorer.Sheet;
if not Empty(MDI.CNav,opt.R.Navigator) then begin
MDI.NavL:=CreateNav(MDI.CNav);
Navigator.ReadOnly:=true;
end
else begin //lex only?
if Navigator<>nil then
Navigator.Items.Clear;
ScanSources(Explorer);
end ;
if not Empty(MDI.CSem,opt.R.Semantik) then begin
Semantik.Items.Clear;
MDI.Seml:=CreateSem(MDI.CSem);
SemantikTab.Enabled:=true;
Semantik.ReadOnly:=true;
end
else begin
if Semantik<>nil then
Semantik.Items.Clear;
end ;
RootFile:=Froot;
//set read only
Explorer.ReadOnly:=true;
if MDI.ReturnValue<>0 then
ShowErrorMessages();
SetHints();
BringToFront;
Realign;
end ;
//------------------------------------------------------------------ }
//- - }
//- SetHints - }
//- - }
//------------------------------------------------------------------ }
procedure TFrame1.ShowErrorMessages();
var
ti,mn:TTreeNode;
begin
if Navigator<>nil then begin
Navigator.ReadOnly:=false;
mn:=nil ;
ti:=Navigator.TopItem;
while ti<>nil do begin
if Pos('Meldungen' ,ti.Text)>0 then begin
Navigator.Selected:=ti;
mn:=ti;
end ;
ti:=ti.GetNext;
end ;
Navigator.Font.Color:=clred;
if mn<>nil then begin
//Navigator.TopItem.Collapse(true);
Navigator.Selected:=mn;
mn.Expand(true);
if (mn.HasChildren) then
mn.getFirstChild.Expand(true);
end ;
Navigator.ReadOnly:=true;
end ;
end ;
//----------------------------------------------------------------------------
//- display Inspector fot print -
//- -
//----------------------------------------------------------------------------
procedure TFrame1.PrintInspector(var RE:TRichEdit);
var
i,j:integer ;
rec:String ;
S:TStrings;
begin
RE.Lines.Clear;
with Inspector do begin
for i:=0 to Items.Count-1 do begin
rec:=Items[i].Caption;
rec:=rec+'=' ;
S:=Items[i].SubItems;
for j:=0 to S.Count-1 do
if j>0 then rec:=rec+', ' +S[j]
else Rec:=Rec+S[j];
RE.Lines.Add(rec);
end ;
end ;
end ;
//------------------------------------------------------------------ }
//- - }
//- SetHints - }
//- - }
//------------------------------------------------------------------ }
procedure TFrame1.SetHints();
begin
if Navigator<>nil then
if Navigator.TopItem<>nil then
Navigator.Hint:=HintBox('Navigation' +crlf+Navigator.TopItem.Text);
if Semantik<>nil then
if Semantik.TopItem<>nil then
Semantik.Hint:=HintBox('Semantik' +crlf+Semantik.TopItem.Text);
if Explorer<>nil then
if Explorer.TopItem<>nil then
Explorer.Hint:=HintBox('Explorer' +crlf+ExtractFileDir(RootFile));
end ;
//------------------------------------------------------------------ }
//- - }
//- Printer - }
//- - }
//------------------------------------------------------------------ }
procedure TFrame1.PrintIt();
begin
if InSight(opt.R.Navigator) then
errorn(141,'Bitte auf das zu druckende Element fokussieren.' )
else if InSight(opt.R.Semantik) then
errorn(141,'Bitte auf das zu druckende Element fokussieren.' )
else if InSight(opt.R.Explorer) then
errorn(141,'Bitte auf das zu druckende Element fokussieren.' )
end ;
//------------------------------------------------------------------ }
//- - }
//- create PL treee - }
//- - }
//------------------------------------------------------------------ }
function TFrame1.CreateSem(CSem:PAnsiChar):PLongTexts;
var
TSEM:PLongTexts;
begin
if not Empty(CSem,opt.R.Semantik) then
LoadFromStream(Semantik,CSem,Im_Root,Im_Level,Im_Branch)
else
Semantik.Items.Add(nil ,makexmlnode('leer' ,1,1,1));
TSEM:=TreeHide(Semantik);
if Semantik.TopItem<>nil then
if Semantik.TopItem.GetNext<>nil then
Semantik.TopItem.GetNext.Selected:=true
else
Semantik.TopItem.Selected:=true;
CreateSem:=TSEM;
end ;
//------------------------------------------------------------------ }
//- - }
//- create Nav tree - }
//- - }
//------------------------------------------------------------------ }
function TFrame1.CreateNav(CNav:PAnsiChar):PLongTexts;
var
TNAV:PLongTexts;
begin
Navigator.Hide;
Navigator.Items.Clear;
if not Empty(CNav,opt.R.Navigator) then begin
LoadFromStream(Navigator,CNav,Im_Root,Im_Level,Im_Branch);
ScanSources(Explorer);
end
else
Navigator.Items.Add(nil ,makexmlnode('leer' ,1,1,1));
TNAV:=TreeHide(Navigator);
if Navigator.TopItem<>nil then
Navigator.TopItem.Selected:=true;
Navigator.show;
CreateNav:=TNAV
end ;
//------------------------------------------------------------------ }
//- - }
//- scan sources - }
//- - }
//------------------------------------------------------------------ }
procedure TFrame1.ScanSources(var T:TTreeView);
var
temp:TTreeNode;
i:integer ;
SH:JString;
begin
T.Items.Clear;
for i:=0 to Length(MDI.Source)-1 do
if MDI.Source[i].Name<>'' then begin
SH:=ExtractFileName(MDI.Source[i].Name);
if T.TopItem=nil then begin
temp:=T.Items.AddFirst(T.TopItem,SH);
temp.ImageIndex:=Im_Root;
temp.SelectedIndex:=Im_Root;
temp.StateIndex:=Im_Root;
end
else begin
temp:=T.Items.AddChild(T.TopItem,SH);
temp.ImageIndex:=Im_Branch;
temp.SelectedIndex:=Im_Branch;
temp.StateIndex:=Im_Branch;
end
end ;
end ;
//------------------------------------------------------------------ }
//- - }
//- posit posit by text - }
//- - }
//------------------------------------------------------------------ }
procedure TFrame1.positbyText(Find:JString);
begin
if Navigator.Items.Count>0 then begin
Screen.Cursor:=crHourGlass;
if InSight(opt.R.Navigator) then
FindText(Navigator,Find);
if InSight(opt.R.Semantik) then
FindText(Semantik,Find);
if InSight(opt.R.Explorer) then
FindText(Navigator,Find);
Screen.Cursor:=crHourGlass;
end ;
end ;
//------------------------------------------------------------------ }
//- - }
//- posit posit by lnr, col - }
//- - }
//------------------------------------------------------------------ }
procedure TFrame1.positbyNode(SN:JString;Sender:TObject);
var
P:TPoint;
Fil:JString;
begin
if (SN<>'' )and (Navigator.Items.Count>0) then begin
Screen.Cursor:=crHourGlass;
Fil:=getpar(S_Fil,SN);
P.Y:=strtoint(getpar(S_Lin,SN));
P.X:=strtoint(getpar(S_Col,SN));
if (Sender<>Navigator)and InSight(opt.R.Navigator) then
FindPosition(Navigator,P);
if (Sender<>Semantik)and InSight(opt.R.Semantik) then
FindPosition(Semantik,P);
if (Sender<>Explorer)and InSight(opt.R.Explorer) then
FindPosition(Navigator,P);
Screen.Cursor:=crdefault;
end
end ;
//------------------------------------------------------------------ }
//- - }
//- posit posit by Point in file - }
//- - }
//------------------------------------------------------------------ }
procedure TFrame1.positbyPoint(P:TPoint;Fnr:integer );
begin
if (Navigator.Items.Count>0) then begin
Screen.Cursor:=crHourGlass;
if InSight(opt.R.Navigator) then
FindPosition(Navigator,P)
else if InSight(opt.R.Semantik) then
FindPosition(Semantik,P)
else if InSight(opt.R.Explorer) then
FindPosition(Navigator,P);
Screen.Cursor:=crdefault;
end ;
end ;
//------------------------------------------------------------------ }
//- - }
//- posit posit by Point in file - }
//- - }
//------------------------------------------------------------------ }
procedure TFrame1.positbyIndex(Nr:integer );
begin
if InSight(opt.R.Navigator) then begin
if (Navigator.Items.Count>Nr) then
Navigator.Selected:=Navigator.Items[Nr]
end
else if InSight(opt.R.Semantik) then begin
if (Semantik.Items.Count>Nr) then
Semantik.Selected:=Semantik.Items[Nr];
end
else
end ;
//------------------------------------------------------------------ }
//- - }
//- fin by lnr, col - }
//- - }
//------------------------------------------------------------------ }
procedure TFrame1.FindPosition(var TS:TTreeView;Pos:TPoint);
var
tt:LongText;
tm:integer ;
Tx,P,Q,F,Fil:JString;
li,co,dsm,i:integer ;
Tree:PLongTexts;
begin
if TS=Navigator then
Tree:=MDI.NavL
else
Tree:=MDI.Seml;
if Tree<>nil then begin
Fil:=lowercase(IntToStr(MDI.Fnr));
dsm:=80*80;
tm:=-1;
if Tree.Items<>nil then begin
i:=0;
tt:=Tree.Items[i];
Tree.Selected:=Tree.Items[0].Ptr;
while (i<Length(Tree.Items)) do begin
tt:=Tree.Items[i];
Tx:=tt.Text;
P:=getpar(S_Lin,Tx);
TryStrtoint(P,li);
Q:=getpar(S_Col,Tx);
TryStrtoint(Q,co);
F:=lowercase(getpar(S_Fil,Tx));
if (F=Fil)and (abs(Pos.Y-li)<dsm)and (Pos.Y<>0) then begin
dsm:=abs(Pos.Y-li);
tm:=i
end ;
i:=i+1;
end
end ;
if tm<>-1 then begin
TS.Selected:=Tree.Items[tm].Ptr;
if TS.Selected<>nil then
TS.Selected.MakeVisible;
TS.AutoExpand:=true;
LastIndex:=tm;
KeyFound:=true;
LastText:=Functor(Tree.Items[tm].Text)
end
end ;
end ;
//------------------------------------------------------------------ }
//- - }
//- find by text - }
//- - }
//------------------------------------------------------------------ }
procedure TFrame1.FindText(TS:TTreeView;Tx:JString);
var
tt:LongText;
i:integer ;
tm:integer ;
foundlast:boolean ;
Tree:PLongTexts;
begin
if TS=Navigator then
Tree:=MDI.NavL
else
Tree:=MDI.Seml;
KeyFound:=false;
tm:=-1;
if (Tree<>nil )and (Tx>'' )and (Length(Tree^.Items)>1) then begin
i:=1;
foundlast:=false;
if LastText=Tx then begin //Find Text beyond last Position
foundlast:=true;
i:=LastIndex+1
end ;
tt:=Tree^.Items[i];
while (i<Length(Tree^.Items))and (tm<0) do begin
if Pos(Tx,Functor(tt.Text))>0 then begin
tm:=i;
end ;
if i<Length(Tree^.Items) then begin
tt:=Tree^.Items[i];
i:=i+1;
end ;
end ;
if (tm>=0)and foundlast then begin
//Wrap around
i:=0;
while (i<Length(Tree^.Items)) do begin
if Pos(Tx,Functor(tt.Text))>0 then begin
tm:=i;
end ;
i:=i+1;
tt:=Tree^.Items[i];
end ;
end ;
if tm<>-1 then begin
TS.Selected:=Tree^.Items[tm].Ptr;
LastIndex:=tm;
KeyFound:=true;
LastText:=Functor(Tree^.Items[tm].Text)
end
end ;
end ;
//------------------------------------------------------------------ }
//- - }
//- click on PL - }
//- - }
//------------------------------------------------------------------ }
procedure TFrame1.TreeClick(Sender:TObject);
begin
if Sender=Navigator then
Key:=Longeur(MDI.NavL,Navigator.Selected)
else
Key:=Longeur(MDI.Seml,Semantik.Selected);
end ;
//------------------------------------------------------------------ }
//- - }
//- Ende dieser Quelle - }
//- - }
//------------------------------------------------------------------ }
end .
quality 89%
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet)
¤
*© Formatika GbR, Deutschland
2026-03-28