-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathEditBone.Form.Options.pas
685 lines (640 loc) · 24.7 KB
/
EditBone.Form.Options.pas
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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
unit EditBone.Form.Options;
interface
uses
Vcl.Graphics, Vcl.Controls, Vcl.Forms, BCCommon.FileUtils, Vcl.StdCtrls, Vcl.ComCtrls, Vcl.ExtCtrls, Vcl.Buttons,
System.Classes, System.SysUtils, Vcl.ActnList, BCCommon.Images, BCCommon.Frames.Options.Editor.Color,
Vcl.ActnMenus, System.Actions, VirtualTrees, BCCommon.Options.Container, System.Generics.Collections,
sSkinProvider, sScrollBox, BCControls.ScrollBox, BCControls.Splitter, sSplitter, sPanel, BCControls.Panel;
type
POptionsRec = ^TOptionsRec;
TOptionsRec = record
Index: Integer;
Caption: string;
ImageIndex: Integer;
end;
TOptionsForm = class(TForm)
ActionCompare: TAction;
ActionDirectory: TAction;
ActionDirectoryTabs: TAction;
ActionEditor: TAction;
ActionEditorCaret: TAction;
ActionEditorCodeFolding: TAction;
ActionEditorColors: TAction;
ActionEditorCompletionProposal: TAction;
ActionEditorDefaults: TAction;
ActionEditorFonts: TAction;
ActionEditorLeftMargin: TAction;
ActionEditorMatchingPair: TAction;
ActionEditorMinimap: TAction;
ActionEditorRightMargin: TAction;
ActionEditorScroll: TAction;
ActionEditorSearch: TAction;
ActionEditorSelection: TAction;
ActionEditorSpecialChars: TAction;
ActionEditorTabs: TAction;
ActionEditorTabulator: TAction;
ActionFileTypes: TAction;
ActionList: TActionList;
ActionMainMenu: TAction;
ActionOutput: TAction;
ActionOutputTabs: TAction;
ActionPrint: TAction;
ActionSQLAlignments: TAction;
ActionSQLCapitalization: TAction;
ActionSQLFormatter: TAction;
ActionSQLIndentation: TAction;
ActionSQLInsert: TAction;
ActionSQLSelect: TAction;
ActionSQLUpdate: TAction;
ActionSQLWhitespace: TAction;
ActionStatusBar: TAction;
ActionToolbar: TAction;
ButtonCancel: TButton;
ButtonOK: TButton;
OptionsPanel: TBCPanel;
PanelButton: TBCPanel;
PanelTop: TBCPanel;
ScrollBox: TBCScrollBox;
SkinProvider: TsSkinProvider;
Splitter: TBCSplitter;
VirtualDrawTreeOptions: TVirtualDrawTree;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure VirtualDrawTreeOptionsClick(Sender: TObject);
procedure VirtualDrawTreeOptionsFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
procedure VirtualDrawTreeOptionsGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex; var Ghosted: Boolean; var ImageIndex: Integer);
procedure VirtualDrawTreeOptionsDrawNode(Sender: TBaseVirtualTree; const PaintInfo: TVTPaintInfo);
procedure VirtualDrawTreeOptionsGetNodeWidth(Sender: TBaseVirtualTree; HintCanvas: TCanvas; Node: PVirtualNode;
Column: TColumnIndex; var NodeWidth: Integer);
procedure VirtualDrawTreeOptionsKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
private
FActionList: TObjectList<TAction>;
FSQLFormatterDLLFound: Boolean;
procedure CreateTree;
procedure ReadIniFile;
procedure SaveSelectedTreeNode;
procedure SetVisibleFrame;
procedure WriteIniFile;
public
function Execute(ActionList: TObjectList<TAction>): Boolean;
end;
function OptionsForm: TOptionsForm;
implementation
{$R *.dfm}
uses
BCCommon.Language.Strings, System.IniFiles, BCCommon.Language.Utils, BCCommon.Utils, Winapi.Windows,
System.Types, BCCommon.Frames.Options.Editor.Minimap, BCCommon.Frames.Options.Editor.Scroll,
BCCommon.Frames.Options.Editor.Selection, BCCommon.Frames.Options.Editor.SpecialChars,
BCCommon.Frames.Options.Editor.Tabulator, EditBone.Frame.Options.Editor.Defaults,
BCCommon.Options.Container.SQL.Formatter, EditBone.Frame.Options.Editor.TabSheet,
BCCommon.Frames.Options.Editor.CompletionProposal, BCCommon.Frames.Options.Editor.Caret,
BCCommon.Frames.Options.Editor.CodeFolding, BCCommon.Frames.Options.Editor.MatchingPair,
BCCommon.Frames.Options.Editor.Search, BCCommon.Frames.Options.Editor.Options, BCCommon.Frames.Options.Editor.Font,
BCCommon.Frames.Options.Editor.LeftMargin, BCCommon.Frames.Options.Editor.RightMargin,
EditBone.Frame.Options.FileTypes, EditBone.Frame.Options.Directory, EditBone.Frame.Options.Directory.TabSheet,
EditBone.Frame.Options.Output.TabSheet, BCCommon.Frames.Options.Compare,
BCCommon.Frames.Options.MainMenu, BCCommon.Frames.Options.StatusBar, BCCommon.Frames.Options.Output,
BCCommon.Frames.Options.Toolbar, BCCommon.Frames.Options.Print, BCCommon.Frames.Options.SQL.Select,
BCCommon.Frames.Options.SQL.Alignments, BCCommon.Frames.Options.SQL.Insert, BCCommon.Frames.Options.SQL.Update,
BCCommon.Frames.Options.SQL.Whitespace, BCCommon.Frames.Options.SQL.Capitalization,
BCCommon.Frames.Options.SQL.Indentation, BCCommon.Frames.Options.SQL.Formatter;
var
FOptionsForm: TOptionsForm;
{ TOptionsDialog }
function OptionsForm: TOptionsForm;
begin
if not Assigned(FOptionsForm) then
Application.CreateForm(TOptionsForm, FOptionsForm);
Result := FOptionsForm;
end;
procedure TOptionsForm.FormDestroy(Sender: TObject);
begin
FOptionsForm := nil;
end;
procedure TOptionsForm.CreateTree;
var
i: Integer;
Data: POptionsRec;
Node, ChildNode: PVirtualNode;
begin
with VirtualDrawTreeOptions do
begin
Clear;
i := 0;
{ Editor }
Node := AddChild(nil);
Data := GetNodeData(Node);
Data.Index := PostInc(i);
Data.ImageIndex := ActionEditor.ImageIndex;
Data.Caption := ActionEditor.Caption;
{ Editor caret }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionEditorCaret.ImageIndex;
Data.Caption := ActionEditorCaret.Caption;
{ Editor code folding }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionEditorCodeFolding.ImageIndex;
Data.Caption := ActionEditorCodeFolding.Caption;
{ Editor color }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionEditorColors.ImageIndex;
Data.Caption := ActionEditorColors.Caption;
{ Editor completion proposal }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionEditorCompletionProposal.ImageIndex;
Data.Caption := ActionEditorCompletionProposal.Caption;
{ Editor defaults }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionEditorDefaults.ImageIndex;
Data.Caption := ActionEditorDefaults.Caption;
{ Editor font }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionEditorFonts.ImageIndex;
Data.Caption := ActionEditorFonts.Caption;
{ Editor left margin }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionEditorLeftMargin.ImageIndex;
Data.Caption := ActionEditorLeftMargin.Caption;
{ Editor matching pair }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionEditorMatchingPair.ImageIndex;
Data.Caption := ActionEditorMatchingPair.Caption;
{ Editor minimap }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionEditorMinimap.ImageIndex;
Data.Caption := ActionEditorMinimap.Caption;
{ Editor right margin }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionEditorRightMargin.ImageIndex;
Data.Caption := ActionEditorRightMargin.Caption;
{ Editor scroll }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionEditorScroll.ImageIndex;
Data.Caption := ActionEditorScroll.Caption;
{ Editor search }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionEditorSearch.ImageIndex;
Data.Caption := ActionEditorSearch.Caption;
{ Editor selection }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionEditorSelection.ImageIndex;
Data.Caption := ActionEditorSelection.Caption;
{ Editor special chars }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionEditorSpecialChars.ImageIndex;
Data.Caption := ActionEditorSpecialChars.Caption;
{ Editor tabs }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionEditorTabs.ImageIndex;
Data.Caption := ActionEditorTabs.Caption;
{ Editor tabulator }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionEditorTabulator.ImageIndex;
Data.Caption := ActionEditorTabulator.Caption;
Node.ChildCount := VirtualDrawTreeOptions.ChildCount[Node];
VirtualDrawTreeOptions.Selected[Node] := True;
VirtualDrawTreeOptions.Expanded[Node] := True;
{ Directory }
Node := AddChild(nil);
Data := GetNodeData(Node);
Data.Index := PostInc(i);
Data.ImageIndex := ActionDirectory.ImageIndex;
Data.Caption := ActionDirectory.Caption;
{ Directory tabs }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionDirectoryTabs.ImageIndex;
Data.Caption := ActionDirectoryTabs.Caption;
Node.ChildCount := VirtualDrawTreeOptions.ChildCount[Node];
VirtualDrawTreeOptions.Selected[Node] := True;
VirtualDrawTreeOptions.Expanded[Node] := True;
{ Output }
Node := AddChild(nil);
Data := GetNodeData(Node);
Data.Index := PostInc(i);
Data.ImageIndex := ActionOutput.ImageIndex;
Data.Caption := ActionOutput.Caption;
{ Output tabs }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionOutputTabs.ImageIndex;
Data.Caption := ActionOutputTabs.Caption;
Node.ChildCount := VirtualDrawTreeOptions.ChildCount[Node];
VirtualDrawTreeOptions.Selected[Node] := True;
VirtualDrawTreeOptions.Expanded[Node] := True;
{ Compare }
Node := AddChild(nil);
Data := GetNodeData(Node);
Data.Index := PostInc(i);
Data.ImageIndex := ActionCompare.ImageIndex;
Data.Caption := ActionCompare.Caption;
{ Print }
Node := AddChild(nil);
Data := GetNodeData(Node);
Data.Index := PostInc(i);
Data.ImageIndex := ActionPrint.ImageIndex;
Data.Caption := ActionPrint.Caption;
{ Main menu }
Node := AddChild(nil);
Data := GetNodeData(Node);
Data.Index := PostInc(i);
Data.ImageIndex := ActionMainMenu.ImageIndex;
Data.Caption := ActionMainMenu.Caption;
{ Toolbar }
Node := AddChild(nil);
Data := GetNodeData(Node);
Data.Index := PostInc(i);
Data.ImageIndex := ActionToolbar.ImageIndex;
Data.Caption := ActionToolbar.Caption;
{ Status Bar }
Node := AddChild(nil);
Data := GetNodeData(Node);
Data.Index := PostInc(i);
Data.ImageIndex := ActionStatusBar.ImageIndex;
Data.Caption := ActionStatusBar.Caption;
{ File types }
Node := AddChild(nil);
Data := GetNodeData(Node);
Data.Index := PostInc(i);
Data.ImageIndex := ActionFileTypes.ImageIndex;
Data.Caption := ActionFileTypes.Caption;
if FSQLFormatterDLLFound then
begin
{ SQL Formatter }
Node := AddChild(nil);
Data := GetNodeData(Node);
Data.Index := PostInc(i);
Data.ImageIndex := ActionSQLFormatter.ImageIndex;
Data.Caption := ActionSQLFormatter.Caption;
{ Alignments }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionSQLAlignments.ImageIndex;
Data.Caption := ActionSQLAlignments.Caption;
{ Capitalization }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionSQLCapitalization.ImageIndex;
Data.Caption := ActionSQLCapitalization.Caption;
{ Indentation }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionSQLIndentation.ImageIndex;
Data.Caption := ActionSQLIndentation.Caption;
{ Insert }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionSQLInsert.ImageIndex;
Data.Caption := ActionSQLInsert.Caption;
{ Select }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionSQLSelect.ImageIndex;
Data.Caption := ActionSQLSelect.Caption;
{ Update }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionSQLUpdate.ImageIndex;
Data.Caption := ActionSQLUpdate.Caption;
{ Whitespace }
ChildNode := AddChild(Node);
Data := GetNodeData(ChildNode);
Data.Index := PostInc(i);
Data.ImageIndex := ActionSQLWhitespace.ImageIndex;
Data.Caption := ActionSQLWhitespace.Caption;
//Node.ChildCount := 7;
Node.ChildCount := VirtualDrawTreeOptions.ChildCount[Node];
VirtualDrawTreeOptions.Selected[Node] := True;
VirtualDrawTreeOptions.Expanded[Node] := True;
end;
VirtualDrawTreeOptions.Selected[VirtualDrawTreeOptions.GetFirst] := True;
end;
end;
function TOptionsForm.Execute(ActionList: TObjectList<TAction>): Boolean;
begin
FActionList := ActionList;
try
ReadIniFile;
UpdateLanguage(Self, GetSelectedLanguage);
Result := Showmodal = mrOk;
WriteIniFile;
SaveSelectedTreeNode;
finally
Free;
end;
if Result then
SQLFormatterOptionsContainer.WriteIniFile; { this is written here because dll is reading settings from the ini file }
end;
procedure TOptionsForm.SaveSelectedTreeNode;
var
Node: PVirtualNode;
Data: POptionsRec;
begin
with TIniFile.Create(GetIniFilename) do
try
Node := VirtualDrawTreeOptions.GetFirstSelected;
Data := VirtualDrawTreeOptions.GetNodeData(Node);
WriteInteger('Options', 'OptionsSelectedItemIndex', Data.Index);
finally
Free;
end;
end;
procedure TOptionsForm.VirtualDrawTreeOptionsClick(Sender: TObject);
begin
SetVisibleFrame;
end;
procedure TOptionsForm.VirtualDrawTreeOptionsDrawNode(Sender: TBaseVirtualTree; const PaintInfo: TVTPaintInfo);
var
Data: POptionsRec;
S: string;
R: TRect;
Format: Cardinal;
begin
with Sender as TVirtualDrawTree, PaintInfo do
begin
Data := Sender.GetNodeData(Node);
if not Assigned(Data) then
Exit;
if Assigned(SkinProvider.SkinData) and Assigned(SkinProvider.SkinData.SkinManager) then
Canvas.Font.Color := SkinProvider.SkinData.SkinManager.GetActiveEditFontColor
else
Canvas.Font.Color := clWindowText;
if vsSelected in PaintInfo.Node.States then
begin
if Assigned(SkinProvider.SkinData) and Assigned(SkinProvider.SkinData.SkinManager) then
begin
Canvas.Brush.Color := SkinProvider.SkinData.SkinManager.GetHighLightColor;
Canvas.Font.Color := SkinProvider.SkinData.SkinManager.GetHighLightFontColor
end
else
begin
Canvas.Brush.Color := clHighlight;
Canvas.Font.Color := clHighlightText;
end;
end;
SetBKMode(Canvas.Handle, TRANSPARENT);
R := ContentRect;
InflateRect(R, -TextMargin, 0);
Dec(R.Right);
Dec(R.Bottom);
S := Data.Caption;
if Length(S) > 0 then
begin
Format := DT_TOP or DT_LEFT or DT_VCENTER or DT_SINGLELINE;
DrawText(Canvas.Handle, S, Length(S), R, Format)
end;
end;
end;
procedure TOptionsForm.SetVisibleFrame;
var
i, Level, ParentIndex: Integer;
TreeNode: PVirtualNode;
begin
inherited;
TreeNode := VirtualDrawTreeOptions.GetFirstSelected;
if Assigned(TreeNode) then
begin
Level := VirtualDrawTreeOptions.GetNodeLevel(TreeNode);
ParentIndex := -1;
if Level = 1 then
ParentIndex := TreeNode.Parent.Index;
for i := 0 to ComponentCount - 1 do
if Components[i] is TFrame then
(Components[i] as TFrame).Hide;
{ don't set the visibility value with the condition because the frame is created }
if (Level = 0) and (TreeNode.Index = 0) then
OptionsEditorOptionsFrame(Self).ShowFrame;
if (ParentIndex = 0) and (Level = 1) and (TreeNode.Index = 0) then
OptionsEditorCaretFrame(Self).ShowFrame;
if (ParentIndex = 0) and (Level = 1) and (TreeNode.Index = 1) then
OptionsEditorCodeFoldingFrame(Self).ShowFrame;
if (ParentIndex = 0) and (Level = 1) and (TreeNode.Index = 2) then
OptionsEditorColorFrame(Self).ShowFrame;
if (ParentIndex = 0) and (Level = 1) and (TreeNode.Index = 3) then
OptionsEditorCompletionProposalFrame(Self).ShowFrame;
if (ParentIndex = 0) and (Level = 1) and (TreeNode.Index = 4) then
OptionsEditorDefaultsFrame(Self).ShowFrame;
if (ParentIndex = 0) and (Level = 1) and (TreeNode.Index = 5) then
OptionsEditorFontFrame(Self).ShowFrame;
if (ParentIndex = 0) and (Level = 1) and (TreeNode.Index = 6) then
OptionsEditorLeftMarginFrame(Self).ShowFrame;
if (ParentIndex = 0) and (Level = 1) and (TreeNode.Index = 7) then
OptionsEditorMatchingPairFrame(Self).ShowFrame;
if (ParentIndex = 0) and (Level = 1) and (TreeNode.Index = 8) then
OptionsEditorMinimapFrame(Self).ShowFrame;
if (ParentIndex = 0) and (Level = 1) and (TreeNode.Index = 9) then
OptionsEditorRightMarginFrame(Self).ShowFrame;
if (ParentIndex = 0) and (Level = 1) and (TreeNode.Index = 10) then
OptionsEditorScrollFrame(Self).ShowFrame;
if (ParentIndex = 0) and (Level = 1) and (TreeNode.Index = 11) then
OptionsEditorSearchFrame(Self).ShowFrame;
if (ParentIndex = 0) and (Level = 1) and (TreeNode.Index = 12) then
OptionsEditorSelectionFrame(Self).ShowFrame;
if (ParentIndex = 0) and (Level = 1) and (TreeNode.Index = 13) then
OptionsEditorSpecialCharsFrame(Self).ShowFrame;
if (ParentIndex = 0) and (Level = 1) and (TreeNode.Index = 14) then
OptionsEditorTabsFrame(Self).ShowFrame;
if (ParentIndex = 0) and (Level = 1) and (TreeNode.Index = 15) then
OptionsEditorTabulatorFrame(Self).ShowFrame;
if (Level = 0) and (TreeNode.Index = 1) then
OptionsDirectoryFrame(Self).ShowFrame;
if (ParentIndex = 1) and (Level = 1) and (TreeNode.Index = 0) then
OptionsDirectoryTabsFrame(Self).ShowFrame;
if (Level = 0) and (TreeNode.Index = 2) then
OptionsOutputFrame(Self).ShowFrame;
if (ParentIndex = 2) and (Level = 1) and (TreeNode.Index = 0) then
OptionsOutputTabsFrame(Self).ShowFrame;
if (Level = 0) and (TreeNode.Index = 3) then
OptionsCompareFrame(Self).ShowFrame;
if (Level = 0) and (TreeNode.Index = 4) then
OptionsPrintFrame(Self).ShowFrame;
if (Level = 0) and (TreeNode.Index = 5) then
OptionsMainMenuFrame(Self).ShowFrame;
if (Level = 0) and (TreeNode.Index = 6) then
OptionsToolbarFrame(Self, FActionList).Show;
if (Level = 0) and (TreeNode.Index = 7) then
OptionsStatusBarFrame(Self).ShowFrame;
if (Level = 0) and (TreeNode.Index = 8) then
OptionsFileTypesFrame(Self).ShowFrame;
if FSQLFormatterDLLFound then
begin
{ SQL Formatter options }
if (Level = 0) and (TreeNode.Index = 9) then
OptionsSQLFormatterFrame(Self).ShowFrame;
if (ParentIndex = 9) and (Level = 1) and (TreeNode.Index = 0) then
OptionsSQLAlignmentsFrame(Self).ShowFrame;
if (ParentIndex = 9) and (Level = 1) and (TreeNode.Index = 1) then
OptionsSQLCapitalizationFrame(Self).ShowFrame;
if (ParentIndex = 9) and (Level = 1) and (TreeNode.Index = 2) then
OptionsSQLIndentationFrame(Self).ShowFrame;
if (ParentIndex = 9) and (Level = 1) and (TreeNode.Index = 3) then
OptionsSQLInsertFrame(Self).ShowFrame;
if (ParentIndex = 9) and (Level = 1) and (TreeNode.Index = 4) then
OptionsSQLSelectFrame(Self).ShowFrame;
if (ParentIndex = 9) and (Level = 1) and (TreeNode.Index = 5) then
OptionsSQLUpdateFrame(Self).ShowFrame;
if (ParentIndex = 9) and (Level = 1) and (TreeNode.Index = 6) then
OptionsSQLWhitespaceFrame(Self).ShowFrame;
end;
end;
end;
procedure TOptionsForm.VirtualDrawTreeOptionsFreeNode(Sender: TBaseVirtualTree;
Node: PVirtualNode);
var
Data: POptionsRec;
begin
Data := Sender.GetNodeData(Node);
Finalize(Data^);
inherited;
end;
procedure TOptionsForm.VirtualDrawTreeOptionsGetImageIndex(Sender: TBaseVirtualTree;
Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex; var Ghosted: Boolean;
var ImageIndex: Integer);
var
Data: POptionsRec;
begin
inherited;
if not (Kind in [ikNormal, ikSelected]) then
Exit;
Data := Sender.GetNodeData(Node);
if Assigned(Data) then
ImageIndex := Data.ImageIndex;
end;
procedure TOptionsForm.VirtualDrawTreeOptionsGetNodeWidth(Sender: TBaseVirtualTree; HintCanvas: TCanvas;
Node: PVirtualNode; Column: TColumnIndex; var NodeWidth: Integer);
var
Data: POptionsRec;
begin
Data := Sender.GetNodeData(Node);
if Assigned(Data) then
NodeWidth := Canvas.TextWidth(Trim(Data.Caption)) + 2;
end;
procedure TOptionsForm.VirtualDrawTreeOptionsKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
SetVisibleFrame;
end;
procedure TOptionsForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
OptionsContainer.SupportedFileExtensions(True);
end;
procedure TOptionsForm.ReadIniFile;
begin
with TMemIniFile.Create(GetIniFilename) do
try
{ Size }
Width := ReadInteger('OptionsSize', 'Width', Width);
Height := ReadInteger('OptionsSize', 'Height', Height);
{ Position }
Left := ReadInteger('OptionsPosition', 'Left', (Screen.Width - Width) div 2);
Top := ReadInteger('OptionsPosition', 'Top', (Screen.Height - Height) div 2);
{ Check if the form is outside the workarea }
Left := SetFormInsideWorkArea(Left, Width);
{ Tree width }
VirtualDrawTreeOptions.Width := ReadInteger('OptionsSize', 'TreeWidth', VirtualDrawTreeOptions.Width);
finally
Free;
end;
end;
procedure TOptionsForm.WriteIniFile;
begin
if Windowstate = wsNormal then
with TMemIniFile.Create(GetIniFilename) do
try
{ Size }
WriteInteger('OptionsSize', 'Width', Width);
WriteInteger('OptionsSize', 'Height', Height);
{ Position }
WriteInteger('OptionsPosition', 'Left', Left);
WriteInteger('OptionsPosition', 'Top', Top);
{ Tree width }
WriteInteger('OptionsSize', 'TreeWidth', VirtualDrawTreeOptions.Width);
finally
UpdateFile;
Free;
end;
end;
procedure TOptionsForm.FormCreate(Sender: TObject);
begin
VirtualDrawTreeOptions.NodeDataSize := SizeOf(TOptionsRec);
{ IDE can lose these properties }
ActionList.Images := ImagesDataModule.ImageListSmall;
VirtualDrawTreeOptions.Images := ImagesDataModule.ImageListSmall;
FSQLFormatterDLLFound := FileExists(GetSQLFormatterDLLFilename);
end;
procedure TOptionsForm.FormShow(Sender: TObject);
var
SelectedItemIndex: Integer;
Node: PVirtualNode;
function FindItem(CurrentNode: PVirtualNode; ItemIndex: Integer): PVirtualNode;
var
Data: POptionsRec;
begin
Data := VirtualDrawTreeOptions.GetNodeData(CurrentNode);
while Assigned(CurrentNode) and (Data.Index <> ItemIndex) do
begin
CurrentNode := VirtualDrawTreeOptions.GetNext(CurrentNode);
Data := VirtualDrawTreeOptions.GetNodeData(CurrentNode);
end;
Result := CurrentNode;
end;
begin
inherited;
CreateTree;
with TIniFile.Create(GetIniFilename) do
try
SelectedItemIndex := ReadInteger('Options', 'OptionsSelectedItemIndex', 0);
finally
Free;
end;
Node := FindItem(VirtualDrawTreeOptions.GetFirst, SelectedItemIndex);
if Assigned(Node) then
begin
VirtualDrawTreeOptions.Selected[Node] := True;
VirtualDrawTreeOptions.ScrollIntoView(Node, True);
end;
SetVisibleFrame;
end;
end.