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