mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-26 15:00:26 +02:00
IDE: setting initial bounds for non form controls
git-svn-id: trunk@15483 -
This commit is contained in:
parent
91c784bc55
commit
4668307b4f
@ -1492,6 +1492,7 @@ var
|
|||||||
DesignForm: TCustomForm;
|
DesignForm: TCustomForm;
|
||||||
NewUnitName: String;
|
NewUnitName: String;
|
||||||
s: String;
|
s: String;
|
||||||
|
NewDesignInfo: LongRec;
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
Temp:=nil;
|
Temp:=nil;
|
||||||
@ -1499,7 +1500,7 @@ begin
|
|||||||
AParent:=nil;
|
AParent:=nil;
|
||||||
NewComponent:=nil;
|
NewComponent:=nil;
|
||||||
try
|
try
|
||||||
DebugLn('[TCustomFormEditor.CreateComponent] Class='''+TypeClass.ClassName+'''');
|
//DebugLn(['[TCustomFormEditor.CreateComponent] Class="'+TypeClass.ClassName+'" ',X,',',Y,',',W,'x',H]);
|
||||||
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TCustomFormEditor.CreateComponent A');{$ENDIF}
|
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TCustomFormEditor.CreateComponent A');{$ENDIF}
|
||||||
|
|
||||||
OwnerComponent:=nil;
|
OwnerComponent:=nil;
|
||||||
@ -1597,7 +1598,7 @@ begin
|
|||||||
if CompLeft<0 then begin
|
if CompLeft<0 then begin
|
||||||
if AParent<>nil then
|
if AParent<>nil then
|
||||||
CompLeft:=(AParent.Width - CompWidth) div 2
|
CompLeft:=(AParent.Width - CompWidth) div 2
|
||||||
else if AControl is TCustomForm then
|
else if (AControl is TCustomForm) then
|
||||||
CompLeft:=Max(1,Min(250,Screen.Width-CompWidth-50))
|
CompLeft:=Max(1,Min(250,Screen.Width-CompWidth-50))
|
||||||
else
|
else
|
||||||
CompLeft:=0;
|
CompLeft:=0;
|
||||||
@ -1605,14 +1606,23 @@ begin
|
|||||||
if CompTop<0 then begin
|
if CompTop<0 then begin
|
||||||
if AParent<>nil then
|
if AParent<>nil then
|
||||||
CompTop:=(AParent.Height - CompHeight) div 2
|
CompTop:=(AParent.Height - CompHeight) div 2
|
||||||
else if AControl is TCustomForm then
|
else if (AControl is TCustomForm) then
|
||||||
CompTop:=Max(1,Min(250,Screen.Height-CompHeight-50))
|
CompTop:=Max(1,Min(250,Screen.Height-CompHeight-50))
|
||||||
else
|
else
|
||||||
CompTop:=0;
|
CompTop:=0;
|
||||||
end;
|
end;
|
||||||
// set parent after placing control to prevent display at (0,0)
|
if (AParent<>nil) or (AControl is TCustomForm) then begin
|
||||||
AControl.SetBounds(CompLeft,CompTop,CompWidth,CompHeight);
|
// set parent after placing control to prevent display at (0,0)
|
||||||
TControl(Temp.Component).Parent := AParent;
|
AControl.SetBounds(CompLeft,CompTop,CompWidth,CompHeight);
|
||||||
|
AControl.Parent := AParent;
|
||||||
|
end else begin
|
||||||
|
// no parent and not a form
|
||||||
|
AControl.SetBounds(0,0,CompWidth,CompHeight);
|
||||||
|
NewDesignInfo.Lo:=CompLeft;
|
||||||
|
NewDesignInfo.Hi:=CompTop;
|
||||||
|
LongRec(AControl.DesignInfo):=NewDesignInfo;
|
||||||
|
//DebugLn(['TCustomFormEditor.CreateComponent ',dbgsName(AControl),' ',LongRec(AControl.DesignInfo).Lo,',',LongRec(AControl.DesignInfo).Hi]);
|
||||||
|
end;
|
||||||
end
|
end
|
||||||
else if (Temp.Component is TDataModule) then begin
|
else if (Temp.Component is TDataModule) then begin
|
||||||
// data module
|
// data module
|
||||||
|
@ -6947,11 +6947,13 @@ begin
|
|||||||
LFMCode:=CodeToolBoss.CreateFile(LFMFilename);
|
LFMCode:=CodeToolBoss.CreateFile(LFMFilename);
|
||||||
LFMCode.Source:=LFMSourceText;
|
LFMCode.Source:=LFMSourceText;
|
||||||
//debugln('TMainIDE.DoNewEditorFile A ',LFMFilename);
|
//debugln('TMainIDE.DoNewEditorFile A ',LFMFilename);
|
||||||
Result:=DoLoadLFM(NewUnitInfo,LFMCode,[],[]);
|
//Result:=DoLoadLFM(NewUnitInfo,LFMCode,[],[]);
|
||||||
//DebugLn(['TMainIDE.DoNewFile ',dbgsName(NewUnitInfo.Component),' ',dbgsName(NewUnitInfo.Component.ClassParent)]);
|
//DebugLn(['TMainIDE.DoNewFile ',dbgsName(NewUnitInfo.Component),' ',dbgsName(NewUnitInfo.Component.ClassParent)]);
|
||||||
end else begin
|
end else begin
|
||||||
// create a default form/datamodule
|
// create a designer form for a form/datamodule/frame
|
||||||
Result := CreateNewForm(NewUnitInfo, AncestorType, nil, NewFileDescriptor.UseCreateFormStatements);
|
//DebugLn(['TMainIDE.DoNewFile Name=',NewFileDescriptor.Name,' Class=',NewFileDescriptor.ClassName]);
|
||||||
|
Result := CreateNewForm(NewUnitInfo, AncestorType, nil,
|
||||||
|
NewFileDescriptor.UseCreateFormStatements);
|
||||||
end;
|
end;
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user