mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-08 09:20:49 +02:00
ide: refactor few codetools options frames from Alexander S. Klenin (#0012842)
git-svn-id: trunk@17912 -
This commit is contained in:
parent
e4710a9de2
commit
67fbb8c8d4
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -2538,6 +2538,7 @@ ide/fpdocselectinherited.pas svneol=native#text/plain
|
|||||||
ide/fpdocselectlink.lfm svneol=native#text/plain
|
ide/fpdocselectlink.lfm svneol=native#text/plain
|
||||||
ide/fpdocselectlink.lrs svneol=native#text/plain
|
ide/fpdocselectlink.lrs svneol=native#text/plain
|
||||||
ide/fpdocselectlink.pas svneol=native#text/plain
|
ide/fpdocselectlink.pas svneol=native#text/plain
|
||||||
|
ide/frames/options_atom_checkboxes.pas svneol=native#text/pascal
|
||||||
ide/frames/options_backup.lfm svneol=native#text/plain
|
ide/frames/options_backup.lfm svneol=native#text/plain
|
||||||
ide/frames/options_backup.lrs svneol=native#text/pascal
|
ide/frames/options_backup.lrs svneol=native#text/pascal
|
||||||
ide/frames/options_backup.pas svneol=native#text/pascal
|
ide/frames/options_backup.pas svneol=native#text/pascal
|
||||||
|
144
ide/frames/options_atom_checkboxes.pas
Normal file
144
ide/frames/options_atom_checkboxes.pas
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
{
|
||||||
|
***************************************************************************
|
||||||
|
* *
|
||||||
|
* This source is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This code is distributed in the hope that it will be useful, but *
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||||
|
* General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* A copy of the GNU General Public License is available on the World *
|
||||||
|
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
|
||||||
|
* obtain it by writing to the Free Software Foundation, *
|
||||||
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
|
* *
|
||||||
|
***************************************************************************
|
||||||
|
}
|
||||||
|
unit options_atom_checkboxes;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, IDEOptionsIntf, SourceChanger, StdCtrls;
|
||||||
|
|
||||||
|
type
|
||||||
|
{ TCodetoolsAtomCheckboxesOptionsFrame }
|
||||||
|
|
||||||
|
TCodetoolsAtomCheckboxesOptionsFrame = class(TAbstractIDEOptionsEditor)
|
||||||
|
protected
|
||||||
|
procedure CreateAtomCheckBoxes(
|
||||||
|
ParentGroupBox: TGroupBox; AtomTypes: TAtomTypes; Columns: integer;
|
||||||
|
AOnClick: TNotifyEvent);
|
||||||
|
function ReadAtomCheckBoxes(ParentGroupBox: TGroupBox): TAtomTypes;
|
||||||
|
procedure SetAtomCheckBoxes(AtomTypes: TAtomTypes; ParentGroupBox: TGroupBox);
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
CodeToolsOptions, SysUtils;
|
||||||
|
|
||||||
|
{ TCodetoolsAtomCheckboxesOptionsFrame }
|
||||||
|
|
||||||
|
procedure TCodetoolsAtomCheckboxesOptionsFrame.CreateAtomCheckBoxes(
|
||||||
|
ParentGroupBox: TGroupBox; AtomTypes: TAtomTypes; Columns: integer;
|
||||||
|
AOnClick: TNotifyEvent);
|
||||||
|
var
|
||||||
|
Count, i, yi, MaxYCount: integer;
|
||||||
|
a: TAtomType;
|
||||||
|
X, Y, CurX, CurY, XStep, YStep: integer;
|
||||||
|
NewCheckBox: TCheckBox;
|
||||||
|
begin
|
||||||
|
if Columns < 1 then
|
||||||
|
Columns := 1;
|
||||||
|
Count := 0;
|
||||||
|
for a := Low(TAtomTypes) to High(TAtomTypes) do
|
||||||
|
if a in AtomTypes then
|
||||||
|
inc(Count);
|
||||||
|
if Count = 0 then
|
||||||
|
Exit;
|
||||||
|
|
||||||
|
MaxYCount := (Count + Columns - 1) div Columns;
|
||||||
|
X := 6;
|
||||||
|
Y := 1;
|
||||||
|
XStep := (ParentGroupBox.ClientWidth - 10) div Columns;
|
||||||
|
YStep := (ParentGroupBox.ClientHeight - 20) div MaxYCount;
|
||||||
|
CurX := X;
|
||||||
|
CurY := Y;
|
||||||
|
i := 0;
|
||||||
|
yi := 0;
|
||||||
|
|
||||||
|
for a := Low(TAtomTypes) to High(TAtomTypes) do
|
||||||
|
begin
|
||||||
|
if a in AtomTypes then
|
||||||
|
begin
|
||||||
|
inc(i);
|
||||||
|
inc(yi);
|
||||||
|
NewCheckBox := TCheckBox.Create(ParentGroupBox);
|
||||||
|
with NewCheckBox do
|
||||||
|
begin
|
||||||
|
Name := ParentGroupBox.Name + 'CheckBox' + IntToStr(i + 1);
|
||||||
|
Parent := ParentGroupBox;
|
||||||
|
SetBounds(CurX, CurY, XStep - 10, Height);
|
||||||
|
Caption := GetTranslatedAtomTypes(a);
|
||||||
|
OnClick := AOnClick;
|
||||||
|
Visible := true;
|
||||||
|
end;
|
||||||
|
if yi >= MaxYCount then
|
||||||
|
begin
|
||||||
|
inc(X, XStep);
|
||||||
|
CurX := X;
|
||||||
|
CurY := Y;
|
||||||
|
yi := 0;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
inc(CurY,YStep);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCodetoolsAtomCheckboxesOptionsFrame.ReadAtomCheckBoxes(
|
||||||
|
ParentGroupBox: TGroupBox): TAtomTypes;
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
ACheckBox: TCheckBox;
|
||||||
|
a: TAtomType;
|
||||||
|
begin
|
||||||
|
Result := [];
|
||||||
|
for i := 0 to ParentGroupBox.ComponentCount - 1 do
|
||||||
|
begin
|
||||||
|
if ParentGroupBox.Components[i] is TCheckBox then
|
||||||
|
begin
|
||||||
|
ACheckBox := TCheckBox(ParentGroupBox.Components[i]);
|
||||||
|
a := TranslatedAtomToType(ACheckBox.Caption);
|
||||||
|
if (a <> atNone) and ACheckBox.Checked then
|
||||||
|
Include(Result, a);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCodetoolsAtomCheckboxesOptionsFrame.SetAtomCheckBoxes(
|
||||||
|
AtomTypes: TAtomTypes; ParentGroupBox: TGroupBox);
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
ACheckBox: TCheckBox;
|
||||||
|
a: TAtomType;
|
||||||
|
begin
|
||||||
|
for i := 0 to ParentGroupBox.ComponentCount - 1 do
|
||||||
|
begin
|
||||||
|
if ParentGroupBox.Components[i] is TCheckBox then
|
||||||
|
begin
|
||||||
|
ACheckBox:=TCheckBox(ParentGroupBox.Components[i]);
|
||||||
|
a := TranslatedAtomToType(ACheckBox.Caption);
|
||||||
|
ACheckBox.Checked := (a <> atNone) and (a in AtomTypes);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
@ -25,14 +25,13 @@ unit options_codetools_linesplitting;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, FileUtil, LResources, Forms, StdCtrls, SynEdit,
|
Classes, SysUtils, LResources, Forms, StdCtrls, SynEdit,
|
||||||
SourceChanger, CodeToolsOptions, LazarusIDEStrConsts, IDEOptionsIntf,
|
SourceChanger, IDEOptionsIntf, EditorOptions, options_atom_checkboxes;
|
||||||
EditorOptions;
|
|
||||||
|
|
||||||
type
|
type
|
||||||
{ TCodetoolsLineSplittingOptionsFrame }
|
{ TCodetoolsLineSplittingOptionsFrame }
|
||||||
|
|
||||||
TCodetoolsLineSplittingOptionsFrame = class(TAbstractIDEOptionsEditor)
|
TCodetoolsLineSplittingOptionsFrame = class(TCodetoolsAtomCheckboxesOptionsFrame)
|
||||||
DoNotSplitLineAfterGroupBox: TGroupBox;
|
DoNotSplitLineAfterGroupBox: TGroupBox;
|
||||||
DoNotSplitLineInFrontGroupBox: TGroupBox;
|
DoNotSplitLineInFrontGroupBox: TGroupBox;
|
||||||
LineLengthEdit: TEdit;
|
LineLengthEdit: TEdit;
|
||||||
@ -43,10 +42,6 @@ type
|
|||||||
private
|
private
|
||||||
BeautifyCodeOptions: TBeautifyCodeOptions;
|
BeautifyCodeOptions: TBeautifyCodeOptions;
|
||||||
FHighlighter: TPreviewPasSyn;
|
FHighlighter: TPreviewPasSyn;
|
||||||
procedure CreateAtomCheckBoxes(ParentGroupBox: TGroupBox;
|
|
||||||
AtomTypes: TAtomTypes; Columns: integer);
|
|
||||||
procedure SetAtomCheckBoxes(AtomTypes: TAtomTypes; ParentGroupBox: TGroupBox);
|
|
||||||
function ReadAtomCheckBoxes(ParentGroupBox: TGroupBox): TAtomTypes;
|
|
||||||
procedure UpdateSplitLineExample;
|
procedure UpdateSplitLineExample;
|
||||||
procedure UpdatePreviewSettings;
|
procedure UpdatePreviewSettings;
|
||||||
procedure WriteBeautifyCodeOptions(Options: TBeautifyCodeOptions);
|
procedure WriteBeautifyCodeOptions(Options: TBeautifyCodeOptions);
|
||||||
@ -64,6 +59,9 @@ type
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
CodeToolsOptions, LazarusIDEStrConsts;
|
||||||
|
|
||||||
{ TCodetoolsLineSplittingOptionsFrame }
|
{ TCodetoolsLineSplittingOptionsFrame }
|
||||||
|
|
||||||
procedure TCodetoolsLineSplittingOptionsFrame.UpdateExample(Sender: TObject);
|
procedure TCodetoolsLineSplittingOptionsFrame.UpdateExample(Sender: TObject);
|
||||||
@ -72,106 +70,12 @@ begin
|
|||||||
UpdatePreviewSettings;
|
UpdatePreviewSettings;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCodetoolsLineSplittingOptionsFrame.CreateAtomCheckBoxes(
|
|
||||||
ParentGroupBox: TGroupBox; AtomTypes: TAtomTypes; Columns: integer);
|
|
||||||
var
|
|
||||||
Count, i, yi, MaxYCount: integer;
|
|
||||||
a: TAtomType;
|
|
||||||
X, Y, CurX, CurY, XStep, YStep: integer;
|
|
||||||
NewCheckBox: TCheckBox;
|
|
||||||
begin
|
|
||||||
if Columns < 1 then
|
|
||||||
Columns := 1;
|
|
||||||
Count := 0;
|
|
||||||
for a := Low(TAtomTypes) to High(TAtomTypes) do
|
|
||||||
if a in AtomTypes then
|
|
||||||
inc(Count);
|
|
||||||
if Count = 0 then
|
|
||||||
Exit;
|
|
||||||
|
|
||||||
MaxYCount := ((Count+Columns-1) div Columns);
|
|
||||||
X:=6;
|
|
||||||
Y:=1;
|
|
||||||
XStep:=((ParentGroupBox.ClientWidth-10) div Columns);
|
|
||||||
YStep:=((ParentGroupBox.ClientHeight-20) div MaxYCount);
|
|
||||||
CurX:=X;
|
|
||||||
CurY:=Y;
|
|
||||||
i:=0;
|
|
||||||
yi:=0;
|
|
||||||
|
|
||||||
for a := Low(TAtomTypes) to High(TAtomTypes) do
|
|
||||||
begin
|
|
||||||
if a in AtomTypes then
|
|
||||||
begin
|
|
||||||
inc(i);
|
|
||||||
inc(yi);
|
|
||||||
NewCheckBox:=TCheckBox.Create(ParentGroupBox);
|
|
||||||
with NewCheckBox do
|
|
||||||
begin
|
|
||||||
Name:=ParentGroupBox.Name+'CheckBox'+IntToStr(i+1);
|
|
||||||
Parent:=ParentGroupBox;
|
|
||||||
SetBounds(CurX,CurY,XStep-10,Height);
|
|
||||||
Caption:=GetTranslatedAtomTypes(a);
|
|
||||||
OnClick:=@UpdateExample;
|
|
||||||
Visible:=true;
|
|
||||||
end;
|
|
||||||
if yi>=MaxYCount then
|
|
||||||
begin
|
|
||||||
inc(X,XStep);
|
|
||||||
CurX:=X;
|
|
||||||
CurY:=Y;
|
|
||||||
yi:=0;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
inc(CurY,YStep);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCodetoolsLineSplittingOptionsFrame.SetAtomCheckBoxes(
|
|
||||||
AtomTypes: TAtomTypes; ParentGroupBox: TGroupBox);
|
|
||||||
var
|
|
||||||
i: integer;
|
|
||||||
ACheckBox: TCheckBox;
|
|
||||||
a: TAtomType;
|
|
||||||
begin
|
|
||||||
for i := 0 to ParentGroupBox.ComponentCount - 1 do
|
|
||||||
begin
|
|
||||||
if (ParentGroupBox.Components[i] is TCheckBox) then
|
|
||||||
begin
|
|
||||||
ACheckBox:=TCheckBox(ParentGroupBox.Components[i]);
|
|
||||||
a := TranslatedAtomToType(ACheckBox.Caption);
|
|
||||||
ACheckBox.Checked := (a <> atNone) and (a in AtomTypes);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TCodetoolsLineSplittingOptionsFrame.ReadAtomCheckBoxes(
|
|
||||||
ParentGroupBox: TGroupBox): TAtomTypes;
|
|
||||||
var
|
|
||||||
i: integer;
|
|
||||||
ACheckBox: TCheckBox;
|
|
||||||
a: TAtomType;
|
|
||||||
begin
|
|
||||||
Result := [];
|
|
||||||
for i := 0 to ParentGroupBox.ComponentCount - 1 do
|
|
||||||
begin
|
|
||||||
if (ParentGroupBox.Components[i] is TCheckBox) then
|
|
||||||
begin
|
|
||||||
ACheckBox := TCheckBox(ParentGroupBox.Components[i]);
|
|
||||||
a := TranslatedAtomToType(ACheckBox.Caption);
|
|
||||||
if (a <> atNone) and (ACheckBox.Checked) then
|
|
||||||
Include(Result, a);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCodetoolsLineSplittingOptionsFrame.UpdateSplitLineExample;
|
procedure TCodetoolsLineSplittingOptionsFrame.UpdateSplitLineExample;
|
||||||
const
|
const
|
||||||
LineSplitExampleText =
|
LineSplitExampleText =
|
||||||
'function(Sender: TObject; const Val1, Val2, Val3:char; '
|
'function F(Sender: TObject; const Val1, Val2, Val3:char; ' +
|
||||||
+'var Var1, Var2: array of const): integer;'#13
|
'var Var1, Var2: array of const): integer;'#13 +
|
||||||
+'const i=1+2+3;';
|
'const i=1+2+3;';
|
||||||
begin
|
begin
|
||||||
if BeautifyCodeOptions = nil then
|
if BeautifyCodeOptions = nil then
|
||||||
Exit;
|
Exit;
|
||||||
@ -243,7 +147,8 @@ begin
|
|||||||
Result := dlgLineSplitting;
|
Result := dlgLineSplitting;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCodetoolsLineSplittingOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
|
procedure TCodetoolsLineSplittingOptionsFrame.Setup(
|
||||||
|
ADialog: TAbstractOptionsEditorDialog);
|
||||||
const
|
const
|
||||||
DoNotSplitAtoms = [
|
DoNotSplitAtoms = [
|
||||||
atKeyword, atIdentifier, atColon, atSemicolon, atComma,
|
atKeyword, atIdentifier, atColon, atSemicolon, atComma,
|
||||||
@ -253,13 +158,15 @@ begin
|
|||||||
Caption:=dlgMaxLineLength;
|
Caption:=dlgMaxLineLength;
|
||||||
|
|
||||||
with DoNotSplitLineInFrontGroupBox do begin
|
with DoNotSplitLineInFrontGroupBox do begin
|
||||||
Caption:=dlgNotSplitLineFront ;
|
Caption:=dlgNotSplitLineFront;
|
||||||
CreateAtomCheckBoxes(DoNotSplitLineInFrontGroupBox,DoNotSplitAtoms,2);
|
CreateAtomCheckBoxes(
|
||||||
|
DoNotSplitLineInFrontGroupBox, DoNotSplitAtoms, 2, @UpdateExample);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
with DoNotSplitLineAfterGroupBox do begin
|
with DoNotSplitLineAfterGroupBox do begin
|
||||||
Caption:=dlgNotSplitLineAfter ;
|
Caption:=dlgNotSplitLineAfter;
|
||||||
CreateAtomCheckBoxes(DoNotSplitLineAfterGroupBox,DoNotSplitAtoms,2);
|
CreateAtomCheckBoxes(
|
||||||
|
DoNotSplitLineAfterGroupBox, DoNotSplitAtoms, 2, @UpdateExample);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
with SplitPreviewLabel do
|
with SplitPreviewLabel do
|
||||||
|
@ -25,15 +25,14 @@ unit options_codetools_space;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, FileUtil, LResources, Forms, StdCtrls, SynEdit,
|
Classes, SysUtils, LResources, Forms, StdCtrls, SynEdit,
|
||||||
SourceChanger, CodeToolsOptions, LazarusIDEStrConsts, IDEOptionsIntf,
|
SourceChanger, IDEOptionsIntf, EditorOptions, options_atom_checkboxes;
|
||||||
EditorOptions;
|
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
{ TCodetoolsSpaceOptionsFrame }
|
{ TCodetoolsSpaceOptionsFrame }
|
||||||
|
|
||||||
TCodetoolsSpaceOptionsFrame = class(TAbstractIDEOptionsEditor)
|
TCodetoolsSpaceOptionsFrame = class(TCodetoolsAtomCheckboxesOptionsFrame)
|
||||||
DoInsertSpaceAfterGroupBox: TGroupBox;
|
DoInsertSpaceAfterGroupBox: TGroupBox;
|
||||||
DoInsertSpaceInFrontGroupBox: TGroupBox;
|
DoInsertSpaceInFrontGroupBox: TGroupBox;
|
||||||
SpacePreviewLabel: TLabel;
|
SpacePreviewLabel: TLabel;
|
||||||
@ -42,10 +41,6 @@ type
|
|||||||
private
|
private
|
||||||
BeautifyCodeOptions: TBeautifyCodeOptions;
|
BeautifyCodeOptions: TBeautifyCodeOptions;
|
||||||
FHighlighter: TPreviewPasSyn;
|
FHighlighter: TPreviewPasSyn;
|
||||||
procedure CreateAtomCheckBoxes(ParentGroupBox: TGroupBox;
|
|
||||||
AtomTypes: TAtomTypes; Columns: integer);
|
|
||||||
procedure SetAtomCheckBoxes(AtomTypes: TAtomTypes; ParentGroupBox: TGroupBox);
|
|
||||||
function ReadAtomCheckBoxes(ParentGroupBox: TGroupBox): TAtomTypes;
|
|
||||||
procedure UpdateSpaceExample;
|
procedure UpdateSpaceExample;
|
||||||
procedure UpdatePreviewSettings;
|
procedure UpdatePreviewSettings;
|
||||||
procedure WriteBeautifyCodeOptions(Options: TBeautifyCodeOptions);
|
procedure WriteBeautifyCodeOptions(Options: TBeautifyCodeOptions);
|
||||||
@ -63,6 +58,9 @@ type
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
CodeToolsOptions, LazarusIDEStrConsts;
|
||||||
|
|
||||||
{ TCodetoolsSpaceOptionsFrame }
|
{ TCodetoolsSpaceOptionsFrame }
|
||||||
|
|
||||||
procedure TCodetoolsSpaceOptionsFrame.UpdateExample(Sender: TObject);
|
procedure TCodetoolsSpaceOptionsFrame.UpdateExample(Sender: TObject);
|
||||||
@ -71,111 +69,17 @@ begin
|
|||||||
UpdatePreviewSettings;
|
UpdatePreviewSettings;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCodetoolsSpaceOptionsFrame.CreateAtomCheckBoxes(
|
|
||||||
ParentGroupBox: TGroupBox; AtomTypes: TAtomTypes; Columns: integer);
|
|
||||||
var
|
|
||||||
Count, i, yi, MaxYCount: integer;
|
|
||||||
a: TAtomType;
|
|
||||||
X, Y, CurX, CurY, XStep, YStep: integer;
|
|
||||||
NewCheckBox: TCheckBox;
|
|
||||||
begin
|
|
||||||
if Columns < 1 then
|
|
||||||
Columns := 1;
|
|
||||||
Count := 0;
|
|
||||||
for a := Low(TAtomTypes) to High(TAtomTypes) do
|
|
||||||
if a in AtomTypes then
|
|
||||||
inc(Count);
|
|
||||||
if Count = 0 then
|
|
||||||
Exit;
|
|
||||||
|
|
||||||
MaxYCount := ((Count+Columns-1) div Columns);
|
|
||||||
X:=6;
|
|
||||||
Y:=1;
|
|
||||||
XStep:=((ParentGroupBox.ClientWidth-10) div Columns);
|
|
||||||
YStep:=((ParentGroupBox.ClientHeight-20) div MaxYCount);
|
|
||||||
CurX:=X;
|
|
||||||
CurY:=Y;
|
|
||||||
i:=0;
|
|
||||||
yi:=0;
|
|
||||||
|
|
||||||
for a := Low(TAtomTypes) to High(TAtomTypes) do
|
|
||||||
begin
|
|
||||||
if a in AtomTypes then
|
|
||||||
begin
|
|
||||||
inc(i);
|
|
||||||
inc(yi);
|
|
||||||
NewCheckBox:=TCheckBox.Create(ParentGroupBox);
|
|
||||||
with NewCheckBox do
|
|
||||||
begin
|
|
||||||
Name:=ParentGroupBox.Name+'CheckBox'+IntToStr(i+1);
|
|
||||||
Parent:=ParentGroupBox;
|
|
||||||
SetBounds(CurX,CurY,XStep-10,Height);
|
|
||||||
Caption:=GetTranslatedAtomTypes(a);
|
|
||||||
OnClick:=@UpdateExample;
|
|
||||||
Visible:=true;
|
|
||||||
end;
|
|
||||||
if yi>=MaxYCount then
|
|
||||||
begin
|
|
||||||
inc(X,XStep);
|
|
||||||
CurX:=X;
|
|
||||||
CurY:=Y;
|
|
||||||
yi:=0;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
inc(CurY,YStep);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCodetoolsSpaceOptionsFrame.SetAtomCheckBoxes(AtomTypes: TAtomTypes;
|
|
||||||
ParentGroupBox: TGroupBox);
|
|
||||||
var
|
|
||||||
i: integer;
|
|
||||||
ACheckBox: TCheckBox;
|
|
||||||
a: TAtomType;
|
|
||||||
begin
|
|
||||||
for i := 0 to ParentGroupBox.ComponentCount - 1 do
|
|
||||||
begin
|
|
||||||
if (ParentGroupBox.Components[i] is TCheckBox) then
|
|
||||||
begin
|
|
||||||
ACheckBox:=TCheckBox(ParentGroupBox.Components[i]);
|
|
||||||
a := TranslatedAtomToType(ACheckBox.Caption);
|
|
||||||
ACheckBox.Checked := (a <> atNone) and (a in AtomTypes);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TCodetoolsSpaceOptionsFrame.ReadAtomCheckBoxes(
|
|
||||||
ParentGroupBox: TGroupBox): TAtomTypes;
|
|
||||||
var
|
|
||||||
i: integer;
|
|
||||||
ACheckBox: TCheckBox;
|
|
||||||
a: TAtomType;
|
|
||||||
begin
|
|
||||||
Result := [];
|
|
||||||
for i := 0 to ParentGroupBox.ComponentCount - 1 do
|
|
||||||
begin
|
|
||||||
if (ParentGroupBox.Components[i] is TCheckBox) then
|
|
||||||
begin
|
|
||||||
ACheckBox := TCheckBox(ParentGroupBox.Components[i]);
|
|
||||||
a := TranslatedAtomToType(ACheckBox.Caption);
|
|
||||||
if (a <> atNone) and (ACheckBox.Checked) then
|
|
||||||
Include(Result, a);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCodetoolsSpaceOptionsFrame.UpdateSpaceExample;
|
procedure TCodetoolsSpaceOptionsFrame.UpdateSpaceExample;
|
||||||
const
|
const
|
||||||
SpaceExampleText =
|
SpaceExampleText =
|
||||||
'function(Sender:TObject;const Val1,Val2,Val3:char;'
|
'function F(Sender:TObject;const Val1,Val2,Val3:char;' +
|
||||||
+'var Var1,Var2:array of const):integer;'#13
|
'var Var1,Var2:array of const):integer;'#13 +
|
||||||
+'const i=1+2+3;'#13
|
'const i=1+2+3;'#13 +
|
||||||
+'begin'#13
|
'begin'#13 +
|
||||||
+' A:=@B.C;D:=3;E:=X[5];'#13
|
' A:=@B.C;D:=3;E:=X[5];'#13 +
|
||||||
+' {$I unit1.lrs}'#13
|
' {$I unit1.lrs}'#13 +
|
||||||
+' {$R-}{$R+}'#13
|
' {$R-}{$R+}'#13 +
|
||||||
+'end;';
|
'end;';
|
||||||
begin
|
begin
|
||||||
if BeautifyCodeOptions = nil then
|
if BeautifyCodeOptions = nil then
|
||||||
Exit;
|
Exit;
|
||||||
@ -256,20 +160,22 @@ const
|
|||||||
begin
|
begin
|
||||||
with DoInsertSpaceInFrontGroupBox do begin
|
with DoInsertSpaceInFrontGroupBox do begin
|
||||||
Caption:=dlgInsSpaceFront;
|
Caption:=dlgInsSpaceFront;
|
||||||
CreateAtomCheckBoxes(DoInsertSpaceInFrontGroupBox,DoInsertSpaceAtoms,2);
|
CreateAtomCheckBoxes(
|
||||||
|
DoInsertSpaceInFrontGroupBox, DoInsertSpaceAtoms, 2, @UpdateExample);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
with DoInsertSpaceAfterGroupBox do begin
|
with DoInsertSpaceAfterGroupBox do begin
|
||||||
Caption:=dlgInsSpaceAfter;
|
Caption:=dlgInsSpaceAfter;
|
||||||
CreateAtomCheckBoxes(DoInsertSpaceAfterGroupBox,DoInsertSpaceAtoms,2);
|
CreateAtomCheckBoxes(
|
||||||
|
DoInsertSpaceAfterGroupBox, DoInsertSpaceAtoms, 2, @UpdateExample);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
with SpacePreviewLabel do
|
with SpacePreviewLabel do
|
||||||
Caption:=dlgWRDPreview;
|
Caption:=dlgWRDPreview;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCodetoolsSpaceOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions
|
procedure TCodetoolsSpaceOptionsFrame.ReadSettings(
|
||||||
);
|
AOptions: TAbstractIDEOptions);
|
||||||
begin
|
begin
|
||||||
with AOptions as TCodetoolsOptions do
|
with AOptions as TCodetoolsOptions do
|
||||||
begin
|
begin
|
||||||
|
@ -130,7 +130,7 @@ uses
|
|||||||
options_editor_general, options_editor_display, options_editor_keymapping,
|
options_editor_general, options_editor_display, options_editor_keymapping,
|
||||||
options_editor_color, options_editor_codetools, options_editor_codefolding,
|
options_editor_color, options_editor_codetools, options_editor_codefolding,
|
||||||
options_editor_general_misc,
|
options_editor_general_misc,
|
||||||
options_codetools_general, options_codetools_codecreation,
|
options_codetools_general, options_codetools_codecreation, options_atom_checkboxes,
|
||||||
options_codetools_wordpolicy, options_codetools_linesplitting,
|
options_codetools_wordpolicy, options_codetools_linesplitting,
|
||||||
options_codetools_space, options_codetools_identifiercompletion,
|
options_codetools_space, options_codetools_identifiercompletion,
|
||||||
options_debugger_general, options_debugger_eventlog,
|
options_debugger_general, options_debugger_eventlog,
|
||||||
|
Loading…
Reference in New Issue
Block a user