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

« back to all changes in this revision

Viewing changes to ide/frames/editor_display_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:
28
28
  Classes, SysUtils, Graphics, Dialogs, StdCtrls,
29
29
  Spin, LCLType, SynEdit, SynEditMouseCmds, EditorOptions, LazarusIDEStrConsts,
30
30
  IDEOptionsIntf, editor_general_options, editor_color_options, IDEProcs,
31
 
  SynGutterLineNumber, SynGutter;
 
31
  SynGutterLineNumber, SynGutterLineOverview, SynGutter, SourceSynEditor;
32
32
 
33
33
type
34
34
  { TEditorDisplayOptionsFrame }
35
35
 
36
36
  TEditorDisplayOptionsFrame = class(TAbstractIDEOptionsEditor)
 
37
    chkTopInfoView: TCheckBox;
 
38
    chkShowOverview: TCheckBox;
37
39
    DisableAntialiasingCheckBox: TCheckBox;
38
40
    DisplayPreview: TSynEdit;
39
41
    EditorFontButton: TButton;
40
42
    EditorFontComboBox: TComboBox;
41
43
    EditorFontGroupBox: TGroupBox;
42
 
    EditorFontHeightComboBox: TComboBox;
43
 
    EditorFontHeightLabel: TLabel;
 
44
    EditorFontSizeSpinEdit: TSpinEdit;
 
45
    EditorFontSizeLabel: TLabel;
44
46
    ExtraCharSpacingComboBox: TComboBox;
45
47
    ExtraCharSpacingLabel: TLabel;
46
48
    ExtraLineSpacingComboBox: TComboBox;
58
60
    VisibleRightMarginCheckBox: TCheckBox;
59
61
    procedure EditorFontButtonClick(Sender: TObject);
60
62
    procedure EditorFontComboBoxEditingDone(Sender: TObject);
 
63
    procedure EditorFontSizeSpinEditChange(Sender: TObject);
61
64
    procedure ComboboxOnExit(Sender: TObject);
62
65
    procedure ComboBoxOnKeyDown(Sender: TObject; var Key: Word;
63
66
      Shift: TShiftState);
69
72
    procedure ShowLineNumbersCheckBoxClick(Sender: TObject);
70
73
  private
71
74
    FDialog: TAbstractOptionsEditorDialog;
 
75
    FUpdatingFontSizeRange: Boolean;
 
76
    function FontSizeNegativeToPositive(NegativeSize: Integer): Integer;
72
77
    function GeneralPage: TEditorGeneralOptionsFrame; inline;
 
78
    procedure SetEditorFontSizeSpinEditValue(FontSize: Integer);
73
79
 
74
80
    procedure FontDialogApplyClicked(Sender: TObject);
75
81
    function DoSynEditMouse(var AnInfo: TSynEditMouseActionInfo;
86
92
 
87
93
{$R *.lfm}
88
94
 
 
95
uses
 
96
  LCLIntf;
 
97
 
 
98
function TEditorDisplayOptionsFrame.FontSizeNegativeToPositive(NegativeSize: Integer): Integer;
 
99
var
 
100
  tm: TTextMetric;
 
101
begin
 
102
  DisplayPreview.Canvas.Font.Assign(DisplayPreview.Font);
 
103
  if LCLIntf.GetTextMetrics(DisplayPreview.Canvas.Handle, tm) then
 
104
    Result := -(NegativeSize + MulDiv(tm.tmInternalLeading, 72, DisplayPreview.Font.PixelsPerInch))
 
105
  else
 
106
    Result := -NegativeSize;
 
107
end;
 
108
 
89
109
procedure TEditorDisplayOptionsFrame.FontDialogApplyClicked(Sender: TObject);
90
110
var
91
111
  a: Integer;
95
115
      if PreviewEdits[a] <> nil then
96
116
        PreviewEdits[a].Font.Assign(TFontDialog(Sender).Font);
97
117
 
98
 
  SetComboBoxText(EditorFontComboBox, DisplayPreview.Font.Name);
99
 
  SetComboBoxText(EditorFontHeightComboBox, IntToStr(DisplayPreview.Font.Height));
 
118
  SetComboBoxText(EditorFontComboBox, DisplayPreview.Font.Name,cstCaseInsensitive);
 
119
  SetEditorFontSizeSpinEditValue(DisplayPreview.Font.Size);
100
120
end;
101
121
 
102
122
function TEditorDisplayOptionsFrame.DoSynEditMouse(var AnInfo: TSynEditMouseActionInfo;
108
128
procedure TEditorDisplayOptionsFrame.EditorFontButtonClick(Sender: TObject);
109
129
var
110
130
  FontDialog: TFontDialog;
111
 
  NewHeight: LongInt;
 
131
  CurFontSize: Integer;
112
132
begin
113
133
  FontDialog := TFontDialog.Create(nil);
114
134
  try
115
135
    with FontDialog do
116
136
    begin
117
137
      Font.Name := EditorFontComboBox.Text;
118
 
      NewHeight := StrToIntDef(EditorFontHeightComboBox.Text, DisplayPreview.Font.Height);
119
 
      RepairEditorFontHeight(NewHeight);
120
 
      Font.Height := NewHeight;
 
138
      CurFontSize := EditorFontSizeSpinEdit.Value;
 
139
      if CurFontSize < 0 then
 
140
      begin
 
141
        CurFontSize := FontSizeNegativeToPositive(CurFontSize);
 
142
        RepairEditorFontSize(CurFontSize);
 
143
      end;
 
144
      Font.Size := CurFontSize;
121
145
      Options := Options + [fdApplyButton];
122
146
      OnApplyClicked := @FontDialogApplyClicked;
123
147
      if Execute then
138
162
        PreviewEdits[i].Font.Name := EditorFontComboBox.Text;
139
163
end;
140
164
 
 
165
procedure TEditorDisplayOptionsFrame.EditorFontSizeSpinEditChange(Sender: TObject);
 
166
var
 
167
  NewVal, a: Integer;
 
168
begin
 
169
  NewVal := EditorFontSizeSpinEdit.Value;
 
170
  if (NewVal < 0) and (NewVal > -EditorOptionsMinimumFontSize) then
 
171
  begin
 
172
    // Skip to minimum positive value. Will trigger OnChange again.
 
173
    SetEditorFontSizeSpinEditValue(EditorOptionsMinimumFontSize);
 
174
  end
 
175
  else
 
176
  begin
 
177
    if (NewVal > 0) and not FUpdatingFontSizeRange then
 
178
      EditorFontSizeSpinEdit.MinValue := EditorOptionsMinimumFontSize;
 
179
 
 
180
    with GeneralPage do
 
181
      for a := Low(PreviewEdits) to High(PreviewEdits) do
 
182
        if PreviewEdits[a] <> nil then
 
183
          PreviewEdits[a].Font.Size := NewVal;
 
184
  end;
 
185
end;
 
186
 
141
187
procedure TEditorDisplayOptionsFrame.ComboboxOnExit(Sender: TObject);
142
188
var
143
189
  NewVal, a: Integer;
144
190
begin
145
 
  if Sender = EditorFontHeightComboBox then
146
 
  begin
147
 
    NewVal := StrToIntDef(EditorFontHeightComboBox.Text, DisplayPreview.Font.Height);
148
 
    RepairEditorFontHeight(NewVal);
149
 
    SetComboBoxText(EditorFontHeightComboBox, IntToStr(NewVal));
150
 
    with GeneralPage do
151
 
      for a := Low(PreviewEdits) to High(PreviewEdits) do
152
 
        if PreviewEdits[a] <> nil then
153
 
          PreviewEdits[a].Font.Height := NewVal;
154
 
  end
155
 
  else
156
191
  if Sender = ExtraCharSpacingComboBox then
157
192
  begin
158
193
    NewVal := StrToIntDef(ExtraCharSpacingComboBox.Text, DisplayPreview.ExtraCharSpacing);
159
 
    SetComboBoxText(ExtraCharSpacingComboBox, IntToStr(NewVal));
 
194
    SetComboBoxText(ExtraCharSpacingComboBox, IntToStr(NewVal),cstCaseInsensitive);
160
195
    with GeneralPage do
161
196
      for a := Low(PreviewEdits) to High(PreviewEdits) do
162
197
        if PreviewEdits[a] <> Nil then
166
201
  if Sender = ExtraLineSpacingComboBox then
167
202
  begin
168
203
    NewVal := StrToIntDef(ExtraLineSpacingComboBox.Text, DisplayPreview.ExtraLineSpacing);
169
 
    SetComboBoxText(ExtraLineSpacingComboBox, IntToStr(NewVal));
 
204
    SetComboBoxText(ExtraLineSpacingComboBox, IntToStr(NewVal),cstCaseInsensitive);
170
205
    with GeneralPage do
171
206
      for a := Low(PreviewEdits) to High(PreviewEdits) do
172
207
        if PreviewEdits[a] <> Nil then
176
211
  if Sender = RightMarginComboBox then
177
212
  begin
178
213
    NewVal := StrToIntDef(RightMarginComboBox.Text, DisplayPreview.RightEdge);
179
 
    SetComboBoxText(RightMarginComboBox, IntToStr(NewVal));
 
214
    SetComboBoxText(RightMarginComboBox, IntToStr(NewVal),cstCaseInsensitive);
180
215
    with GeneralPage do
181
216
      for a := Low(PreviewEdits) to High(PreviewEdits) do
182
217
        if PreviewEdits[a] <> nil then
183
218
        begin
 
219
          PreviewEdits[a].RightEdge := NewVal;
184
220
          if VisibleRightMarginCheckBox.Checked then
185
 
            PreviewEdits[a].RightEdge := NewVal
 
221
            PreviewEdits[a].Options := PreviewEdits[a].Options - [eoHideRightMargin]
186
222
          else
187
 
            PreviewEdits[a].RightEdge := 0;
 
223
            PreviewEdits[a].Options := PreviewEdits[a].Options + [eoHideRightMargin];
188
224
        end;
189
225
  end;
190
226
end;
220
256
      if PreviewEdits[a] <> nil then
221
257
      begin
222
258
        PreviewEdits[a].Gutter.Visible := VisibleGutterCheckBox.Checked;
 
259
        PreviewEdits[a].RightGutter.Visible := chkShowOverview.Checked;
223
260
        PreviewEdits[a].Gutter.LineNumberPart.Visible
224
261
          := ShowLineNumbersCheckBox.Checked;
225
262
        if Assigned(PreviewEdits[a].Gutter.Parts.ByClass[TSynGutterLineNumber, 0]) then
233
270
          if Separator.Visible then
234
271
            Separator.Index := GutterSeparatorIndexSpinBox.Value;
235
272
        end;
 
273
        PreviewEdits[a].RightEdge := StrToIntDef(RightMarginComboBox.Text, 80);
236
274
        if VisibleRightMarginCheckBox.Checked then
237
 
          PreviewEdits[a].RightEdge := StrToIntDef(RightMarginComboBox.Text, 80)
 
275
          PreviewEdits[a].Options := PreviewEdits[a].Options - [eoHideRightMargin]
238
276
        else
239
 
          PreviewEdits[a].RightEdge := 0;
 
277
          PreviewEdits[a].Options := PreviewEdits[a].Options + [eoHideRightMargin];
240
278
        if DisableAntialiasingCheckBox.Checked then
241
279
          PreviewEdits[a].Font.Quality := fqNonAntialiased
242
280
        else
277
315
  Result := TEditorGeneralOptionsFrame(FDialog.FindEditor(TEditorGeneralOptionsFrame));
278
316
end;
279
317
 
 
318
procedure TEditorDisplayOptionsFrame.SetEditorFontSizeSpinEditValue(FontSize: Integer);
 
319
begin
 
320
  FUpdatingFontSizeRange := True;
 
321
  if FontSize < 0 then
 
322
    EditorFontSizeSpinEdit.MinValue := -EditorFontSizeSpinEdit.MaxValue
 
323
  else
 
324
    EditorFontSizeSpinEdit.MinValue := EditorOptionsMinimumFontSize;
 
325
  FUpdatingFontSizeRange := False;
 
326
  EditorFontSizeSpinEdit.Value := FontSize;
 
327
end;
 
328
 
280
329
function TEditorDisplayOptionsFrame.GetTitle: String;
281
330
begin
282
331
  Result := dlgEdDisplay;
287
336
  // Prevent the caret from moving
288
337
  DisplayPreview.RegisterMouseActionSearchHandler(@DoSynEditMouse);
289
338
  FDialog := ADialog;
 
339
  FUpdatingFontSizeRange := False;
290
340
 
291
341
  MarginAndGutterGroupBox.Caption := dlgMarginGutter;
292
342
  VisibleRightMarginCheckBox.Caption := dlgVisibleRightMargin;
296
346
  GutterSeparatorIndexLabel.Caption := dlgGutterSeparatorIndex;
297
347
  RightMarginLabel.Caption := dlgRightMargin;
298
348
  EditorFontGroupBox.Caption := dlgDefaultEditorFont;
299
 
  EditorFontHeightLabel.Caption := dlgEditorFontHeight;
 
349
  EditorFontSizeLabel.Caption := dlgEditorFontSize;
300
350
  ExtraCharSpacingLabel.Caption := dlgExtraCharSpacing;
301
351
  ExtraLineSpacingLabel.Caption := dlgExtraLineSpacing;
302
352
  DisableAntialiasingCheckBox.Caption := dlgDisableAntialiasing;
303
353
  RightMarginColorLink.Caption := dlgColorLink;
 
354
  chkShowOverview.Caption := lisShowOverviewGutter;
 
355
  chkTopInfoView.Caption := lisTopInfoView;
304
356
 
305
357
  with GeneralPage do
306
358
    AddPreviewEdit(DisplayPreview);
 
359
 
 
360
  with TSynGutterSeparator.Create(DisplayPreview.RightGutter.Parts) do
 
361
    Name := 'DPSynGutterSeparatorR2';
 
362
  with TSynGutterLineOverview.Create(DisplayPreview.RightGutter.Parts) do begin
 
363
    Name := 'DPSynGutterLineOverview1';
 
364
    with TIDESynGutterLOvProviderIDEMarks.Create(Providers) do
 
365
      Priority := 20;
 
366
    with TSynGutterLOvProviderModifiedLines.Create(Providers) do
 
367
      Priority := 9;
 
368
    with TSynGutterLOvProviderCurrentPage.Create(Providers) do
 
369
      Priority := 1;
 
370
    with TIDESynGutterLOvProviderPascal.Create(Providers) do
 
371
      Priority := 0;
 
372
  end;
 
373
  with TSynGutterSeparator.Create(DisplayPreview.RightGutter.Parts) do begin
 
374
    Name := 'DPSynGutterSeparatorR3';
 
375
    AutoSize := False;
 
376
    Width := 1;
 
377
    LineWidth := 0;
 
378
  end;
 
379
 
307
380
end;
308
381
 
309
382
procedure TEditorDisplayOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
311
384
  with AOptions as TEditorOptions do
312
385
  begin
313
386
    // init the spin-edit first, since it does not trigger on change,
314
 
    // but is copied when checkboxes are initalized
 
387
    // but is copied when checkboxes are initialized
315
388
    ShowOnlyLineNumbersMultiplesOfSpinEdit.Value := ShowOnlyLineNumbersMultiplesOf;
316
389
    GutterSeparatorIndexSpinBox.Value := GutterSeparatorIndex;
317
390
    VisibleRightMarginCheckBox.Checked := VisibleRightMargin;
318
391
    VisibleGutterCheckBox.Checked := VisibleGutter;
319
392
    ShowLineNumbersCheckBox.Checked := ShowLineNumbers;
320
393
    VisibleRightMarginCheckBox.Checked := VisibleRightMargin;
321
 
    SetComboBoxText(RightMarginComboBox, IntToStr(RightMargin));
322
 
    SetComboBoxText(EditorFontComboBox, EditorFont);
323
 
    SetComboBoxText(EditorFontHeightComboBox, IntToStr(EditorFontHeight));
324
 
    SetComboBoxText(ExtraCharSpacingComboBox, IntToStr(ExtraCharSpacing));
325
 
    SetComboBoxText(ExtraLineSpacingComboBox, IntToStr(ExtraLineSpacing));
 
394
    SetComboBoxText(RightMarginComboBox, IntToStr(RightMargin),cstCaseInsensitive);
 
395
    SetComboBoxText(EditorFontComboBox, EditorFont,cstCaseInsensitive);
 
396
    SetEditorFontSizeSpinEditValue(EditorFontSize);
 
397
    SetComboBoxText(ExtraCharSpacingComboBox, IntToStr(ExtraCharSpacing),cstCaseInsensitive);
 
398
    SetComboBoxText(ExtraLineSpacingComboBox, IntToStr(ExtraLineSpacing),cstCaseInsensitive);
326
399
    DisableAntialiasingCheckBox.Checked := DisableAntialiasing;
 
400
    chkShowOverview.Checked := ShowOverviewGutter;
 
401
    chkTopInfoView.Checked := TopInfoView;
327
402
  end;
328
403
 
329
404
  ShowOnlyLineNumbersMultiplesOfLabel.Enabled := ShowLineNumbersCheckBox.Checked;
342
417
    VisibleRightMargin := VisibleRightMarginCheckBox.Checked;
343
418
    RightMargin := StrToIntDef(RightMarginComboBox.Text, 80);
344
419
    EditorFont := EditorFontComboBox.Text;
345
 
    EditorFontHeight := StrToIntDef(EditorFontHeightComboBox.Text, EditorFontHeight);
 
420
    EditorFontSize := EditorFontSizeSpinEdit.Value;
346
421
    ExtraCharSpacing := StrToIntDef(ExtraCharSpacingComboBox.Text, ExtraCharSpacing);
347
422
    ExtraLineSpacing := StrToIntDef(ExtraLineSpacingComboBox.Text, ExtraLineSpacing);
348
423
    DisableAntialiasing := DisableAntialiasingCheckBox.Checked;
 
424
    ShowOverviewGutter := chkShowOverview.Checked;
 
425
    TopInfoView := chkTopInfoView.Checked;
349
426
  end;
350
427
end;
351
428