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

View File

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

View File

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

View File

@ -56,40 +56,12 @@ implementation
procedure TPackageUsageOptionsFrame.PathEditBtnClick(Sender: TObject);
var
AButton: TPathEditorButton;
OldPath: string;
AnEdit: TEdit;
Templates: string;
begin
if not (Sender is TPathEditorButton) then
exit;
if not (Sender is TPathEditorButton) then exit;
AButton := TPathEditorButton(Sender);
AnEdit := GetEditForPathButton(AButton);
OldPath := 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);
AButton.CurrentPathEditor.Path := AnEdit.Text;
end;
procedure TPackageUsageOptionsFrame.PathEditBtnExecuted(Sender: TObject);
@ -132,8 +104,7 @@ begin
mrYes:
begin
// remove directory from search path
NewPath := copy(NewPath, 1, OldStartPos - 1) +
copy(NewPath, StartPos, length(NewPath));
NewPath := copy(NewPath,1,OldStartPos-1) + copy(NewPath,StartPos,length(NewPath));
StartPos := OldStartPos;
end;
else
@ -190,6 +161,13 @@ begin
AnchorParallel(akRight, 6, AddPathsGroupBox);
AnchorParallel(akTop, 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;
OnExecuted := @PathEditBtnExecuted;
end;
@ -206,6 +184,8 @@ begin
AnchorParallel(akRight, 6, AddPathsGroupBox);
AnchorParallel(akTop, 0, IncludePathEdit);
AnchorParallel(akBottom, 0, IncludePathEdit);
AssociatedEdit := IncludePathEdit;
Templates := 'include';
OnClick := @PathEditBtnClick;
OnExecuted := @PathEditBtnExecuted;
end;
@ -222,6 +202,8 @@ begin
AnchorParallel(akRight, 6, AddPathsGroupBox);
AnchorParallel(akTop, 0, ObjectPathEdit);
AnchorParallel(akBottom, 0, ObjectPathEdit);
AssociatedEdit := ObjectPathEdit;
Templates := 'objects';
OnClick := @PathEditBtnClick;
OnExecuted := @PathEditBtnExecuted;
end;
@ -238,6 +220,7 @@ begin
AnchorParallel(akRight, 6, AddPathsGroupBox);
AnchorParallel(akTop, 0, LibraryPathEdit);
AnchorParallel(akBottom, 0, LibraryPathEdit);
AssociatedEdit := LibraryPathEdit;
OnClick := @PathEditBtnClick;
OnExecuted := @PathEditBtnExecuted;
end;