mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 14:58:13 +02:00
added status icons to nodes, expand/collapse menu items
git-svn-id: trunk@7656 -
This commit is contained in:
parent
a3a98f7ca6
commit
fc0770006d
10
.gitattributes
vendored
10
.gitattributes
vendored
@ -446,9 +446,6 @@ designer/sizecompsdlg.pp svneol=native#text/pascal
|
||||
designer/taborderdlg.lfm svneol=native#text/plain
|
||||
designer/taborderdlg.lrs svneol=native#text/pascal
|
||||
designer/taborderdlg.pas svneol=native#text/pascal
|
||||
doceditor/add.xpm -text svneol=native#image/x-xpixmap
|
||||
doceditor/delete.xpm -text svneol=native#image/x-xpixmap
|
||||
doceditor/edit.xpm -text svneol=native#image/x-xpixmap
|
||||
doceditor/eleditor.pp svneol=native#text/pascal
|
||||
doceditor/eleditor.xml svneol=native#text/xml
|
||||
doceditor/fmmakeskel.lfm svneol=native#text/plain
|
||||
@ -487,6 +484,13 @@ doceditor/frmtable.lfm svneol=native#text/plain
|
||||
doceditor/frmtable.lrs svneol=native#text/pascal
|
||||
doceditor/frmtable.pp svneol=native#text/pascal
|
||||
doceditor/icons.lrs svneol=native#text/pascal
|
||||
doceditor/images/add.xpm -text svneol=native#image/x-xpixmap
|
||||
doceditor/images/delete.xpm -text svneol=native#image/x-xpixmap
|
||||
doceditor/images/edit.xpm -text svneol=native#image/x-xpixmap
|
||||
doceditor/images/node_edit.xpm -text svneol=native#image/x-xpixmap
|
||||
doceditor/images/node_finished.xpm -text svneol=native#image/x-xpixmap
|
||||
doceditor/images/node_modified.xpm -text svneol=native#image/x-xpixmap
|
||||
doceditor/images/node_new.xpm -text svneol=native#image/x-xpixmap
|
||||
doceditor/lazde.lpi svneol=native#text/plain
|
||||
doceditor/lazde.lpr svneol=native#text/pascal
|
||||
doceditor/lazdemsg.pp svneol=native#text/pascal
|
||||
|
@ -40,16 +40,22 @@ Type
|
||||
|
||||
TCustomElementEditor = Class(TPanel)
|
||||
private
|
||||
FChangedEvent: TNotifyEvent;
|
||||
Felement : TDomElement;
|
||||
FGetElementList: TGetElementListEvent;
|
||||
FSavedNode,
|
||||
FModified : Boolean;
|
||||
FTargetFileName: string;
|
||||
FGetInitialDir: TGetInitialDirEvent;
|
||||
FChangeEvent: TNotifyEvent;
|
||||
FOnChangeCount: Integer;
|
||||
procedure SetModified(const AValue: Boolean);
|
||||
Protected
|
||||
Function GetCurrentSelection : String; virtual; abstract;
|
||||
Procedure SetElement (Value : TDomElement); virtual;
|
||||
Function GetInitialDir: String;
|
||||
procedure LockOnChange;
|
||||
procedure UnLockOnChange;
|
||||
Public
|
||||
Procedure Refresh; virtual; abstract;
|
||||
Function TestSave(S : String) : Boolean; virtual; abstract;
|
||||
@ -63,11 +69,12 @@ Type
|
||||
Procedure InsertTable(Cols,Rows : Integer; UseHeader : Boolean); virtual; abstract;
|
||||
Property Element : TDomElement Read FElement Write SetElement;
|
||||
Property CurrentSelection : String Read GetCurrentSelection;
|
||||
Property Modified : Boolean Read FModified Write FModified;
|
||||
Property Modified : Boolean Read FModified Write SetModified;
|
||||
Property SavedNode : Boolean Read FSavedNode Write FSavedNode;
|
||||
Property TargetFileName: String read FTargetFileName write FTargetFileName;
|
||||
Property OnGetElementList : TGetElementListEvent Read FGetElementList Write FGetElementList;
|
||||
Property OnGetInitialDir: TGetInitialDirEvent read FGetInitialdir write FGetInitialDir;
|
||||
Property OnChange: TNotifyEvent read FChangeEvent write FChangeEvent;
|
||||
end;
|
||||
|
||||
{ TElementEditor }
|
||||
@ -133,6 +140,13 @@ uses frmexample,frmLink;
|
||||
|
||||
{ TCustomElementEditor }
|
||||
|
||||
procedure TCustomElementEditor.SetModified(const AValue: Boolean);
|
||||
begin
|
||||
FModified := AValue;
|
||||
if (FOnChangeCount=0) and FModified and Assigned(FChangeEvent) then
|
||||
FChangeEvent(Self);
|
||||
end;
|
||||
|
||||
procedure TCustomElementEditor.SetElement(Value: TDomElement);
|
||||
|
||||
begin
|
||||
@ -146,6 +160,16 @@ begin
|
||||
result := FGetInitialdir();
|
||||
end;
|
||||
|
||||
procedure TCustomElementEditor.LockOnChange;
|
||||
begin
|
||||
FOnChangeCount := 1;
|
||||
end;
|
||||
|
||||
procedure TCustomElementEditor.UnLockOnChange;
|
||||
begin
|
||||
FOnChangeCount := 0;
|
||||
end;
|
||||
|
||||
{ ---------------------------------------------------------------------
|
||||
TElementEditor
|
||||
---------------------------------------------------------------------}
|
||||
@ -158,6 +182,7 @@ Var
|
||||
L : Tlabel;
|
||||
|
||||
begin
|
||||
LockOnChange;
|
||||
Inherited;
|
||||
FExampleNodes:=TList.create;
|
||||
ILElements:=TImageList.Create(Self);
|
||||
@ -450,6 +475,7 @@ begin
|
||||
else
|
||||
FLabel.Text:=SNoElement;
|
||||
S:=TStringStream.Create('');
|
||||
LockOnChange;
|
||||
Try
|
||||
FShortEntry.Text:=RemoveLineFeeds(NodeToString(FShortNode));
|
||||
FDescrMemo.Text:=NodeToString(FDescrNode);
|
||||
@ -471,6 +497,7 @@ begin
|
||||
FModified:=False;
|
||||
Finally
|
||||
S.Free;
|
||||
UnLockOnChange;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -603,7 +630,7 @@ begin
|
||||
S:=Format('<%s>%s</%s>',[TagName,S,TagName]);
|
||||
Seltext:=S;
|
||||
SelLength:=Length(S);
|
||||
FModified:=True;
|
||||
Modified:=True;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -711,7 +738,7 @@ Procedure TElementEditor.OnTextModified(Sender : TObject);
|
||||
|
||||
begin
|
||||
if Sender=nil then ;
|
||||
FModified:=True;
|
||||
Modified:=True;
|
||||
end;
|
||||
|
||||
procedure TElementEditor.DoAddExample(Sender: TObject);
|
||||
|
@ -13,6 +13,7 @@ object MainForm: TMainForm
|
||||
Height = 544
|
||||
Width = 602
|
||||
object TBMain: TToolBar
|
||||
BorderSpacing.OnChange = nil
|
||||
ButtonHeight = 28
|
||||
ButtonWidth = 28
|
||||
Caption = 'TBMain'
|
||||
@ -187,6 +188,7 @@ object MainForm: TMainForm
|
||||
end
|
||||
object PCFiles: TPageControl
|
||||
Align = alClient
|
||||
BorderSpacing.OnChange = nil
|
||||
TabOrder = 1
|
||||
Left = 5
|
||||
Height = 468
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -37,3 +37,47 @@ LazarusResources.Add('edit','XPM',[
|
||||
+'..#aaaaaa#.......",'#10'".......#aaaaa#........",'#10'"........#####.......'
|
||||
+'..",'#10'"......................"};'#10
|
||||
]);
|
||||
LazarusResources.Add('node_edit','XPM',[
|
||||
'/* XPM */'#10'static char * node_edit_xpm[] = {'#10'"13 14 13 1",'#10'" '#9
|
||||
+'c None",'#10'".'#9'c #FFFFFF",'#10'"+'#9'c #909290",'#10'"@'#9'c #848684",'
|
||||
+#10'"#'#9'c #FFFF00",'#10'"$'#9'c #C6C7C6",'#10'"%'#9'c #EE0808",'#10'"&'#9
|
||||
+'c #000000",'#10'"*'#9'c #888B88",'#10'"='#9'c #FDFEFD",'#10'"-'#9'c #8B8E8B'
|
||||
+'",'#10'";'#9'c #FDFDFD",'#10'">'#9'c #FEFEFE",'#10'".............",'#10'".+'
|
||||
+'@@@@@@@....",'#10'".+#.#.#.$@...",'#10'".+.#.#.#$.@..",'#10'".+#.%.#.&&&&."'
|
||||
+','#10'".*.#%%.%%#$&.",'#10'"=-#.%%%%%.$&.",'#10'";+.#%#%#%#$&.",'#10'";+#.%'
|
||||
+'.%.%.$&.",'#10'";+.#%#.#%#$&.",'#10'">+#.#.#.#.$&.",'#10'";+$$$$$$$$$&.",'
|
||||
+#10'">&&&&&&&&&&&.",'#10'">............"};'#10
|
||||
]);
|
||||
LazarusResources.Add('node_finished','XPM',[
|
||||
'/* XPM */'#10'static char * node_finished_xpm[] = {'#10'"13 14 13 1",'#10'" '
|
||||
+#9'c None",'#10'".'#9'c #FFFFFF",'#10'"+'#9'c #909290",'#10'"@'#9'c #848684"'
|
||||
+','#10'"#'#9'c #FFFF00",'#10'"$'#9'c #C6C7C6",'#10'"%'#9'c #000000",'#10'"&'
|
||||
+#9'c #888B88",'#10'"*'#9'c #086F1E",'#10'"='#9'c #FDFEFD",'#10'"-'#9'c #8B8E'
|
||||
+'8B",'#10'";'#9'c #FDFDFD",'#10'">'#9'c #FEFEFE",'#10'".............",'#10'"'
|
||||
+'.+@@@@@@@....",'#10'".+#.#.#.$@...",'#10'".+.#.#.#$.@..",'#10'".+#.#.#.%%%%'
|
||||
+'.",'#10'".&.#.#.**#$%.",'#10'"=-#*#.#**.$%.",'#10'";+.**#**.#$%.",'#10'";+#'
|
||||
+'**.**#.$%.",'#10'";+.#***#.#$%.",'#10'">+#.#**.#.$%.",'#10'";+$$$$$$$$$%.",'
|
||||
+#10'">%%%%%%%%%%%.",'#10'">............"};'#10
|
||||
]);
|
||||
LazarusResources.Add('node_modified','XPM',[
|
||||
'/* XPM */'#10'static char * node_modified_xpm[] = {'#10'"13 14 13 1",'#10'" '
|
||||
+#9'c None",'#10'".'#9'c #FFFFFF",'#10'"+'#9'c #909290",'#10'"@'#9'c #848684"'
|
||||
+','#10'"#'#9'c #FFFF00",'#10'"$'#9'c #C6C7C6",'#10'"%'#9'c #000000",'#10'"&'
|
||||
+#9'c #888B88",'#10'"*'#9'c #2A00FD",'#10'"='#9'c #FDFEFD",'#10'"-'#9'c #8B8E'
|
||||
+'8B",'#10'";'#9'c #FDFDFD",'#10'">'#9'c #FEFEFE",'#10'".............",'#10'"'
|
||||
+'.+@@@@@@@....",'#10'".+#.#.#.$@...",'#10'".+.#.#.#$.@..",'#10'".+#.#.#.%%%%'
|
||||
+'.",'#10'".&.******#$%.",'#10'"=-#******.$%.",'#10'";+.*.**#*#$%.",'#10'";+#'
|
||||
+'.#**.#.$%.",'#10'";+.#.**#.#$%.",'#10'">+#.****#.$%.",'#10'";+$$$$$$$$$%.",'
|
||||
+#10'">%%%%%%%%%%%.",'#10'">............"};'#10
|
||||
]);
|
||||
LazarusResources.Add('node_new','XPM',[
|
||||
'/* XPM */'#10'static char * node_new_xpm[] = {'#10'"13 14 12 1",'#10'" '#9'c'
|
||||
+' None",'#10'".'#9'c #FFFFFF",'#10'"+'#9'c #909290",'#10'"@'#9'c #848684",'
|
||||
+#10'"#'#9'c #FFFF00",'#10'"$'#9'c #C6C7C6",'#10'"%'#9'c #000000",'#10'"&'#9
|
||||
+'c #888B88",'#10'"*'#9'c #FDFEFD",'#10'"='#9'c #8B8E8B",'#10'"-'#9'c #FDFDFD'
|
||||
+'",'#10'";'#9'c #FEFEFE",'#10'".............",'#10'".+@@@@@@@....",'#10'".+#'
|
||||
+'.#.#.$@...",'#10'".+.#.#.#$.@..",'#10'".+#.#.#.%%%%.",'#10'".&.#.#.#.#$%.",'
|
||||
+#10'"*=#.#.#.#.$%.",'#10'"-+.#.#.#.#$%.",'#10'"-+#.#.#.#.$%.",'#10'"-+.#.#.#'
|
||||
+'.#$%.",'#10'";+#.#.#.#.$%.",'#10'"-+$$$$$$$$$%.",'#10'";%%%%%%%%%%%.",'#10
|
||||
+'";............"};'#10
|
||||
]);
|
||||
|
30
doceditor/images/node_edit.xpm
Normal file
30
doceditor/images/node_edit.xpm
Normal file
@ -0,0 +1,30 @@
|
||||
/* XPM */
|
||||
static char * node_edit_xpm[] = {
|
||||
"13 14 13 1",
|
||||
" c None",
|
||||
". c #FFFFFF",
|
||||
"+ c #909290",
|
||||
"@ c #848684",
|
||||
"# c #FFFF00",
|
||||
"$ c #C6C7C6",
|
||||
"% c #EE0808",
|
||||
"& c #000000",
|
||||
"* c #888B88",
|
||||
"= c #FDFEFD",
|
||||
"- c #8B8E8B",
|
||||
"; c #FDFDFD",
|
||||
"> c #FEFEFE",
|
||||
".............",
|
||||
".+@@@@@@@....",
|
||||
".+#.#.#.$@...",
|
||||
".+.#.#.#$.@..",
|
||||
".+#.%.#.&&&&.",
|
||||
".*.#%%.%%#$&.",
|
||||
"=-#.%%%%%.$&.",
|
||||
";+.#%#%#%#$&.",
|
||||
";+#.%.%.%.$&.",
|
||||
";+.#%#.#%#$&.",
|
||||
">+#.#.#.#.$&.",
|
||||
";+$$$$$$$$$&.",
|
||||
">&&&&&&&&&&&.",
|
||||
">............"};
|
30
doceditor/images/node_finished.xpm
Normal file
30
doceditor/images/node_finished.xpm
Normal file
@ -0,0 +1,30 @@
|
||||
/* XPM */
|
||||
static char * node_finished_xpm[] = {
|
||||
"13 14 13 1",
|
||||
" c None",
|
||||
". c #FFFFFF",
|
||||
"+ c #909290",
|
||||
"@ c #848684",
|
||||
"# c #FFFF00",
|
||||
"$ c #C6C7C6",
|
||||
"% c #000000",
|
||||
"& c #888B88",
|
||||
"* c #086F1E",
|
||||
"= c #FDFEFD",
|
||||
"- c #8B8E8B",
|
||||
"; c #FDFDFD",
|
||||
"> c #FEFEFE",
|
||||
".............",
|
||||
".+@@@@@@@....",
|
||||
".+#.#.#.$@...",
|
||||
".+.#.#.#$.@..",
|
||||
".+#.#.#.%%%%.",
|
||||
".&.#.#.**#$%.",
|
||||
"=-#*#.#**.$%.",
|
||||
";+.**#**.#$%.",
|
||||
";+#**.**#.$%.",
|
||||
";+.#***#.#$%.",
|
||||
">+#.#**.#.$%.",
|
||||
";+$$$$$$$$$%.",
|
||||
">%%%%%%%%%%%.",
|
||||
">............"};
|
30
doceditor/images/node_modified.xpm
Normal file
30
doceditor/images/node_modified.xpm
Normal file
@ -0,0 +1,30 @@
|
||||
/* XPM */
|
||||
static char * node_modified_xpm[] = {
|
||||
"13 14 13 1",
|
||||
" c None",
|
||||
". c #FFFFFF",
|
||||
"+ c #909290",
|
||||
"@ c #848684",
|
||||
"# c #FFFF00",
|
||||
"$ c #C6C7C6",
|
||||
"% c #000000",
|
||||
"& c #888B88",
|
||||
"* c #2A00FD",
|
||||
"= c #FDFEFD",
|
||||
"- c #8B8E8B",
|
||||
"; c #FDFDFD",
|
||||
"> c #FEFEFE",
|
||||
".............",
|
||||
".+@@@@@@@....",
|
||||
".+#.#.#.$@...",
|
||||
".+.#.#.#$.@..",
|
||||
".+#.#.#.%%%%.",
|
||||
".&.******#$%.",
|
||||
"=-#******.$%.",
|
||||
";+.*.**#*#$%.",
|
||||
";+#.#**.#.$%.",
|
||||
";+.#.**#.#$%.",
|
||||
">+#.****#.$%.",
|
||||
";+$$$$$$$$$%.",
|
||||
">%%%%%%%%%%%.",
|
||||
">............"};
|
29
doceditor/images/node_new.xpm
Normal file
29
doceditor/images/node_new.xpm
Normal file
@ -0,0 +1,29 @@
|
||||
/* XPM */
|
||||
static char * node_new_xpm[] = {
|
||||
"13 14 12 1",
|
||||
" c None",
|
||||
". c #FFFFFF",
|
||||
"+ c #909290",
|
||||
"@ c #848684",
|
||||
"# c #FFFF00",
|
||||
"$ c #C6C7C6",
|
||||
"% c #000000",
|
||||
"& c #888B88",
|
||||
"* c #FDFEFD",
|
||||
"= c #8B8E8B",
|
||||
"- c #FDFDFD",
|
||||
"; c #FEFEFE",
|
||||
".............",
|
||||
".+@@@@@@@....",
|
||||
".+#.#.#.$@...",
|
||||
".+.#.#.#$.@..",
|
||||
".+#.#.#.%%%%.",
|
||||
".&.#.#.#.#$%.",
|
||||
"*=#.#.#.#.$%.",
|
||||
"-+.#.#.#.#$%.",
|
||||
"-+#.#.#.#.$%.",
|
||||
"-+.#.#.#.#$%.",
|
||||
";+#.#.#.#.$%.",
|
||||
"-+$$$$$$$$$%.",
|
||||
";%%%%%%%%%%%.",
|
||||
";............"};
|
@ -80,7 +80,6 @@ ResourceString
|
||||
'See http://www.freepascal.org/';
|
||||
SFileStructure = 'Documentation structure';
|
||||
SModuleElements = 'Elements for selected node';
|
||||
|
||||
{ ---------------------------------------------------------------------
|
||||
Menu strings
|
||||
---------------------------------------------------------------------}
|
||||
@ -115,6 +114,8 @@ ResourceString
|
||||
|
||||
SMenuRename = 'Rename';
|
||||
SMenuDelete = 'Delete';
|
||||
SMenuExpandAll = 'Expand All';
|
||||
SMenuCollapseAll = 'Collapse All';
|
||||
|
||||
SMenuExtra = 'Extra';
|
||||
SMenuExtraoptions = 'Options';
|
||||
|
@ -299,6 +299,14 @@ lazdemsg.smenurename='Rename'
|
||||
lazdemsg.smenudelete='Delete'
|
||||
|
||||
|
||||
# hash value = 138578252
|
||||
lazdemsg.smenuexpandall='Expand All'
|
||||
|
||||
|
||||
# hash value = 53573292
|
||||
lazdemsg.smenucollapseall='Collapse All'
|
||||
|
||||
|
||||
# hash value = 5045121
|
||||
lazdemsg.smenuextra='Extra'
|
||||
|
||||
|
@ -39,6 +39,12 @@ Var
|
||||
CmdMakeSkel : String;
|
||||
cmdFPDoc : String;
|
||||
|
||||
Const
|
||||
ImgIndxNew = 0;
|
||||
ImgIndxEdited = 1;
|
||||
ImgIndxModified = 2;
|
||||
imgIndxFinished = 3;
|
||||
|
||||
Procedure LoadOptions;
|
||||
Procedure SaveOptions;
|
||||
Function GetOptionFileName : String;
|
||||
|
@ -83,6 +83,7 @@ Type
|
||||
Function GetModified : Boolean;
|
||||
Function MakeBackup(FN : String) : Boolean;
|
||||
Procedure DisplayDocument;
|
||||
Procedure ElementChanged(Sender: TObject);
|
||||
Public
|
||||
Constructor Create(AOwner : TComponent); override;
|
||||
Function FirstPackage : TDomElement;
|
||||
@ -139,6 +140,7 @@ begin
|
||||
Felement.Align:=AlClient;
|
||||
FElement.OnGetElementList:=@GetELementList;
|
||||
FElement.OnGetInitialDir:=@GetInitialDir;
|
||||
FElement.OnChange:=@ElementChanged;
|
||||
end;
|
||||
|
||||
|
||||
@ -229,6 +231,11 @@ begin
|
||||
FPackages.DescriptionNode:=FDocument.DocumentElement;
|
||||
end;
|
||||
|
||||
procedure TEditorPage.ElementChanged(Sender: TObject);
|
||||
begin
|
||||
TPackageEditor(FPackages).UpdateSelectedNodeStatus;
|
||||
end;
|
||||
|
||||
|
||||
Procedure TEditorPage.ElementSelected(Node : TDomElement) ;
|
||||
|
||||
|
@ -86,7 +86,10 @@ Type
|
||||
FMRenameMenu,
|
||||
FMDeleteMenu,
|
||||
FERenameMenu,
|
||||
FECollapseAllMenu,
|
||||
FEExpandAllMenu,
|
||||
FEDeleteMenu : TMenuItem;
|
||||
FImagelist : TImageList;
|
||||
// Callbacks for visual controls.
|
||||
Procedure ModuleChange(Sender: TObject; Node: TTreeNode);
|
||||
Procedure ModuleChanging(Sender: TObject; Node: TTreeNode;
|
||||
@ -98,6 +101,8 @@ Type
|
||||
Procedure TreeClick(Sender: TObject);
|
||||
Procedure MenuRenameClick(Sender : TObject);
|
||||
Procedure MenuDeleteClick(Sender : TObject);
|
||||
Procedure MenuCollapseAllClick(Sender: TObject);
|
||||
procedure MenuExpandAllClick(Sender: TObject);
|
||||
// Internal node methods.
|
||||
Procedure DeleteNode(Msg : String; N : TTreeNode; E : TDomElement);
|
||||
Procedure DeleteElementNode(N : TTreeNode);
|
||||
@ -126,6 +131,9 @@ Type
|
||||
Procedure SetCurrentModuleNode(N : TTreeNode);
|
||||
Procedure SetCurrentPackageNode(N : TTreeNode);
|
||||
Procedure SetCurrentTopicNode(T : TTreeNode);
|
||||
// Other methods
|
||||
procedure UpdateNodeImage(N: TTreeNode);
|
||||
procedure SetNodeImage(N: TTreeNode; Index: Integer);
|
||||
Protected
|
||||
Procedure SetCurrentModule(Value : TDomElement); override;
|
||||
Procedure SetCurrentPackage(Value : TDomElement); override;
|
||||
@ -144,6 +152,7 @@ Type
|
||||
Procedure RenameModule(M : TDomElement); override;
|
||||
Procedure RenameElement(E : TDomElement); override;
|
||||
Procedure RenameTopic(T : TDomElement); override;
|
||||
procedure UpdateSelectedNodeStatus;
|
||||
Property ModuleTree : TTreeView Read FModuleTree;
|
||||
Property ElementTree : TTreeView Read FElementTree;
|
||||
end;
|
||||
@ -151,7 +160,7 @@ Type
|
||||
|
||||
implementation
|
||||
|
||||
uses frmNewNode;
|
||||
uses frmNewNode, graphics;
|
||||
|
||||
{ ---------------------------------------------------------------------
|
||||
Auxiliary routines
|
||||
@ -246,7 +255,9 @@ end;
|
||||
---------------------------------------------------------------------}
|
||||
|
||||
Constructor TPackageEditor.Create(AOwner : TComponent);
|
||||
|
||||
var
|
||||
TmpPanel: TPanel;
|
||||
|
||||
Function NewMenuItem(ACaption : String; AOnClick : TNotifyEvent) : TMenuItem;
|
||||
|
||||
begin
|
||||
@ -257,6 +268,12 @@ Constructor TPackageEditor.Create(AOwner : TComponent);
|
||||
|
||||
begin
|
||||
Inherited;
|
||||
FImageList := TImageList.Create(Self);
|
||||
Fimagelist.AddFromLazarusResource('node_new'); // ImgIndxNew
|
||||
Fimagelist.AddFromLazarusResource('node_edit'); // ImgIndxEdited
|
||||
Fimagelist.AddFromLazarusResource('node_modified'); // ImgIndxModified
|
||||
Fimagelist.AddFromLazarusResource('node_finished'); // ImgIndxFinished
|
||||
|
||||
FLModules:=Tlabel.Create(Self);
|
||||
With FLModules do
|
||||
begin
|
||||
@ -271,6 +288,7 @@ begin
|
||||
Parent:=Self;
|
||||
Align:=AlTop;
|
||||
Height:=150;
|
||||
Images:=FImageList;
|
||||
OnChange:=@ModuleChange;
|
||||
OnChanging:=@ModuleChanging;
|
||||
// Till the above two get fixed, use this
|
||||
@ -301,6 +319,7 @@ begin
|
||||
begin
|
||||
Parent:=FpElements;
|
||||
Align:=AlClient;
|
||||
Images:=FImageList;
|
||||
OnChange:=@ElementChange;
|
||||
OnChanging:=@ElementChanging;
|
||||
// Till the above two get fixed, use this:
|
||||
@ -309,8 +328,13 @@ begin
|
||||
PEMenu:=TPopupMenu.Create(Self);
|
||||
FERenameMenu:=NewMenuItem(SMenuRename,@MenuRenameClick);
|
||||
FEDeleteMenu:=NewMenuItem(SMenuDelete,@MenuDeleteClick);
|
||||
FEExpandAllMenu:=NewMenuItem(SMenuExpandAll,@MenuExpandAllClick);
|
||||
FECollapseAllMenu:=NewMenuItem(SMenuCollapseAll,@MenuCollapseAllClick);
|
||||
PEMenu.Items.Add(FERenameMenu);
|
||||
PEMenu.Items.Add(FEDeleteMenu);
|
||||
PEMenu.Items.Add(NewMenuItem('-',nil));
|
||||
PEMEnu.Items.Add(FEExpandAllMenu);
|
||||
PEMenu.Items.Add(FECollapseAllMenu);
|
||||
FElementTree.PopupMenu:=PEMenu;
|
||||
PMMenu:=TPopupMenu.Create(Self);
|
||||
FMRenameMenu:=NewMenuItem(SMenuRename,@MenuRenameClick);
|
||||
@ -493,6 +517,21 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPackageEditor.MenuCollapseAllClick(Sender: TObject);
|
||||
var
|
||||
Node: TTreeNode;
|
||||
begin
|
||||
ElementTree.FullCollapse;
|
||||
Node := ElementTree.Items.GetFirstNode;
|
||||
if Node<>nil then
|
||||
Node.Expand(False);
|
||||
end;
|
||||
|
||||
procedure TPackageEditor.MenuExpandAllClick(Sender: TObject);
|
||||
begin
|
||||
ElementTree.FullExpand;
|
||||
end;
|
||||
|
||||
|
||||
Procedure TPackageEditor.SetModuleNode(N : TTreeNode);
|
||||
|
||||
@ -662,6 +701,59 @@ begin
|
||||
RenameNode(SRenameTopic,N);
|
||||
end;
|
||||
|
||||
procedure DebugElement(Element: TDomElement);
|
||||
var
|
||||
Level: integer;
|
||||
const
|
||||
NType:Array[0..12] of String[30] =
|
||||
(
|
||||
'0:UNKNOWN',
|
||||
'1:ELEMENT_NODE',
|
||||
'2:ATTRIBUTE_NODE',
|
||||
'3:TEXT_NODE',
|
||||
'4:CDATA_SECTION_NODE',
|
||||
'5:ENTITY_REFERENCE_NODE',
|
||||
'6:ENTITY_NODE',
|
||||
'7:PROCESSING_INSTRUCTION_NODE',
|
||||
'8:COMMENT_NODE',
|
||||
'9:DOCUMENT_NODE',
|
||||
'10:DOCUMENT_TYPE_NODE',
|
||||
'11:DOCUMENT_FRAGMENT_NODE',
|
||||
'12:NOTATION_NODE'
|
||||
);
|
||||
function GetLevelSpc: String;
|
||||
begin
|
||||
SetLength(Result, Level*2);
|
||||
FillChar(Result[1], Level*2, ' ');
|
||||
end;
|
||||
procedure DebugNodes(Node: TDomNode);
|
||||
begin
|
||||
Node := Node.FirstChild;
|
||||
while node<>nil do begin
|
||||
WriteLn(GetLevelSpc, 'Node=',Node.NodeName,' Type=',NType[Node.NodeType],' Value=',Node.NodeValue);
|
||||
if (node.NodeType = ELEMENT_NODE) then begin
|
||||
Inc(Level);
|
||||
DebugNodes(Node);
|
||||
Dec(Level);
|
||||
end;
|
||||
Node := Node.NextSibling;
|
||||
end;
|
||||
end;
|
||||
begin
|
||||
if assigned(Element) then begin
|
||||
WriteLn('Element: ', Element['name'],': ');
|
||||
level := 1;
|
||||
DebugNodes(Element);
|
||||
end else
|
||||
WriteLn('Element <nil>');
|
||||
end;
|
||||
|
||||
|
||||
procedure TPackageEditor.UpdateSelectedNodeStatus;
|
||||
begin
|
||||
if ElementTree.Selected<>nil then
|
||||
SetNodeImage(ElementTree.Selected, ImgIndxModified);
|
||||
end;
|
||||
|
||||
Procedure TPackageEditor.RenameElement(E : TDomElement);
|
||||
|
||||
@ -697,6 +789,7 @@ begin
|
||||
FModuleNode:=FElementTree.Items.Add(Nil,Module['name']);
|
||||
S:=TStringList.Create;
|
||||
Try
|
||||
// get sorted list of elements
|
||||
Node:=Module.FirstChild;
|
||||
While Assigned(Node) do
|
||||
begin
|
||||
@ -705,12 +798,15 @@ begin
|
||||
Node:=Node.NextSibling;
|
||||
end;
|
||||
S.Sorted:=True;
|
||||
// root node
|
||||
TNode:=FModuleNode;
|
||||
// process list of elements, create levels
|
||||
For I:=0 to S.Count-1 do
|
||||
begin
|
||||
PNode:=Nil;
|
||||
SNode:=TNode;
|
||||
N:=S[i];
|
||||
// look for a tentative new parents
|
||||
While (SNode<>FModuleNode) and (PNode=Nil) do
|
||||
begin
|
||||
PN:=TDomElement(SNode.Data)['name']+'.';
|
||||
@ -725,6 +821,7 @@ begin
|
||||
System.Delete(N,1,L);
|
||||
TNode:=FElementTree.Items.AddChild(PNode,N);
|
||||
TNode.Data:=S.Objects[i];
|
||||
UpdateNodeImage(TNode);
|
||||
end;
|
||||
Finally
|
||||
S.Free;
|
||||
@ -962,6 +1059,58 @@ begin
|
||||
CurrentElement:=Nil;
|
||||
end;
|
||||
|
||||
procedure TPackageEditor.UpdateNodeImage(N: TTreeNode);
|
||||
var
|
||||
ImgIndex: Integer;
|
||||
Node: TDomNode;
|
||||
Element: TDomElement;
|
||||
begin
|
||||
if assigned(N) then begin
|
||||
|
||||
Element := TDomElement(N.Data);
|
||||
//DebugElement(Element);
|
||||
if not Assigned(Element) then
|
||||
exit;
|
||||
|
||||
// get image index accoding of element edit state
|
||||
ImgIndex := ImgIndxNew;
|
||||
node := Element.FirstChild;
|
||||
while Assigned(node) do begin
|
||||
if (node.NodeType=ELEMENT_NODE) and node.HasChildNodes then begin
|
||||
if
|
||||
(
|
||||
(node.NodeName = 'short') or
|
||||
(node.NodeName = 'descr') or
|
||||
(node.NodeName = 'sealso') or
|
||||
(node.NodeName = 'example') or
|
||||
(node.NodeName = 'errors')
|
||||
) then begin
|
||||
ImgIndex := ImgIndxModified;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
Node := Node.NextSibling;
|
||||
end;
|
||||
|
||||
// assign index to node and propagate status to parent
|
||||
SetNodeImage(N, ImgIndex);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPackageEditor.SetNodeImage(N: TTreeNode; Index: Integer);
|
||||
begin
|
||||
N.ImageIndex := Index;
|
||||
N.SelectedIndex := Index;
|
||||
if Index>ImgIndxEdited then
|
||||
while assigned(N.Parent) do begin
|
||||
N := N.Parent;
|
||||
if N.ImageIndex < ImgIndxEdited then begin
|
||||
N.ImageIndex := ImgIndxEdited;
|
||||
N.SelectedIndex := ImgIndxEdited;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TPackageEditor.SetCurrentElement(E : TDomElement);
|
||||
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user