📄 jvdockinfo.pas
字号:
TreeZone: TJvDockInfoZone;
begin
if FAppStorage.PathExists(FormList[Index]) then
begin
TreeZone := TJvDockInfoZone(AddChildZone(CurrTreeZone, nil));
with TreeZone, FAppStorage do
begin
{ Move down into the folder of the form.. }
Path := ConcatPaths([Path, FormList[Index]]);
DockFormName := FormList[Index];
ParentName := ReadString('ParentName');
DockRect := Rect(ReadInteger('DockLeft'), ReadInteger('DockTop'),
ReadInteger('DockRight'), ReadInteger('DockBottom'));
LRDockWidth := ReadInteger('LRDockWidth');
LastDockSiteName := ReadString('LastDockSiteName');
UnDockLeft := ReadInteger('UnDockLeft');
UnDockTop := ReadInteger('UnDockTop');
TBDockHeight := ReadInteger('TBDockHeight');
UnDockWidth := ReadInteger('UnDockWidth');
UnDockHeight := ReadInteger('UnDockHeight');
VSPaneWidth := ReadInteger('VSPaneWidth');
Visible := ReadBoolean('Visible');
BorderStyle := TBorderStyle(ReadInteger('BorderStyle'));
FormStyle := TFormStyle(ReadInteger('FormStyle'));
WindowState := TWindowState(ReadInteger('WindowState'));
DockFormStyle := TJvDockFormStyle(ReadInteger('DockFormStyle'));
CanDocked := ReadBoolean('CanDocked');
EachOtherDocked := ReadBoolean('EachOtherDocked');
LeftDocked := ReadBoolean('LeftDocked');
TopDocked := ReadBoolean('TopDocked');
RightDocked := ReadBoolean('RightDocked');
BottomDocked := ReadBoolean('BottomDocked');
CustomDocked := ReadBoolean('CustomDocked'); {NEW}
DockClientData := ReadString('DockClientData');
{ ..and move up a level }
Path := ConcatPaths([Path, '..']);
end;
for I := Index - 1 downto 0 do
begin
{ Search for forms that have this form (FormList[I]) as parent }
if FAppStorage.ReadString(FAppStorage.ConcatPaths([FormList[I], 'ParentName'])) = FormList[Index] then
begin
CurrTreeZone := TreeZone;
CreateZoneAndAddInfo(I);
CurrTreeZone := TreeZone.GetParentZone;
end;
end;
end;
end;
begin
FormList := TStringList.Create;
FJvDockInfoStyle := isJVCLReadInfo; // set mode for Scan.
try
{ Normally, we wouldn't find duplicate names, but if so ignore them otherwise havoc }
FormList.Duplicates := dupIgnore;
OldPath := FAppStorage.Path;
try
FAppStorage.Path := FAppStorage.ConcatPaths([FAppStorage.Path, AppStoragePath, 'Forms']);
if FAppStorage.ValueStored('FormNames') then
begin
S := FAppStorage.ReadString('FormNames');
{ UniqueString is used because we modify the contents of S after
casting S to a PChar. S might point to an actual string in a storage,
as is the case with TJvAppXMLFileStorage. Not using UniqueString would
change the value in the storage too. }
UniqueString(S);
CP := PChar(S);
CP1 := StrPos(CP, ';');
while CP1 <> nil do
begin
CP1^ := #0;
FormList.Add(string(CP));
CP := CP1 + 1;
CP1 := StrPos(CP, ';');
end;
for I := FormList.Count - 1 downto 0 do
if FAppStorage.ReadString(FAppStorage.ConcatPaths([FormList[I], 'ParentName'])) = '' then
CreateZoneAndAddInfo(I);
end;
finally
FAppStorage.Path := OldPath;
end;
finally
FormList.Free;
FJvDockInfoStyle := isNone;
end;
end;
{$ENDIF USEJVCL}
procedure TJvDockInfoTree.CreateZoneAndAddInfoFromIni;
var
I: Integer;
Sections: TStringList;
TempDockInfoZoneArray: array of TJvDockInfoZone;
procedure CreateTempDockInfoZoneArray;
var
I: Integer;
begin
SetLength(TempDockInfoZoneArray, SizeOf(TJvDockInfoZone) * Sections.Count);
for I := 0 to Sections.Count - 1 do
begin
TempDockInfoZoneArray[I] := TJvDockInfoZone.Create(nil);
with TempDockInfoZoneArray[I], DockInfoIni do
begin
DockFormName := Sections[I];
ParentName := ReadString(DockFormName, 'ParentName', 'ERROR');
DockRect := Rect(ReadInteger(DockFormName, 'DockLeft', 0),
ReadInteger(DockFormName, 'DockTop', 0),
ReadInteger(DockFormName, 'DockRight', 100),
ReadInteger(DockFormName, 'DockBottom', 100));
LastDockSiteName := ReadString(DockFormName, 'LastDockSiteName', 'ERROR');
UnDockLeft := ReadInteger(DockFormName, 'UnDockLeft', 100);
UnDockTop := ReadInteger(DockFormName, 'UnDockTop', 100);
LRDockWidth := ReadInteger(DockFormName, 'LRDockWidth', 100);
TBDockHeight := ReadInteger(DockFormName, 'TBDockHeight', 100);
UnDockWidth := ReadInteger(DockFormName, 'UnDockWidth', 100);
UnDockHeight := ReadInteger(DockFormName, 'UnDockHeight', 100);
VSPaneWidth := ReadInteger(DockFormName, 'VSPaneWidth', 100);
Visible := ReadBool(DockFormName, 'Visible', True);
BorderStyle := TBorderStyle(ReadInteger(DockFormName, 'BorderStyle', 0));
FormStyle := TFormStyle(ReadInteger(DockFormName, 'FormStyle', 0));
WindowState := TWindowState(ReadInteger(DockFormName, 'WindowState', 0));
DockFormStyle := TJvDockFormStyle(ReadInteger(DockFormName, 'DockFormStyle', 0));
CanDocked := ReadBool(DockFormName, 'CanDocked', True);
EachOtherDocked := ReadBool(DockFormName, 'EachOtherDocked', True);
LeftDocked := ReadBool(DockFormName, 'LeftDocked', LeftDocked);
TopDocked := ReadBool(DockFormName, 'TopDocked', True);
RightDocked := ReadBool(DockFormName, 'RightDocked', True);
BottomDocked := ReadBool(DockFormName, 'BottomDocked', True);
CustomDocked := ReadBool(DockFormName, 'CustomDocked', True);
DockClientData := ReadString(DockFormName, 'DockClientData', '');
end;
end;
end;
procedure DestroyTempDockInfoZoneArray;
var
I: Integer;
begin
for I := Sections.Count - 1 downto 0 do
TempDockInfoZoneArray[I].Free;
end;
procedure CreateZoneAndAddInfo(Index: Integer);
var
I: Integer;
TreeZone: TJvDockInfoZone;
begin
TreeZone := TJvDockInfoZone(AddChildZone(CurrTreeZone, nil));
with TempDockInfoZoneArray[Index] do
begin
TreeZone.DockFormName := DockFormName;
TreeZone.ParentName := ParentName;
TreeZone.DockRect := DockRect;
TreeZone.LastDockSiteName := LastDockSiteName;
TreeZone.UnDockLeft := UnDockLeft;
TreeZone.UnDockTop := UnDockTop;
TreeZone.LRDockWidth := LRDockWidth;
TreeZone.TBDockHeight := TBDockHeight;
TreeZone.UnDockWidth := UnDockWidth;
TreeZone.UnDockHeight := UnDockHeight;
TreeZone.VSPaneWidth := VSPaneWidth;
TreeZone.Visible := Visible;
TreeZone.BorderStyle := BorderStyle;
TreeZone.FormStyle := FormStyle;
TreeZone.WindowState := WindowState;
TreeZone.DockFormStyle := DockFormStyle;
TreeZone.CanDocked := CanDocked;
TreeZone.EachOtherDocked := EachOtherDocked;
TreeZone.LeftDocked := LeftDocked;
TreeZone.TopDocked := TopDocked;
TreeZone.RightDocked := RightDocked;
TreeZone.BottomDocked := BottomDocked;
TreeZone.CustomDocked := CustomDocked; {NEW!}
TreeZone.DockClientData := DockClientData;
end;
for I := Index - 1 downto 0 do
if TempDockInfoZoneArray[I].ParentName = Sections[Index] then
begin
CurrTreeZone := TreeZone;
CreateZoneAndAddInfo(I);
CurrTreeZone := TreeZone.GetParentZone;
end;
end;
begin
Sections := TStringList.Create;
try
DockInfoIni.ReadSections(Sections);
CreateTempDockInfoZoneArray;
for I := Sections.Count - 1 downto 0 do
if TempDockInfoZoneArray[I].ParentName = '' then
CreateZoneAndAddInfo(I);
FJvDockInfoStyle := isNone;
finally
DestroyTempDockInfoZoneArray;
Sections.Free;
end;
end;
procedure TJvDockInfoTree.CreateZoneAndAddInfoFromReg;
var
FormList: TStringList;
CP, CP1: PChar;
I: Integer;
S: string;
procedure CreateZoneAndAddInfo(Index: Integer);
var
I: Integer;
TreeZone: TJvDockInfoZone;
begin
DockInfoReg.OpenKey(FRegName, False);
if DockInfoReg.KeyExists(FormList[Index]) then
begin
DockInfoReg.OpenKey(FRegName + '\' + FormList[Index], False);
TreeZone := TJvDockInfoZone(AddChildZone(CurrTreeZone, nil));
with TreeZone, DockInfoReg do
begin
DockFormName := FormList[Index];
ParentName := ReadString('ParentName');
DockRect := Rect(ReadInteger('DockLeft'), ReadInteger('DockTop'),
ReadInteger('DockRight'), ReadInteger('DockBottom'));
LRDockWidth := ReadInteger('LRDockWidth');
LastDockSiteName := ReadString('LastDockSiteName');
UnDockLeft := ReadInteger('UnDockLeft');
UnDockTop := ReadInteger('UnDockTop');
TBDockHeight := ReadInteger('TBDockHeight');
UnDockWidth := ReadInteger('UnDockWidth');
UnDockHeight := ReadInteger('UnDockHeight');
VSPaneWidth := ReadInteger('VSPaneWidth');
Visible := ReadBool('Visible');
BorderStyle := TBorderStyle(ReadInteger('BorderStyle'));
FormStyle := TFormStyle(ReadInteger('FormStyle'));
WindowState := TWindowState(ReadInteger('WindowState'));
DockFormStyle := TJvDockFormStyle(ReadInteger('DockFormStyle'));
CanDocked := ReadBool('CanDocked');
EachOtherDocked := ReadBool('EachOtherDocked');
LeftDocked := ReadBool('LeftDocked');
TopDocked := ReadBool('TopDocked');
RightDocked := ReadBool('RightDocked');
BottomDocked := ReadBool('BottomDocked');
CustomDocked := ReadBool('CustomDocked'); {NEW!}
DockClientData := ReadString('DockClientData');
end;
for I := Index - 1 downto 0 do
begin
DockInfoReg.OpenKey(FRegName + '\' + FormList[I], False);
if DockInfoReg.ReadString('ParentName') = FormList[Index] then
begin
CurrTreeZone := TreeZone;
CreateZoneAndAddInfo(I);
CurrTreeZone := TreeZone.GetParentZone;
end;
end;
end;
end;
begin
FormList := TStringList.Create;
try
if DockInfoReg.OpenKey(FRegName, False) then
begin
S := DockInfoReg.ReadString('FormNames');
CP := PChar(S);
CP1 := StrPos(CP, '\');
while CP1 <> nil do
begin
CP1^ := #0;
FormList.Add(CP);
CP := CP1 + 1;
CP1 := StrPos(CP, '\');
end;
FJvDockInfoStyle := isReadFileInfo;
for I := FormList.Count - 1 downto 0 do
begin
DockInfoReg.OpenKey(FRegName + '\' + FormList[I], False);
if DockInfoReg.ReadString('ParentName') = '' then
CreateZoneAndAddInfo(I);
end;
FJvDockInfoStyle := isNone;
end;
finally
DockInfoReg.CloseKey;
FormList.Free;
end;
end;
function TJvDockInfoTree.FindDockForm(const FormName: string): TCustomForm;
begin
if Pos(RsDockJvDockInfoSplitter, FormName) > 0 then
Result := nil
else
Result := JvDockFindDockFormWithName(FormName);
end;
{$IFDEF USEJVCL}
procedure TJvDockInfoTree.ReadInfoFromAppStorage;
begin
AppStorage.BeginUpdate;
try
CreateZoneAndAddInfoFromAppStorage;
DoFloatAllForm;
// (rom) this is disputable
Application.ProcessMessages;
try
FJvDockInfoStyle := isJVCLReadInfo;
MiddleScanTree(TopTreeZone);
finally
FJvDockInfoStyle := isNone;
end;
finally
AppStorage.EndUpdate;
end;
end;
{$ENDIF USEJVCL}
procedure TJvDockInfoTree.ReadInfoFromIni;
begin
CreateZoneAndAddInfoFromIni;
DoFloatAllForm;
// (rom) this is disputable
Application.ProcessMessages;
{$IFDEF USEJVCL}
FJvDockInfoStyle := isJVCLReadInfo;
{$ELSE}
FJvDockInfoStyle := isReadFileInfo;
{$ENDIF USEJVCL}
MiddleScanTree(TopTreeZone);
FJvDockInfoStyle := isNone;
end;
procedure TJvDockInfoTree.ReadInfoFromReg(const RegName: string);
begin
FRegName := RegName;
CreateZoneAndAddInfoFromReg;
DoFloatAllForm;
// (rom) this is disputable
Application.ProcessMessages;
FJvDockInfoStyle := isReadRegInfo;
MiddleScanTree(TopTreeZone);
FJvDockInfoStyle := isNone;
end;
{$IFDEF USEJVCL}
procedure TJvDockInfoTree.ScanTreeZone(TreeZone: TJvDockBaseZone);
var
I: Integer;
OldPath: string;
begin
if FJvDockInfoStyle = isJVCLReadInfo then { JVCL Mode persistance : READ }
begin
for I := 0 to TreeZone.GetChildCount - 1 do
with TJvDockInfoZone(TreeZone.GetChildZone(I)) do
DockControl := FindDockForm(DockFormName);
SetDockControlInfo(TJvDockInfoZone(TreeZone));
end
else
if FJvDockInfoStyle = isJVCLWriteInfo then { JVCL Mode persistance : WRITE }
begin
if TreeZone <> TopTreeZone then
with TJvDockInfoZone(TreeZone), FAppStorage do
begin
OldPath := Path;
try
Path := ConcatPaths([Path, AppStoragePath, 'Forms']);
WriteString('FormNames', ReadString('FormNames') + DockFormName + ';');
Path := ConcatPaths([Path, DockFormName]);
WriteString('ParentName', ParentName);
WriteInteger('DockLeft', DockRect.Left);
WriteInteger('DockTop', DockRect.Top);
WriteInteger('DockRight', DockRect.Right);
WriteInteger('DockBottom', DockRect.Bottom);
WriteString('LastDockSiteName', LastDockSiteName);
WriteInteger('UnDockLeft', UnDockLeft);
WriteInteger('UnDockTop', UnDockTop);
WriteInteger('LRDockWidth', LRDockWidth);
WriteInteger('TBDockHeight', TBDockHeight);
WriteInteger('UnDockWidth', UnDockWidth);
WriteInteger('UnDockHeight', UnDockHeight);
WriteInteger('VSPaneWidth', VSPaneWidth);
WriteBoolean('Visible', Visible);
WriteInteger('BorderStyle', Integer(BorderStyle));
WriteInteger('FormStyle', Integer(FormStyle));
WriteInteger('WindowState', Integer(WindowState));
WriteInteger('DockFormStyle', Integer(DockFormStyle));
WriteBoolean('CanDocked', CanDocked);
WriteBoolean('EachOtherDocked', EachOtherDocked);
WriteBoolean('LeftDocked', LeftDocked);
WriteBoolean('TopDocked', TopDocked);
WriteBoolean('RightDocked', RightDocked);
WriteBoolean('BottomDocked', BottomDocked);
WriteBoolean('CustomDocked', CustomDocked); {NEW!}
WriteString('DockClientData', DockClientData);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -