Added: VirtualTree header settings
Fixed: CalcImagePos takes toShowRoot into account
This commit is contained in:
parent
52c944f97c
commit
cc9f8a792e
@ -21,40 +21,42 @@ 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
|
||||||
if ReadBool('Maximized', (AForm.WindowState = wsMaximized)) then
|
if ReadBool('Maximized', (AForm.WindowState = wsMaximized)) then
|
||||||
AForm.WindowState := wsMaximized
|
AForm.WindowState := wsMaximized
|
||||||
else with THackCustomForm(AForm) do begin
|
else with THackCustomForm(AForm) do begin
|
||||||
WindowState := wsNormal;
|
WindowState := wsNormal;
|
||||||
Position := poDesigned;
|
Position := poDesigned;
|
||||||
Left := ReadInteger('Left', Left);
|
Left := ReadInteger('Left', Left);
|
||||||
Top := ReadInteger('Top', Top);
|
Top := ReadInteger('Top', Top);
|
||||||
Width := ReadInteger('Width', Width);
|
Width := ReadInteger('Width', Width);
|
||||||
Height := ReadInteger('Height', Height);
|
Height := ReadInteger('Height', Height);
|
||||||
end;
|
|
||||||
finally
|
|
||||||
Free();
|
|
||||||
end;
|
end;
|
||||||
|
finally
|
||||||
|
Free();
|
||||||
|
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
|
||||||
WriteBool('Maximized', (AForm.WindowState = wsMaximized));
|
WriteBool('Maximized', (AForm.WindowState = wsMaximized));
|
||||||
if AForm.WindowState <> wsMaximized then
|
if AForm.WindowState <> wsMaximized then
|
||||||
with THackCustomForm(AForm) do begin
|
with THackCustomForm(AForm) do begin
|
||||||
WriteInteger('Left', Left);
|
WriteInteger('Left', Left);
|
||||||
WriteInteger('Top', Top);
|
WriteInteger('Top', Top);
|
||||||
WriteInteger('Width', Width);
|
WriteInteger('Width', Width);
|
||||||
WriteInteger('Height', Height);
|
WriteInteger('Height', Height);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
Free();
|
Free();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
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,12 +47,13 @@ begin
|
|||||||
Tag := 0;
|
Tag := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if SortColumn = AColumn then
|
if AApplySort then
|
||||||
SortDirection := TSortDirection(1 - Integer(SortDirection))
|
if SortColumn = AColumn then
|
||||||
else begin
|
SortDirection := TSortDirection(1 - Integer(SortDirection))
|
||||||
SortColumn := AColumn;
|
else begin
|
||||||
SortDirection := sdAscending;
|
SortColumn := AColumn;
|
||||||
end;
|
SortDirection := sdAscending;
|
||||||
|
end;
|
||||||
|
|
||||||
if ASortColor <> clNone then
|
if ASortColor <> clNone then
|
||||||
with Columns[SortColumn] do
|
with Columns[SortColumn] do
|
||||||
@ -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