+ Support for example files

This commit is contained in:
michael 2004-08-04 20:59:20 +00:00
parent 49c3f3927e
commit 67779d5035
2 changed files with 29 additions and 7 deletions

View File

@ -44,6 +44,7 @@ ResourceString
SDescription = 'Description'; SDescription = 'Description';
SErrors = 'Errors'; SErrors = 'Errors';
SSeeAlso = 'See Also'; SSeeAlso = 'See Also';
SCodeExample = 'Example code File';
SMakeSkelFromSource = 'Make new document from source file'; SMakeSkelFromSource = 'Make new document from source file';
SSkelErrorWithFile = 'makeskel reported an error (%d). Try to load produced file anyway ?'; SSkelErrorWithFile = 'makeskel reported an error (%d). Try to load produced file anyway ?';
SSkelErrorWithoutFile = 'makeskel reported an error (%d) and produced no file.'; SSkelErrorWithoutFile = 'makeskel reported an error (%d) and produced no file.';

View File

@ -114,6 +114,7 @@ Type
TElementEditor = Class(TFPGtkVBox) TElementEditor = Class(TFPGtkVBox)
Private Private
FExampleNode,
FShortNode, FShortNode,
FDescrNode, FDescrNode,
FErrorsNode, FErrorsNode,
@ -124,6 +125,7 @@ Type
FDescrMemo, FDescrMemo,
FErrorsMemo, FErrorsMemo,
FSeeAlsoMemo : TFPGtkScrollText; FSeeAlsoMemo : TFPGtkScrollText;
FExample : TFPGtkEntry;
FCurrentEditable : TFPGtkEditable; FCurrentEditable : TFPGtkEditable;
FModified : Boolean; FModified : Boolean;
Procedure GetNodes; Procedure GetNodes;
@ -231,11 +233,9 @@ begin
FLabel:=TFPgtkLabel.Create(SNoElement); FLabel:=TFPgtkLabel.Create(SNoElement);
PackStart(FLabel,False,False,0); PackStart(FLabel,False,False,0);
L:=TFPGtkLabel.Create(SShortDescription); L:=TFPGtkLabel.Create(SShortDescription);
V:=TFPGtkVBox.Create;
// Short // Short
V:=TFPGtkVBox.Create;
FShortEntry:=TFPGtkEntry.Create; FShortEntry:=TFPGtkEntry.Create;
// FShortEntry.ConnectEnterNotify(@OnEnterEditable,Nil);
// FShortEntry.ConnectStateChanged(@OnEditableStateChanged,Nil);
FShortEntry.ConnectFocusInEvent(@OnEditableFocusIn,Nil); FShortEntry.ConnectFocusInEvent(@OnEditableFocusIn,Nil);
FShortEntry.ConnectChanged(@OnTextModified,Nil); FShortEntry.ConnectChanged(@OnTextModified,Nil);
V.PackStart(L,False,False,0); V.PackStart(L,False,False,0);
@ -245,7 +245,6 @@ begin
L:=TFPGtkLabel.Create(SErrors); L:=TFPGtkLabel.Create(SErrors);
V:=TFPGtkVBox.Create; V:=TFPGtkVBox.Create;
FErrorsMemo:=TFPGtkScrollText.Create; FErrorsMemo:=TFPGtkScrollText.Create;
// FErrorsMemo.TheText.ConnectEnterNotify(@OnEnterEditable,Nil);
FErrorsMemo.TheText.ConnectFocusInEvent(@OnEditableFocusIn,Nil); FErrorsMemo.TheText.ConnectFocusInEvent(@OnEditableFocusIn,Nil);
FErrorsMemo.TheText.ConnectChanged(@OnTextModified,Nil); FErrorsMemo.TheText.ConnectChanged(@OnTextModified,Nil);
FErrorsMemo.setusize(400,50); FErrorsMemo.setusize(400,50);
@ -253,9 +252,10 @@ begin
V.PackStart(FErrorsMemo,True,true,0); V.PackStart(FErrorsMemo,True,true,0);
F2:=TFPGtkVPaned.Create; F2:=TFPGtkVPaned.Create;
F2.Pack1(V,True,True); F2.Pack1(V,True,True);
// See Also // See Also
L:=TFPGtkLabel.Create(SSeeAlso);
V:=TFPGtkVBox.Create; V:=TFPGtkVBox.Create;
L:=TFPGtkLabel.Create(SSeeAlso);
FSeeAlsoMemo:=TFPGtkScrollText.Create; FSeeAlsoMemo:=TFPGtkScrollText.Create;
// FSeeAlsoMemo.TheText.ConnectEnterNotify(@OnEnterEditable,Nil); // FSeeAlsoMemo.TheText.ConnectEnterNotify(@OnEnterEditable,Nil);
FSeeAlsoMemo.TheText.ConnectFocusInEvent(@OnEditableFocusIn,Nil); FSeeAlsoMemo.TheText.ConnectFocusInEvent(@OnEditableFocusIn,Nil);
@ -278,6 +278,15 @@ begin
F1.Pack1(V,True,True); F1.Pack1(V,True,True);
F1.Pack2(F2,False,True); F1.Pack2(F2,False,True);
PackStart(F1,true,true,0); PackStart(F1,true,true,0);
// Example
V:=TFPGtkVBox.Create;
L:=TFPGtkLabel.Create(SCodeExample);
FExample:=TFPGtkEntry.Create;
FExample.ConnectFocusInEvent(@OnEditableFocusIn,Nil);
FExample.ConnectChanged(@OnTextModified,Nil);
V.PackStart(L,False,False,0);
V.PackStart(FExample,True,true,0);
PackStart(V,false,false,0);
end; end;
Procedure TElementEditor.SetElement (Value : TDomElement); Procedure TElementEditor.SetElement (Value : TDomElement);
@ -357,6 +366,10 @@ begin
FDescrMemo.Text:=NodeToString(FDescrNode); FDescrMemo.Text:=NodeToString(FDescrNode);
FErrorsMemo.Text:=NodeToString(FErrorsNode); FErrorsMemo.Text:=NodeToString(FErrorsNode);
FSeeAlsoMemo.Text:=NodeToString(FSeeAlsoNode); FSeeAlsoMemo.Text:=NodeToString(FSeeAlsoNode);
If FExampleNode=Nil then
FExample.Text:=''
else
FExample.Text:=FExampleNode['file'];
FModified:=False; FModified:=False;
Finally Finally
S.Free; S.Free;
@ -409,6 +422,8 @@ Function TElementEditor.CurrentXML : String;
result:='<'+NodeName+'/>'; result:='<'+NodeName+'/>';
end; end;
Var
S : String;
begin begin
// Writeln('In currentxml'); // Writeln('In currentxml');
@ -419,6 +434,9 @@ begin
Result:=Result+GetNodeString('descr',trim(FDescrMemo.Text)); Result:=Result+GetNodeString('descr',trim(FDescrMemo.Text));
Result:=Result+GetNodeString('errors',trim(FErrorsMemo.Text)); Result:=Result+GetNodeString('errors',trim(FErrorsMemo.Text));
Result:=Result+GetNodeString('seealso',trim(FSeeAlsoMemo.Text)); Result:=Result+GetNodeString('seealso',trim(FSeeAlsoMemo.Text));
S:=Trim(FExample.Text);
If (S<>'') then
Result:=Result+'<example file="'+S+'"/>';
// Writeln('Currentxml : ',Result); // Writeln('Currentxml : ',Result);
end; end;
@ -538,6 +556,7 @@ begin
FDescrNode:=Nil; FDescrNode:=Nil;
FErrorsNode:=Nil; FErrorsNode:=Nil;
FSeeAlsoNode:=Nil; FSeeAlsoNode:=Nil;
FExampleNode:=Nil;
If Assigned(FElement) then If Assigned(FElement) then
begin begin
Node:=FElement.FirstChild; Node:=FElement.FirstChild;
@ -553,7 +572,9 @@ begin
else if S='errors' then else if S='errors' then
FErrorsNode:=TDomElement(Node) FErrorsNode:=TDomElement(Node)
else if S='seealso' then else if S='seealso' then
FSeeAlsoNode:=TDomElement(Node); FSeeAlsoNode:=TDomElement(Node)
else if S='example' then
FExampleNode:=TDomElement(Node);
end; end;
Node:=Node.NextSibling; Node:=Node.NextSibling;
end; end;