1
unit package_usage_options;
8
Classes, SysUtils, FileUtil, Forms, Controls, StdCtrls, Dialogs, PathEditorDlg,
9
IDEOptionsIntf, MacroIntf,
10
LazarusIDEStrConsts, IDEProcs, PackageDefs;
14
{ TPackageUsageOptionsFrame }
16
TPackageUsageOptionsFrame = class(TAbstractIDEOptionsEditor)
17
AddOptionsGroupBox: TGroupBox;
18
AddPackageUnitToProjectCheckBox: TCheckBox;
19
AddPathsGroupBox: TGroupBox;
20
CustomOptionsLabel: TLabel;
21
CustomOptionsMemo: TMemo;
22
IncludePathEdit: TEdit;
23
IncludePathLabel: TLabel;
24
LibraryPathEdit: TEdit;
25
LibraryPathLabel: TLabel;
26
LinkerOptionsLabel: TLabel;
27
LinkerOptionsMemo: TMemo;
28
ObjectPathEdit: TEdit;
29
ObjectPathLabel: TLabel;
30
ProjectGroupBox: TGroupBox;
32
UnitPathLabel: TLabel;
34
UnitPathButton: TPathEditorButton;
35
IncludePathButton: TPathEditorButton;
36
ObjectPathButton: TPathEditorButton;
37
LibraryPathButton: TPathEditorButton;
38
FLazPackage: TLazPackage;
39
procedure PathEditBtnClick(Sender: TObject);
40
procedure PathEditBtnExecuted(Sender: TObject);
41
function GetEditForPathButton(AButton: TPathEditorButton): TEdit;
43
function GetTitle: string; override;
44
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
45
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
46
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
47
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
54
{ TPackageUsageOptionsFrame }
56
procedure TPackageUsageOptionsFrame.PathEditBtnClick(Sender: TObject);
58
AButton: TPathEditorButton;
63
if not (Sender is TPathEditorButton) then
65
AButton := TPathEditorButton(Sender);
66
AnEdit := GetEditForPathButton(AButton);
67
OldPath := AnEdit.Text;
68
if AButton = UnitPathButton then
70
Templates := SetDirSeparators('$(PkgOutDir)' +
71
'$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)' +
72
';$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType)' +
73
';$(LazarusDir)/components/codetools/units/$(TargetCPU)-$(TargetOS)' +
74
';$(LazarusDir)/components/custom' +
75
';$(LazarusDir)/packager/units/$(TargetCPU)-$(TargetOS)');
77
else if AButton = IncludePathButton then
79
Templates := 'include';
82
if AButton = ObjectPathButton then
84
Templates := 'objects';
87
if AButton = LibraryPathButton then
91
AButton.CurrentPathEditor.Path := OldPath;
92
AButton.CurrentPathEditor.Templates := SetDirSeparators(Templates);
95
procedure TPackageUsageOptionsFrame.PathEditBtnExecuted(Sender: TObject);
97
AButton: TPathEditorButton;
103
DlgResult: TModalResult;
104
OldStartPos: longint;
106
if not (Sender is TPathEditorButton) then
108
AButton := TPathEditorButton(Sender);
109
if AButton.CurrentPathEditor.ModalResult <> mrOk then
111
NewPath := AButton.CurrentPathEditor.Path;
112
AnEdit := GetEditForPathButton(AButton);
113
OldPath := AnEdit.Text;
114
if OldPath <> NewPath then
119
OldStartPos := StartPos;
120
CurDir := GetNextDirectoryInSearchPath(NewPath, StartPos);
123
IDEMacros.SubstituteMacros(CurDir);
124
FLazPackage.LongenFilename(CurDir);
125
if not DirPathExists(CurDir) then
127
DlgResult := QuestionDlg(lisEnvOptDlgDirectoryNotFound,
128
Format(lisDirectoryNotFound, ['"', CurDir, '"']),
129
mtError, [mrIgnore, mrYes, lisRemoveFromSearchPath, mrCancel], 0);
134
// remove directory from search path
135
NewPath := copy(NewPath, 1, OldStartPos - 1) +
136
copy(NewPath, StartPos, length(NewPath));
137
StartPos := OldStartPos;
146
until StartPos > length(NewPath);
148
AnEdit.Text := NewPath;
151
function TPackageUsageOptionsFrame.GetEditForPathButton(
152
AButton: TPathEditorButton): TEdit;
154
if AButton = UnitPathButton then
155
Result := UnitPathEdit
156
else if AButton = IncludePathButton then
157
Result := IncludePathEdit
158
else if AButton = ObjectPathButton then
159
Result := ObjectPathEdit
160
else if AButton = LibraryPathButton then
161
Result := LibraryPathEdit
166
function TPackageUsageOptionsFrame.GetTitle: string;
168
Result := lisPckOptsUsage;
171
procedure TPackageUsageOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
173
AddPathsGroupBox.Caption := lisPckOptsAddPathsToDependentPackagesProjects;
174
UnitPathLabel.Caption := lisPkgFileTypeUnit;
175
IncludePathLabel.Caption := lisPckOptsInclude;
176
ObjectPathLabel.Caption := lisPckOptsObject;
177
LibraryPathLabel.Caption := lisPckOptsLibrary;
178
AddOptionsGroupBox.Caption := lisPckOptsAddOptionsToDependentPackagesAndProjects;
179
LinkerOptionsLabel.Caption := lisPckOptsLinker;
180
CustomOptionsLabel.Caption := lisPckOptsCustom;
182
UnitPathButton := TPathEditorButton.Create(Self);
183
with UnitPathButton do
185
Name := 'UnitPathButton';
186
Parent := AddPathsGroupBox;
189
Anchors := [akRight];
190
AnchorParallel(akRight, 6, AddPathsGroupBox);
191
AnchorParallel(akTop, 0, UnitPathEdit);
192
AnchorParallel(akBottom, 0, UnitPathEdit);
193
OnClick := @PathEditBtnClick;
194
OnExecuted := @PathEditBtnExecuted;
196
UnitPathEdit.AnchorToNeighbour(akRight,0,UnitPathButton);
198
IncludePathButton := TPathEditorButton.Create(Self);
199
with IncludePathButton do
201
Name := 'IncludePathButton';
202
Parent := AddPathsGroupBox;
205
Anchors := [akRight];
206
AnchorParallel(akRight, 6, AddPathsGroupBox);
207
AnchorParallel(akTop, 0, IncludePathEdit);
208
AnchorParallel(akBottom, 0, IncludePathEdit);
209
OnClick := @PathEditBtnClick;
210
OnExecuted := @PathEditBtnExecuted;
212
IncludePathEdit.AnchorToNeighbour(akRight,0,IncludePathButton);
214
ObjectPathButton := TPathEditorButton.Create(Self);
215
with ObjectPathButton do
217
Name := 'ObjectPathButton';
218
Parent := AddPathsGroupBox;
221
Anchors := [akRight];
222
AnchorParallel(akRight, 6, AddPathsGroupBox);
223
AnchorParallel(akTop, 0, ObjectPathEdit);
224
AnchorParallel(akBottom, 0, ObjectPathEdit);
225
OnClick := @PathEditBtnClick;
226
OnExecuted := @PathEditBtnExecuted;
228
ObjectPathEdit.AnchorToNeighbour(akRight,0,ObjectPathButton);
230
LibraryPathButton := TPathEditorButton.Create(Self);
231
with LibraryPathButton do
233
Name := 'LibraryPathButton';
234
Parent := AddPathsGroupBox;
237
Anchors := [akRight];
238
AnchorParallel(akRight, 6, AddPathsGroupBox);
239
AnchorParallel(akTop, 0, LibraryPathEdit);
240
AnchorParallel(akBottom, 0, LibraryPathEdit);
241
OnClick := @PathEditBtnClick;
242
OnExecuted := @PathEditBtnExecuted;
244
LibraryPathEdit.AnchorToNeighbour(akRight,0,LibraryPathButton);
246
ProjectGroupBox.Caption := dlgProject;
247
AddPackageUnitToProjectCheckBox.Caption := podAddPackageUnitToUsesSection;
250
procedure TPackageUsageOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
252
LazPackage: TLazPackage absolute AOptions;
254
FLazPackage := LazPackage;
255
with LazPackage.UsageOptions do
257
UnitPathEdit.Text := UnitPath;
258
IncludePathEdit.Text := IncludePath;
259
ObjectPathEdit.Text := ObjectPath;
260
LibraryPathEdit.Text := LibraryPath;
261
LinkerOptionsMemo.Text := LinkerOptions;
262
CustomOptionsMemo.Text := CustomOptions;
264
AddPackageUnitToProjectCheckBox.Checked := LazPackage.AddToProjectUsesSection;
267
procedure TPackageUsageOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
269
LazPackage: TLazPackage absolute AOptions;
271
with LazPackage.UsageOptions do
273
UnitPath := TrimSearchPath(UnitPathEdit.Text, '');
274
IncludePath := TrimSearchPath(IncludePathEdit.Text, '');
275
ObjectPath := TrimSearchPath(ObjectPathEdit.Text, '');
276
LibraryPath := TrimSearchPath(LibraryPathEdit.Text, '');
277
LinkerOptions := LinkerOptionsMemo.Text;
278
CustomOptions := CustomOptionsMemo.Text;
280
LazPackage.AddToProjectUsesSection := AddPackageUnitToProjectCheckBox.Checked;
283
class function TPackageUsageOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
285
Result := TLazPackage;
289
RegisterIDEOptionsEditor(GroupPackage, TPackageUsageOptionsFrame, PackageOptionsUsage);