IDE: Improve TPathEditorButton class, handle Templates better.

git-svn-id: trunk@47490 -
This commit is contained in:
juha 2015-01-22 23:03:27 +00:00
parent 94b310ce46
commit bd0bafb893
4 changed files with 54 additions and 72 deletions

View File

@ -431,54 +431,29 @@ end;
procedure TCompilerPathOptionsFrame.PathEditBtnClick(Sender: TObject); procedure TCompilerPathOptionsFrame.PathEditBtnClick(Sender: TObject);
var var
AButton: TPathEditorButton; AButton: TPathEditorButton;
OldPath, Templates: string; OldPath: string;
begin begin
if Sender is TPathEditorButton then if Sender is TPathEditorButton then
begin begin
AButton := TPathEditorButton(Sender); AButton := TPathEditorButton(Sender);
if AButton = OtherUnitsPathEditBtn then if AButton = OtherUnitsPathEditBtn then
begin OldPath := OtherUnitsEdit.Text
OldPath := OtherUnitsEdit.Text;
Templates := SetDirSeparators(
'$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)' +
';$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType)' +
';$(LazarusDir)/components/codetools/units/$(TargetCPU)-$(TargetOS)' +
';$(LazarusDir)/components/custom' +
';$(LazarusDir)/packager/units/$(TargetCPU)-$(TargetOS)');
end
else else
if AButton = IncludeFilesPathEditBtn then if AButton = IncludeFilesPathEditBtn then
begin OldPath := IncludeFilesEdit.Text
OldPath := IncludeFilesEdit.Text;
Templates := 'include' + ';inc';
end
else else
if AButton = OtherSourcesPathEditBtn then if AButton = OtherSourcesPathEditBtn then
begin OldPath := OtherSourcesEdit.Text
OldPath := OtherSourcesEdit.Text;
Templates := SetDirSeparators('$(LazarusDir)/lcl' +
';$(LazarusDir)/lcl/interfaces/$(LCLWidgetType)' +
';$(LazarusDir)/components/synedit' + ';$(LazarusDir)/components/codetools');
end
else else
if AButton = LibrariesPathEditBtn then if AButton = LibrariesPathEditBtn then
begin OldPath := LibrariesEdit.Text
OldPath := LibrariesEdit.Text;
Templates := SetDirSeparators('/usr/X11R6/lib;/sw/lib');
end
else else
if AButton = DebugPathEditBtn then if AButton = DebugPathEditBtn then
begin OldPath := DebugPathEdit.Text
OldPath := DebugPathEdit.Text;
Templates := SetDirSeparators('$(LazarusDir)/lcl/include' +
';$(LazarusDir)/lcl/interfaces/$(LCLWidgetType)' +
';$(LazarusDir)/include');
end
else else
Exit; Exit;
AButton.CurrentPathEditor.BaseDirectory := FCompilerOpts.BaseDirectory; AButton.CurrentPathEditor.BaseDirectory := FCompilerOpts.BaseDirectory;
AButton.CurrentPathEditor.Path := OldPath; AButton.CurrentPathEditor.Path := OldPath;
AButton.CurrentPathEditor.Templates := SetDirSeparators(Templates);
end; end;
end; end;
@ -596,6 +571,12 @@ begin
AnchorParallel(akBottom, 0, OtherUnitsEdit); AnchorParallel(akBottom, 0, OtherUnitsEdit);
AnchorParallel(akRight, 0, Self); AnchorParallel(akRight, 0, Self);
AutoSize := True; AutoSize := True;
AssociatedEdit := OtherUnitsEdit;
Templates:='$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)' +
';$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType)' +
';$(LazarusDir)/components/codetools/units/$(TargetCPU)-$(TargetOS)' +
';$(LazarusDir)/components/custom' +
';$(LazarusDir)/packager/units/$(TargetCPU)-$(TargetOS)';
OnClick := @PathEditBtnClick; OnClick := @PathEditBtnClick;
OnExecuted := @PathEditBtnExecuted; OnExecuted := @PathEditBtnExecuted;
Parent := Self; Parent := Self;
@ -611,12 +592,14 @@ begin
with IncludeFilesPathEditBtn do with IncludeFilesPathEditBtn do
begin begin
Name := 'IncludeFilesPathEditBtn'; Name := 'IncludeFilesPathEditBtn';
Caption := '...';
Anchors := [akRight, akTop, akBottom]; Anchors := [akRight, akTop, akBottom];
AnchorParallel(akTop, 0, IncludeFilesEdit); AnchorParallel(akTop, 0, IncludeFilesEdit);
AnchorParallel(akBottom, 0, IncludeFilesEdit); AnchorParallel(akBottom, 0, IncludeFilesEdit);
AnchorParallel(akRight, 0, Self); AnchorParallel(akRight, 0, Self);
AutoSize := True; AutoSize := True;
Caption := '...'; AssociatedEdit := IncludeFilesEdit;
Templates := 'include;inc';
OnClick := @PathEditBtnClick; OnClick := @PathEditBtnClick;
OnExecuted := @PathEditBtnExecuted; OnExecuted := @PathEditBtnExecuted;
Parent := Self; Parent := Self;
@ -632,12 +615,17 @@ begin
with OtherSourcesPathEditBtn do with OtherSourcesPathEditBtn do
begin begin
Name := 'OtherSourcesPathEditBtn'; Name := 'OtherSourcesPathEditBtn';
Caption := '...';
Anchors := [akRight, akTop, akBottom]; Anchors := [akRight, akTop, akBottom];
AnchorParallel(akTop, 0, OtherSourcesEdit); AnchorParallel(akTop, 0, OtherSourcesEdit);
AnchorParallel(akBottom, 0, OtherSourcesEdit); AnchorParallel(akBottom, 0, OtherSourcesEdit);
AnchorParallel(akRight, 0, Self); AnchorParallel(akRight, 0, Self);
AutoSize := True; AutoSize := True;
Caption := '...'; AssociatedEdit := OtherSourcesEdit;
Templates := '$(LazarusDir)/lcl' +
';$(LazarusDir)/lcl/interfaces/$(LCLWidgetType)' +
';$(LazarusDir)/components/synedit' +
';$(LazarusDir)/components/codetools';
OnClick := @PathEditBtnClick; OnClick := @PathEditBtnClick;
OnExecuted := @PathEditBtnExecuted; OnExecuted := @PathEditBtnExecuted;
Parent := Self; Parent := Self;
@ -653,12 +641,14 @@ begin
with LibrariesPathEditBtn do with LibrariesPathEditBtn do
begin begin
Name := 'LibrariesPathEditBtn'; Name := 'LibrariesPathEditBtn';
Caption := '...';
Anchors := [akRight, akTop, akBottom]; Anchors := [akRight, akTop, akBottom];
AnchorParallel(akTop, 0, LibrariesEdit); AnchorParallel(akTop, 0, LibrariesEdit);
AnchorParallel(akBottom, 0, LibrariesEdit); AnchorParallel(akBottom, 0, LibrariesEdit);
AnchorParallel(akRight, 0, Self); AnchorParallel(akRight, 0, Self);
AutoSize := True; AutoSize := True;
Caption := '...'; AssociatedEdit := LibrariesEdit;
Templates := '/usr/X11R6/lib;/sw/lib';
OnClick := @PathEditBtnClick; OnClick := @PathEditBtnClick;
OnExecuted := @PathEditBtnExecuted; OnExecuted := @PathEditBtnExecuted;
Parent := Self; Parent := Self;
@ -674,12 +664,12 @@ begin
with btnUnitOutputDir do with btnUnitOutputDir do
begin begin
Name := 'btnUnitOutputDir'; Name := 'btnUnitOutputDir';
Caption := '...';
Anchors := [akRight, akTop, akBottom]; Anchors := [akRight, akTop, akBottom];
AnchorParallel(akTop, 0, UnitOutputDirEdit); AnchorParallel(akTop, 0, UnitOutputDirEdit);
AnchorParallel(akBottom, 0, UnitOutputDirEdit); AnchorParallel(akBottom, 0, UnitOutputDirEdit);
AnchorParallel(akRight, 0, Self); AnchorParallel(akRight, 0, Self);
AutoSize := True; AutoSize := True;
Caption := '...';
OnClick := @FileBrowseBtnClick; OnClick := @FileBrowseBtnClick;
Parent := Self; Parent := Self;
TabOrder:=7; TabOrder:=7;
@ -696,12 +686,16 @@ begin
with DebugPathEditBtn do with DebugPathEditBtn do
begin begin
Name := 'DebugPathEditBtn'; Name := 'DebugPathEditBtn';
Caption := '...';
Anchors := [akRight, akTop, akBottom]; Anchors := [akRight, akTop, akBottom];
AnchorParallel(akTop, 0, DebugPathEdit); AnchorParallel(akTop, 0, DebugPathEdit);
AnchorParallel(akBottom, 0, DebugPathEdit); AnchorParallel(akBottom, 0, DebugPathEdit);
AnchorParallel(akRight, 0, Self); AnchorParallel(akRight, 0, Self);
AutoSize := True; AutoSize := True;
Caption := '...'; AssociatedEdit := DebugPathEdit;
Templates := '$(LazarusDir)/lcl/include' +
';$(LazarusDir)/lcl/interfaces/$(LCLWidgetType)' +
';$(LazarusDir)/include';
OnClick := @PathEditBtnClick; OnClick := @PathEditBtnClick;
OnExecuted := @PathEditBtnExecuted; OnExecuted := @PathEditBtnExecuted;
Parent := Self; Parent := Self;

View File

@ -102,15 +102,21 @@ type
TOnPathEditorExecuted = TNotifyEvent; TOnPathEditorExecuted = TNotifyEvent;
{ TPathEditorButton }
TPathEditorButton = class(TButton) TPathEditorButton = class(TButton)
private private
FCurrentPathEditor: TPathEditorDialog; FCurrentPathEditor: TPathEditorDialog;
FAssociatedEdit: TCustomEdit;
FTemplates: String;
FOnExecuted: TOnPathEditorExecuted; FOnExecuted: TOnPathEditorExecuted;
protected protected
procedure DoOnPathEditorExecuted; procedure DoOnPathEditorExecuted;
public public
procedure Click; override; procedure Click; override;
property CurrentPathEditor: TPathEditorDialog read FCurrentPathEditor; property CurrentPathEditor: TPathEditorDialog read FCurrentPathEditor;
property AssociatedEdit: TCustomEdit read FAssociatedEdit write FAssociatedEdit;
property Templates: String read FTemplates write FTemplates;
property OnExecuted: TOnPathEditorExecuted read FOnExecuted write FOnExecuted; property OnExecuted: TOnPathEditorExecuted read FOnExecuted write FOnExecuted;
end; end;
@ -586,6 +592,7 @@ begin
FCurrentPathEditor:=PathEditorDialog; FCurrentPathEditor:=PathEditorDialog;
try try
inherited Click; inherited Click;
FCurrentPathEditor.Templates := SetDirSeparators(FTemplates);
FCurrentPathEditor.ShowModal; FCurrentPathEditor.ShowModal;
DoOnPathEditorExecuted; DoOnPathEditorExecuted;
finally finally

View File

@ -84,11 +84,8 @@ begin
end; end;
procedure TPackageIntegrationOptionsFrame.PathEditBtnClick(Sender: TObject); procedure TPackageIntegrationOptionsFrame.PathEditBtnClick(Sender: TObject);
var
AButton: TPathEditorButton absolute Sender;
begin begin
AButton.CurrentPathEditor.Path := FPDocSearchPathsEdit.Text; (Sender as TPathEditorButton).CurrentPathEditor.Path := FPDocSearchPathsEdit.Text;
AButton.CurrentPathEditor.Templates := '';
end; end;
function TPackageIntegrationOptionsFrame.GetSelectedPkgType: TLazPackageType; function TPackageIntegrationOptionsFrame.GetSelectedPkgType: TLazPackageType;
@ -204,6 +201,7 @@ begin
AnchorParallel(akRight, 6, DocGroupBox); AnchorParallel(akRight, 6, DocGroupBox);
AnchorParallel(akTop, 0, FPDocSearchPathsEdit); AnchorParallel(akTop, 0, FPDocSearchPathsEdit);
AnchorParallel(akBottom, 0, FPDocSearchPathsEdit); AnchorParallel(akBottom, 0, FPDocSearchPathsEdit);
AssociatedEdit := FPDocSearchPathsEdit;
OnClick := @PathEditBtnClick; OnClick := @PathEditBtnClick;
OnExecuted := @PathEditBtnExecuted; OnExecuted := @PathEditBtnExecuted;
Parent := DocGroupBox; Parent := DocGroupBox;

View File

@ -56,40 +56,12 @@ implementation
procedure TPackageUsageOptionsFrame.PathEditBtnClick(Sender: TObject); procedure TPackageUsageOptionsFrame.PathEditBtnClick(Sender: TObject);
var var
AButton: TPathEditorButton; AButton: TPathEditorButton;
OldPath: string;
AnEdit: TEdit; AnEdit: TEdit;
Templates: string;
begin begin
if not (Sender is TPathEditorButton) then if not (Sender is TPathEditorButton) then exit;
exit;
AButton := TPathEditorButton(Sender); AButton := TPathEditorButton(Sender);
AnEdit := GetEditForPathButton(AButton); AnEdit := GetEditForPathButton(AButton);
OldPath := AnEdit.Text; AButton.CurrentPathEditor.Path := AnEdit.Text;
if AButton = UnitPathButton then
begin
Templates := SetDirSeparators('$(PkgOutDir)' +
'$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)' +
';$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType)' +
';$(LazarusDir)/components/codetools/units/$(TargetCPU)-$(TargetOS)' +
';$(LazarusDir)/components/custom' +
';$(LazarusDir)/packager/units/$(TargetCPU)-$(TargetOS)');
end
else if AButton = IncludePathButton then
begin
Templates := 'include';
end
else
if AButton = ObjectPathButton then
begin
Templates := 'objects';
end
else
if AButton = LibraryPathButton then
begin
Templates := '';
end;
AButton.CurrentPathEditor.Path := OldPath;
AButton.CurrentPathEditor.Templates := SetDirSeparators(Templates);
end; end;
procedure TPackageUsageOptionsFrame.PathEditBtnExecuted(Sender: TObject); procedure TPackageUsageOptionsFrame.PathEditBtnExecuted(Sender: TObject);
@ -132,8 +104,7 @@ begin
mrYes: mrYes:
begin begin
// remove directory from search path // remove directory from search path
NewPath := copy(NewPath, 1, OldStartPos - 1) + NewPath := copy(NewPath,1,OldStartPos-1) + copy(NewPath,StartPos,length(NewPath));
copy(NewPath, StartPos, length(NewPath));
StartPos := OldStartPos; StartPos := OldStartPos;
end; end;
else else
@ -190,6 +161,13 @@ begin
AnchorParallel(akRight, 6, AddPathsGroupBox); AnchorParallel(akRight, 6, AddPathsGroupBox);
AnchorParallel(akTop, 0, UnitPathEdit); AnchorParallel(akTop, 0, UnitPathEdit);
AnchorParallel(akBottom, 0, UnitPathEdit); AnchorParallel(akBottom, 0, UnitPathEdit);
AssociatedEdit := UnitPathEdit;
Templates := '$(PkgOutDir)' +
'$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)' +
';$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType)' +
';$(LazarusDir)/components/codetools/units/$(TargetCPU)-$(TargetOS)' +
';$(LazarusDir)/components/custom' +
';$(LazarusDir)/packager/units/$(TargetCPU)-$(TargetOS)';
OnClick := @PathEditBtnClick; OnClick := @PathEditBtnClick;
OnExecuted := @PathEditBtnExecuted; OnExecuted := @PathEditBtnExecuted;
end; end;
@ -206,6 +184,8 @@ begin
AnchorParallel(akRight, 6, AddPathsGroupBox); AnchorParallel(akRight, 6, AddPathsGroupBox);
AnchorParallel(akTop, 0, IncludePathEdit); AnchorParallel(akTop, 0, IncludePathEdit);
AnchorParallel(akBottom, 0, IncludePathEdit); AnchorParallel(akBottom, 0, IncludePathEdit);
AssociatedEdit := IncludePathEdit;
Templates := 'include';
OnClick := @PathEditBtnClick; OnClick := @PathEditBtnClick;
OnExecuted := @PathEditBtnExecuted; OnExecuted := @PathEditBtnExecuted;
end; end;
@ -222,6 +202,8 @@ begin
AnchorParallel(akRight, 6, AddPathsGroupBox); AnchorParallel(akRight, 6, AddPathsGroupBox);
AnchorParallel(akTop, 0, ObjectPathEdit); AnchorParallel(akTop, 0, ObjectPathEdit);
AnchorParallel(akBottom, 0, ObjectPathEdit); AnchorParallel(akBottom, 0, ObjectPathEdit);
AssociatedEdit := ObjectPathEdit;
Templates := 'objects';
OnClick := @PathEditBtnClick; OnClick := @PathEditBtnClick;
OnExecuted := @PathEditBtnExecuted; OnExecuted := @PathEditBtnExecuted;
end; end;
@ -238,6 +220,7 @@ begin
AnchorParallel(akRight, 6, AddPathsGroupBox); AnchorParallel(akRight, 6, AddPathsGroupBox);
AnchorParallel(akTop, 0, LibraryPathEdit); AnchorParallel(akTop, 0, LibraryPathEdit);
AnchorParallel(akBottom, 0, LibraryPathEdit); AnchorParallel(akBottom, 0, LibraryPathEdit);
AssociatedEdit := LibraryPathEdit;
OnClick := @PathEditBtnClick; OnClick := @PathEditBtnClick;
OnExecuted := @PathEditBtnExecuted; OnExecuted := @PathEditBtnExecuted;
end; end;