-
Notifications
You must be signed in to change notification settings - Fork 261
/
Copy pathVirtualTrees.BaseTree.pas
22651 lines (19239 loc) · 852 KB
/
VirtualTrees.BaseTree.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
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit VirtualTrees.BaseTree;
interface
{$if CompilerVersion < 24}{$MESSAGE FATAL 'This version supports only RAD Studio XE3 and higher. Please use V5 from http://www.jam-software.com/virtual-treeview/VirtualTreeViewV5.5.3.zip or https://github.com/Virtual-TreeView/Virtual-TreeView/archive/V5_stable.zip'}{$ifend}
{$booleval off} // Use fastest possible boolean evaluation
// For some things to work we need code, which is classified as being unsafe for .NET.
{$WARN UNSAFE_TYPE OFF}
{$WARN UNSAFE_CAST OFF}
{$WARN UNSAFE_CODE OFF}
{$LEGACYIFEND ON}
{$WARN UNSUPPORTED_CONSTRUCT OFF}
{$HPPEMIT '#include <objidl.h>'}
{$HPPEMIT '#include <oleidl.h>'}
{$HPPEMIT '#include <oleacc.h>'}
{$ifdef BCB}
{$HPPEMIT '#pragma comment(lib, "VirtualTreesCR")'}
{$else}
{$HPPEMIT '#pragma comment(lib, "VirtualTreesR")'}
{$endif}
{$HPPEMIT '#pragma comment(lib, "Shell32")'}
{$HPPEMIT '#pragma comment(lib, "uxtheme")'}
{$HPPEMIT '#pragma link "VirtualTrees.Accessibility"'}
uses
Winapi.Windows, Winapi.Messages, Winapi.ActiveX, Winapi.CommCtrl,
Winapi.UxTheme, Winapi.ShlObj,
System.SysUtils, System.Classes, System.Types,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.ImgList, Vcl.StdCtrls,
Vcl.Menus, Vcl.Printers, Vcl.Themes,
System.UITypes, // some types moved from Vcl.* to System.UITypes
VirtualTrees.Types,
VirtualTrees.Colors,
VirtualTrees.DragImage,
VirtualTrees.Header
{$IFDEF VT_FMX}
, VirtualTrees.BaseAncestorFMX
{$ELSE}
, VirtualTrees.BaseAncestorVCL
{$ENDIF}
;
{$MinEnumSize 1, make enumerations as small as possible}
type
{$IFDEF VT_FMX}
TVTBaseAncestor = TVTBaseAncestorFMX;
TCanvas = FMX.Graphics.TCanvas;
{$ELSE}
TVTBaseAncestor = TVTBaseAncestorVcl;
TCanvas = Vcl.Graphics.TCanvas;
TFormatEtcArray = VirtualTrees.Types.TFormatEtcArray;
{$ENDIF}
// Alias defintions for convenience
TImageIndex = System.UITypes.TImageIndex;
//these were moved, aliases are for backwards compatibility.
//some may be removed once we sort out excactly what is needed.
TDimension = VirtualTrees.Types.TDimension;
TColumnIndex = VirtualTrees.Types.TColumnIndex;
TColumnPosition = VirtualTrees.Types.TColumnPosition;
EVirtualTreeError = VirtualTrees.Types.EVirtualTreeError;
TAutoScrollInterval = VirtualTrees.Types.TAutoScrollInterval;
TVTScrollIncrement = VirtualTrees.Types.TVTScrollIncrement;
TFormatArray = VirtualTrees.Types.TFormatArray;
TVTPaintOption = VirtualTrees.Types.TVTPaintOption;
TVTPaintOptions = VirtualTrees.Types.TVTPaintOptions;
TVTAnimateOption = VirtualTrees.Types.TVTAnimationOption;
TVTAnimateOptions = VirtualTrees.Types.TVTAnimationOptions;
TVTAutoOption = VirtualTrees.Types.TVTAutoOption;
TVTAutoOptions = VirtualTrees.Types.TVTAutoOptions;
TVTSelectionOption = VirtualTrees.Types.TVTSelectionOption;
TVTSelectionOptions = VirtualTrees.Types.TVTSelectionOptions;
TVTEditOptions = VirtualTrees.Types.TVTEditOptions;
TVTMiscOption = VirtualTrees.Types.TVTMiscOption;
TVTMiscOptions = VirtualTrees.Types.TVTMiscOptions;
TVTExportMode = VirtualTrees.Types.TVTExportMode;
TVTStringOption = VirtualTrees.Types.TVTStringOption;
TVTStringOptions = VirtualTrees.Types.TVTStringOptions;
TCustomVirtualTreeOptions= VirtualTrees.Types.TCustomVirtualTreeOptions;
TVirtualTreeOptions = VirtualTrees.Types.TVirtualTreeOptions;
TTreeOptionsClass = VirtualTrees.Types.TTreeOptionsClass;
TCustomStringTreeOptions = VirtualTrees.Types.TCustomStringTreeOptions;
TStringTreeOptions = VirtualTrees.Types.TStringTreeOptions;
TScrollBarStyle = VirtualTrees.Types.TScrollBarStyle;
TScrollBarOptions = VirtualTrees.Types.TScrollBarOptions;
TVTColumnOption = VirtualTrees.Types.TVTColumnOption;
TVTColumnOptions = VirtualTrees.Types.TVTColumnOptions;
TVirtualTreeColumnStyle = VirtualTrees.Types.TVirtualTreeColumnStyle;
TSortDirection = VirtualTrees.Types.TSortDirection;
TCheckType = VirtualTrees.Types.TCheckType;
TCheckState = VirtualTrees.Types.TCheckState;
TVTDropMarkMode = VirtualTrees.Types.TVTDropMarkMode;
TScrollDirections = VirtualTrees.Types.TScrollDirections;
TVirtualTreeColumn = VirtualTrees.Header.TVirtualTreeColumn;
TVirtualTreeColumns = VirtualTrees.Header.TVirtualTreeColumns;
TVirtualTreeColumnClass = VirtualTrees.Header.TVirtualTreeColumnClass;
TColumnsArray = VirtualTrees.Header.TColumnsArray;
TCardinalArray = VirtualTrees.Header.TCardinalArray;
TIndexArray = VirtualTrees.Header.TIndexArray;
TVTColors = VirtualTrees.Colors.TVTColors;
//
type
TBaseVirtualTree = class;
TVirtualTreeClass = class of TBaseVirtualTree;
// This record must already be defined here and not later because otherwise BCB users will not be able
// to compile (conversion done by BCB is wrong).
TCacheEntry = record
Node: PVirtualNode;
AbsoluteTop: TNodeHeight;
end;
TCache = array of TCacheEntry;
// Used in the CF_VTREFERENCE clipboard format.
PVTReference = ^TVTReference;
TVTReference = record
Process: Cardinal;
Tree: TBaseVirtualTree;
end;
// ----- OLE drag'n drop handling
IVTDragManager = interface(IUnknown)
['{C4B25559-14DA-446B-8901-0C879000EB16}']
procedure ForceDragLeave; stdcall;
function GetDataObject: IDataObject; stdcall;
function GetDragSource: TBaseVirtualTree; stdcall;
function GetIsDropTarget: Boolean; stdcall;
property DataObject: IDataObject read GetDataObject;
property DragSource: TBaseVirtualTree read GetDragSource;
property IsDropTarget: Boolean read GetIsDropTarget;
end;
PVTHintData = ^TVTHintData;
TVTHintData = record
Tree: TBaseVirtualTree;
Node: PVirtualNode;
Column: TColumnIndex;
HintRect: TRect; // used for draw trees only, string trees get the size from the hint string
HintText: string; // set when size of the hint window is calculated
BidiMode: TBidiMode;
Alignment: TAlignment;
LineBreakStyle: TVTToolTipLineBreakStyle;
end;
// Communication interface between a tree editor and the tree itself (declared as using stdcall in case it
// is implemented in a (C/C++) DLL). The GUID is not nessecary in Delphi but important for BCB users
// to allow QueryInterface and _uuidof calls.
IVTEditLink = interface
['{2BE3EAFA-5ACB-45B4-9D9A-B58BCC496E17}']
function BeginEdit: Boolean; stdcall; // Called when editing actually starts.
function CancelEdit: Boolean; stdcall; // Called when editing has been cancelled by the tree.
function EndEdit: Boolean; stdcall; // Called when editing has been finished by the tree. Returns True if successful, False if edit mode is still active.
function PrepareEdit(Tree: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex): Boolean; stdcall;
// Called after creation to allow a setup.
procedure ProcessMessage(var Message: TMessage); stdcall;
// Used to forward messages to the edit window(s)-
procedure SetBounds(R: TRect); stdcall; // Called to place the editor.
end;
TVTNodeExportEvent = procedure (Sender: TBaseVirtualTree; aExportType: TVTExportType; Node: PVirtualNode) of object;
TVTColumnExportEvent = procedure (Sender: TBaseVirtualTree; aExportType: TVTExportType; Column: TVirtualTreeColumn) of object;
TVTTreeExportEvent = procedure(Sender: TBaseVirtualTree; aExportType: TVTExportType) of object;
TClipboardFormats = class(TStringList)
private
FOwner: TBaseVirtualTree;
public
constructor Create(AOwner: TBaseVirtualTree); virtual;
function Add(const S: string): Integer; override;
procedure Insert(Index: Integer; const S: string); override;
property Owner: TBaseVirtualTree read FOwner;
end;
// ----- Event prototypes:
// node enumeration
TVTGetNodeProc = reference to procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Data: Pointer; var Abort: Boolean);
// node events
TVTChangingEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; var Allowed: Boolean) of object;
TVTCheckChangingEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; var NewState: TCheckState;
var Allowed: Boolean) of object;
TVTChangeEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode) of object;
TVTStructureChangeEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Reason: TChangeReason) of object;
TVTEditCancelEvent = procedure(Sender: TBaseVirtualTree; Column: TColumnIndex) of object;
TVTEditChangingEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
var Allowed: Boolean) of object;
TVTEditChangeEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex) of object;
TVTFreeNodeEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode) of object;
TVTFocusChangingEvent = procedure(Sender: TBaseVirtualTree; OldNode, NewNode: PVirtualNode; OldColumn,
NewColumn: TColumnIndex; var Allowed: Boolean) of object;
TVTFocusChangeEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex) of object;
TVTAddToSelectionEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode) of object;
TVTRemoveFromSelectionEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode) of object;
TVTGetImageEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var Ghosted: Boolean; var ImageIndex: TImageIndex) of object;
TVTGetImageExEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var Ghosted: Boolean; var ImageIndex: TImageIndex; var ImageList: TCustomImageList) of object;
TVTGetImageTextEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var ImageText: string) of object;
TVTHotNodeChangeEvent = procedure(Sender: TBaseVirtualTree; OldNode, NewNode: PVirtualNode) of object;
TVTInitChildrenEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; var ChildCount: Cardinal) of object;
TVTInitNodeEvent = procedure(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode;
var InitialStates: TVirtualNodeInitStates) of object;
TVTPopupEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; const P: TPoint;
var AskParent: Boolean; var PopupMenu: TPopupMenu) of object;
TVTHelpContextEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
var HelpContext: Integer) of object;
TVTCreateEditorEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
out EditLink: IVTEditLink) of object;
TVTSaveTreeEvent = procedure(Sender: TBaseVirtualTree; Stream: TStream) of object;
TVTSaveNodeEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Stream: TStream) of object;
TVTBeforeGetCheckStateEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode) of object;
// header/column events
TVTHeaderAddPopupItemEvent = procedure(const Sender: TObject; const Column: TColumnIndex; var Cmd: TAddPopupItemType) of object;
TVTHeaderClickEvent = procedure(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo) of object;
TVTHeaderMouseEvent = procedure(Sender: TVTHeader; Button: TMouseButton; Shift: TShiftState; X, Y: TDimension) of object;
TVTHeaderMouseMoveEvent = procedure(Sender: TVTHeader; Shift: TShiftState; X, Y: TDimension) of object;
TVTBeforeHeaderHeightTrackingEvent = procedure(Sender: TVTHeader; Shift: TShiftState) of object;
TVTAfterHeaderHeightTrackingEvent = procedure(Sender: TVTHeader) of object;
TVTHeaderHeightTrackingEvent = procedure(Sender: TVTHeader; var P: TPoint; Shift: TShiftState; var Allowed: Boolean) of object;
TVTHeaderHeightDblClickResizeEvent = procedure(Sender: TVTHeader; var P: TPoint; Shift: TShiftState; var Allowed: Boolean) of object;
TVTHeaderNotifyEvent = procedure(Sender: TVTHeader; Column: TColumnIndex) of object;
TVTHeaderDraggingEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; var Allowed: Boolean) of object;
TVTHeaderDraggedEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; OldPosition: Integer) of object;
TVTHeaderDraggedOutEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; DropPosition: TPoint) of object;
TVTHeaderPaintEvent = procedure(Sender: TVTHeader; HeaderCanvas: TCanvas; Column: TVirtualTreeColumn; R: TRect; Hover,
Pressed: Boolean; DropMark: TVTDropMarkMode) of object;
TVTHeaderPaintQueryElementsEvent = procedure(Sender: TVTHeader; var PaintInfo: THeaderPaintInfo;
var Elements: THeaderPaintElements) of object;
TVTAdvancedHeaderPaintEvent = procedure(Sender: TVTHeader; var PaintInfo: THeaderPaintInfo;
const Elements: THeaderPaintElements) of object;
TVTBeforeAutoFitColumnsEvent = procedure(Sender: TVTHeader; var SmartAutoFitType: TSmartAutoFitType) of object;
TVTBeforeAutoFitColumnEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; var SmartAutoFitType: TSmartAutoFitType;
var Allowed: Boolean) of object;
TVTAfterAutoFitColumnEvent = procedure(Sender: TVTHeader; Column: TColumnIndex) of object;
TVTAfterAutoFitColumnsEvent = procedure(Sender: TVTHeader) of object;
TVTColumnCheckChangingEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; var NewState: TCheckState;
var Allowed: Boolean) of object;
TVTColumnClickEvent = procedure (Sender: TBaseVirtualTree; Column: TColumnIndex; Shift: TShiftState) of object;
TVTColumnDblClickEvent = procedure (Sender: TBaseVirtualTree; Column: TColumnIndex; Shift: TShiftState) of object;
TColumnChangeEvent = procedure(const Sender: TBaseVirtualTree; const Column: TColumnIndex; Visible: Boolean) of object;
TVTColumnWidthDblClickResizeEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; Shift: TShiftState; P: TPoint;
var Allowed: Boolean) of object;
TVTBeforeColumnWidthTrackingEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; Shift: TShiftState) of object;
TVTAfterColumnWidthTrackingEvent = procedure(Sender: TVTHeader; Column: TColumnIndex) of object;
TVTColumnWidthTrackingEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; Shift: TShiftState; var TrackPoint: TPoint; P: TPoint;
var Allowed: Boolean) of object;
TVTGetHeaderCursorEvent = procedure(Sender: TVTHeader; var Cursor: TVTCursor) of object;
TVTBeforeGetMaxColumnWidthEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; var UseSmartColumnWidth: Boolean) of object;
TVTAfterGetMaxColumnWidthEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; var MaxWidth: TDimension) of object;
TVTCanSplitterResizeColumnEvent = procedure(Sender: TVTHeader; P: TPoint; Column: TColumnIndex; var Allowed: Boolean) of object;
TVTCanSplitterResizeHeaderEvent = procedure(Sender: TVTHeader; P: TPoint; var Allowed: Boolean) of object;
// move, copy and node tracking events
TVTNodeMovedEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode) of object;
TVTNodeMovingEvent = procedure(Sender: TBaseVirtualTree; Node, Target: PVirtualNode;
var Allowed: Boolean) of object;
TVTNodeCopiedEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode) of object;
TVTNodeCopyingEvent = procedure(Sender: TBaseVirtualTree; Node, Target: PVirtualNode;
var Allowed: Boolean) of object;
TVTNodeClickEvent = procedure(Sender: TBaseVirtualTree; const HitInfo: THitInfo) of object;
TVTNodeHeightTrackingEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; Shift: TShiftState;
var TrackPoint: TPoint; P: TPoint; var Allowed: Boolean) of object;
TVTNodeHeightDblClickResizeEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
Shift: TShiftState; P: TPoint; var Allowed: Boolean) of object;
TVTCanSplitterResizeNodeEvent = procedure(Sender: TBaseVirtualTree; P: TPoint; Node: PVirtualNode;
Column: TColumnIndex; var Allowed: Boolean) of object;
TVTGetUserClipboardFormatsEvent = procedure(Sender: TBaseVirtualTree; var Formats: TFormatEtcArray) of object;
// drag'n drop/OLE events
TVTCreateDragManagerEvent = procedure(Sender: TBaseVirtualTree; out DragManager: IVTDragManager) of object;
TVTCreateDataObjectEvent = procedure(Sender: TBaseVirtualTree; out IDataObject: TVTDragDataObject) of object;
TVTDragAllowedEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
var Allowed: Boolean) of object;
TVTDragOverEvent = procedure(Sender: TBaseVirtualTree; Source: TObject; Shift: TShiftState; State: TDragState;
Pt: TPoint; Mode: TDropMode; var Effect: Integer; var Accept: Boolean) of object;
TVTDragDropEvent = procedure(Sender: TBaseVirtualTree; Source: TObject; DataObject: TVTDragDataObject;
Formats: TFormatArray; Shift: TShiftState; Pt: TPoint; var Effect: Integer; Mode: TDropMode) of object;
// paint events
TVTBeforeItemEraseEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode; ItemRect: TRect;
var ItemColor: TColor; var EraseAction: TItemEraseAction) of object;
TVTAfterItemEraseEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode;
ItemRect: TRect) of object;
TVTBeforeItemPaintEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode;
ItemRect: TRect; var CustomDraw: Boolean) of object;
TVTAfterItemPaintEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode;
ItemRect: TRect) of object;
TVTBeforeCellPaintEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode;
Column: TColumnIndex; CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect) of object;
TVTAfterCellPaintEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode;
Column: TColumnIndex; CellRect: TRect) of object;
TVTPaintEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas) of object;
TVTBackgroundPaintEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; R: TRect;
var Handled: Boolean) of object;
TVTGetLineStyleEvent = procedure(Sender: TBaseVirtualTree; var Bits: Pointer) of object;
TVTMeasureItemEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode;
var NodeHeight: TDimension) of object;
TVTPaintText = procedure(Sender: TBaseVirtualTree; const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
TextType: TVSTTextType) of object;
TVTPrepareButtonImagesEvent = procedure(Sender: TBaseVirtualTree; const APlusBM : TBitmap; const APlusHotBM :TBitmap;
const APlusSelectedHotBM :TBitmap; const AMinusBM : TBitmap; const AMinusHotBM : TBitmap;
const AMinusSelectedHotBM :TBitmap; var ASize : TSize) of object;
TVTColumnHeaderSpanningEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; var Count: Integer) of object;
// search, sort
TVTCompareEvent = procedure(Sender: TBaseVirtualTree; Node1, Node2: PVirtualNode; Column: TColumnIndex;
var Result: Integer) of object;
TVTIncrementalSearchEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; const SearchText: string;
var Result: Integer) of object;
// operations
TVTOperationEvent = procedure(Sender: TBaseVirtualTree; OperationKind: TVTOperationKind) of object;
TVTHintKind = (vhkText, vhkOwnerDraw);
TVTHintKindEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; var Kind: TVTHintKind) of object;
TVTDrawHintEvent = procedure(Sender: TBaseVirtualTree; HintCanvas: TCanvas; Node: PVirtualNode; R: TRect; Column: TColumnIndex) of object;
TVTGetHintSizeEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; var R: TRect) of object;
// miscellaneous
TVTBeforeDrawLineImageEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Level: Integer; var PosX: TDimension) of object;
TVTGetNodeDataSizeEvent = procedure(Sender: TBaseVirtualTree; var NodeDataSize: Integer) of object;
TVTKeyActionEvent = procedure(Sender: TBaseVirtualTree; var CharCode: Word; var Shift: TShiftState;
var DoDefault: Boolean) of object;
TVTScrollEvent = procedure(Sender: TBaseVirtualTree; DeltaX, DeltaY: TDimension) of object;
TVTUpdatingEvent = procedure(Sender: TBaseVirtualTree; State: TVTUpdateState) of object;
TVTGetCursorEvent = procedure(Sender: TBaseVirtualTree; var Cursor: TCursor) of object;
TVTStateChangeEvent = procedure(Sender: TBaseVirtualTree; Enter, Leave: TVirtualTreeStates) of object;
TVTGetCellIsEmptyEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
var IsEmpty: Boolean) of object;
TVTScrollBarShowEvent = procedure(Sender: TBaseVirtualTree; Bar: Integer; Show: Boolean) of object;
// Helper types for node iterations.
TGetFirstNodeProc = function: PVirtualNode of object;
TGetNextNodeProc = function(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode of object;
TVZVirtualNodeEnumerationMode = (
vneAll,
vneChecked,
vneChild,
vneCutCopy,
vneInitialized,
vneLeaf,
vneLevel,
vneNoInit,
vneSelected,
vneVisible,
vneVisibleChild,
vneVisibleNoInitChild,
vneVisibleNoInit
);
PVTVirtualNodeEnumeration = ^TVTVirtualNodeEnumeration;
TVTVirtualNodeEnumerator = record
private
FNode: PVirtualNode;
FCanMoveNext: Boolean;
FEnumeration: PVTVirtualNodeEnumeration;
function GetCurrent: PVirtualNode; inline;
public
function MoveNext: Boolean; inline;
property Current: PVirtualNode read GetCurrent;
end;
TVTVirtualNodeEnumeration = record
private
FMode: TVZVirtualNodeEnumerationMode;
FTree: TBaseVirtualTree;
// GetNextXxx parameters:
FConsiderChildrenAbove: Boolean;
FNode: PVirtualNode;
FNodeLevel: Cardinal;
FState: TCheckState;
FIncludeFiltered: Boolean;
public
function GetEnumerator: TVTVirtualNodeEnumerator;
private
function GetNext(Node: PVirtualNode): PVirtualNode;
end;
// ----- TBaseVirtualTree
TBaseVirtualTree = class abstract(TVTBaseAncestor)
private
FTotalInternalDataSize: Cardinal; // Cache of the sum of the necessary internal data size for all tree
FBorderStyle: TBorderStyle;
FHeader: TVTHeader;
FRoot: PVirtualNode;
FDefaultNodeHeight,
FIndent: TDimension;
FOptions: TCustomVirtualTreeOptions;
FUpdateCount: Cardinal; // update stopper, updates of the tree control are only done if = 0
FSynchUpdateCount: Cardinal; // synchronizer, causes all events which are usually done via timers
// to happen immediately, regardless of the normal update state
FNodeDataSize: Integer; // number of bytes to allocate with each node (in addition to its base
// structure and the internal data), if -1 then do callback
FStates: TVirtualTreeStates; // various active/pending states the tree needs to consider
FLastSelected,
FFocusedNode: PVirtualNode;
FEditColumn, // column to be edited (focused node)
FFocusedColumn: TColumnIndex; // NoColumn if no columns are active otherwise the last hit column of
// the currently focused node
FHeightTrackPoint: TPoint; // Starting point of a node's height changing operation.
FHeightTrackNode: PVirtualNode; // Node which height is being changed.
FHeightTrackColumn: TColumnIndex; // Initial column where the height changing operation takes place.
FScrollDirections: TScrollDirections; // directions to scroll client area into depending on mouse position
FLastStructureChangeReason: TChangeReason; // Used for delayed structure change event.
FLastStructureChangeNode, // dito
FLastChangedNode, // used for delayed change event
FCurrentHotNode: PVirtualNode; // Node over which the mouse is hovering.
FCurrentHotColumn: TColumnIndex; // Column over which the mouse is hovering.
FHotNodeButtonHit: Boolean; // Indicates wether the mouse is hovering over the hot node's button.
FLastSelRect,
FNewSelRect: TRect; // used while doing draw selection
FHotCursor: TCursor; // can be set to additionally indicate the current hot node
FLastHitInfo: THitInfo; // The THitInfo of the last mouse-down event.
// in Win98 (slide) and Windows 2000 (fade))
FHintMode: TVTHintMode; // determines the kind of the hint window
FHintData: TVTHintData; // used while preparing the hint window
FChangeDelay: Cardinal; // used to delay OnChange event
FEditDelay: Cardinal; // determines time to elapse before a node goes into edit mode
FPositionCache: TCache; // array which stores node references ordered by vertical positions
// (see also DoValidateCache for more information)
FVisibleCount: Cardinal; // number of currently visible nodes
FStartIndex: Cardinal; // index to start validating cache from
FSelection: TNodeArray; // list of currently selected nodes
FSelectionLocked: Boolean; // prevents the tree from changing the selection
FRangeAnchor: PVirtualNode; // anchor node for selection with the keyboard, determines start of a
// selection range
FCheckPropagationCount: Cardinal; // nesting level of check propagation (WL, 05.02.2004)
FLastSelectionLevel: Integer; // keeps the last node level for constrained multiselection
FDrawSelShiftState: TShiftState; // keeps the initial shift state when the user starts selection with
// the mouse
FEditLink: IVTEditLink; // used to comunicate with an application defined editor
FTempNodeCache: TNodeArray; // used at various places to hold temporarily a bunch of node refs.
FTempNodeCount: Cardinal; // number of nodes in FTempNodeCache
FBackground: TVTBackground; // A background image loadable at design and runtime.
FBackgroundImageTransparent: Boolean; // By default, this is off. When switched on, will try to draw the image
// transparent by using the color of the component as transparent color
FMargin: TDimension; // horizontal distance to border and columns
FTextMargin: TDimension; // space between the node's text and its horizontal bounds
FBackgroundOffsetX,
FBackgroundOffsetY: TDimension; // used to fine tune the position of the background image
FAnimationDuration: Cardinal; // specifies how long an animation shall take (expanding, hint)
FWantTabs: Boolean; // If True then the tree also consumes the tab key.
FNodeAlignment: TVTNodeAlignment; // determines how to interpret the align member of a node
FHeaderRect: TRect; // Space which the header currently uses in the control (window coords).
FLastHintRect: TRect; // Area which the mouse must leave to reshow a hint.
FUpdateRect: TRect;
FEmptyListMessage: string; // Optional message that will be displayed if no nodes exist in the control.
// paint support and images
FPlusBM,
FMinusBM, // small bitmaps used for tree buttons
FHotPlusBM,
FHotMinusBM,
FSelectedHotPlusBM,
FSelectedHotMinusBM: TBitmap; // small bitmaps used for hot tree buttons
FImages, // normal images in the tree
FStateImages, // state images in the tree
FCustomCheckImages: TCustomImageList; // application defined check images
FCheckImageKind: TCheckImageKind; // light or dark, cross marks or tick marks
FCheckImages: TCustomImageList; // Reference to global image list to be used for the check images.
//TODO: Use this margin for other images as well
FImagesMargin: TDimension; // The margin used left and right of the checkboxes.
FImageChangeLink,
FStateChangeLink,
FCustomCheckChangeLink: TChangeLink; // connections to the image lists
FOldFontChange: TNotifyEvent; // helper method pointer for tracking font changes in the off screen buffer
FColors: TVTColors; // class comprising all customizable colors in the tree
FButtonStyle: TVTButtonStyle; // style of the tree buttons
FButtonFillMode: TVTButtonFillMode; // for rectangular tree buttons only: how to fill them
FLineStyle: TVTLineStyle; // style of the tree lines
FLineMode: TVTLineMode; // tree lines or bands etc.
FSelectionCurveRadius: Cardinal; // radius for rounded selection rectangles
FSelectionBlendFactor: Byte; // Determines the factor by which the selection rectangle is to be
// faded if enabled.
FDrawSelectionMode: TVTDrawSelectionMode; // determines the paint mode for draw selection
// alignment and directionality support
FAlignment: TAlignment; // default alignment of the tree if no columns are shown
// drag'n drop and clipboard support
FDragImageKind: TVTDragImageKind; // determines whether or not and what to show in the drag image
FDragOperations: TDragOperations; // determines which operations are allowed during drag'n drop
FDragThreshold: Integer; // used to determine when to actually start a drag'n drop operation
FDragManager: IVTDragManager; // drag'n drop, cut'n paste
FDropTargetNode: PVirtualNode; // node currently selected as drop target
FLastDropMode: TDropMode; // set while dragging and used to track changes
FDragSelection: TNodeArray; // temporary copy of FSelection used during drag'n drop
FLastDragEffect: Integer; // The last executed drag effect
FDragType: TVTDragType; // used to switch between OLE and VCL drag'n drop
FDragWidth,
FDragHeight: Integer; // size of the drag image, the larger the more CPU power is needed
FClipboardFormats: TClipboardFormats; // a list of clipboard format descriptions enabled for this tree
FLastVCLDragTarget: PVirtualNode; // A node cache for VCL drag'n drop (keywords: DragLeave on DragDrop).
FVCLDragEffect: Integer; // A cache for VCL drag'n drop to keep the current drop effect.
// scroll support
FScrollBarOptions: TScrollBarOptions; // common properties of horizontal and vertical scrollbar
FAutoScrollInterval: TAutoScrollInterval; // determines speed of auto scrolling
FAutoScrollDelay: Cardinal; // amount of milliseconds to wait until autoscrolling becomes active
FAutoExpandDelay: Cardinal; // amount of milliseconds to wait until a node is expanded if it is the
// drop target
FOffsetX: TDimension;
FOffsetY: TDimension; // Determines left and top scroll offset.
FEffectiveOffsetX: TDimension; // Actual position of the horizontal scroll bar (varies depending on bidi mode).
FRangeX,
FRangeY: TNodeHeight; // current virtual width and height of the tree
FBottomSpace: TDimension; // Extra space below the last node.
FDefaultPasteMode: TVTNodeAttachMode; // Used to determine where to add pasted nodes to.
FDragScrollStart: Cardinal; // Contains the start time when a tree does auto scrolling as drop target.
// search
FIncrementalSearch: TVTIncrementalSearch; // Used to determine whether and how incremental search is to be used.
FSearchTimeout: Cardinal; // Number of milliseconds after which to stop incremental searching.
FSearchBuffer: string; // Collects a sequence of keypresses used to do incremental searching.
FLastSearchNode: PVirtualNode; // Reference to node which was last found as search fit.
FSearchDirection: TVTSearchDirection; // Direction to incrementally search the tree.
FSearchStart: TVTSearchStart; // Where to start iteration on each key press.
// miscellanous
FPanningWindow: TForm; // Helper window for wheel panning
FPanningCursor: TVTCursor; // Current wheel panning cursor.
FLastClickPos: TPoint; // Used for retained drag start and wheel mouse scrolling.
FOperationCount: Cardinal; // Counts how many nested long-running operations are in progress.
FOperationCanceled: Boolean; // Used to indicate that a long-running operation should be canceled.
FChangingTheme: Boolean; // Used to indicate that a theme change is goi ng on
FNextNodeToSelect: PVirtualNode; // Next tree node that we would like to select if the current one gets deleted or looses selection for other reasons.
FPendingSyncProcs:Integer; // Counter that indicates whether we have queued anonymous calls to the min thread, see issue #1199
// export
FOnBeforeNodeExport: TVTNodeExportEvent; // called before exporting a node
FOnNodeExport: TVTNodeExportEvent;
FOnAfterNodeExport: TVTNodeExportEvent; // called after exporting a node
FOnBeforeColumnExport: TVTColumnExportEvent; // called before exporting a column
FOnColumnExport: TVTColumnExportEvent;
FOnAfterColumnExport: TVTColumnExportEvent; // called after exporting a column
FOnBeforeTreeExport: TVTTreeExportEvent; // called before starting the export
FOnAfterTreeExport: TVTTreeExportEvent; // called after finishing the export
FOnBeforeHeaderExport: TVTTreeExportEvent; // called before exporting the header
FOnAfterHeaderExport: TVTTreeExportEvent; // called after exporting the header
// common events
FOnChange: TVTChangeEvent; // selection change
FOnStructureChange: TVTStructureChangeEvent; // structural change like adding nodes etc.
FOnInitChildren: TVTInitChildrenEvent; // called when a node's children are needed (expanding etc.)
FOnInitNode: TVTInitNodeEvent; // called when a node needs to be initialized (child count etc.)
FOnFreeNode: TVTFreeNodeEvent; // called when a node is about to be destroyed, user data can and should
// be freed in this event
FOnGetImage: TVTGetImageEvent; // Used to retrieve the image index of a given node.
FOnGetImageEx: TVTGetImageExEvent; // Used to retrieve the image index of a given node along with a custom
// image list.
FOnGetImageText: TVTGetImageTextEvent; // Used to retrieve the image alternative text of a given node.
// Used by the accessibility interface to provide useful text for status images.
FOnHotChange: TVTHotNodeChangeEvent; // called when the current "hot" node (that is, the node under the mouse)
// changes and hot tracking is enabled
FOnExpanding, // called just before a node is expanded
FOnCollapsing: TVTChangingEvent; // called just before a node is collapsed
FOnChecking: TVTCheckChangingEvent; // called just before a node's check state is changed
FOnExpanded, // called after a node has been expanded
FOnCollapsed, // called after a node has been collapsed
FOnChecked: TVTChangeEvent; // called after a node's check state has been changed
FOnResetNode: TVTChangeEvent; // called when a node is set to be uninitialized
FOnNodeMoving: TVTNodeMovingEvent; // called just before a node is moved from one parent node to another
// (this can be cancelled)
FOnNodeMoved: TVTNodeMovedEvent; // called after a node and its children have been moved to another
// parent node (probably another tree, but within the same application)
FOnNodeCopying: TVTNodeCopyingEvent; // called when a node is copied to another parent node (probably in
// another tree, but within the same application, can be cancelled)
FOnNodeClick: TVTNodeClickEvent; // called when the user clicks on a node
FOnNodeDblClick: TVTNodeClickEvent; // called when the user double clicks on a node
FOnCanSplitterResizeNode: TVTCanSplitterResizeNodeEvent; // called to query the application wether resizing a node is allowed
FOnNodeHeightTracking: TVTNodeHeightTrackingEvent; // called when a node's height is being changed via mouse
FOnNodeHeightDblClickResize: TVTNodeHeightDblClickResizeEvent; // called when a node's vertical splitter is double clicked
FOnNodeCopied: TVTNodeCopiedEvent; // call after a node has been copied
FOnEditing: TVTEditChangingEvent; // called just before a node goes into edit mode
FOnEditCancelled: TVTEditCancelEvent; // called when editing has been cancelled
FOnEdited: TVTEditChangeEvent; // called when editing has successfully been finished
FOnFocusChanging: TVTFocusChangingEvent; // called when the focus is about to go to a new node and/or column
// (can be cancelled)
FOnFocusChanged: TVTFocusChangeEvent; // called when the focus goes to a new node and/or column
FOnAddToSelection: TVTAddToSelectionEvent; // called when a node is added to the selection
FOnRemoveFromSelection: TVTRemoveFromSelectionEvent; // called when a node is removed from the selection
FOnGetPopupMenu: TVTPopupEvent; // called when the popup for a node or the header needs to be shown
FOnGetHelpContext: TVTHelpContextEvent; // called when a node specific help theme should be called
FOnCreateEditor: TVTCreateEditorEvent; // called when a node goes into edit mode, this allows applications
// to supply their own editor
FOnLoadNode, // called after a node has been loaded from a stream (file, clipboard,
// OLE drag'n drop) to allow an application to load their own data
// saved in OnSaveNode
FOnSaveNode: TVTSaveNodeEvent; // called when a node needs to be serialized into a stream
// (see OnLoadNode) to give the application the opportunity to save
// their node specific, persistent data (note: never save memory
// references)
FOnLoadTree, // called after the tree has been loaded from a stream to allow an
// application to load their own data saved in OnSaveTree
FOnSaveTree: TVTSaveTreeEvent; // called after the tree has been saved to a stream to allow an
// application to save its own data
// header/column mouse events
FOnAfterAutoFitColumn: TVTAfterAutoFitColumnEvent;
FOnAfterAutoFitColumns: TVTAfterAutoFitColumnsEvent;
FOnBeforeAutoFitColumns: TVTBeforeAutoFitColumnsEvent;
FOnBeforeAutoFitColumn: TVTBeforeAutoFitColumnEvent;
FOnHeaderAddPopupItem: TVTHeaderAddPopupItemEvent;
FOnHeaderClick: TVTHeaderClickEvent;
FOnHeaderDblClick: TVTHeaderClickEvent;
FOnAfterHeaderHeightTracking: TVTAfterHeaderHeightTrackingEvent;
FOnBeforeHeaderHeightTracking: TVTBeforeHeaderHeightTrackingEvent;
FOnHeaderHeightTracking: TVTHeaderHeightTrackingEvent;
FOnHeaderHeightDblClickResize: TVTHeaderHeightDblClickResizeEvent;
FOnHeaderMouseDown,
FOnHeaderMouseUp: TVTHeaderMouseEvent;
FOnHeaderMouseMove: TVTHeaderMouseMoveEvent;
FOnAfterGetMaxColumnWidth: TVTAfterGetMaxColumnWidthEvent;
FOnBeforeGetMaxColumnWidth: TVTBeforeGetMaxColumnWidthEvent;
FOnColumnChecked: TVTHeaderNotifyEvent; // triggered when the column is about to be checked
FOnColumnChecking: TVTColumnCheckChangingEvent;
FOnColumnClick: TVTColumnClickEvent;
FOnColumnDblClick: TVTColumnDblClickEvent;
FOnColumnResize: TVTHeaderNotifyEvent;
fOnColumnVisibilityChanged: TColumnChangeEvent;
FOnColumnWidthDblClickResize: TVTColumnWidthDblClickResizeEvent;
FOnAfterColumnWidthTracking: TVTAfterColumnWidthTrackingEvent;
FOnBeforeColumnWidthTracking: TVTBeforeColumnWidthTrackingEvent;
FOnColumnWidthTracking: TVTColumnWidthTrackingEvent;
FOnGetHeaderCursor: TVTGetHeaderCursorEvent; // triggered to allow the app. to use customized cursors for the header
FOnCanSplitterResizeColumn: TVTCanSplitterResizeColumnEvent;
FOnCanSplitterResizeHeader: TVTCanSplitterResizeHeaderEvent;
// paint events
FOnAfterPaint, // triggered when the tree has entirely been painted
FOnBeforePaint: TVTPaintEvent; // triggered when the tree is about to be painted
FOnAfterItemPaint: TVTAfterItemPaintEvent; // triggered after an item has been painted
FOnBeforeItemPaint: TVTBeforeItemPaintEvent; // triggered when an item is about to be painted
FOnBeforeItemErase: TVTBeforeItemEraseEvent; // triggered when an item's background is about to be erased
FOnAfterItemErase: TVTAfterItemEraseEvent; // triggered after an item's background has been erased
FOnAfterCellPaint: TVTAfterCellPaintEvent; // triggered after a column of an item has been painted
FOnBeforeCellPaint: TVTBeforeCellPaintEvent; // triggered when a column of an item is about to be painted
FOnHeaderDraw: TVTHeaderPaintEvent; // Used when owner draw is enabled for the header and a column is set
// to owner draw mode.
FOnPrepareButtonImages : TVTPrepareButtonImagesEvent; //allow use to customise plus/minus bitmap images
FOnHeaderDrawQueryElements: TVTHeaderPaintQueryElementsEvent; // Used for advanced header painting to query the
// application for the elements, which are drawn by it and which should
// be drawn by the tree.
FOnAdvancedHeaderDraw: TVTAdvancedHeaderPaintEvent; // Used when owner draw is enabled for the header and a column
// is set to owner draw mode. But only if OnHeaderDrawQueryElements
// returns at least one element to be drawn by the application.
// In this case OnHeaderDraw is not used.
FOnGetLineStyle: TVTGetLineStyleEvent; // triggered when a custom line style is used and the pattern brush
// needs to be build
FOnPaintBackground: TVTBackgroundPaintEvent; // triggered if a part of the tree's background must be erased which is
// not covered by any node
FOnMeasureItem: TVTMeasureItemEvent; // Triggered when a node is about to be drawn and its height was not yet
// determined by the application.
FOnColumnHeaderSpanning: TVTColumnHeaderSpanningEvent; // triggered before the header column area been create for painting
FOnGetUserClipboardFormats: TVTGetUserClipboardFormatsEvent; // gives application/descendants the opportunity to
// add own clipboard formats on the fly
FOnPaintText: TVTPaintText; // triggered before either normal or fixed text is painted to allow
// even finer customization (kind of sub cell painting)
// drag'n drop events
FOnCreateDragManager: TVTCreateDragManagerEvent; // called to allow for app./descendant defined drag managers
FOnCreateDataObject: TVTCreateDataObjectEvent; // called to allow for app./descendant defined data objects
FOnDragAllowed: TVTDragAllowedEvent; // used to get permission for manual drag in mouse down
FOnDragOver: TVTDragOverEvent; // called for every mouse move
FOnDragDrop: TVTDragDropEvent; // called on release of mouse button (if drop was allowed)
FOnHeaderDragged: TVTHeaderDraggedEvent; // header (column) drag'n drop
FOnHeaderDraggedOut: TVTHeaderDraggedOutEvent; // header (column) drag'n drop, which did not result in a valid drop.
FOnHeaderDragging: TVTHeaderDraggingEvent; // header (column) drag'n drop
// miscellanous events
FOnGetNodeDataSize: TVTGetNodeDataSizeEvent; // Called if NodeDataSize is -1.
FOnBeforeDrawLineImage: TVTBeforeDrawLineImageEvent; // Called to allow adjusting the indention of treelines.
FOnKeyAction: TVTKeyActionEvent; // Used to selectively prevent key actions (full expand on Ctrl+'+' etc.).
FOnScroll: TVTScrollEvent; // Called when one or both paint offsets changed.
FOnUpdating: TVTUpdatingEvent; // Called from BeginUpdate, EndUpdate, BeginSynch and EndSynch.
FOnGetCursor: TVTGetCursorEvent; // Called to allow the app. to set individual cursors.
FOnStateChange: TVTStateChangeEvent; // Called whenever a state in the tree changes.
FOnGetCellIsEmpty: TVTGetCellIsEmptyEvent; // Called when the tree needs to know if a cell is empty.
FOnShowScrollBar: TVTScrollBarShowEvent; // Called when a scrollbar is changed in its visibility.
FOnBeforeGetCheckState: TVTBeforeGetCheckStateEvent; // Called before a CheckState for a Node is obtained.
// Gives the application a chance to do special processing
// when a check state is actually required for the first time.
// search, sort
FOnCompareNodes: TVTCompareEvent; // used during sort
FOnDrawHint: TVTDrawHintEvent;
FOnGetHintSize: TVTGetHintSizeEvent;
FOnGetHintKind: TVTHintKindEvent;
FOnIncrementalSearch: TVTIncrementalSearchEvent; // triggered on every key press (not key down)
FOnMouseEnter: TNotifyEvent;
FOnMouseLeave: TNotifyEvent;
// operations
FOnStartOperation: TVTOperationEvent; // Called when an operation starts
FOnEndOperation: TVTOperationEvent; // Called when an operation ends
FVclStyleEnabled: Boolean;
FSelectionCount: Integer;
procedure CMStyleChanged(var Message: TMessage); message CM_STYLECHANGED;
procedure CMParentDoubleBufferedChange(var Message: TMessage); message CM_PARENTDOUBLEBUFFEREDCHANGED;
procedure AdjustTotalCount(Node: PVirtualNode; Value: Integer; relative: Boolean = False);
function CalculateCacheEntryCount: Integer;
procedure CalculateVerticalAlignments(var PaintInfo: TVTPaintInfo; var VButtonAlign: TDimension);
function ChangeCheckState(Node: PVirtualNode; Value: TCheckState): Boolean;
function CollectSelectedNodesLTR(MainColumn: Integer; NodeLeft, NodeRight: TDimension; Alignment: TAlignment; OldRect,
NewRect: TRect): Boolean;
function CollectSelectedNodesRTL(MainColumn: Integer; NodeLeft, NodeRight: TDimension; Alignment: TAlignment; OldRect,
NewRect: TRect): Boolean;
procedure ClearNodeBackground(const PaintInfo: TVTPaintInfo; UseBackground, Floating: Boolean; R: TRect);
function CompareNodePositions(Node1, Node2: PVirtualNode; ConsiderChildrenAbove: Boolean = False): Integer;
procedure DrawLineImage(const PaintInfo: TVTPaintInfo; X, Y, H, VAlign: TDimension; Style: TVTLineType; Reverse: Boolean);
function FindInPositionCache(Node: PVirtualNode; var CurrentPos: TNodeHeight): PVirtualNode; overload;
function FindInPositionCache(Position: TDimension; var CurrentPos: TNodeHeight): PVirtualNode; overload;
procedure FixupTotalCount(Node: PVirtualNode);
procedure FixupTotalHeight(Node: PVirtualNode);
function GetBottomNode: PVirtualNode;
function GetCheckState(Node: PVirtualNode): TCheckState;
function GetCheckType(Node: PVirtualNode): TCheckType;
function GetChildCount(Node: PVirtualNode): Cardinal;
function GetChildrenInitialized(Node: PVirtualNode): Boolean; inline;
function GetCutCopyCount: Integer;
function GetDisabled(Node: PVirtualNode): Boolean;
function GetSyncCheckstateWithSelection(Node: PVirtualNode): Boolean;
function GetDragManager: IVTDragManager;
function GetExpanded(Node: PVirtualNode): Boolean;
function GetFiltered(Node: PVirtualNode): Boolean;
function GetFullyVisible(Node: PVirtualNode): Boolean;
function GetHasChildren(Node: PVirtualNode): Boolean;
function GetMultiline(Node: PVirtualNode): Boolean;
function GetNodeHeight(Node: PVirtualNode): TNodeHeight;
function GetNodeParent(Node: PVirtualNode): PVirtualNode;
function GetOffsetXY: TPoint;
function GetRootNodeCount: Cardinal;
function GetSelected(Node: PVirtualNode): Boolean;
function GetTopNode: PVirtualNode;
function GetTotalCount: Cardinal;
function GetVerticalAlignment(Node: PVirtualNode): Byte;
function GetVisible(Node: PVirtualNode): Boolean;
function GetVisiblePath(Node: PVirtualNode): Boolean;
function HandleDrawSelection(X, Y: TDimension): Boolean;
procedure HandleCheckboxClick(pHitNode: PVirtualNode; pKeys: LongInt);
function HasVisibleNextSibling(Node: PVirtualNode): Boolean;
function HasVisiblePreviousSibling(Node: PVirtualNode): Boolean;
procedure ImageListChange(Sender: TObject);
procedure InitializeFirstColumnValues(var PaintInfo: TVTPaintInfo);
procedure InitRootNode(OldSize: Cardinal = 0);
function IsFirstVisibleChild(Parent, Node: PVirtualNode): Boolean;
function IsLastVisibleChild(Parent, Node: PVirtualNode): Boolean;
function MakeNewNode: PVirtualNode;
function PackArray({*}const TheArray: TNodeArray; Count: Integer): Integer;
procedure FakeReadIdent(Reader: TReader);
procedure SetAlignment(const Value: TAlignment);
procedure SetAnimationDuration(const Value: Cardinal);
procedure SetBackground(const Value: TVTBackground);
procedure SetBackGroundImageTransparent(const Value: Boolean);
procedure SetBackgroundOffset(const Index: Integer; const Value: TDimension);
procedure SetBorderStyle(Value: TBorderStyle);
procedure SetBottomNode(Node: PVirtualNode);
procedure SetBottomSpace(const Value: TDimension);
procedure SetButtonFillMode(const Value: TVTButtonFillMode);
procedure SetButtonStyle(const Value: TVTButtonStyle);
procedure SetCheckImageKind(Value: TCheckImageKind);
procedure SetCheckState(Node: PVirtualNode; Value: TCheckState);
procedure SetCheckType(Node: PVirtualNode; Value: TCheckType);
procedure SetClipboardFormats(const Value: TClipboardFormats);
procedure SetColors(const Value: TVTColors);
procedure SetCustomCheckImages(const Value: TCustomImageList);
procedure SetDefaultNodeHeight(Value: TDimension);
procedure SetDisabled(Node: PVirtualNode; Value: Boolean);
procedure SetEmptyListMessage(const Value: string);
procedure SetExpanded(Node: PVirtualNode; Value: Boolean);
procedure SetFocusedColumn(Value: TColumnIndex);
procedure SetFocusedNode(Value: PVirtualNode);
procedure SetFullyVisible(Node: PVirtualNode; Value: Boolean);
procedure SetHasChildren(Node: PVirtualNode; Value: Boolean);
procedure SetHeader(const Value: TVTHeader);
procedure SetHotNode(Value: PVirtualNode);
procedure SetFiltered(Node: PVirtualNode; Value: Boolean);
procedure SetImages(const Value: TCustomImageList);
procedure SetIndent(Value: TDimension);
procedure SetLineMode(const Value: TVTLineMode);
procedure SetLineStyle(const Value: TVTLineStyle);
procedure SetMargin(Value: TDimension);
procedure SetMultiline(Node: PVirtualNode; const Value: Boolean);
procedure SetNodeAlignment(const Value: TVTNodeAlignment);
procedure SetNodeDataSize(Value: Integer);
procedure SetNodeHeight(Node: PVirtualNode; Value: TNodeHeight);
procedure SetNodeParent(Node: PVirtualNode; const Value: PVirtualNode);
procedure SetOffsetX(const Value: TDimension);
procedure SetOffsetXY(const Value: TPoint);
procedure SetOffsetY(const Value: TDimension);
procedure SetOptions(const Value: TCustomVirtualTreeOptions);
procedure SetRootNodeCount(Value: Cardinal);
procedure SetScrollBarOptions(Value: TScrollBarOptions);
procedure SetSearchOption(const Value: TVTIncrementalSearch);
procedure SetSelected(Node: PVirtualNode; Value: Boolean);
procedure SetSelectionCurveRadius(const Value: Cardinal);
procedure SetStateImages(const Value: TCustomImageList);
procedure SetTextMargin(Value: TDimension);
procedure SetTopNode(Node: PVirtualNode);
procedure SetUpdateState(Updating: Boolean);
procedure SetVerticalAlignment(Node: PVirtualNode; Value: Byte);
procedure SetVisible(Node: PVirtualNode; Value: Boolean);
procedure SetVisiblePath(Node: PVirtualNode; Value: Boolean);
procedure PrepareBackGroundPicture(Source: TVTBackground; DrawingBitmap: TBitmap; DrawingBitmapWidth: TDimension; DrawingBitmapHeight: TDimension; ABkgcolor: TColor);
procedure StaticBackground(Source: TVTBackground; Target: TCanvas; OffsetPosition: TPoint; R: TRect; aBkgColor: TColor);
procedure TileBackground(Source: TVTBackground; Target: TCanvas; Offset: TPoint; R: TRect; aBkgColor: TColor);
function ToggleCallback(Step, StepSize: Integer; Data: Pointer): Boolean;
procedure CMColorChange(var Message: TMessage); message CM_COLORCHANGED;
procedure CMCtl3DChanged(var Message: TMessage); message CM_CTL3DCHANGED;
procedure CMBiDiModeChanged(var Message: TMessage); message CM_BIDIMODECHANGED;
procedure CMBorderChanged(var Message: TMessage); message CM_BORDERCHANGED;
procedure CMDenySubclassing(var Message: TMessage); message CM_DENYSUBCLASSING;
procedure CMDrag(var Message: TCMDrag); message CM_DRAG;
procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED;
procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
procedure CMHintShow(var Message: TCMHintShow); message CM_HINTSHOW;
procedure CMHintShowPause(var Message: TCMHintShowPause); message CM_HINTSHOWPAUSE;
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
procedure CMMouseWheel(var Message: TCMMouseWheel); message CM_MOUSEWHEEL;
procedure CMSysColorChange(var Message: TMessage); message CM_SYSCOLORCHANGE;
procedure TVMGetItem(var Message: TMessage); message TVM_GETITEM;
procedure TVMGetItemRect(var Message: TMessage); message TVM_GETITEMRECT;
procedure TVMGetNextItem(var Message: TMessage); message TVM_GETNEXTITEM;
procedure WMCancelMode(var Message: TWMCancelMode); message WM_CANCELMODE;
procedure WMChar(var Message: TWMChar); message WM_CHAR;
procedure WMContextMenu(var Message: TWMContextMenu); message WM_CONTEXTMENU;
procedure WMCopy(var Message: TWMCopy); message WM_COPY;
procedure WMCut(var Message: TWMCut); message WM_CUT;
procedure WMEnable(var Message: TWMEnable); message WM_ENABLE;
procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE;
procedure WMHScroll(var Message: TWMHScroll); message WM_HSCROLL;
procedure WMKeyDown(var Message: TWMKeyDown); message WM_KEYDOWN;
procedure WMKeyUp(var Message: TWMKeyUp); message WM_KEYUP;
procedure WMKillFocus(var Msg: TWMKillFocus); message WM_KILLFOCUS;
procedure WMLButtonDblClk(var Message: TWMLButtonDblClk); message WM_LBUTTONDBLCLK;
procedure WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN;
procedure WMLButtonUp(var Message: TWMLButtonUp); message WM_LBUTTONUP;
procedure WMMButtonDblClk(var Message: TWMMButtonDblClk); message WM_MBUTTONDBLCLK;
procedure WMMButtonDown(var Message: TWMMButtonDown); message WM_MBUTTONDOWN;
procedure WMMButtonUp(var Message: TWMMButtonUp); message WM_MBUTTONUP;
procedure WMNCCalcSize(var Message: TWMNCCalcSize); message WM_NCCALCSIZE;
procedure WMNCDestroy(var Message: TWMNCDestroy); message WM_NCDESTROY;
procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;
procedure WMNCPaint(var Message: TWMNCPaint); message WM_NCPAINT;
procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
procedure WMPaste(var Message: TWMPaste); message WM_PASTE;
procedure WMPrint(var Message: TWMPrint); message WM_PRINT;
procedure WMRButtonDblClk(var Message: TWMRButtonDblClk); message WM_RBUTTONDBLCLK;
procedure WMRButtonDown(var Message: TWMRButtonDown); message WM_RBUTTONDOWN;
procedure WMRButtonUp(var Message: TWMRButtonUp); message WM_RBUTTONUP;
procedure WMSetCursor(var Message: TWMSetCursor); message WM_SETCURSOR;
procedure WMSetFocus(var Msg: TWMSetFocus); message WM_SETFOCUS;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
procedure WMTimer(var Message: TWMTimer); message WM_TIMER;
procedure WMThemeChanged(var Message: TMessage); message WM_THEMECHANGED;
procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
function GetRangeX: TDimension;
procedure SetDoubleBuffered(const Value: Boolean);
function GetVclStyleEnabled: Boolean; inline;
procedure SetOnPrepareButtonImages(const Value: TVTPrepareButtonImagesEvent);
function IsStored_BackgroundOffsetXY(const Index: Integer): Boolean;
function IsStored_BottomSpace: Boolean;
function IsStored_DefaultNodeHeight: Boolean;
function IsStored_Indent: Boolean;
function IsStored_Margin: Boolean;
function IsStored_TextMargin: Boolean;
protected
FFontChanged: Boolean; // flag for keeping informed about font changes in the off screen buffer // [IPK] - private to protected
procedure AutoScale(); virtual;
procedure AddToSelection(const NewItems: TNodeArray; NewLength: Integer; ForceInsert: Boolean = False); overload; virtual;
procedure AdjustPaintCellRect(var PaintInfo: TVTPaintInfo; var NextNonEmpty: TColumnIndex); virtual;
procedure AdjustPanningCursor(X, Y: TDimension); virtual;
procedure AdjustTotalHeight(Node: PVirtualNode; Value: TNodeHeight; relative: Boolean = False);
procedure AdviseChangeEvent(StructureChange: Boolean; Node: PVirtualNode; Reason: TChangeReason); virtual;
function AllocateInternalDataArea(Size: Cardinal): Cardinal; virtual;
procedure Animate(Steps, Duration: Cardinal; Callback: TVTAnimationCallback; Data: Pointer); virtual;
function CalculateSelectionRect(X, Y: TDimension): Boolean; virtual;
function CanAutoScroll: Boolean; virtual;
function CanShowDragImage: Boolean; virtual;
function CanSplitterResizeNode(P: TPoint; Node: PVirtualNode; Column: TColumnIndex): Boolean;
procedure Change(Node: PVirtualNode); virtual;
procedure ChangeTreeStatesAsync(EnterStates, LeaveStates: TVirtualTreeStates);
procedure ChangeScale(M, D: Integer{$if CompilerVersion >= 31}; isDpiChange: Boolean{$ifend}); override;
function CheckParentCheckState(Node: PVirtualNode; NewCheckState: TCheckState): Boolean; virtual;
procedure ClearDragManager;
procedure ClearSelection(pFireChangeEvent: Boolean); overload; virtual;
procedure ClearTempCache; virtual;
function ColumnIsEmpty(Node: PVirtualNode; Column: TColumnIndex): Boolean; virtual;
function ComputeRTLOffset(ExcludeScrollBar: Boolean = False): TDimension; virtual;
function CountLevelDifference(Node1, Node2: PVirtualNode): Integer; virtual;
function CountVisibleChildren(Node: PVirtualNode): Cardinal; virtual;
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
procedure DecVisibleCount;
procedure DefineProperties(Filer: TFiler); override;
procedure DeleteNode(Node: PVirtualNode; Reindex: Boolean; ParentClearing: Boolean); overload;
function DetermineDropMode(const P: TPoint; var HitInfo: THitInfo; var NodeRect: TRect): TDropMode; virtual;
procedure DetermineHiddenChildrenFlag(Node: PVirtualNode); virtual;
procedure DetermineHiddenChildrenFlagAllNodes; virtual;
procedure DetermineHitPositionLTR(var HitInfo: THitInfo; Offset, Right: TDimension; Alignment: TAlignment); virtual;
procedure DetermineHitPositionRTL(var HitInfo: THitInfo; Offset, Right: TDimension; Alignment: TAlignment); virtual;
function DetermineLineImageAndSelectLevel(Node: PVirtualNode; var LineImage: TLineImage): Integer; virtual;
function DetermineNextCheckState(CheckType: TCheckType; CheckState: TCheckState): TCheckState; virtual;
function DetermineScrollDirections(X, Y: TDimension): TScrollDirections; virtual;
procedure DoAddToSelection(Node: PVirtualNode); virtual;
procedure DoAdvancedHeaderDraw(var PaintInfo: THeaderPaintInfo; const Elements: THeaderPaintElements); virtual;
procedure DoAfterCellPaint(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; CellRect: TRect); virtual;
procedure DoAfterItemErase(Canvas: TCanvas; Node: PVirtualNode; ItemRect: TRect); virtual;
procedure DoAfterItemPaint(Canvas: TCanvas; Node: PVirtualNode; ItemRect: TRect); virtual;
procedure DoAfterPaint(Canvas: TCanvas); virtual;
procedure DoAutoScroll(X, Y: TDimension); virtual;
function DoBeforeDrag(Node: PVirtualNode; Column: TColumnIndex): Boolean; virtual;
procedure DoBeforeCellPaint(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect); virtual;
procedure DoBeforeItemErase(Canvas: TCanvas; Node: PVirtualNode; ItemRect: TRect; var Color: TColor;
var EraseAction: TItemEraseAction); virtual;
function DoBeforeItemPaint(Canvas: TCanvas; Node: PVirtualNode; ItemRect: TRect): Boolean; virtual;
procedure DoBeforePaint(Canvas: TCanvas); virtual;
function DoCancelEdit: Boolean; virtual;
procedure DoCanEdit(Node: PVirtualNode; Column: TColumnIndex; var Allowed: Boolean); virtual;
procedure DoCanSplitterResizeNode(P: TPoint; Node: PVirtualNode; Column: TColumnIndex;
var Allowed: Boolean); virtual;
procedure DoChange(Node: PVirtualNode); virtual;
procedure DoCheckClick(Node: PVirtualNode; NewCheckState: TCheckState); virtual;
procedure DoChecked(Node: PVirtualNode); virtual;
function DoChecking(Node: PVirtualNode; var NewCheckState: TCheckState): Boolean; virtual;
procedure DoCollapsed(Node: PVirtualNode); virtual;
function DoCollapsing(Node: PVirtualNode): Boolean; virtual;
procedure DoColumnChecked(Column: TColumnIndex); virtual;
function DoColumnChecking(Column: TColumnIndex; var NewCheckState: TCheckState): Boolean; virtual;
procedure DoColumnClick(Column: TColumnIndex; Shift: TShiftState); virtual;
procedure DoColumnDblClick(Column: TColumnIndex; Shift: TShiftState); virtual;
procedure DoColumnResize(Column: TColumnIndex); virtual;
procedure DoColumnVisibilityChanged(const Column: TColumnIndex; Visible: Boolean); virtual;
function DoCompare(Node1, Node2: PVirtualNode; Column: TColumnIndex): Integer; virtual;
function DoCreateDataObject: IDataObject; virtual;
function DoCreateDragManager: IVTDragManager; virtual;
function DoCreateEditor(Node: PVirtualNode; Column: TColumnIndex): IVTEditLink; virtual;
procedure DoDragging(P: TPoint); virtual;
procedure DoDragExpand; virtual;
procedure DoBeforeDrawLineImage(Node: PVirtualNode; Level: Integer; var XPos: TDimension); virtual;
function DoDragOver(Source: TObject; Shift: TShiftState; State: TDragState; Pt: TPoint; Mode: TDropMode;
var Effect: Integer): Boolean; virtual;
procedure DoDragDrop(Source: TObject; const DataObject: TVTDragDataObject; const Formats: TFormatArray; Shift: TShiftState; Pt: TPoint;
var Effect: Integer; Mode: TDropMode); virtual;
procedure DoDrawHint(Canvas: TCanvas; Node: PVirtualNode; R: TRect; Column:
TColumnIndex);
procedure DoEdit; virtual;
procedure DoEndDrag(Target: TObject; X, Y: TDimension); override;
function DoEndEdit(pCancel: Boolean = False): Boolean; virtual;
procedure DoEndOperation(OperationKind: TVTOperationKind); virtual;
procedure DoEnter(); override;
procedure DoExpanded(Node: PVirtualNode); virtual;
function DoExpanding(Node: PVirtualNode): Boolean; virtual;
procedure DoFocusChange(Node: PVirtualNode; Column: TColumnIndex); virtual;
function DoFocusChanging(OldNode, NewNode: PVirtualNode; OldColumn, NewColumn: TColumnIndex): Boolean; virtual;
procedure DoFocusNode(Node: PVirtualNode; Ask: Boolean); virtual;
procedure DoFreeNode(Node: PVirtualNode); virtual;
function DoGetCellContentMargin(Node: PVirtualNode; Column: TColumnIndex;
CellContentMarginType: TVTCellContentMarginType = ccmtAllSides; Canvas: TCanvas = nil): TPoint; virtual;
procedure DoGetCursor(var Cursor: TCursor); virtual;
procedure DoGetHeaderCursor(var Cursor: TVTCursor); virtual;
procedure DoGetHintSize(Node: PVirtualNode; Column: TColumnIndex; var R:
TRect); virtual;