~ubuntu-branches/ubuntu/saucy/lazarus/saucy

« back to all changes in this revision

Viewing changes to packager/frames/package_usage_options.pas

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Bart Martens, Paul Gevers
  • Date: 2013-06-08 14:12:17 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130608141217-7k0cy9id8ifcnutc
Tags: 1.0.8+dfsg-1
[ Abou Al Montacir ]
* New upstream major release and multiple maintenace release offering many
  fixes and new features marking a new milestone for the Lazarus development
  and its stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch
* LCL changes:
  - LCL is now a normal package.
      + Platform independent parts of the LCL are now in the package LCLBase
      + LCL is automatically recompiled when switching the target platform,
        unless pre-compiled binaries for this target are already installed.
      + No impact on existing projects.
      + Linker options needed by LCL are no more added to projects that do
        not use the LCL package.
  - Minor changes in LCL basic classes behaviour
      + TCustomForm.Create raises an exception if a form resource is not
        found.
      + TNotebook and TPage: a new implementation of these classes was added.
      + TDBNavigator: It is now possible to have focusable buttons by setting
        Options = [navFocusableButtons] and TabStop = True, useful for
        accessibility and for devices with neither mouse nor touch screen.
      + Names of TControlBorderSpacing.GetSideSpace and GetSpace were swapped
        and are now consistent. GetSideSpace = Around + GetSpace.
      + TForm.WindowState=wsFullscreen was added
      + TCanvas.TextFitInfo was added to calculate how many characters will
        fit into a specified Width. Useful for word-wrapping calculations.
      + TControl.GetColorResolvingParent and
        TControl.GetRGBColorResolvingParent were added, simplifying the work
        to obtain the final color of the control while resolving clDefault
        and the ParentColor.
      + LCLIntf.GetTextExtentExPoint now has a good default implementation
        which works in any platform not providing a specific implementation.
        However, Widgetset specific implementation is better, when available.
      + TTabControl was reorganized. Now it has the correct class hierarchy
        and inherits from TCustomTabControl as it should.
  - New unit in the LCL:
      + lazdialogs.pas: adds non-native versions of various native dialogs,
        for example TLazOpenDialog, TLazSaveDialog, TLazSelectDirectoryDialog.
        It is used by widgetsets which either do not have a native dialog, or
        do not wish to use it because it is limited. These dialogs can also be
        used by user applications directly.
      + lazdeviceapis.pas: offers an interface to more hardware devices such
        as the accelerometer, GPS, etc. See LazDeviceAPIs
      + lazcanvas.pas: provides a TFPImageCanvas descendent implementing
        drawing in a LCL-compatible way, but 100% in Pascal.
      + lazregions.pas. LazRegions is a wholly Pascal implementation of
        regions for canvas clipping, event clipping, finding in which control
        of a region tree one an event should reach, for drawing polygons, etc.
      + customdrawncontrols.pas, customdrawndrawers.pas,
        customdrawn_common.pas, customdrawn_android.pas and
        customdrawn_winxp.pas: are the Lazarus Custom Drawn Controls -controls
        which imitate the standard LCL ones, but with the difference that they
        are non-native and support skinning.
  - New APIs added to the LCL to improve support of accessibility software
    such as screen readers.
* IDE changes:
  - Many improvments.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/New_IDE_features_since#v1.0_.282012-08-29.29
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes#IDE_Changes
* Debugger / Editor changes:
  - Added pascal sources and breakpoints to the disassembler
  - Added threads dialog.
* Components changes:
  - TAChart: many fixes and new features
  - CodeTool: support Delphi style generics and new syntax extensions.
  - AggPas: removed to honor free licencing. (Closes: Bug#708695)
[Bart Martens]
* New debian/watch file fixing issues with upstream RC release.
[Abou Al Montacir]
* Avoid changing files in .pc hidden directory, these are used by quilt for
  internal purpose and could lead to surprises during build.
[Paul Gevers]
* Updated get-orig-source target and it compinion script orig-tar.sh so that they
  repack the source file, allowing bug 708695 to be fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
unit package_usage_options;
 
2
 
 
3
{$mode objfpc}{$H+}
 
4
 
 
5
interface
 
6
 
 
7
uses
 
8
  Classes, SysUtils, FileUtil, Forms, Controls, StdCtrls, Dialogs, PathEditorDlg,
 
9
  IDEOptionsIntf, MacroIntf,
 
10
  LazarusIDEStrConsts, IDEProcs, PackageDefs;
 
11
 
 
12
type
 
13
 
 
14
  { TPackageUsageOptionsFrame }
 
15
 
 
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;
 
31
    UnitPathEdit: TEdit;
 
32
    UnitPathLabel: TLabel;
 
33
  private
 
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;
 
42
  public
 
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;
 
48
  end;
 
49
 
 
50
implementation
 
51
 
 
52
{$R *.lfm}
 
53
 
 
54
{ TPackageUsageOptionsFrame }
 
55
 
 
56
procedure TPackageUsageOptionsFrame.PathEditBtnClick(Sender: TObject);
 
57
var
 
58
  AButton: TPathEditorButton;
 
59
  OldPath: string;
 
60
  AnEdit: TEdit;
 
61
  Templates: string;
 
62
begin
 
63
  if not (Sender is TPathEditorButton) then
 
64
    exit;
 
65
  AButton := TPathEditorButton(Sender);
 
66
  AnEdit := GetEditForPathButton(AButton);
 
67
  OldPath := AnEdit.Text;
 
68
  if AButton = UnitPathButton then
 
69
  begin
 
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)');
 
76
  end
 
77
  else if AButton = IncludePathButton then
 
78
  begin
 
79
    Templates := 'include';
 
80
  end
 
81
  else
 
82
  if AButton = ObjectPathButton then
 
83
  begin
 
84
    Templates := 'objects';
 
85
  end
 
86
  else
 
87
  if AButton = LibraryPathButton then
 
88
  begin
 
89
    Templates := '';
 
90
  end;
 
91
  AButton.CurrentPathEditor.Path := OldPath;
 
92
  AButton.CurrentPathEditor.Templates := SetDirSeparators(Templates);
 
93
end;
 
94
 
 
95
procedure TPackageUsageOptionsFrame.PathEditBtnExecuted(Sender: TObject);
 
96
var
 
97
  AButton: TPathEditorButton;
 
98
  NewPath: string;
 
99
  AnEdit: TEdit;
 
100
  OldPath: string;
 
101
  CurDir: string;
 
102
  StartPos: integer;
 
103
  DlgResult: TModalResult;
 
104
  OldStartPos: longint;
 
105
begin
 
106
  if not (Sender is TPathEditorButton) then
 
107
    exit;
 
108
  AButton := TPathEditorButton(Sender);
 
109
  if AButton.CurrentPathEditor.ModalResult <> mrOk then
 
110
    exit;
 
111
  NewPath := AButton.CurrentPathEditor.Path;
 
112
  AnEdit := GetEditForPathButton(AButton);
 
113
  OldPath := AnEdit.Text;
 
114
  if OldPath <> NewPath then
 
115
  begin
 
116
    // check NewPath
 
117
    StartPos := 1;
 
118
    repeat
 
119
      OldStartPos := StartPos;
 
120
      CurDir := GetNextDirectoryInSearchPath(NewPath, StartPos);
 
121
      if CurDir <> '' then
 
122
      begin
 
123
        IDEMacros.SubstituteMacros(CurDir);
 
124
        FLazPackage.LongenFilename(CurDir);
 
125
        if not DirPathExists(CurDir) then
 
126
        begin
 
127
          DlgResult := QuestionDlg(lisEnvOptDlgDirectoryNotFound,
 
128
            Format(lisDirectoryNotFound, ['"', CurDir, '"']),
 
129
            mtError, [mrIgnore, mrYes, lisRemoveFromSearchPath, mrCancel], 0);
 
130
          case DlgResult of
 
131
            mrIgnore: ;
 
132
            mrYes:
 
133
            begin
 
134
              // remove directory from search path
 
135
              NewPath := copy(NewPath, 1, OldStartPos - 1) +
 
136
                copy(NewPath, StartPos, length(NewPath));
 
137
              StartPos := OldStartPos;
 
138
            end;
 
139
            else
 
140
              // undo
 
141
              NewPath := OldPath;
 
142
              break;
 
143
          end;
 
144
        end;
 
145
      end;
 
146
    until StartPos > length(NewPath);
 
147
  end;
 
148
  AnEdit.Text := NewPath;
 
149
end;
 
150
 
 
151
function TPackageUsageOptionsFrame.GetEditForPathButton(
 
152
  AButton: TPathEditorButton): TEdit;
 
153
begin
 
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
 
162
  else
 
163
    Result := nil;
 
164
end;
 
165
 
 
166
function TPackageUsageOptionsFrame.GetTitle: string;
 
167
begin
 
168
  Result := lisPckOptsUsage;
 
169
end;
 
170
 
 
171
procedure TPackageUsageOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
 
172
begin
 
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;
 
181
 
 
182
  UnitPathButton := TPathEditorButton.Create(Self);
 
183
  with UnitPathButton do
 
184
  begin
 
185
    Name := 'UnitPathButton';
 
186
    Parent := AddPathsGroupBox;
 
187
    Caption := '...';
 
188
    AutoSize := True;
 
189
    Anchors := [akRight];
 
190
    AnchorParallel(akRight, 6, AddPathsGroupBox);
 
191
    AnchorParallel(akTop, 0, UnitPathEdit);
 
192
    AnchorParallel(akBottom, 0, UnitPathEdit);
 
193
    OnClick := @PathEditBtnClick;
 
194
    OnExecuted := @PathEditBtnExecuted;
 
195
  end;
 
196
  UnitPathEdit.AnchorToNeighbour(akRight,0,UnitPathButton);
 
197
 
 
198
  IncludePathButton := TPathEditorButton.Create(Self);
 
199
  with IncludePathButton do
 
200
  begin
 
201
    Name := 'IncludePathButton';
 
202
    Parent := AddPathsGroupBox;
 
203
    Caption := '...';
 
204
    AutoSize := True;
 
205
    Anchors := [akRight];
 
206
    AnchorParallel(akRight, 6, AddPathsGroupBox);
 
207
    AnchorParallel(akTop, 0, IncludePathEdit);
 
208
    AnchorParallel(akBottom, 0, IncludePathEdit);
 
209
    OnClick := @PathEditBtnClick;
 
210
    OnExecuted := @PathEditBtnExecuted;
 
211
  end;
 
212
  IncludePathEdit.AnchorToNeighbour(akRight,0,IncludePathButton);
 
213
 
 
214
  ObjectPathButton := TPathEditorButton.Create(Self);
 
215
  with ObjectPathButton do
 
216
  begin
 
217
    Name := 'ObjectPathButton';
 
218
    Parent := AddPathsGroupBox;
 
219
    Caption := '...';
 
220
    AutoSize := True;
 
221
    Anchors := [akRight];
 
222
    AnchorParallel(akRight, 6, AddPathsGroupBox);
 
223
    AnchorParallel(akTop, 0, ObjectPathEdit);
 
224
    AnchorParallel(akBottom, 0, ObjectPathEdit);
 
225
    OnClick := @PathEditBtnClick;
 
226
    OnExecuted := @PathEditBtnExecuted;
 
227
  end;
 
228
  ObjectPathEdit.AnchorToNeighbour(akRight,0,ObjectPathButton);
 
229
 
 
230
  LibraryPathButton := TPathEditorButton.Create(Self);
 
231
  with LibraryPathButton do
 
232
  begin
 
233
    Name := 'LibraryPathButton';
 
234
    Parent := AddPathsGroupBox;
 
235
    Caption := '...';
 
236
    AutoSize := True;
 
237
    Anchors := [akRight];
 
238
    AnchorParallel(akRight, 6, AddPathsGroupBox);
 
239
    AnchorParallel(akTop, 0, LibraryPathEdit);
 
240
    AnchorParallel(akBottom, 0, LibraryPathEdit);
 
241
    OnClick := @PathEditBtnClick;
 
242
    OnExecuted := @PathEditBtnExecuted;
 
243
  end;
 
244
  LibraryPathEdit.AnchorToNeighbour(akRight,0,LibraryPathButton);
 
245
 
 
246
  ProjectGroupBox.Caption := dlgProject;
 
247
  AddPackageUnitToProjectCheckBox.Caption := podAddPackageUnitToUsesSection;
 
248
end;
 
249
 
 
250
procedure TPackageUsageOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
 
251
var
 
252
  LazPackage: TLazPackage absolute AOptions;
 
253
begin
 
254
  FLazPackage := LazPackage;
 
255
  with LazPackage.UsageOptions do
 
256
  begin
 
257
    UnitPathEdit.Text := UnitPath;
 
258
    IncludePathEdit.Text := IncludePath;
 
259
    ObjectPathEdit.Text := ObjectPath;
 
260
    LibraryPathEdit.Text := LibraryPath;
 
261
    LinkerOptionsMemo.Text := LinkerOptions;
 
262
    CustomOptionsMemo.Text := CustomOptions;
 
263
  end;
 
264
  AddPackageUnitToProjectCheckBox.Checked := LazPackage.AddToProjectUsesSection;
 
265
end;
 
266
 
 
267
procedure TPackageUsageOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
 
268
var
 
269
  LazPackage: TLazPackage absolute AOptions;
 
270
begin
 
271
  with LazPackage.UsageOptions do
 
272
  begin
 
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;
 
279
  end;
 
280
  LazPackage.AddToProjectUsesSection := AddPackageUnitToProjectCheckBox.Checked;
 
281
end;
 
282
 
 
283
class function TPackageUsageOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
 
284
begin
 
285
  Result := TLazPackage;
 
286
end;
 
287
 
 
288
initialization
 
289
  RegisterIDEOptionsEditor(GroupPackage, TPackageUsageOptionsFrame, PackageOptionsUsage);
 
290
end.
 
291