Skip to content

Commit 23d928c

Browse files
committed
Now using NodeParent[] instead of TVirtualNode.Parent. Related to #831
1 parent da7dab9 commit 23d928c

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

Demos/Advanced/AlignDemo.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ procedure TAlignForm.AlignTreePaintText(Sender: TBaseVirtualTree; const Canvas:
152152
Canvas.Font.Color := clSilver;
153153
2:
154154
begin
155-
if not Odd(Node.Parent.Index) then
155+
if not Odd(Sender.NodeParent[Node].Index) then
156156
Canvas.Font := FArabicFont
157157
else
158158
Canvas.Font := FHebrewFont;
@@ -162,7 +162,7 @@ procedure TAlignForm.AlignTreePaintText(Sender: TBaseVirtualTree; const Canvas:
162162
// Reset the text color for selected and drop target nodes.
163163
if ((Node = Sender.DropTargetNode) or (vsSelected in Node.States)) and (Column = Sender.FocusedColumn) then
164164
Canvas.Font.Color := clHighlightText;
165-
if Node.Parent = Sender.RootNode then
165+
if Sender.NodeParent[Node] = nil then
166166
Canvas.Font.Style := [fsBold];
167167
end;
168168

Demos/Advanced/DrawTreeDemo.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ procedure TDrawTreeForm.VDT1GetNodeWidth(Sender: TBaseVirtualTree; Canvas: TCanv
493493
case Column of
494494
0:
495495
begin
496-
if Node.Parent = Sender.RootNode then
496+
if Sender.NodeParent[Node] = nil then
497497
NodeWidth := Canvas.TextWidth(Data.FullPath) + 2 * AMargin
498498
else
499499
NodeWidth := Canvas.TextWidth(ExtractFileName(Data.FullPath)) + 2 * AMargin;

Demos/Advanced/Editors.pas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ function TPropertyEditLink.EndEdit: Boolean;
286286
begin
287287
Result := True;
288288

289-
Data := FTree.GetNodeData(FNode);
289+
Data := FNode.GetData();
290290
if FEdit is TComboBox then
291291
S := TComboBox(FEdit).Text
292292
else
@@ -329,7 +329,7 @@ function TPropertyEditLink.PrepareEdit(Tree: TBaseVirtualTree; Node: PVirtualNod
329329
// determine what edit type actually is needed
330330
FEdit.Free;
331331
FEdit := nil;
332-
Data := FTree.GetNodeData(Node);
332+
Data := Node.GetData();
333333
case Data.ValueType of
334334
vtString:
335335
begin
@@ -455,7 +455,7 @@ function TGridEditLink.EndEdit: Boolean;
455455

456456
begin
457457
Result := True;
458-
Data := FTree.GetNodeData<TGridData>(FNode);
458+
Data := FNode.GetData<TGridData>();
459459
if FEdit is TComboBox then
460460
begin
461461
S := TComboBox(FEdit).Text;

Demos/Advanced/PropertiesDemo.pas

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface
1010

1111
uses
1212
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
13-
StdCtrls, VirtualTrees, ImgList, ExtCtrls, UITypes;
13+
StdCtrls, VirtualTrees, ImgList, ExtCtrls, UITypes, System.ImageList;
1414

1515
const
1616
// Helper message to decouple node change handling from edit handling.
@@ -125,7 +125,7 @@ procedure TPropertiesForm.VST3GetText(Sender: TBaseVirtualTree; Node: PVirtualNo
125125
if TextType = ttNormal then
126126
case Column of
127127
0:
128-
if Node.Parent = Sender.RootNode then
128+
if Sender.NodeParent[Node] = nil then
129129
begin
130130
// root nodes
131131
if Node.Index = 0 then
@@ -134,7 +134,7 @@ procedure TPropertiesForm.VST3GetText(Sender: TBaseVirtualTree; Node: PVirtualNo
134134
CellText := 'Origin';
135135
end
136136
else
137-
CellText := PropertyTexts[Node.Parent.Index, Node.Index, ptkText];
137+
CellText := PropertyTexts[Sender.NodeParent[Node].Index, Node.Index, ptkText];
138138
1:
139139
begin
140140
Data := Sender.GetNodeData(Node);
@@ -150,9 +150,9 @@ procedure TPropertiesForm.VST3GetHint(Sender: TBaseVirtualTree; Node: PVirtualNo
150150

151151
begin
152152
// Add a dummy hint to the normal hint to demonstrate multiline hints.
153-
if (Column = 0) and (Node.Parent <> Sender.RootNode) then
153+
if (Column = 0) and (Sender.NodeParent[Node] <> nil) then
154154
begin
155-
HintText := PropertyTexts[Node.Parent.Index, Node.Index, ptkHint];
155+
HintText := PropertyTexts[Sender.NodeParent[Node].Index, Node.Index, ptkHint];
156156
{ Related to #Issue 623
157157
Observed when solving issue #623. For hmToolTip, the multi-line mode
158158
depends on the node's multi-lin emode. Hence, append a line only
@@ -177,7 +177,7 @@ procedure TPropertiesForm.VST3GetImageIndex(Sender: TBaseVirtualTree; Node: PVir
177177
begin
178178
if (Kind in [ikNormal, ikSelected]) and (Column = 0) then
179179
begin
180-
if Node.Parent = Sender.RootNode then
180+
if Sender.NodeParent[Node] = nil then
181181
Index := 12 // root nodes, this is an open folder
182182
else
183183
begin
@@ -201,7 +201,7 @@ procedure TPropertiesForm.VST3Editing(Sender: TBaseVirtualTree; Node: PVirtualNo
201201
with Sender do
202202
begin
203203
Data := GetNodeData(Node);
204-
Allowed := (Node.Parent <> RootNode) and (Column = 1) and (Data.ValueType <> vtNone);
204+
Allowed := (Sender.NodeParent[Node] <> nil) and (Column = 1) and (Data.ValueType <> vtNone);
205205
end;
206206
end;
207207

@@ -213,7 +213,7 @@ procedure TPropertiesForm.VST3Change(Sender: TBaseVirtualTree; Node: PVirtualNod
213213
with Sender do
214214
begin
215215
// Start immediate editing as soon as another node gets focused.
216-
if Assigned(Node) and (Node.Parent <> RootNode) and not (tsIncrementalSearching in TreeStates) then
216+
if Assigned(Node) and (Sender.NodeParent[Node] <> nil) and not (tsIncrementalSearching in TreeStates) then
217217
begin
218218
// We want to start editing the currently selected node. However it might well happen that this change event
219219
// here is caused by the node editor if another node is currently being edited. It causes trouble
@@ -249,7 +249,7 @@ procedure TPropertiesForm.VST3PaintText(Sender: TBaseVirtualTree; const TargetCa
249249

250250
begin
251251
// Make the root nodes underlined and draw changed nodes in bold style.
252-
if Node.Parent = Sender.RootNode then
252+
if Sender.NodeParent[Node] = nil then
253253
TargetCanvas.Font.Style := [fsUnderline]
254254
else
255255
begin
@@ -274,7 +274,7 @@ procedure TPropertiesForm.VST3IncrementalSearch(Sender: TBaseVirtualTree; Node:
274274
S := SearchText;
275275
SetStatusbarText('Searching for: ' + S);
276276

277-
if Node.Parent = Sender.RootNode then
277+
if Sender.NodeParent[Node] = nil then
278278
begin
279279
// root nodes
280280
if Node.Index = 0 then
@@ -284,7 +284,7 @@ procedure TPropertiesForm.VST3IncrementalSearch(Sender: TBaseVirtualTree; Node:
284284
end
285285
else
286286
begin
287-
PropText := PropertyTexts[Node.Parent.Index, Node.Index, ptkText];
287+
PropText := PropertyTexts[Sender.NodeParent[Node].Index, Node.Index, ptkText];
288288
end;
289289

290290
// By using StrLIComp we can specify a maximum length to compare. This allows us to find also nodes

Demos/Advanced/WindowsXPStyleDemo.pas

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ procedure TWindowsXPForm.XPTreeGetImageIndex(Sender: TBaseVirtualTree; Node: PVi
104104
Data := Sender.GetNodeData(Node);
105105
case Kind of
106106
ikNormal, ikSelected:
107-
if (Column = 0) and (Node.Parent = Sender.RootNode) then
107+
if (Column = 0) and (Sender.NodeParent[Node] = nil) then
108108
Index := Data.Image;
109109
ikState:
110110
case Column of
111111
0:
112-
if Node.Parent <> Sender.RootNode then
112+
if Sender.NodeParent[Node] <> nil then
113113
Index := 21;
114114
end;
115115
end;
@@ -168,15 +168,15 @@ procedure TWindowsXPForm.XPTreeGetText(Sender: TBaseVirtualTree; Node: PVirtualN
168168
Data := Sender.GetNodeData(Node);
169169
case Column of
170170
0:
171-
if Node.Parent = Sender.RootNode then
171+
if Sender.NodeParent[Node] = nil then
172172
CellText := Data.Caption
173173
else
174174
CellText := 'More entries';
175175
1:
176-
if Node.Parent = Sender.RootNode then
176+
if Sender.NodeParent[Node] = nil then
177177
CellText := FloatToStr(Data.Size / 1000) + ' MB';
178178
2:
179-
if Node.Parent = Sender.RootNode then
179+
if Sender.NodeParent[Node] = nil then
180180
CellText := 'System Folder';
181181
end;
182182
end;

0 commit comments

Comments
 (0)