//------------------------------------------------------------------------------ // //1. Sch�tzung f�r Graphgr��e etc. �berpr�fen //2. Copy von dynamischen Arrays bei neuer Allokation //.... // //------------------------------------------------------------------------------ unit Frame22; //---------------------------------------------------------------------------- // //---------------------------------------------------------------------------- interface uses //---------------------------------------------------------------------------- //local //----------------------------------------------------------------------------
GenDefs,OwnUtils,OptionClass,Graphs,language,Utilities,Natural,Memtree,
MDIClass,Splash, //---------------------------------------------------------------------------- //global //----------------------------------------------------------------------------
Forms,ComCtrls,ExtCtrls,Classes,Controls,Types,StdCtrls,Menus,ImgList,
Graphics,Editor,Windows; //---------------------------------------------------------------------------- //local //---------------------------------------------------------------------------- type //---------------------------------------------------------------------------- // //----------------------------------------------------------------------------
TFrame2= class(TFrame)
DFA:TImage;
CFA:TImage;
PageControl1:TPageControl;
SourceTab:TTabSheet;
CfaTab:TTabSheet;
DfaTab:TTabSheet;
MeasureTab:TTabSheet;
FunktionTab:TTabSheet;
StatusBar1:TStatusBar;
TokenBox:TListBox;
ImageList1:TImageList;
FlowImages:TImageList;
ScrollBox1:TScrollBox;
ScrollBox2:TScrollBox;
Source:TEde;
Measures:TEde;
Funktion:TEde; constructor Create(Owner:TComponent);override; destructor Destroy;override; procedure Loader(Nr:integer;PF:TSplashForm); procedure findText(TF:JString;regular:boolean); function positbyPoint(P:TPoint):integer; function positInfo(P:TPoint;Sender:TObject):JString; procedure positbyNode(TF:JString;Sender:TObject); procedure Seterror(var MI:TMenuItem); procedure setBlocknumbers(); procedure SetHints(); procedure PrintIt(PS:TStream); procedure CreateMeasure(); procedure CreateFunktion(); procedure CreateSource(Fnr:integer;PF:TSplashForm); procedure Zoom(G:TGraph;var Im:TImage;C:PAnsiChar;WheelDelta:integer; var SB:TScrollBox); procedure TokenBoxClick(Sender:TObject); procedure TokenBoxKeyPress(Sender:TObject;var Key:Char); procedure CreateGraph(var GR:TGraph;Img:TImage;Plong:PLongTexts;gwidth,gheight:integer); function getSourcePoint():TPoint; procedure sourcenames(D:TDocument); function getPointfromNode(TF:JString):TPoint; public
Solution:TMemTree;
BrushStyle:TBrushStyle;
PenStyle:TPenStyle;
PenWide:integer;
Drawing:boolean;
Origin,MovePt:TPoint;
DrawingTool:TGraphShape;
CurrentFile:JString;
FunktionStream:PAnsiChar;
MeasuresStream:PAnsiChar;
AllDisabled:boolean;
Page1Last:integer;
LastKeyPressed:Word;
LastClick:ViewType;
vmax:integer;
TimeSet:TDateTime;
SourceDuration:integer;
CFADuration:integer;
DFADuration:integer;
ToBeinserted:JString;
LoadTime:TDateTime;
lastkey:integer;
TimeRatio:Jstring; end; //---------------------------------------------------------------------------- // //---------------------------------------------------------------------------- implementation uses
Messages,SysUtils,Variants,Dialogs,jpeg,ToolWin,Buttons,Math,
StrUtils,Printers,Chart,CheckLst,Clipbrd,DateUtils,Tabs; //---------------------------------------------------------------------------- // //----------------------------------------------------------------------------
{$R *.dfm} //---------------------------------------------------------------------------- // //---------------------------------------------------------------------------- constructor TFrame2.Create(Owner:TComponent); begin inherited Create(Owner);
vmax:=10000;
AllDisabled:=false;
Page1Last:=0;
TimeSet:=Now;
SourceDuration:=0;
CFADuration:=0;
DFADuration:=0;
LoadTime:=Now;
LastClick:=ViewSource; with Source dobegin
oldwinproc:=WindowProc;
WindowProc:=WindProc; end; end; //---------------------------------------------------------------------------- // //---------------------------------------------------------------------------- destructor TFrame2.Destroy; begin inherited Free; end; //------------------------------------------------------------------ //-- //set error conditions -- //-- //------------------------------------------------------------------ procedure TFrame2.Seterror(var MI:TMenuItem); begin //disable Blocknumbers
Opt.r.Blocknumbers:=false;
MI.Checked:=Opt.r.Blocknumbers; end; //------------------------------------------------------------------ //-- //------------------------------------------------------------------ procedure TFrame2.sourcenames(D:TDocument); var
mdiar: arrayof JString;
i:integer; begin
setlength(mdiar,length(mdi.Source)); for i:=0 to length(mdi.Source)-1 do
mdiar[i]:=D.Source[i].Name;
Source.LoadNames(mdiar); end; //------------------------------------------------------------------ //-- //load a new source -- //-- //------------------------------------------------------------------ procedure TFrame2.Loader(Nr:integer;PF:TSplashForm); var
Efs:JString; begin
Efs:=mdi.Source[Nr].Name; If FileExists(Efs) thenbegin
sourcenames(mdi);
CreateSource(Nr,PF);
Source.CodeCompleter.setCodeCompletionVerbs(mdi.KeyVerbs);
TimeSet:=Now; ifnot (errorcount>0) andnot Empty(MDI.GC.CStream,Opt.r.CFA)and(Opt.r.Semantik.Sheet<>nil) then with Opt.r.CFA.Sheet dobegin
TabVisible:=true;
CreateGraph(mdi.GC,CFA,mdi.SemL,width,height); with mdi.GC do if CStream<>nilthenbegin
width:=Opt.r.CFA.Sheet.width;
height:=Opt.r.CFA.Sheet.height;
VWidth:=0;
VHeight:=0;
ReDraw(); end; end elsebegin
Opt.r.CFA.Sheet.TabVisible:=false;
MDI.GC.CStream:=nil end;
CFADuration:=MilliSecondsBetween(Now,TimeSet);
TimeSet:=Now; ifnot (errorcount>0) andnot Empty(mdi.GD.CStream,Opt.r.DFA) then with Opt.r.DFA.Sheet dobegin
TabVisible:=true;
CreateGraph(mdi.GD,DFA,mdi.NavL,width,height); with mdi.GD do if CStream<>nilthenbegin
width:=Opt.r.CFA.Sheet.width;
height:=Opt.r.CFA.Sheet.height;
VWidth:=0;
VHeight:=0;
ReDraw(); end; end elsebegin
Opt.r.DFA.Sheet.TabVisible:=false;
MDI.GD.CStream:=nil end;
DFADuration:=MilliSecondsBetween(Now,TimeSet);
TimeSet:=Now; ifnot (errorcount>0) andnot Empty(MDI.Cmes,Opt.r.Measures) thenbegin
Opt.r.Measures.Sheet.TabVisible:=true;
CreateMeasure(); end elsebegin
Opt.r.Measures.Sheet.TabVisible:=false;
MDI.Cmes:=nil end; ifnot (errorcount>0) andnot Empty(MDI.CFun,Opt.r.Funktion) thenbegin
Opt.r.Funktion.Sheet.TabVisible:=true;
CreateFunktion(); end elsebegin
Opt.r.Funktion.Sheet.TabVisible:=false;
MDI.CFun:=nil end;
AllDisabled:=false;
LoadTime:=Now;
SetHints(); end end; //------------------------------------------------------------------ //-- //Printer -- //-- //------------------------------------------------------------------ procedure TFrame2.PrintIt(PS:TStream); begin if InSight(Opt.r.Source) then
Source.Print(CurrentFile) elseif InSight(Opt.r.CFA) then
CFA.Picture.Bitmap.SaveToStream(PS) elseif InSight(Opt.r.DFA) then
DFA.Picture.Bitmap.SaveToStream(PS) elseif InSight(Opt.r.Measures) then
Measures.Lines.SaveToStream(PS) end; //------------------------------------------------------------------ //-- //Posit Editor -- //-- //------------------------------------------------------------------ function TFrame2.getPointfromNode(TF:JString):TPoint; const
white:setof ansichar=[' ',chr(Key_Tab),chr(Key_return),chr(Key_Linefeed)]; var
CFile:JString;
Cfi:integer;
Li,co:JString;
P:TPoint; begin
Li:=getpar(S_Lin,TF);
co:=getpar(S_Col,TF);
P.x:=1;
P.y:=1;
TryStrtoInt(Li,P.y);
TryStrtoInt(co,P.x);
CFile:=getpar(S_Fil,TF);
TryStrtoInt(CFile,Cfi); if (CFile<>'')and(Cfi<>Source.LoadedFileNumber) thenbegin if (Cfi>length(MDI.Source))or(Cfi<0) then
errorn(4, 'Dateinummer korrupt, Datei='+getpar(S_Lab,TF)+', Nummer:'+IntToStr
(Cfi)) else
source.CreateHighlited(Cfi); end;
result:=P; end; //------------------------------------------------------------------ //-- //ForegroundbyText -- //-- //------------------------------------------------------------------ procedure TFrame2.findText(TF:JString;regular:boolean); var
KeyPos:integer; begin if TF=''then//do nothing elseif InSight(Opt.r.Source) thenbegin
Screen.Cursor:=crHourGlass; if InSight(Opt.r.Source) thenbegin
KeyPos:=Source.FindText(TF,0,length(Source.Lines.Text),[]); if KeyPos<>-1 thenbegin
Source.setCharPos(KeyPos,length(TF));
setl(Source.SearchString.S,TF); end; end elseif InSight(Opt.r.CFA) then
mdi.GC.GraphPositbyText(TF,CFA) elseif InSight(Opt.r.DFA) then
mdi.GC.GraphPositbyText(TF,DFA) elseif InSight(Opt.r.Funktion) thenbegin
KeyPos:=Funktion.FindText(TF,0,length(Funktion.Lines.Text),[]); if KeyPos<>-1 thenbegin
Funktion.setCharPos(KeyPos,length(TF));
setl(Source.SearchString.S,TF) end; end;
ViewList.Per[F2].Node:=Source.CaretPos.y;
Screen.Cursor:=crDefault; end elseif InSight(Opt.r.Funktion) thenbegin
Screen.Cursor:=crHourGlass;
KeyPos:=Funktion.FindText(TF,0,length(Funktion.Lines.Text),[]); if KeyPos<>-1 thenbegin
Funktion.setCharPos(KeyPos,length(TF));
setl(Source.SearchString.S,TF) end;
Screen.Cursor:=crDefault; end; end; //------------------------------------------------------------------ //-- //ForegroundbyNode -- //-- //------------------------------------------------------------------ procedure TFrame2.positbyNode(TF:JString;Sender:TObject); var P:TPOint;Wo:JString; begin if (Sender<>Source)and InSight(Opt.r.Source) thenbegin
Opt.r.Source.Sheet.PageControl.ActivePage:=Opt.r.Source.Sheet; //Source.positbyNode(TF);
P:=getPointfromNode(TF);
Wo:=getpar(S_Lab,TF);
Source.markWord(P.Y,P.x,length(Wo)); if ViewList<>nilthen
ViewList.Per[F2].Node:=Source.CaretPos.y; end; if InSight(Opt.r.CFA) thenbegin
LastClick:=ViewCFA;
mdi.GC.GraphPositbyText(Functor(TF),CFA); end; If InSight(Opt.r.DFA) thenbegin
LastClick:=ViewDFA;
mdi.GC.GraphPositbyText(Functor(TF),DFA); end; end; //------------------------------------------------------------------ //-- //ForegroundbyNode -- //-- //------------------------------------------------------------------ function TFrame2.positbyPoint(P:TPoint):integer; var
se,co:integer;
Key:JString;Q:TPoint; begin
positbyPoint:=0;
Key:=''; If InSight(Opt.r.CFA) thenbegin
LastClick:=ViewDFA;
se:=mdi.GC.FindGraphNode(CFA,P); if se>0 thenbegin
positbyPoint:=se;
mdi.GC.Selected:=se;
co:=mdi.GC.Maps(se).Tree; if (co>=0)and(co<=length(mdi.GC.Content^.items)) then
Key:=mdi.GC.Content^.items[co].Text;
mdi.GC.GraphPositbyNode(se,CFA); end; end; If InSight(Opt.r.DFA) thenbegin
LastClick:=ViewDFA;
se:=mdi.GD.FindGraphNode(DFA,P); if se>0 thenbegin
positbyPoint:=se;
mdi.GD.Selected:=se;
co:=mdi.GD.Maps(se).Tree; if (co>=0)and(co<=length(mdi.GD.Content^.items)) then
Key:=mdi.GD.Content^.items[co].Text;
mdi.GD.GraphPositbyNode(se,DFA); end; end; if InSight(Opt.r.Source) thenbegin
Opt.r.Source.Sheet.PageControl.ActivePage:=Opt.r.Source.Sheet; if Key=''then
Source.markLinePos(P.y,1) elseif Key>''thenbegin //positbynode(Key)
Q:=getPointfromNode(Key);
Source.markLinePos(Q.Y,Q.x);
positbyPoint:=1; end; end;
Screen.Cursor:=crDefault; end; //------------------------------------------------------------------ //-- //ForegroundbyNode -- //-- //------------------------------------------------------------------ function TFrame2.positInfo(P:TPoint;Sender:TObject):JString; var
se,co:integer;
Key:JString; begin
Key:=''; If InSight(Opt.r.CFA) thenbegin
LastClick:=ViewDFA;
se:=mdi.GC.FindGraphNode(CFA,P); if se>0 thenbegin
mdi.GC.Selected:=se;
co:=mdi.GC.Maps(se).Tree; if (co>=0)and(co<=length(mdi.GC.Content^.items)) then
Key:=Functor(mdi.GC.Content^.items[co].Text); end; end; If InSight(Opt.r.DFA) thenbegin
LastClick:=ViewDFA;
se:=mdi.GD.FindGraphNode(DFA,P); if se>0 thenbegin
mdi.GD.Selected:=se;
co:=mdi.GC.Maps(se).Tree; if (co>=0)and(co<=length(mdi.GD.Content^.items)) then
Key:=Functor(mdi.GD.Content^.items[co].Text); end; end;
positInfo:=Key; end; //------------------------------------------------------------------ //Zoom Handler -- //-- //------------------------------------------------------------------ procedure TFrame2.Zoom(G:TGraph;var Im:TImage;C:PAnsiChar;WheelDelta:integer; var SB:TScrollBox); function wheelup:boolean; begin
wheelup:=WheelDelta<0 end; function wheeldown:boolean; begin
wheeldown:=WheelDelta<0 end; const
facn=95;
facd=100;
facmax=2;
facmin=0.95*0.95*0.95; var
vw,vh,vt,vl:integer; begin
vw:=G.VWidth;
vh:=G.VHeight;
vt:=G.VTop;
vl:=G.VLeft; if wheelup() thenbegin
G.VWidth:=(facd*G.VWidth)div facn;
G.VHeight:=(facd*G.VHeight)div facn; end elsebegin
G.VWidth:=(facn*G.VWidth)div facd;
G.VHeight:=(facn*G.VHeight)div facd; end; if G.VWidth<G.width thenbegin
G.VTop:=(G.height-G.VHeight)div 2;
G.VLeft:=(G.width-G.VWidth)div 2; end; if (G.VWidth<facmin*G.width)or(G.VHeight<100)or
(G.VHeight>Screen.height*facmax) thenbegin
G.VWidth:=vw;
G.VHeight:=vh;
G.VTop:=vt;
G.VLeft:=vl; end;
SB.HorzScrollBar.Range:=G.VWidth;
SB.VertScrollBar.Range:=G.VHeight; end; //------------------------------------------------------------------ //Function Blocknumbers -- //-- //------------------------------------------------------------------ procedure TFrame2.setBlocknumbers(); var
S,Att:JString;
P,bnr,Lin,Last,i,ii,ll:integer; begin if mdi.SemL<>nilthen with Source,mdi dobegin for P:=1 to Blockarray.count do
Blockarray.lines[P]:=-1;
ll:=length(SemL^.items); for ii:=0 to ll-1 dobegin
S:=SemL^.items[ii].Text;
Att:=getattribute(S_Bnr,S);
TryStrtoInt(Att,bnr);
Att:=getattribute(S_Lin,S);
TryStrtoInt(Att,Lin); if (Lin>0)and(Lin<Blockarray.count)and(Blockarray.lines[Lin]<0) then
Blockarray.lines[Lin]:=bnr; end;
Last:=-1; for i:=1 to Blockarray.count-1 dobegin if Blockarray.lines[i]>0 then
Last:=Blockarray.lines[i] elseif (Last>0)and(Blockarray.lines[i]<0) then
Blockarray.lines[i]:=Last; end; end; end; //------------------------------------------------------------------ //-- //create Measures -- //-- //------------------------------------------------------------------ procedure TFrame2.CreateSource(Fnr:integer;PF:TSplashForm); var T1,T2,T31,T32,T33:integer;Tim1:TDatetime;TT:TimeTripel; begin //check modification
Opt.r.Source.Sheet.TabVisible:=true;
PageControl1.ActivePage:=Opt.r.Source.Sheet; //now load frames
Tim1:=Now;
TimeSet:=Now;
mdi.Source[Fnr].Age:=FormatDateTime('yyyy.mm.dd hh:ss',
getFileAge(mdi.Source[Fnr].Name));
Source.ReadOnly:=false;
Source.lang:=lang;
Source.SyntaxHighlight:=Opt.r.SyntaxHighlight;
Source.Syntaxbold:=Opt.r.Syntaxbold;
Source.LoadHighLites(Opt.r.Highlites);
T1:=milliSecondsBetween(Now,Tim1);
PF.Progress(5); //
Tim1:=Now;
Source.LoadAttributes(mdi.Cattr);
T2:=milliSecondsBetween(Now,Tim1);
PF.Progress(35); //
Source.LineNumbers:=Opt.r.LineNumbers;
Source.Blocknumbers:=Opt.r.Blocknumbers;
TT:=Source.CreateHighlited(Fnr);
T31:=TT.T1;T32:=TT.T2;T33:=TT.T3;
PF.Progress(5); //done
setBlocknumbers();
setl(Source.SearchString.S,'');
SourceDuration:=MilliSecondsBetween(Now,TimeSet);
mdi.Fnr:=Fnr; //Source.Mark();
PF.Progress(5);
TimeRatio:=''; if IsDebuggerPresent and (T2>100)thenbegin if T2>1000 then
TimeRatio:=' F2=/'+IntToStr(T1 div 1000)+'/'+IntToStr(T2 div 1000)+'/'
+IntToStr(T31 div 1000)+'/'+IntToStr(T32 div 1000)+'/'+IntToStr(T33 div 1000)+' sec' else
TimeRatio:=' F2=/'+IntToStr(T1)+'/'+IntToStr(T2)+'/'+IntToStr(T31)
+'/'+IntToStr(T32)+'/'+IntToStr(T33)+' msec' end; end; //------------------------------------------------------------------ //-- //create Measures -- //-- //------------------------------------------------------------------ procedure TFrame2.CreateGraph(var GR:TGraph;Img:TImage;Plong:PLongTexts;gwidth,gheight:integer); begin with GR dobegin
getgraph(PLong^);
Im:=Img;
Imclear:=Img;
width:=gwidth;
height:=gheight; end; end; //------------------------------------------------------------------ //-- //create Measures -- //-- //------------------------------------------------------------------ procedure TFrame2.CreateMeasure(); var
Line:JString;
F:TFont; begin
Measures.Lines.Clear;
Measures.ReadOnly:=false; if mdi.Cmes<>nilthenbegin
FunktionStream:=mdi.Cmes;
Measures.Paragraph.FirstIndent:=20;
F:=TFont.Create;
F.Name:=Opt.r.FontName;
F.size:=Opt.r.FontSize;
F.Style:=Opt.r.FontStyle;
F.Color:=Opt.r.FontColor;
OpenStream(mdi.Cmes); whilenot eofs dobegin
Line:=GetNextRec(mdi.Cmes);
Measures.Lines.add(Line) end; end;
Measures.ReadOnly:=true; end; //------------------------------------------------------------------ // //create Funktion -- // //------------------------------------------------------------------ procedure TFrame2.CreateFunktion(); var
SN,FN:AnsiString; begin if (mdi.CFun<>nil) thenbegin
FN:=IntToStr(Source.getFileNumber(Source.LoadedFile));
SN:=makexmlnode('Root',1,1,1);
TimeSet:=Now;
Solution:=TMemTree.Create(SN,0);
Solution.LoadTreeFromStream(MDI.CFun);
Displayres(Solution,Funktion); //posit on first line
Funktion.mark();
Funktion.markLinePos(1,1); end else
Funktion.CreateDummyFile();
Funktion.ReadOnly:=true; end; //------------------------------------------------------------------ // //Box Click -- // //------------------------------------------------------------------ procedure TFrame2.TokenBoxClick(Sender:TObject); begin if TokenBox.ItemIndex>0 thenbegin
Clipboard.SetTextBuf(PChar(TokenBox.items[TokenBox.ItemIndex]));
Source.PasteFromClipboard;
TokenBox.Visible:=false;
Source.SetFocus end end; //------------------------------------------------------------------ //-- //Box key down -- //-- //------------------------------------------------------------------ procedure TFrame2.TokenBoxKeyPress(Sender:TObject;var Key:Char); begin iford(Key)=Key_Escape thenbegin
TokenBox.Visible:=false;
Source.SetFocus end elseiford(Key) in [Key_up,Key_down,Key_Left,Key_Right] then elseiford(Key)=Key_return then
TokenBoxClick(Sender) end; //------------------------------------------------------------------ // //SetHints -- // //------------------------------------------------------------------ procedure TFrame2.SetHints(); begin with Source dobegin if Opt.r.language=english thenbegin if Source<>nilthen
Hint:=HintBox('Source'+crlf+ExtractFileName(LoadedFile)); if CFA<>nilthen
CFA.Hint:=HintBox('Controlflow'+crlf+ExtractFileName(LoadedFile)); if DFA<>nilthen
DFA.Hint:=HintBox('Dataflow'+crlf+ExtractFileName(LoadedFile)); if Measures<>nilthen
Measures.Hint:=HintBox('Measures'+crlf+ExtractFileName(LoadedFile)); if Funktion<>nilthen
Funktion.Hint:=HintBox('Function'+crlf+ExtractFileName(LoadedFile)); end elsebegin if Source<>nilthen
Hint:=HintBox('Quelle'+crlf+ExtractFileName(LoadedFile)); if CFA<>nilthen
CFA.Hint:=HintBox('Kontrollfluss'+crlf+ExtractFileName(LoadedFile)); if DFA<>nilthen
DFA.Hint:=HintBox('Datenfluss'+crlf+ExtractFileName(LoadedFile)); if Measures<>nilthen
Measures.Hint:=HintBox('Messwerte'+crlf+ExtractFileName(LoadedFile)); if Funktion<>nilthen
Funktion.Hint:=HintBox('Funktion'+crlf+ExtractFileName(LoadedFile)); end; end; end; //------------------------------------------------------------------ // //SetHints -- // //------------------------------------------------------------------ function TFrame2.getSourcePoint():TPoint; var
P:TPoint; begin
P.x:=Source.CaretPos.x+1;
P.y:=Source.CaretPos.y+1;
getSourcePoint:=P end; //------------------------------------------------------------------ //-- //Ende dieser Quelle -- //-- //------------------------------------------------------------------ end.
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.28Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.