forked from pyscripter/pyscripter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cVirtualStringTreeHelper.pas
81 lines (64 loc) · 2.36 KB
/
cVirtualStringTreeHelper.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
{-----------------------------------------------------------------------------
Unit Name: cVirtualStringTreeHelper
Author: Kiriakos
Date: 06-March-2012
Purpose: SpTBXLib themeing of TVirtualStringTree
History:
-----------------------------------------------------------------------------}
unit cVirtualStringTreeHelper;
interface
uses
Types, Windows, Classes, Graphics, VirtualTrees, VirtualTrees.Utils,
SpTBXSkins;
type
TVirtualStringTreeHelper = class helper for TCustomVirtualStringTree
public
procedure ReinitInitializedNode(Node: PVirtualNode; Recursive: Boolean);
procedure ReinitInitializedChildren(Node: PVirtualNode; Recursive: Boolean);
end;
implementation
type
// to help us access protected methods
TCrackedVirtualStringTree = class(TCustomVirtualStringTree)
end;
{ TThemedVirtualStringTree }
procedure TVirtualStringTreeHelper.ReinitInitializedChildren(Node: PVirtualNode;
Recursive: Boolean);
// Forces all child nodes of Node to be reinitialized.
// If Recursive is True then also the grandchildren are reinitialized.
// Modified version to reinitialize only when the node is already initialized
var
Run: PVirtualNode;
begin
if Assigned(Node) then
begin
TCrackedVirtualStringTree(Self).InitChildren(Node);
Run := Node.FirstChild;
end
else
begin
TCrackedVirtualStringTree(Self).InitChildren(RootNode);
Run := RootNode.FirstChild;
end;
while Assigned(Run) do
begin
if vsInitialized in Run.States then
ReinitInitializedNode(Run, Recursive);
Run := Run.NextSibling;
end;
end;
procedure TVirtualStringTreeHelper.ReinitInitializedNode(Node: PVirtualNode;
Recursive: Boolean);
// Forces the given node and all its children (if recursive is True) to be initialized again without
// modifying any data in the nodes nor deleting children (unless the application requests a different amount).
begin
if Assigned(Node) and (Node <> RootNode) and (vsInitialized in Node.States) then
begin
// Remove dynamic styles.
Node.States := Node.States - [vsChecking, vsCutOrCopy, vsDeleting, vsHeightMeasured];
TCrackedVirtualStringTree(self).InitNode(Node);
end;
if Recursive and (not Assigned(Node) or Assigned(Node) and (vsInitialized in Node.States)) then
ReinitInitializedChildren(Node, True);
end;
end.