-
Notifications
You must be signed in to change notification settings - Fork 261
/
Copy pathVirtualTrees.DrawTree.pas
352 lines (317 loc) · 10.5 KB
/
VirtualTrees.DrawTree.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
unit VirtualTrees.DrawTree;
interface
uses
System.Types,
System.Classes,
Vcl.Themes,
VirtualTrees.Types,
VirtualTrees.BaseTree,
{$IFDEF VT_FMX}
VirtualTrees.AncestorFMX,
{$ELSE}
VirtualTrees.AncestorVCL
{$ENDIF}
;
type
{$IFDEF VT_FMX}
TVTAncestor = TVTAncestorFMX;
{$ELSE}
TVTAncestor = TVTAncestorVcl;
{$ENDIF}
// Tree descendant to let an application draw its stuff itself.
TCustomVirtualDrawTree = class(TVTAncestor)
private
FOnDrawNode: TVTDrawNodeEvent;
FOnGetCellContentMargin: TVTGetCellContentMarginEvent;
FOnGetNodeWidth: TVTGetNodeWidthEvent;
protected
function DoGetCellContentMargin(Node: PVirtualNode; Column: TColumnIndex;
CellContentMarginType: TVTCellContentMarginType = ccmtAllSides; Canvas: TCanvas = nil): TPoint; override;
function DoGetNodeWidth(Node: PVirtualNode; Column: TColumnIndex; Canvas: TCanvas = nil): TDimension; override;
procedure DoPaintNode(var PaintInfo: TVTPaintInfo); override;
function GetDefaultHintKind: TVTHintKind; override;
property OnDrawNode: TVTDrawNodeEvent read FOnDrawNode write FOnDrawNode;
property OnGetCellContentMargin: TVTGetCellContentMarginEvent read FOnGetCellContentMargin write FOnGetCellContentMargin;
property OnGetNodeWidth: TVTGetNodeWidthEvent read FOnGetNodeWidth write FOnGetNodeWidth;
end;
[ComponentPlatformsAttribute(pidWin32 or pidWin64)]
TVirtualDrawTree = class(TCustomVirtualDrawTree)
private
function GetOptions: TVirtualTreeOptions;
procedure SetOptions(const Value: TVirtualTreeOptions);
protected
function GetOptionsClass: TTreeOptionsClass; override;
public
property Canvas;
property LastDragEffect;
property CheckImageKind; // should no more be published to make #622 fix working
published
property Action;
property Align;
property Alignment;
property Anchors;
property AnimationDuration;
property AutoExpandDelay;
property AutoScrollDelay;
property AutoScrollInterval;
property Background;
property BackgroundOffsetX;
property BackgroundOffsetY;
property BiDiMode;
property BevelEdges;
property BevelInner;
property BevelOuter;
property BevelKind;
property BevelWidth;
property BorderStyle;
property BottomSpace;
property ButtonFillMode;
property ButtonStyle;
property BorderWidth;
property ChangeDelay;
property ClipboardFormats;
property Color;
property Colors;
property Constraints;
property Ctl3D;
property CustomCheckImages;
property DefaultNodeHeight;
property DefaultPasteMode;
property DragCursor;
property DragHeight;
property DragKind;
property DragImageKind;
property DragMode;
property DragOperations;
property DragType;
property DragWidth;
property DrawSelectionMode;
property EditDelay;
property Enabled;
property Font;
property Header;
property HintMode;
property HotCursor;
property Images;
property IncrementalSearch;
property IncrementalSearchDirection;
property IncrementalSearchStart;
property IncrementalSearchTimeout;
property Indent;
property LineMode;
property LineStyle;
property Margin;
property NodeAlignment;
property NodeDataSize;
property OperationCanceled;
property ParentBiDiMode;
property ParentColor default False;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property RootNodeCount;
property ScrollBarOptions;
property SelectionBlendFactor;
property SelectionCurveRadius;
property ShowHint;
property StateImages;
property TabOrder;
property TabStop default True;
property TextMargin;
property TreeOptions: TVirtualTreeOptions read GetOptions write SetOptions;
property Visible;
property WantTabs;
property OnAddToSelection;
property OnAdvancedHeaderDraw;
property OnAfterAutoFitColumn;
property OnAfterAutoFitColumns;
property OnAfterCellPaint;
property OnAfterColumnExport;
property OnAfterColumnWidthTracking;
property OnAfterGetMaxColumnWidth;
property OnAfterHeaderExport;
property OnAfterHeaderHeightTracking;
property OnAfterItemErase;
property OnAfterItemPaint;
property OnAfterNodeExport;
property OnAfterPaint;
property OnAfterTreeExport;
property OnBeforeAutoFitColumn;
property OnBeforeAutoFitColumns;
property OnBeforeCellPaint;
property OnBeforeColumnExport;
property OnBeforeColumnWidthTracking;
property OnBeforeDrawTreeLine;
property OnBeforeGetMaxColumnWidth;
property OnBeforeHeaderExport;
property OnBeforeHeaderHeightTracking;
property OnBeforeItemErase;
property OnBeforeItemPaint;
property OnBeforeNodeExport;
property OnBeforePaint;
property OnBeforeTreeExport;
property OnCanSplitterResizeColumn;
property OnCanSplitterResizeHeader;
property OnCanSplitterResizeNode;
property OnChange;
property OnChecked;
property OnChecking;
property OnClick;
property OnCollapsed;
property OnCollapsing;
property OnColumnChecked;
property OnColumnChecking;
property OnColumnClick;
property OnColumnDblClick;
property OnColumnExport;
property OnColumnResize;
property OnColumnVisibilityChanged;
property OnColumnWidthDblClickResize;
property OnColumnWidthTracking;
property OnCompareNodes;
property OnContextPopup;
property OnCreateDataObject;
property OnCreateDragManager;
property OnCreateEditor;
property OnDblClick;
property OnDragAllowed;
property OnDragOver;
property OnDragDrop;
property OnDrawHint;
property OnDrawNode;
property OnEdited;
property OnEditing;
property OnEndDock;
property OnEndDrag;
property OnEndOperation;
property OnEnter;
property OnExit;
property OnExpanded;
property OnExpanding;
property OnFocusChanged;
property OnFocusChanging;
property OnFreeNode;
property OnGetCellIsEmpty;
property OnGetCursor;
property OnGetHeaderCursor;
property OnGetHelpContext;
property OnGetHintKind;
property OnGetHintSize;
property OnGetImageIndex;
property OnGetImageIndexEx;
property OnGetLineStyle;
property OnGetNodeDataSize;
property OnGetNodeWidth;
property OnGetPopupMenu;
property OnGetUserClipboardFormats;
property OnHeaderAddPopupItem;
property OnHeaderClick;
property OnHeaderDblClick;
property OnHeaderDragged;
property OnHeaderDraggedOut;
property OnHeaderDragging;
property OnHeaderDraw;
property OnHeaderDrawQueryElements;
property OnHeaderHeightTracking;
property OnHeaderHeightDblClickResize;
property OnHeaderMouseDown;
property OnHeaderMouseMove;
property OnHeaderMouseUp;
property OnHotChange;
property OnIncrementalSearch;
property OnInitChildren;
property OnInitNode;
property OnKeyAction;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnLoadNode;
property OnLoadTree;
property OnMeasureItem;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnMouseWheel;
property OnNodeClick;
property OnNodeCopied;
property OnNodeCopying;
property OnNodeDblClick;
property OnNodeExport;
property OnNodeHeightTracking;
property OnNodeHeightDblClickResize;
property OnNodeMoved;
property OnNodeMoving;
property OnPaintBackground;
property OnPrepareButtonBitmaps;
property OnRemoveFromSelection;
property OnRenderOLEData;
property OnResetNode;
property OnResize;
property OnSaveNode;
property OnSaveTree;
property OnScroll;
property OnShowScrollBar;
property OnStartDock;
property OnStartDrag;
property OnStartOperation;
property OnStateChange;
property OnStructureChange;
property OnUpdating;
property OnCanResize;
property OnGesture;
property Touch;
property StyleElements;
end;
implementation
uses
VirtualTrees.StyleHooks;
//----------------------------------------------------------------------------------------------------------------------
function TCustomVirtualDrawTree.DoGetCellContentMargin(Node: PVirtualNode; Column: TColumnIndex;
CellContentMarginType: TVTCellContentMarginType = ccmtAllSides; Canvas: TCanvas = nil): TPoint;
begin
Result := Point(0, 0);
if Canvas = nil then
Canvas := Self.Canvas;
if Assigned(FOnGetCellContentMargin) then
FOnGetCellContentMargin(Self, Canvas, Node, Column, CellContentMarginType, Result);
end;
//----------------------------------------------------------------------------------------------------------------------
function TCustomVirtualDrawTree.DoGetNodeWidth(Node: PVirtualNode; Column: TColumnIndex; Canvas: TCanvas = nil): TDimension;
begin
Result := 2 * TextMargin;
if Canvas = nil then
Canvas := Self.Canvas;
if Assigned(FOnGetNodeWidth) then
FOnGetNodeWidth(Self, Canvas, Node, Column, Result);
end;
//----------------------------------------------------------------------------------------------------------------------
procedure TCustomVirtualDrawTree.DoPaintNode(var PaintInfo: TVTPaintInfo);
begin
if Assigned(FOnDrawNode) then
FOnDrawNode(Self, PaintInfo);
end;
function TCustomVirtualDrawTree.GetDefaultHintKind: TVTHintKind;
begin
Result := vhkOwnerDraw;
end;
//----------------- TVirtualDrawTree -----------------------------------------------------------------------------------
function TVirtualDrawTree.GetOptions: TVirtualTreeOptions;
begin
Result := inherited TreeOptions as TVirtualTreeOptions;
end;
//----------------------------------------------------------------------------------------------------------------------
procedure TVirtualDrawTree.SetOptions(const Value: TVirtualTreeOptions);
begin
TreeOptions.Assign(Value);
end;
//----------------------------------------------------------------------------------------------------------------------
function TVirtualDrawTree.GetOptionsClass: TTreeOptionsClass;
begin
Result := TVirtualTreeOptions;
end;
initialization
TCustomStyleEngine.RegisterStyleHook(TVirtualDrawTree, TVclStyleScrollBarsHook);
finalization
TCustomStyleEngine.UnRegisterStyleHook(TVirtualDrawTree, TVclStyleScrollBarsHook);
end.