mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-21 00:39:10 +02:00
IDE: using DesignInfo for frames to store position, LCL: TFrame storing DesignLeft and DesignTop
git-svn-id: trunk@15227 -
This commit is contained in:
parent
29eab2b98f
commit
a75241f932
@ -60,8 +60,8 @@ end;
|
|||||||
|
|
||||||
procedure TFrameDesignerForm.SetLookupRoot(const AValue: TComponent);
|
procedure TFrameDesignerForm.SetLookupRoot(const AValue: TComponent);
|
||||||
begin
|
begin
|
||||||
if (AValue <> nil) and (AValue is TCustomFrame) then
|
if (AValue is TControl) then
|
||||||
TCustomFrame(AValue).Parent := Self;
|
TControl(AValue).Parent := Self;
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -78,15 +78,22 @@ procedure TFrameDesignerForm.DoLoadBounds;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
CurFrame: TCustomFrame;
|
CurControl: TControl;
|
||||||
|
NewLeft: integer;
|
||||||
|
NewTop: integer;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
|
||||||
if LookupRoot is TCustomFrame then
|
if LookupRoot is TControl then
|
||||||
begin
|
begin
|
||||||
CurFrame := TCustomFrame(LookupRoot);
|
CurControl := TControl(LookupRoot);
|
||||||
SetNewBounds(Left, Top, CurFrame.Width, CurFrame.Height);
|
// restore designer position
|
||||||
end
|
NewLeft:=LongRec(LookupRoot.DesignInfo).Lo;
|
||||||
|
NewTop:=LongRec(LookupRoot.DesignInfo).Hi;
|
||||||
|
// resize designer form
|
||||||
|
SetNewBounds(NewLeft,NewTop,CurControl.Width,CurControl.Height);
|
||||||
|
DebugLn(['TFrameDesignerForm.DoLoadBounds ',NewLeft,',',NewTop]);
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if LookupRoot <> nil then
|
if LookupRoot <> nil then
|
||||||
DebugLn(['Unsupported component type in TFrameDesignerForm.DoLoadBounds: ', LookupRoot.ClassName])
|
DebugLn(['Unsupported component type in TFrameDesignerForm.DoLoadBounds: ', LookupRoot.ClassName])
|
||||||
@ -94,9 +101,14 @@ end;
|
|||||||
|
|
||||||
procedure TFrameDesignerForm.DoSaveBounds;
|
procedure TFrameDesignerForm.DoSaveBounds;
|
||||||
begin
|
begin
|
||||||
if LookupRoot is TCustomFrame then
|
if LookupRoot is TControl then begin
|
||||||
TFrame(LookupRoot).SetBounds(0, 0, Width, Height)
|
// store designer position
|
||||||
else
|
LongRec(LookupRoot.DesignInfo).Lo:=Left;
|
||||||
|
LongRec(LookupRoot.DesignInfo).Hi:=Top;
|
||||||
|
// always fill the whole designer form
|
||||||
|
TControl(LookupRoot).SetBounds(0, 0, Width, Height);
|
||||||
|
DebugLn(['TFrameDesignerForm.DoSaveBounds ',Left,',',Top,' ',LongRec(LookupRoot.DesignInfo).Lo,',',LongRec(LookupRoot.DesignInfo).hi]);
|
||||||
|
end else
|
||||||
if LookupRoot <> nil then
|
if LookupRoot <> nil then
|
||||||
DebugLn(['Unsupported component type in TFrameDesignerForm.DoSaveBounds: ', LookupRoot.ClassName]);
|
DebugLn(['Unsupported component type in TFrameDesignerForm.DoSaveBounds: ', LookupRoot.ClassName]);
|
||||||
inherited;
|
inherited;
|
||||||
@ -106,8 +118,8 @@ procedure TFrameDesignerForm.SetBounds(aLeft, aTop, aWidth, aHeight: integer);
|
|||||||
begin
|
begin
|
||||||
// auto apply width and height
|
// auto apply width and height
|
||||||
inherited SetBounds(aLeft, aTop, aWidth, aHeight);
|
inherited SetBounds(aLeft, aTop, aWidth, aHeight);
|
||||||
if (LookupRoot <> nil) and (LookupRoot is TCustomFrame) then
|
if (LookupRoot is TControl) then
|
||||||
TCustomFrame(LookupRoot).SetBounds(0, 0, Width, Height);
|
TControl(LookupRoot).SetBounds(0, 0, Width, Height);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -247,15 +247,19 @@ type
|
|||||||
private
|
private
|
||||||
procedure AddActionList(ActionList: TCustomActionList);
|
procedure AddActionList(ActionList: TCustomActionList);
|
||||||
procedure RemoveActionList(ActionList: TCustomActionList);
|
procedure RemoveActionList(ActionList: TCustomActionList);
|
||||||
|
procedure ReadDesignLeft(Reader: TReader);
|
||||||
|
procedure ReadDesignTop(Reader: TReader);
|
||||||
|
procedure WriteDesignLeft(Writer: TWriter);
|
||||||
|
procedure WriteDesignTop(Writer: TWriter);
|
||||||
protected
|
protected
|
||||||
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
|
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
|
||||||
procedure Notification(AComponent: TComponent;
|
procedure Notification(AComponent: TComponent;
|
||||||
Operation: TOperation); override;
|
Operation: TOperation); override;
|
||||||
procedure SetParent(AParent: TWinControl); override;
|
procedure SetParent(AParent: TWinControl); override;
|
||||||
class function GetControlClassDefaultSize: TPoint; override;
|
class function GetControlClassDefaultSize: TPoint; override;
|
||||||
|
procedure DefineProperties(Filer: TFiler); override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
procedure SetBounds(aLeft, aTop, aWidth, aHeight: integer); override;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TCustomFrameClass = class of TCustomFrame;
|
TCustomFrameClass = class of TCustomFrame;
|
||||||
|
@ -38,6 +38,34 @@ begin
|
|||||||
ParentForm.FActionLists.Remove(ActionList);
|
ParentForm.FActionLists.Remove(ActionList);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomFrame.ReadDesignLeft(Reader: TReader);
|
||||||
|
var
|
||||||
|
Temp: LongInt;
|
||||||
|
begin
|
||||||
|
Temp:=DesignInfo;
|
||||||
|
LongRec(Temp).Lo:=Reader.ReadInteger;
|
||||||
|
DesignInfo:=Temp;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomFrame.ReadDesignTop(Reader: TReader);
|
||||||
|
var
|
||||||
|
Temp: LongInt;
|
||||||
|
begin
|
||||||
|
Temp:=DesignInfo;
|
||||||
|
LongRec(Temp).Hi:=Reader.ReadInteger;
|
||||||
|
DesignInfo:=Temp;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomFrame.WriteDesignLeft(Writer: TWriter);
|
||||||
|
begin
|
||||||
|
Writer.WriteInteger(LongRec(DesignInfo).Lo);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomFrame.WriteDesignTop(Writer: TWriter);
|
||||||
|
begin
|
||||||
|
Writer.WriteInteger(LongRec(DesignInfo).Hi);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomFrame.GetChildren(Proc: TGetChildProc; Root: TComponent);
|
procedure TCustomFrame.GetChildren(Proc: TGetChildProc; Root: TComponent);
|
||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
@ -100,6 +128,20 @@ begin
|
|||||||
Result.Y:=240;
|
Result.Y:=240;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomFrame.DefineProperties(Filer: TFiler);
|
||||||
|
Var
|
||||||
|
Ancestor: TComponent;
|
||||||
|
Temp: longint;
|
||||||
|
begin
|
||||||
|
Temp:=0;
|
||||||
|
Ancestor:=TComponent(Filer.Ancestor);
|
||||||
|
if Assigned(Ancestor) then Temp:=Ancestor.DesignInfo;
|
||||||
|
Filer.Defineproperty('DesignLeft',@ReadDesignLeft,@WriteDesignLeft,
|
||||||
|
(longrec(DesignInfo).Lo<>Longrec(Temp).Lo));
|
||||||
|
Filer.Defineproperty('DesignTop',@ReadDesignTop,@WriteDesignTop,
|
||||||
|
(longrec(DesignInfo).Hi<>Longrec(Temp).Hi));
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TCustomFrame.Create(AOwner: TComponent);
|
constructor TCustomFrame.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
@ -114,17 +156,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomFrame.SetBounds(aLeft, aTop, aWidth, aHeight: integer);
|
|
||||||
begin
|
|
||||||
if csDesignInstance in ComponentState then
|
|
||||||
begin
|
|
||||||
// dont move frame in the designer
|
|
||||||
aLeft := 0;
|
|
||||||
aTop := 0;
|
|
||||||
end;
|
|
||||||
inherited SetBounds(aLeft, aTop, aWidth, aHeight);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TFrame }
|
{ TFrame }
|
||||||
|
|
||||||
function TFrame.LCLVersionIsStored: boolean;
|
function TFrame.LCLVersionIsStored: boolean;
|
||||||
|
Loading…
Reference in New Issue
Block a user