1
0
mirror of synced 2024-09-19 17:56:09 +00:00

Added: CalcImagePos function

This commit is contained in:
Mark van Renswoude 2005-02-26 22:06:31 +00:00
parent 92db5a273e
commit 52c944f97c

View File

@ -11,9 +11,10 @@ unit X2UtVirtualTree;
interface interface
uses uses
Graphics, Graphics,
VirtualTrees; VirtualTrees,
Windows;
//:$ Applies the sort order on the specified column //:$ Applies the sort order on the specified column.
//:: When a column is already sorted, the sort order is reversed. //:: When a column is already sorted, the sort order is reversed.
//:: Specify a SortColor to provide the new column with that color //:: Specify a SortColor to provide the new column with that color
//:: (similar to Explorer in Windows XP). If you choose to use SortColor, //:: (similar to Explorer in Windows XP). If you choose to use SortColor,
@ -23,9 +24,16 @@ uses
const AColumn: TColumnIndex; const AColumn: TColumnIndex;
const ASortColor: TColor = clNone); const ASortColor: TColor = clNone);
//:$ Calculates the position of an image in a virtual string tree.
function CalcImagePos(const ATree: TVirtualStringTree;
const ANode: PVirtualNode;
const AItemRect: TRect): TPoint;
implementation implementation
procedure SortColumn; procedure SortColumn(const AHeader: TVTHeader;
const AColumn: TColumnIndex;
const ASortColor: TColor = clNone);
begin begin
with AHeader do with AHeader do
begin begin
@ -53,5 +61,28 @@ begin
end; end;
end; end;
function CalcImagePos(const ATree: TVirtualStringTree;
const ANode: PVirtualNode;
const AItemRect: TRect): TPoint;
var
pNode: PVirtualNode;
begin
Result := AItemRect.TopLeft;
with ATree do
begin
pNode := ANode;
while Assigned(pNode) and (pNode <> ATree.RootNode) do
begin
Inc(Result.X, Indent);
pNode := pNode^.Parent;
end;
Inc(Result.X, Margin);
Inc(Result.Y, (Integer(NodeHeight[ANode]) - Images.Height) div 2);
end;
end;
end. end.