Added: VirtualTree header settings
Fixed: CalcImagePos takes toShowRoot into account
This commit is contained in:
parent
52c944f97c
commit
cc9f8a792e
@ -21,7 +21,8 @@ implementation
|
|||||||
type
|
type
|
||||||
THackCustomForm = class(TCustomForm);
|
THackCustomForm = class(TCustomForm);
|
||||||
|
|
||||||
procedure ReadFormPos;
|
procedure ReadFormPos(const AFactory: TX2SettingsFactory;
|
||||||
|
const ASection: String; const AForm: TCustomForm);
|
||||||
begin
|
begin
|
||||||
with AFactory[ASection] do
|
with AFactory[ASection] do
|
||||||
try
|
try
|
||||||
@ -40,7 +41,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure WriteFormPos;
|
procedure WriteFormPos(const AFactory: TX2SettingsFactory;
|
||||||
|
const ASection: String; const AForm: TCustomForm);
|
||||||
begin
|
begin
|
||||||
with AFactory[ASection] do
|
with AFactory[ASection] do
|
||||||
try
|
try
|
||||||
|
81
X2UtSettingsVirtualTree.pas
Normal file
81
X2UtSettingsVirtualTree.pas
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
{
|
||||||
|
:: X2UtSettingsVirtualTree provides functions to read and write VirtualTree
|
||||||
|
:: settings.
|
||||||
|
::
|
||||||
|
:: Last changed: $Date: 2004-07-22 16:52:09 +0200 (Thu, 22 Jul 2004) $
|
||||||
|
:: Revision: $Rev: 25 $
|
||||||
|
:: Author: $Author: psycho $
|
||||||
|
}
|
||||||
|
unit X2UtSettingsVirtualTree;
|
||||||
|
|
||||||
|
interface
|
||||||
|
uses
|
||||||
|
VirtualTrees,
|
||||||
|
X2UtSettings;
|
||||||
|
|
||||||
|
procedure ReadVTHeader(const AFactory: TX2SettingsFactory;
|
||||||
|
const ASection: String; const AHeader: TVTHeader);
|
||||||
|
procedure WriteVTHeader(const AFactory: TX2SettingsFactory;
|
||||||
|
const ASection: String; const AHeader: TVTHeader);
|
||||||
|
|
||||||
|
implementation
|
||||||
|
uses
|
||||||
|
SysUtils;
|
||||||
|
|
||||||
|
procedure ReadVTHeader(const AFactory: TX2SettingsFactory;
|
||||||
|
const ASection: String; const AHeader: TVTHeader);
|
||||||
|
var
|
||||||
|
iColumn: Integer;
|
||||||
|
sColumn: String;
|
||||||
|
|
||||||
|
begin
|
||||||
|
with AFactory[ASection] do
|
||||||
|
try
|
||||||
|
AHeader.SortColumn := ReadInteger('SortColumn', AHeader.SortColumn);
|
||||||
|
if ReadBool('SortAscending', AHeader.SortDirection = sdAscending) then
|
||||||
|
AHeader.SortDirection := sdAscending
|
||||||
|
else
|
||||||
|
AHeader.SortDirection := sdDescending;
|
||||||
|
|
||||||
|
for iColumn := 0 to Pred(AHeader.Columns.Count) do
|
||||||
|
with AHeader.Columns[iColumn] do
|
||||||
|
begin
|
||||||
|
sColumn := IntToStr(iColumn) + '.';
|
||||||
|
Position := ReadInteger(sColumn + 'Position', Position);
|
||||||
|
Width := ReadInteger(sColumn + 'Width', Width);
|
||||||
|
if ReadBool(sColumn + 'Visible', coVisible in Options) then
|
||||||
|
Options := Options + [coVisible]
|
||||||
|
else
|
||||||
|
Options := Options - [coVisible];
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
Free();
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure WriteVTHeader(const AFactory: TX2SettingsFactory;
|
||||||
|
const ASection: String; const AHeader: TVTHeader);
|
||||||
|
var
|
||||||
|
iColumn: Integer;
|
||||||
|
sColumn: String;
|
||||||
|
|
||||||
|
begin
|
||||||
|
with AFactory[ASection] do
|
||||||
|
try
|
||||||
|
WriteInteger('SortColumn', AHeader.SortColumn);
|
||||||
|
WriteBool('SortAscending', AHeader.SortDirection = sdAscending);
|
||||||
|
|
||||||
|
for iColumn := 0 to Pred(AHeader.Columns.Count) do
|
||||||
|
with AHeader.Columns[iColumn] do
|
||||||
|
begin
|
||||||
|
sColumn := IntToStr(iColumn) + '.';
|
||||||
|
WriteInteger(sColumn + 'Position', Position);
|
||||||
|
WriteInteger(sColumn + 'Width', Width);
|
||||||
|
WriteBool(sColumn + 'Visible', coVisible in Options);
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
Free();
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
@ -22,18 +22,20 @@ uses
|
|||||||
//:: SortColumn for the second time, so be sure not to rely on that.
|
//:: SortColumn for the second time, so be sure not to rely on that.
|
||||||
procedure SortColumn(const AHeader: TVTHeader;
|
procedure SortColumn(const AHeader: TVTHeader;
|
||||||
const AColumn: TColumnIndex;
|
const AColumn: TColumnIndex;
|
||||||
const ASortColor: TColor = clNone);
|
const ASortColor: TColor = clNone;
|
||||||
|
const AApplySort: Boolean = True);
|
||||||
|
|
||||||
//:$ Calculates the position of an image in a virtual string tree.
|
//:$ Calculates the position of an image in a virtual string tree.
|
||||||
function CalcImagePos(const ATree: TVirtualStringTree;
|
function CalcImagePos(const ATree: TVirtualStringTree;
|
||||||
const ANode: PVirtualNode;
|
const ANode: PVirtualNode;
|
||||||
const AItemRect: TRect): TPoint;
|
const ACellRect: TRect): TPoint;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
procedure SortColumn(const AHeader: TVTHeader;
|
procedure SortColumn(const AHeader: TVTHeader;
|
||||||
const AColumn: TColumnIndex;
|
const AColumn: TColumnIndex;
|
||||||
const ASortColor: TColor = clNone);
|
const ASortColor: TColor;
|
||||||
|
const AApplySort: Boolean);
|
||||||
begin
|
begin
|
||||||
with AHeader do
|
with AHeader do
|
||||||
begin
|
begin
|
||||||
@ -45,6 +47,7 @@ begin
|
|||||||
Tag := 0;
|
Tag := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if AApplySort then
|
||||||
if SortColumn = AColumn then
|
if SortColumn = AColumn then
|
||||||
SortDirection := TSortDirection(1 - Integer(SortDirection))
|
SortDirection := TSortDirection(1 - Integer(SortDirection))
|
||||||
else begin
|
else begin
|
||||||
@ -63,16 +66,19 @@ end;
|
|||||||
|
|
||||||
function CalcImagePos(const ATree: TVirtualStringTree;
|
function CalcImagePos(const ATree: TVirtualStringTree;
|
||||||
const ANode: PVirtualNode;
|
const ANode: PVirtualNode;
|
||||||
const AItemRect: TRect): TPoint;
|
const ACellRect: TRect): TPoint;
|
||||||
var
|
var
|
||||||
pNode: PVirtualNode;
|
pNode: PVirtualNode;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result := AItemRect.TopLeft;
|
Result := ACellRect.TopLeft;
|
||||||
|
|
||||||
with ATree do
|
with ATree do
|
||||||
begin
|
begin
|
||||||
pNode := ANode;
|
pNode := ANode;
|
||||||
|
if Assigned(pNode) and not (toShowRoot in ATree.TreeOptions.PaintOptions) then
|
||||||
|
pNode := pNode^.Parent;
|
||||||
|
|
||||||
while Assigned(pNode) and (pNode <> ATree.RootNode) do
|
while Assigned(pNode) and (pNode <> ATree.RootNode) do
|
||||||
begin
|
begin
|
||||||
Inc(Result.X, Indent);
|
Inc(Result.X, Indent);
|
||||||
|
Loading…
Reference in New Issue
Block a user