changed OI SHow Hints option to resource string, added TProjectDescriptor.DoInitDescriptor

git-svn-id: trunk@7203 -
This commit is contained in:
mattias 2005-05-26 15:54:02 +00:00
parent 73ca58ffc8
commit 31d368a4d8
6 changed files with 102 additions and 43 deletions

View File

@ -3938,14 +3938,13 @@ begin
MaxValue:=100; MaxValue:=100;
end; end;
OIShowHintCheckBox :=TCheckBox.Create(Self); OIShowHintCheckBox:=TCheckBox.Create(Self);
with OIShowHintCheckBox do begin with OIShowHintCheckBox do begin
Name := 'OIShowHintCheckBox'; Name := 'OIShowHintCheckBox';
Parent := OIMiscGroupBox; Parent := OIMiscGroupBox;
Left := 6; Left := 6;
Top := 33; Top := 33;
Height := 25; Caption := lisShowHintsInObjectInspector;
Caption := 'Show hints';
end; end;
OIDefaultItemHeightLabel:=TLabel.Create(Self); OIDefaultItemHeightLabel:=TLabel.Create(Self);

View File

@ -728,6 +728,7 @@ resourcestring
dlgOIMiscellaneous = 'Miscellaneous'; dlgOIMiscellaneous = 'Miscellaneous';
dlgOIItemHeight = 'Item height'; dlgOIItemHeight = 'Item height';
lisShowHintsInObjectInspector = 'Show hints in Object Inspector';
dlgEnvColors = 'Colors'; dlgEnvColors = 'Colors';
dlgEnvBackupHelpNote = dlgEnvBackupHelpNote =
'Notes: Project files are all files in the project directory'; 'Notes: Project files are all files in the project directory';

View File

@ -523,7 +523,8 @@ type
function CloseDesignerForm(AnUnitInfo: TUnitInfo): TModalResult; function CloseDesignerForm(AnUnitInfo: TUnitInfo): TModalResult;
// methods for creating a project // methods for creating a project
function CreateProjectObject(ProjectDesc: TProjectDescriptor): TProject; function CreateProjectObject(ProjectDesc,
FallbackProjectDesc: TProjectDescriptor): TProject;
procedure OnLoadProjectInfoFromXMLConfig(TheProject: TProject; procedure OnLoadProjectInfoFromXMLConfig(TheProject: TProject;
XMLConfig: TXMLConfig); XMLConfig: TXMLConfig);
procedure OnSaveProjectInfoToXMLConfig(TheProject: TProject; procedure OnSaveProjectInfoToXMLConfig(TheProject: TProject;
@ -4289,9 +4290,19 @@ begin
Result:=mrOk; Result:=mrOk;
end; end;
function TMainIDE.CreateProjectObject(ProjectDesc: TProjectDescriptor): TProject; function TMainIDE.CreateProjectObject(ProjectDesc,
FallbackProjectDesc: TProjectDescriptor): TProject;
begin begin
Result:=TProject.Create(ProjectDesc); Result:=TProject.Create(ProjectDesc);
// custom initialization
if ProjectDesc.InitProject(Result)<>mrOk then begin
Result.Free;
Result:=nil;
if FallbackProjectDesc=nil then exit;
Result:=TProject.Create(FallbackProjectDesc);
FallbackProjectDesc.InitProject(Result);
end;
Result.OnFileBackup:=@DoBackupFile; Result.OnFileBackup:=@DoBackupFile;
Result.OnLoadProjectInfo:=@OnLoadProjectInfoFromXMLConfig; Result.OnLoadProjectInfo:=@OnLoadProjectInfoFromXMLConfig;
Result.OnSaveProjectInfo:=@OnSaveProjectInfoToXMLConfig; Result.OnSaveProjectInfo:=@OnSaveProjectInfoToXMLConfig;
@ -5620,7 +5631,10 @@ function TMainIDE.DoNewProject(ProjectDesc: TProjectDescriptor):TModalResult;
var i:integer; var i:integer;
Begin Begin
DebugLn('TMainIDE.DoNewProject A'); DebugLn('TMainIDE.DoNewProject A');
Result:=mrCancel;
// init the descriptor (it can now ask the user for options)
Result:=ProjectDesc.InitDescriptor;
if Result<>mrOk then exit;
// invalidate cached substituted macros // invalidate cached substituted macros
IncreaseCompilerParseStamp; IncreaseCompilerParseStamp;
@ -5649,7 +5663,7 @@ Begin
// create new project (TProject will automatically create the mainunit) // create new project (TProject will automatically create the mainunit)
Project1:=CreateProjectObject(ProjectDesc); Project1:=CreateProjectObject(ProjectDesc,ProjectDescriptorProgram);
Project1.BeginUpdate(true); Project1.BeginUpdate(true);
try try
Project1.CompilerOptions.CompilerPath:='$(CompPath)'; Project1.CompilerOptions.CompilerPath:='$(CompPath)';
@ -5659,7 +5673,9 @@ Begin
// add and load default required packages // add and load default required packages
PkgBoss.AddDefaultDependencies(Project1); PkgBoss.AddDefaultDependencies(Project1);
ProjectDesc.CreateStartFiles(Project1); if ProjectDesc.CreateStartFiles(Project1)<>mrOk then begin
debugln('TMainIDE.DoNewProject ProjectDesc.CreateStartFiles failed');
end;
// rebuild codetools defines // rebuild codetools defines
RescanCompilerDefines(true); RescanCompilerDefines(true);
@ -5896,7 +5912,8 @@ begin
writeln('TMainIDE.DoOpenProjectFile B'); writeln('TMainIDE.DoOpenProjectFile B');
{$ENDIF} {$ENDIF}
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.DoOpenProjectFile B');{$ENDIF} {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.DoOpenProjectFile B');{$ENDIF}
Project1:=CreateProjectObject(ProjectDescriptorProgram); Project1:=CreateProjectObject(ProjectDescriptorProgram,
ProjectDescriptorProgram);
Project1.BeginUpdate(true); Project1.BeginUpdate(true);
try try
if ProjInspector<>nil then ProjInspector.LazProject:=Project1; if ProjInspector<>nil then ProjInspector.LazProject:=Project1;
@ -6106,7 +6123,7 @@ begin
ExpandFilename(ExtractFilePath(ProgramBuf.Filename)); ExpandFilename(ExtractFilePath(ProgramBuf.Filename));
// create a new project // create a new project
Project1:=CreateProjectObject(NewProjectDesc); Project1:=CreateProjectObject(NewProjectDesc,ProjectDescriptorProgram);
Project1.BeginUpdate(true); Project1.BeginUpdate(true);
try try
if ProjInspector<>nil then ProjInspector.LazProject:=Project1; if ProjInspector<>nil then ProjInspector.LazProject:=Project1;
@ -7287,7 +7304,7 @@ begin
// create a new project // create a new project
debugln('TMainIDE.DoConvertDelphiProject creating new project ...'); debugln('TMainIDE.DoConvertDelphiProject creating new project ...');
NewProjectDesc:=TProjectEmptyProgramDescriptor.Create; NewProjectDesc:=TProjectEmptyProgramDescriptor.Create;
Project1:=CreateProjectObject(NewProjectDesc); Project1:=CreateProjectObject(NewProjectDesc,ProjectDescriptorApplication);
Project1.BeginUpdate(true); Project1.BeginUpdate(true);
try try
if ProjInspector<>nil then ProjInspector.LazProject:=Project1; if ProjInspector<>nil then ProjInspector.LazProject:=Project1;
@ -11542,6 +11559,9 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.866 2005/05/26 15:54:02 mattias
changed OI SHow Hints option to resource string, added TProjectDescriptor.DoInitDescriptor
Revision 1.865 2005/05/21 15:38:07 mattias Revision 1.865 2005/05/21 15:38:07 mattias
fixed some typos fixed some typos

View File

@ -308,8 +308,8 @@ type
constructor Create; override; constructor Create; override;
function GetLocalizedName: string; override; function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override; function GetLocalizedDescription: string; override;
procedure InitProject(AProject: TLazProject); override; function InitProject(AProject: TLazProject): TModalResult; override;
procedure CreateStartFiles(AProject: TLazProject); override; function CreateStartFiles(AProject: TLazProject): TModalResult; override;
end; end;
{ TProjectProgramDescriptor } { TProjectProgramDescriptor }
@ -319,8 +319,8 @@ type
constructor Create; override; constructor Create; override;
function GetLocalizedName: string; override; function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override; function GetLocalizedDescription: string; override;
procedure InitProject(AProject: TLazProject); override; function InitProject(AProject: TLazProject): TModalResult; override;
procedure CreateStartFiles(AProject: TLazProject); override; function CreateStartFiles(AProject: TLazProject): TModalResult; override;
end; end;
{ TProjectManualProgramDescriptor } { TProjectManualProgramDescriptor }
@ -332,8 +332,8 @@ type
constructor Create; override; constructor Create; override;
function GetLocalizedName: string; override; function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override; function GetLocalizedDescription: string; override;
procedure InitProject(AProject: TLazProject); override; function InitProject(AProject: TLazProject): TModalResult; override;
procedure CreateStartFiles(AProject: TLazProject); override; function CreateStartFiles(AProject: TLazProject): TModalResult; override;
property AddMainSource: boolean read FAddMainSource write FAddMainSource; property AddMainSource: boolean read FAddMainSource write FAddMainSource;
end; end;
@ -1210,9 +1210,6 @@ begin
fTargetFileExt := GetDefaultExecutableExt; fTargetFileExt := GetDefaultExecutableExt;
Title := ''; Title := '';
fUnitList := TList.Create; // list of TUnitInfo fUnitList := TList.Create; // list of TUnitInfo
// custom initialization
ProjectDescription.InitProject(Self);
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -3001,13 +2998,14 @@ begin
Result:=Format(lisProgramAFreepascalProgramTheProgramFileIsAutomatic, [#13]); Result:=Format(lisProgramAFreepascalProgramTheProgramFileIsAutomatic, [#13]);
end; end;
procedure TProjectProgramDescriptor.InitProject(AProject: TLazProject); function TProjectProgramDescriptor.InitProject(AProject: TLazProject
): TModalResult;
var var
le: String; le: String;
NewSource: String; NewSource: String;
MainFile: TLazProjectFile; MainFile: TLazProjectFile;
begin begin
inherited InitProject(AProject); Result:=inherited InitProject(AProject);
MainFile:=AProject.CreateProjectFile('project1.lpr'); MainFile:=AProject.CreateProjectFile('project1.lpr');
MainFile.IsPartOfProject:=true; MainFile.IsPartOfProject:=true;
@ -3030,9 +3028,10 @@ begin
AProject.MainFile.SetSourceText(NewSource); AProject.MainFile.SetSourceText(NewSource);
end; end;
procedure TProjectProgramDescriptor.CreateStartFiles(AProject: TLazProject); function TProjectProgramDescriptor.CreateStartFiles(AProject: TLazProject
): TModalResult;
begin begin
LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1, Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,
[ofProjectLoading,ofRegularFile]); [ofProjectLoading,ofRegularFile]);
end; end;
@ -3054,13 +3053,14 @@ begin
Result:=Format(lisApplicationAGraphicalLclFreepascalProgramTheProgra, [#13]); Result:=Format(lisApplicationAGraphicalLclFreepascalProgramTheProgra, [#13]);
end; end;
procedure TProjectApplicationDescriptor.InitProject(AProject: TLazProject); function TProjectApplicationDescriptor.InitProject(
AProject: TLazProject): TModalResult;
var var
le: string; le: string;
NewSource: String; NewSource: String;
MainFile: TLazProjectFile; MainFile: TLazProjectFile;
begin begin
inherited InitProject(AProject); Result:=inherited InitProject(AProject);
MainFile:=AProject.CreateProjectFile('project1.lpr'); MainFile:=AProject.CreateProjectFile('project1.lpr');
MainFile.IsPartOfProject:=true; MainFile.IsPartOfProject:=true;
@ -3092,10 +3092,10 @@ begin
AProject.LazCompilerOptions.Win32GraphicApp:=true; AProject.LazCompilerOptions.Win32GraphicApp:=true;
end; end;
procedure TProjectApplicationDescriptor.CreateStartFiles(AProject: TLazProject function TProjectApplicationDescriptor.CreateStartFiles(AProject: TLazProject
); ): TModalResult;
begin begin
LazarusIDE.DoNewEditorFile(FileDescriptorForm,'','', Result:=LazarusIDE.DoNewEditorFile(FileDescriptorForm,'','',
[nfIsPartOfProject,nfOpenInEditor,nfCreateDefaultSrc]); [nfIsPartOfProject,nfOpenInEditor,nfCreateDefaultSrc]);
end; end;
@ -3121,13 +3121,14 @@ begin
Result:=Format(lisCustomProgramAFreepascalProgram, [#13]) Result:=Format(lisCustomProgramAFreepascalProgram, [#13])
end; end;
procedure TProjectManualProgramDescriptor.InitProject(AProject: TLazProject); function TProjectManualProgramDescriptor.InitProject(AProject: TLazProject
): TModalResult;
var var
le: string; le: string;
NewSource: String; NewSource: String;
MainFile: TLazProjectFile; MainFile: TLazProjectFile;
begin begin
inherited InitProject(AProject); Result:=inherited InitProject(AProject);
if AddMainSource then begin if AddMainSource then begin
MainFile:=AProject.CreateProjectFile('project1.pas'); MainFile:=AProject.CreateProjectFile('project1.pas');
@ -3152,10 +3153,10 @@ begin
end; end;
end; end;
procedure TProjectManualProgramDescriptor.CreateStartFiles(AProject: TLazProject function TProjectManualProgramDescriptor.CreateStartFiles(AProject: TLazProject
); ): TModalResult;
begin begin
LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1, Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,
[ofProjectLoading,ofRegularFile]); [ofProjectLoading,ofRegularFile]);
end; end;
@ -3171,6 +3172,9 @@ end.
{ {
$Log$ $Log$
Revision 1.183 2005/05/26 15:54:02 mattias
changed OI SHow Hints option to resource string, added TProjectDescriptor.DoInitDescriptor
Revision 1.182 2005/03/23 10:45:05 mattias Revision 1.182 2005/03/23 10:45:05 mattias
fixed ambigious with ambiguous fixed ambigious with ambiguous

View File

@ -22,7 +22,7 @@ unit ProjectIntf;
interface interface
uses uses
Classes, SysUtils, LCLProc, FileUtil, NewItemIntf; Classes, SysUtils, LCLProc, FileUtil, Controls, Forms, NewItemIntf;
const const
FileDescGroupName = 'File'; FileDescGroupName = 'File';
@ -420,29 +420,40 @@ type
); );
TProjectFlags = set of TProjectFlag; TProjectFlags = set of TProjectFlag;
{ TProjectDescriptor
- to show an option dialog to the user override the DoInitDescriptor
- to initialize project compiler settings and paths override InitProject
- to create files on creation override CreateStartFiles
}
TProjectDescriptor = class(TPersistent) TProjectDescriptor = class(TPersistent)
private private
FDefaultExt: string; FDefaultExt: string;
FFlags: TProjectFlags; FFlags: TProjectFlags;
FInitialized: boolean;
FName: string; FName: string;
FReferenceCount: integer; FReferenceCount: integer;
FVisibleInNewDialog: boolean; FVisibleInNewDialog: boolean;
protected protected
procedure SetName(const AValue: string); virtual; procedure SetName(const AValue: string); virtual;
procedure SetFlags(const AValue: TProjectFlags); virtual; procedure SetFlags(const AValue: TProjectFlags); virtual;
procedure SetInitialized;
function DoInitDescriptor: TModalResult; virtual;// put here option dialogs
public public
constructor Create; virtual; constructor Create; virtual;
function GetLocalizedName: string; virtual; function GetLocalizedName: string; virtual;
function GetLocalizedDescription: string; virtual; function GetLocalizedDescription: string; virtual;
procedure Release; procedure Release;
procedure Reference; procedure Reference;
procedure InitProject(AProject: TLazProject); virtual; function InitDescriptor: TModalResult;
procedure CreateStartFiles(AProject: TLazProject); virtual; function InitProject(AProject: TLazProject): TModalResult; virtual;
function CreateStartFiles(AProject: TLazProject): TModalResult; virtual;
public public
property Name: string read FName write SetName; property Name: string read FName write SetName;
property VisibleInNewDialog: boolean read FVisibleInNewDialog write FVisibleInNewDialog; property VisibleInNewDialog: boolean read FVisibleInNewDialog write FVisibleInNewDialog;
property Flags: TProjectFlags read FFlags write SetFlags; property Flags: TProjectFlags read FFlags write SetFlags;
property DefaultExt: string read FDefaultExt write FDefaultExt; property DefaultExt: string read FDefaultExt write FDefaultExt;
property Initialized: boolean read FInitialized;
end; end;
TProjectDescriptorClass = class of TProjectDescriptor; TProjectDescriptorClass = class of TProjectDescriptor;
@ -830,6 +841,16 @@ begin
FFlags:=AValue; FFlags:=AValue;
end; end;
procedure TProjectDescriptor.SetInitialized;
begin
FInitialized:=true;
end;
function TProjectDescriptor.DoInitDescriptor: TModalResult;
begin
Result:=mrOk;
end;
procedure TProjectDescriptor.SetName(const AValue: string); procedure TProjectDescriptor.SetName(const AValue: string);
begin begin
if FName=AValue then exit; if FName=AValue then exit;
@ -868,15 +889,26 @@ begin
inc(FReferenceCount); inc(FReferenceCount);
end; end;
procedure TProjectDescriptor.InitProject(AProject: TLazProject); function TProjectDescriptor.InitDescriptor: TModalResult;
begin
if not Initialized then begin
Result:=DoInitDescriptor;
SetInitialized;
end else
Result:=mrOk;
end;
function TProjectDescriptor.InitProject(AProject: TLazProject): TModalResult;
begin begin
AProject.Title:='project1'; AProject.Title:='project1';
AProject.Flags:=Flags; AProject.Flags:=Flags;
Result:=mrOk;
end; end;
procedure TProjectDescriptor.CreateStartFiles(AProject: TLazProject); function TProjectDescriptor.CreateStartFiles(AProject: TLazProject
): TModalResult;
begin begin
Result:=mrOk;
end; end;
{ TLazProject } { TLazProject }

View File

@ -476,7 +476,7 @@ begin
descent^ := PANGO_DESCENT(extents) div PANGO_SCALE; descent^ := PANGO_DESCENT(extents) div PANGO_SCALE;
end; end;
{$EndIf} {$EndIf Gtk2}
procedure BeginGDKErrorTrap; procedure BeginGDKErrorTrap;
begin begin
@ -8204,6 +8204,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.358 2005/05/26 15:54:02 mattias
changed OI SHow Hints option to resource string, added TProjectDescriptor.DoInitDescriptor
Revision 1.357 2005/05/21 19:27:41 marc Revision 1.357 2005/05/21 19:27:41 marc
* fixed synedit navigation on OSX * fixed synedit navigation on OSX