1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
|
unit frm_main;
{$mode objfpc}{$H+}
{
NOTE: This is still work in progress!!!!!!!
}
interface
uses
Classes,
SysUtils,
fpg_base,
fpg_main,
fpg_form,
fpg_button,
fpg_edit,
fpg_label,
fpg_menu,
fpg_memo,
fpg_tree,
fpg_panel,
dom, XMLWrite, XMLRead, contnrs, model;
type
TMainForm = class(TfpgForm)
private
FFile: TDescDocument;
FDescriptionNode: TDomNode;
FDoc: TXMLDocument;
FModified: Boolean;
CurrentModule: TDomElement;
FModuleTree: TObjectList;
FElementTree: TObjectList;
procedure btnQuitClicked(Sender: TObject);
procedure miFileQuitClicked(Sender: TObject);
procedure miFileOpenClicked(Sender: TObject);
procedure miFileSaveAsClicked(Sender: TObject);
procedure miHelpAboutClicked(Sender: TObject);
procedure miExtraOptionsClicked(Sender: TObject);
procedure GetElementList(List: TStrings);
public
{@VFD_HEAD_BEGIN: MainForm}
menubar: TfpgMenuBar;
miFile: TfpgPopupMenu;
miInsert: TfpgPopupMenu;
miExtra: TfpgPopupMenu;
miHelp: TfpgPopupMenu;
btnQuit: TfpgButton;
tvXML: TfpgTreeView;
pnlName1: TfpgBevel;
lblFilename: TfpgLabel;
{@VFD_HEAD_END: MainForm}
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure AfterCreate; override;
property DescriptionNode: TDomNode read FDescriptionNode write FDescriptionNode;
end;
{@VFD_NEWFORM_DECL}
implementation
uses
fpg_dialogs, frm_options;
const
cAppName = 'FPDoc Documentation Editor';
type
TNodeTreeItem = class(TObjectList)
private
FNode: TDomElement;
public
constructor Create(ANode: TDomElement); virtual;
procedure CheckSubItems;
property Node: TDomElement Read FNode;
end;
TModuleTreeItem = class(TNodeTreeItem);
TTopicTreeItem = class(TNodeTreeItem);
TPackageTreeItem = class(TNodeTreeItem);
{@VFD_NEWFORM_IMPL}
{ TNodeTreeItem }
constructor TNodeTreeItem.Create(ANode: TDomElement);
begin
inherited Create(false);
FNode := ANode;
end;
procedure TNodeTreeItem.CheckSubItems;
begin
// If (SubTree=Nil) then
// SubTree:=TFPgtkTree.Create;
end;
{ TMainForm }
procedure TMainForm.btnQuitClicked(Sender: TObject);
begin
Close;
end;
procedure TMainForm.miFileQuitClicked(Sender: TObject);
begin
Close;
end;
procedure TMainForm.miFileOpenClicked(Sender: TObject);
var
dlg: TfpgFileDialog;
begin
dlg := TfpgFileDialog.Create(nil);
try
dlg.Filter := 'FPDoc Desc Files (*.xml)|*.xml|All Files (*)|*';
if dlg.RunOpenFile then
begin
lblFilename.Text := dlg.FileName;
FFile := TDescDocument.Create(dlg.Filename);
// ProcessXMLFile(dlg.FileName);
end
finally
dlg.Free;
end;
end;
procedure TMainForm.miFileSaveAsClicked(Sender: TObject);
var
dlg: TfpgFileDialog;
begin
dlg := TfpgFileDialog.Create(nil);
try
dlg.Filter := 'FPDoc Desc Files (*.xml)|*.xml|All Files (*)|*';
dlg.FileName := lblFilename.Text;
if dlg.RunSaveFile then
lblFilename.Text := dlg.FileName;
finally
dlg.Free;
end;
end;
procedure TMainForm.miHelpAboutClicked(Sender: TObject);
begin
ShowMessage(cAppName
+ #10
+ #10 + 'Written by Graeme Geldenhuys - 2007'
+ #10 + 'Using the ' + fpGUIName + ' v' + fpGUI_Version
,'About');
end;
procedure TMainForm.miExtraOptionsClicked(Sender: TObject);
var
frm: TfrmOptions;
begin
frm := TfrmOptions.Create(nil);
try
frm.ShowModal;
finally
frm.Free;
end;
end;
procedure TMainForm.GetElementList(List: TStrings);
var
N: TDOMNode;
begin
with List do
begin
Clear;
if Assigned(CurrentModule) then
begin
N := Currentmodule.FirstChild;
while (N <> Nil) do
begin
if (N is TDomElement) and (N.NodeName = 'element') then
Add(TDomElement(N)['name']);
N := N.NextSibling;
end;
end;
end;
end;
constructor TMainForm.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
WindowTitle := cAppName;
Sizeable := False;
FModuleTree := TObjectList.Create;
FElementTree := TObjectList.Create;
end;
destructor TMainForm.Destroy;
begin
FModuleTree.Free;
FElementTree.Free;
inherited Destroy;
end;
procedure TMainForm.AfterCreate;
begin
{@VFD_BODY_BEGIN: MainForm}
Name := 'MainForm';
SetPosition(346, 279, 650, 402);
WindowTitle := 'fpGUI Documentation Editor';
WindowPosition := wpScreenCenter;
menubar := TfpgMenuBar.Create(self);
with menubar do
begin
Name := 'menubar';
SetPosition(0, 0, 650, 23);
Anchors := [anLeft,anRight,anTop];
end;
miFile := TfpgPopupMenu.Create(self);
with miFile do
begin
Name := 'miFile';
SetPosition(464, 169, 160, 24);
AddMenuItem('&New...', 'Ctrl-N', nil);
AddMenuItem('&Open..', 'Ctrl-O', @miFileOpenClicked);
AddMenuItem('&Save', 'Ctrl-S', nil);
AddMenuItem('S&ave As..', 'Ctrl+Shift+S', @miFileSaveAsClicked);
AddMenuItem('-', '', nil);
AddMenuItem('&Close', 'Ctrl-W', nil);
AddMenuItem('&Recent', '', nil);
AddMenuItem('-', '', nil);
AddMenuItem('&Quit', 'Ctrl-Q', @miFileQuitClicked);
end;
miInsert := TfpgPopupMenu.Create(self);
with miInsert do
begin
Name := 'miInsert';
SetPosition(464, 190, 160, 24);
AddMenuItem('&Package', '', nil);
AddMenuItem('&Module', '', nil);
AddMenuItem('&Topic', '', nil);
AddMenuItem('&Element', '', nil);
AddMenuItem('&Link', '', nil);
AddMenuItem('T&able', '', nil);
AddMenuItem('&Short Desc Link', '', nil);
end;
miExtra := TfpgPopupMenu.Create(self);
with miExtra do
begin
Name := 'miExtra';
SetPosition(464, 211, 160, 24);
AddMenuItem('&Options...', '', @miExtraOptionsClicked);
AddMenuItem('&Build...', '', nil);
end;
miHelp := TfpgPopupMenu.Create(self);
with miHelp do
begin
Name := 'miHelp';
SetPosition(464, 232, 160, 24);
AddMenuItem('About...', '', @miHelpAboutClicked);
end;
btnQuit := TfpgButton.Create(self);
with btnQuit do
begin
Name := 'btnQuit';
SetPosition(566, 350, 75, 23);
Anchors := [anRight,anBottom];
Text := 'Quit';
FontDesc := '#Label1';
ImageName := 'stdimg.Quit';
ModalResult := 0;
ShowImage := True;
OnClick := @btnQuitClicked;
end;
tvXML := TfpgTreeView.Create(self);
with tvXML do
begin
Name := 'tvXML';
SetPosition(4, 28, 226, 340);
FontDesc := '#Label1';
DefaultColumnWidth := 15;
TreeLineStyle := lsDot;
ScrollWheelDelta := 15;
end;
pnlName1 := TfpgBevel.Create(self);
with pnlName1 do
begin
Name := 'pnlName1';
SetPosition(0, 381, 650, 20);
Anchors := [anLeft,anRight,anBottom];
Shape := bsBox;
Style := bsLowered;
Focusable := False;
end;
lblFilename := TfpgLabel.Create(pnlName1);
with lblFilename do
begin
Name := 'lblFilename';
SetPosition(6, 2, 636, 16);
Anchors := [anLeft,anRight,anTop];
Text := '<filename>';
FontDesc := '#Label1';
end;
{@VFD_BODY_END: MainForm}
menubar.AddMenuItem('&File', nil).SubMenu := miFile;
menubar.AddMenuItem('&Insert', nil).SubMenu := miInsert;
menubar.AddMenuItem('&Extra', nil).SubMenu := miExtra;
menubar.AddMenuItem('&Help', nil).SubMenu := miHelp;
end;
end.
|