mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 21:19:24 +02:00
anchordocking: using workarearect
git-svn-id: trunk@26332 -
This commit is contained in:
parent
c2313cc163
commit
7fd50883d7
@ -1189,7 +1189,7 @@ end;
|
|||||||
function TAnchorDockMaster.RestoreLayout(Tree: TAnchorDockLayoutTree;
|
function TAnchorDockMaster.RestoreLayout(Tree: TAnchorDockLayoutTree;
|
||||||
Scale: boolean): boolean;
|
Scale: boolean): boolean;
|
||||||
var
|
var
|
||||||
ScreenWidth, ScreenHeight: integer;
|
WorkArea: TRect;
|
||||||
|
|
||||||
function SrcRectValid(const r: TRect): boolean;
|
function SrcRectValid(const r: TRect): boolean;
|
||||||
begin
|
begin
|
||||||
@ -1199,15 +1199,19 @@ var
|
|||||||
function ScaleX(p: integer; const SrcRect: TRect): integer;
|
function ScaleX(p: integer; const SrcRect: TRect): integer;
|
||||||
begin
|
begin
|
||||||
Result:=p;
|
Result:=p;
|
||||||
if SrcRectValid(SrcRect) then
|
if SrcRectValid(SrcRect) and SrcRectValid(WorkArea) then
|
||||||
Result:=((p-SrcRect.Left)*ScreenWidth) div (SrcRect.Right-SrcRect.Left);
|
Result:=((p-SrcRect.Left)*(WorkArea.Right-WorkArea.Left))
|
||||||
|
div (SrcRect.Right-SrcRect.Left)
|
||||||
|
+WorkArea.Left;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ScaleY(p: integer; const SrcRect: TRect): integer;
|
function ScaleY(p: integer; const SrcRect: TRect): integer;
|
||||||
begin
|
begin
|
||||||
Result:=p;
|
Result:=p;
|
||||||
if SrcRectValid(SrcRect) then
|
if SrcRectValid(SrcRect) then
|
||||||
Result:=((p-SrcRect.Top)*ScreenHeight) div (SrcRect.Bottom-SrcRect.Top);
|
Result:=((p-SrcRect.Top)*(WorkArea.Bottom-WorkArea.Top))
|
||||||
|
div (SrcRect.Bottom-SrcRect.Top)
|
||||||
|
+WorkArea.Top;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure SetupSite(Site: TCustomForm;
|
procedure SetupSite(Site: TCustomForm;
|
||||||
@ -1217,6 +1221,8 @@ var
|
|||||||
aManager: TAnchorDockManager;
|
aManager: TAnchorDockManager;
|
||||||
NewBounds: TRect;
|
NewBounds: TRect;
|
||||||
begin
|
begin
|
||||||
|
if Parent=nil then
|
||||||
|
WorkArea:=Site.Monitor.WorkareaRect;
|
||||||
if IsCustomSite(Site) then begin
|
if IsCustomSite(Site) then begin
|
||||||
aManager:=TAnchorDockManager(Site.DockManager);
|
aManager:=TAnchorDockManager(Site.DockManager);
|
||||||
if Node.Count>0 then begin
|
if Node.Count>0 then begin
|
||||||
@ -1264,8 +1270,8 @@ var
|
|||||||
NewBounds: TRect;
|
NewBounds: TRect;
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
if Scale and SrcRectValid(Node.ScreenRect) then
|
if Scale and SrcRectValid(Node.WorkAreaRect) then
|
||||||
SrcRect:=Node.ScreenRect;
|
SrcRect:=Node.WorkAreaRect;
|
||||||
//debugln(['Restore ',Node.Name,' ',dbgs(Node.NodeType),' Bounds=',dbgs(Node.BoundsRect),' Parent=',DbgSName(Parent),' ']);
|
//debugln(['Restore ',Node.Name,' ',dbgs(Node.NodeType),' Bounds=',dbgs(Node.BoundsRect),' Parent=',DbgSName(Parent),' ']);
|
||||||
if Node.NodeType=adltnControl then begin
|
if Node.NodeType=adltnControl then begin
|
||||||
// restore control
|
// restore control
|
||||||
@ -1402,8 +1408,7 @@ var
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=true;
|
Result:=true;
|
||||||
ScreenWidth:=Screen.Width;
|
WorkArea:=Rect(0,0,0,0);
|
||||||
ScreenHeight:=Screen.Height;
|
|
||||||
Restore(Tree.Root,nil,Rect(0,0,0,0));
|
Restore(Tree.Root,nil,Rect(0,0,0,0));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ type
|
|||||||
FNodes: TFPList; // list of TAnchorDockLayoutTreeNode
|
FNodes: TFPList; // list of TAnchorDockLayoutTreeNode
|
||||||
FNodeType: TADLTreeNodeType;
|
FNodeType: TADLTreeNodeType;
|
||||||
FParent: TAnchorDockLayoutTreeNode;
|
FParent: TAnchorDockLayoutTreeNode;
|
||||||
FScreenRect: TRect;
|
FWorkAreaRect: TRect;
|
||||||
FTabPosition: TTabPosition;
|
FTabPosition: TTabPosition;
|
||||||
FWindowState: TWindowState;
|
FWindowState: TWindowState;
|
||||||
function GetAnchors(Site: TAnchorKind): string;
|
function GetAnchors(Site: TAnchorKind): string;
|
||||||
@ -101,7 +101,7 @@ type
|
|||||||
procedure SetNodeType(const AValue: TADLTreeNodeType);
|
procedure SetNodeType(const AValue: TADLTreeNodeType);
|
||||||
procedure SetParent(const AValue: TAnchorDockLayoutTreeNode);
|
procedure SetParent(const AValue: TAnchorDockLayoutTreeNode);
|
||||||
procedure SetRight(const AValue: integer);
|
procedure SetRight(const AValue: integer);
|
||||||
procedure SetScreenRect(const AValue: TRect);
|
procedure SetWorkAreaRect(const AValue: TRect);
|
||||||
procedure SetTabPosition(const AValue: TTabPosition);
|
procedure SetTabPosition(const AValue: TTabPosition);
|
||||||
procedure SetTop(const AValue: integer);
|
procedure SetTop(const AValue: integer);
|
||||||
procedure SetWidth(const AValue: integer);
|
procedure SetWidth(const AValue: integer);
|
||||||
@ -142,7 +142,7 @@ type
|
|||||||
property Bottom: integer read GetBottom write SetBottom;
|
property Bottom: integer read GetBottom write SetBottom;
|
||||||
property BoundsRect: TRect read FBoundsRect write SetBoundsRect;
|
property BoundsRect: TRect read FBoundsRect write SetBoundsRect;
|
||||||
property BoundSplitterPos: integer read FBoundSplitterPos write SetBoundSplitterPos;
|
property BoundSplitterPos: integer read FBoundSplitterPos write SetBoundSplitterPos;
|
||||||
property ScreenRect: TRect read FScreenRect write SetScreenRect;
|
property WorkAreaRect: TRect read FWorkAreaRect write SetWorkAreaRect;
|
||||||
property Anchors[Site: TAnchorKind]: string read GetAnchors write SetAnchors; // empty means default (parent)
|
property Anchors[Site: TAnchorKind]: string read GetAnchors write SetAnchors; // empty means default (parent)
|
||||||
property Align: TAlign read FAlign write SetAlign;
|
property Align: TAlign read FAlign write SetAlign;
|
||||||
property WindowState: TWindowState read FWindowState write SetWindowState;
|
property WindowState: TWindowState read FWindowState write SetWindowState;
|
||||||
@ -971,10 +971,10 @@ begin
|
|||||||
IncreaseChangeStamp;
|
IncreaseChangeStamp;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TAnchorDockLayoutTreeNode.SetScreenRect(const AValue: TRect);
|
procedure TAnchorDockLayoutTreeNode.SetWorkAreaRect(const AValue: TRect);
|
||||||
begin
|
begin
|
||||||
if CompareRect(@FScreenRect,@AValue) then exit;
|
if CompareRect(@FWorkAreaRect,@AValue) then exit;
|
||||||
FScreenRect:=AValue;
|
FWorkAreaRect:=AValue;
|
||||||
IncreaseChangeStamp;
|
IncreaseChangeStamp;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1033,7 +1033,7 @@ begin
|
|||||||
HeaderPosition:=adlhpAuto;
|
HeaderPosition:=adlhpAuto;
|
||||||
TabPosition:=tpTop;
|
TabPosition:=tpTop;
|
||||||
BoundSplitterPos:=0;
|
BoundSplitterPos:=0;
|
||||||
ScreenRect:=Rect(0,0,0,0);
|
WorkAreaRect:=Rect(0,0,0,0);
|
||||||
for a:=low(TAnchorKind) to high(TAnchorKind) do
|
for a:=low(TAnchorKind) to high(TAnchorKind) do
|
||||||
Anchors[a]:='';
|
Anchors[a]:='';
|
||||||
end;
|
end;
|
||||||
@ -1054,7 +1054,7 @@ begin
|
|||||||
or (HeaderPosition<>Node.HeaderPosition)
|
or (HeaderPosition<>Node.HeaderPosition)
|
||||||
or (TabPosition<>Node.TabPosition)
|
or (TabPosition<>Node.TabPosition)
|
||||||
or (BoundSplitterPos<>Node.BoundSplitterPos)
|
or (BoundSplitterPos<>Node.BoundSplitterPos)
|
||||||
or (not CompareRect(@FScreenRect,@Node.FScreenRect))
|
or (not CompareRect(@FWorkAreaRect,@Node.FWorkAreaRect))
|
||||||
then
|
then
|
||||||
exit;
|
exit;
|
||||||
for a:=low(TAnchorKind) to high(TAnchorKind) do
|
for a:=low(TAnchorKind) to high(TAnchorKind) do
|
||||||
@ -1078,7 +1078,7 @@ begin
|
|||||||
HeaderPosition:=Node.HeaderPosition;
|
HeaderPosition:=Node.HeaderPosition;
|
||||||
TabPosition:=Node.TabPosition;
|
TabPosition:=Node.TabPosition;
|
||||||
BoundSplitterPos:=Node.BoundSplitterPos;
|
BoundSplitterPos:=Node.BoundSplitterPos;
|
||||||
ScreenRect:=Node.ScreenRect;
|
WorkAreaRect:=Node.WorkAreaRect;
|
||||||
for a:=low(TAnchorKind) to high(TAnchorKind) do
|
for a:=low(TAnchorKind) to high(TAnchorKind) do
|
||||||
Anchors[a]:=Node.Anchors[a];
|
Anchors[a]:=Node.Anchors[a];
|
||||||
while Count>Node.Count do Nodes[Count-1].Free;
|
while Count>Node.Count do Nodes[Count-1].Free;
|
||||||
@ -1104,7 +1104,7 @@ begin
|
|||||||
if (AControl.Parent=nil) and (AControl is TCustomForm) then begin
|
if (AControl.Parent=nil) and (AControl is TCustomForm) then begin
|
||||||
WindowState:=TCustomForm(AControl).WindowState;
|
WindowState:=TCustomForm(AControl).WindowState;
|
||||||
Monitor:=TCustomForm(AControl).Monitor.MonitorNum;
|
Monitor:=TCustomForm(AControl).Monitor.MonitorNum;
|
||||||
ScreenRect:=Rect(0,0,Screen.Width,Screen.Height);
|
WorkAreaRect:=TCustomForm(AControl).Monitor.WorkareaRect;
|
||||||
end else
|
end else
|
||||||
WindowState:=wsNormal;
|
WindowState:=wsNormal;
|
||||||
if AControl is TCustomNotebook then
|
if AControl is TCustomNotebook then
|
||||||
@ -1134,7 +1134,7 @@ begin
|
|||||||
Width:=Config.GetValue('Bounds/Width',0);
|
Width:=Config.GetValue('Bounds/Width',0);
|
||||||
Height:=Config.GetValue('Bounds/Height',0);
|
Height:=Config.GetValue('Bounds/Height',0);
|
||||||
BoundSplitterPos:=Config.GetValue('Bounds/SplitterPos',0);
|
BoundSplitterPos:=Config.GetValue('Bounds/SplitterPos',0);
|
||||||
Config.GetValue('Bounds/Screen/Rect/',FScreenRect,Rect(0,0,0,0));
|
Config.GetValue('Bounds/WorkArea/Rect/',FWorkAreaRect,Rect(0,0,0,0));
|
||||||
Anchors[akLeft]:=Config.GetValue('Anchors/Left','');
|
Anchors[akLeft]:=Config.GetValue('Anchors/Left','');
|
||||||
Anchors[akTop]:=Config.GetValue('Anchors/Top','');
|
Anchors[akTop]:=Config.GetValue('Anchors/Top','');
|
||||||
Anchors[akRight]:=Config.GetValue('Anchors/Right','');
|
Anchors[akRight]:=Config.GetValue('Anchors/Right','');
|
||||||
@ -1166,7 +1166,7 @@ begin
|
|||||||
Config.SetDeleteValue('Bounds/Width',Width,0);
|
Config.SetDeleteValue('Bounds/Width',Width,0);
|
||||||
Config.SetDeleteValue('Bounds/Height',Height,0);
|
Config.SetDeleteValue('Bounds/Height',Height,0);
|
||||||
Config.SetDeleteValue('Bounds/SplitterPos',BoundSplitterPos,0);
|
Config.SetDeleteValue('Bounds/SplitterPos',BoundSplitterPos,0);
|
||||||
Config.SetDeleteValue('Bounds/Screen/Rect/',FScreenRect,Rect(0,0,0,0));
|
Config.SetDeleteValue('Bounds/WorkArea/Rect/',FWorkAreaRect,Rect(0,0,0,0));
|
||||||
Config.SetDeleteValue('Anchors/Left',Anchors[akLeft],'');
|
Config.SetDeleteValue('Anchors/Left',Anchors[akLeft],'');
|
||||||
Config.SetDeleteValue('Anchors/Top',Anchors[akTop],'');
|
Config.SetDeleteValue('Anchors/Top',Anchors[akTop],'');
|
||||||
Config.SetDeleteValue('Anchors/Right',Anchors[akRight],'');
|
Config.SetDeleteValue('Anchors/Right',Anchors[akRight],'');
|
||||||
|
Loading…
Reference in New Issue
Block a user