mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-02 11:52:37 +02:00
ide: implement designer form window state saving, start loading
git-svn-id: trunk@21737 -
This commit is contained in:
parent
6cfe3a9bba
commit
795adc7dd5
37
ide/main.pp
37
ide/main.pp
@ -666,6 +666,7 @@ type
|
||||
procedure OnProjectGetTestDirectory(TheProject: TProject;
|
||||
out TestDir: string);
|
||||
procedure OnProjectChangeInfoFile(TheProject: TProject);
|
||||
procedure OnSaveProjectUnitSessionInfo(AUnitInfo: TUnitInfo);
|
||||
|
||||
// methods for 'save project'
|
||||
procedure GetMainUnit(var MainUnitInfo: TUnitInfo;
|
||||
@ -4305,6 +4306,7 @@ function TMainIDE.CreateNewForm(NewUnitInfo: TUnitInfo;
|
||||
var
|
||||
CInterface: TComponentInterface;
|
||||
NewComponent: TComponent;
|
||||
DesignerForm: TCustomForm;
|
||||
new_x, new_y: integer;
|
||||
begin
|
||||
if not AncestorType.InheritsFrom(TComponent) then
|
||||
@ -4349,6 +4351,9 @@ begin
|
||||
TControl(NewComponent).Caption:=NewComponent.Name;
|
||||
NewUnitInfo.Component := NewComponent;
|
||||
CreateDesignerForComponent(NewComponent);
|
||||
DesignerForm := FormEditor1.GetDesignerForm(NewComponent);
|
||||
if Assigned(DesignerForm) then
|
||||
DesignerForm.WindowState := NewUnitInfo.ComponentState;
|
||||
|
||||
NewUnitInfo.ComponentName:=NewComponent.Name;
|
||||
NewUnitInfo.ComponentResourceName:=NewUnitInfo.ComponentName;
|
||||
@ -5732,10 +5737,12 @@ begin
|
||||
{$ENDIF}
|
||||
AnUnitInfo.ComponentName:=NewComponent.Name;
|
||||
AnUnitInfo.ComponentResourceName:=AnUnitInfo.ComponentName;
|
||||
DesignerForm:=nil;
|
||||
if not (ofLoadHiddenResource in OpenFlags) then begin
|
||||
DesignerForm := nil;
|
||||
if not (ofLoadHiddenResource in OpenFlags) then
|
||||
begin
|
||||
CreateDesignerForComponent(NewComponent);
|
||||
DesignerForm:=FormEditor1.GetDesignerForm(NewComponent);
|
||||
DesignerForm := FormEditor1.GetDesignerForm(NewComponent);
|
||||
DesignerForm.WindowState := AnUnitInfo.ComponentState;
|
||||
end;
|
||||
|
||||
// select the new form (object inspector, formeditor, control selection)
|
||||
@ -6569,10 +6576,34 @@ begin
|
||||
Result.OnFileBackup:=@MainBuildBoss.BackupFile;
|
||||
Result.OnLoadProjectInfo:=@OnLoadProjectInfoFromXMLConfig;
|
||||
Result.OnSaveProjectInfo:=@OnSaveProjectInfoToXMLConfig;
|
||||
Result.OnSaveUnitSessionInfo:=@OnSaveProjectUnitSessionInfo;
|
||||
Result.OnGetTestDirectory:=@OnProjectGetTestDirectory;
|
||||
Result.OnChangeProjectInfoFile:=@OnProjectChangeInfoFile;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.OnSaveProjectUnitSessionInfo(AUnitInfo: TUnitInfo);
|
||||
|
||||
function GetWindowState(ACustomForm: TCustomForm): TWindowState;
|
||||
begin
|
||||
Result := wsNormal;
|
||||
if ACustomForm.HandleAllocated then
|
||||
if IsIconic(ACustomForm.Handle) then
|
||||
Result := wsMinimized
|
||||
else
|
||||
if IsZoomed(ACustomForm.Handle) then
|
||||
Result := wsMaximized;
|
||||
end;
|
||||
var
|
||||
DesignerForm: TCustomForm;
|
||||
begin
|
||||
if (AUnitInfo.Component <> nil) then
|
||||
begin
|
||||
DesignerForm := FormEditor1.GetDesignerForm(AUnitInfo.Component);
|
||||
if DesignerForm <> nil then
|
||||
AUnitInfo.ComponentState := GetWindowState(DesignerForm);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.OnLoadProjectInfoFromXMLConfig(TheProject: TProject;
|
||||
XMLConfig: TXMLConfig; Merge: boolean);
|
||||
begin
|
||||
|
@ -75,6 +75,8 @@ type
|
||||
TOnProjectGetTestDirectory = procedure(TheProject: TProject;
|
||||
out TestDir: string) of object;
|
||||
TOnChangeProjectInfoFile = procedure(TheProject: TProject) of object;
|
||||
|
||||
TOnSaveUnitSessionInfoInfo = procedure(AUnitInfo: TUnitInfo) of object;
|
||||
|
||||
TUnitInfoList = (
|
||||
uilPartOfProject,
|
||||
@ -600,6 +602,7 @@ type
|
||||
FOnGetTestDirectory: TOnProjectGetTestDirectory;
|
||||
FOnLoadProjectInfo: TOnLoadProjectInfo;
|
||||
FOnSaveProjectInfo: TOnSaveProjectInfo;
|
||||
FOnSaveUnitSessionInfo: TOnSaveUnitSessionInfoInfo;
|
||||
fPathDelimChanged: boolean; // PathDelim in system and current config differ (see StorePathDelim and SessionStorePathDelim)
|
||||
FPOOutputDirectory: string;
|
||||
fProjectDirectory: string;
|
||||
@ -873,6 +876,8 @@ type
|
||||
write FOnLoadProjectInfo;
|
||||
property OnSaveProjectInfo: TOnSaveProjectInfo read FOnSaveProjectInfo
|
||||
write FOnSaveProjectInfo;
|
||||
property OnSaveUnitSessionInfo: TOnSaveUnitSessionInfoInfo
|
||||
read FOnSaveUnitSessionInfo write FOnSaveUnitSessionInfo;
|
||||
property POOutputDirectory: string read FPOOutputDirectory
|
||||
write SetPOOutputDirectory;
|
||||
property ProjectDirectory: string read fProjectDirectory;
|
||||
@ -1193,23 +1198,26 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TUnitInfo.SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
||||
SaveData, SaveSession: boolean; UsePathDelim: TPathDelimSwitch);
|
||||
var AFilename:string;
|
||||
var
|
||||
AFilename: String;
|
||||
begin
|
||||
// global data
|
||||
AFilename:=Filename;
|
||||
if Assigned(fOnLoadSaveFilename) then
|
||||
fOnLoadSaveFilename(AFilename,false);
|
||||
fOnLoadSaveFilename(AFilename, False);
|
||||
XMLConfig.SetValue(Path+'Filename/Value',SwitchPathDelims(AFilename,UsePathDelim));
|
||||
|
||||
if SaveData then
|
||||
XMLConfig.SetDeleteValue(Path+'IsPartOfProject/Value',IsPartOfProject,false);
|
||||
|
||||
if SaveSession and Assigned(Project.OnSaveUnitSessionInfo) then
|
||||
Project.OnSaveUnitSessionInfo(Self);
|
||||
|
||||
// context data (project/session)
|
||||
if (IsPartOfProject and SaveData)
|
||||
or ((not IsPartOfProject) and SaveSession)
|
||||
then begin
|
||||
XMLConfig.SetDeleteValue(Path+'ComponentName/Value',fComponentName,'');
|
||||
XMLConfig.SetDeleteValue(Path+'ComponentState/Value',Ord(FComponentState),0);
|
||||
XMLConfig.SetDeleteValue(Path+'HasResources/Value',fHasResources,false);
|
||||
XMLConfig.SetDeleteValue(Path+'ResourceBaseClass/Value',
|
||||
PFComponentBaseClassNames[FResourceBaseClass],
|
||||
@ -1220,7 +1228,9 @@ begin
|
||||
end;
|
||||
|
||||
// session data
|
||||
if SaveSession then begin
|
||||
if SaveSession then
|
||||
begin
|
||||
XMLConfig.SetDeleteValue(Path+'ComponentState/Value',Ord(FComponentState),0);
|
||||
XMLConfig.SetDeleteValue(Path+'CursorPos/X',fCursorPos.X,-1);
|
||||
XMLConfig.SetDeleteValue(Path+'CursorPos/Y',fCursorPos.Y,-1);
|
||||
XMLConfig.SetDeleteValue(Path+'TopLine/Value',fTopLine,-1);
|
||||
|
Loading…
Reference in New Issue
Block a user