1 {
2 ***************************************************************************
3 * *
4 * This source is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This code is distributed in the hope that it will be useful, but *
10 * WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * General Public License for more details. *
13 * *
14 * A copy of the GNU General Public License is available on the World *
15 * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
16 * obtain it by writing to the Free Software Foundation, *
17 * Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA. *
18 * *
19 ***************************************************************************
20 }
21 unit codetools_codecreation_options;
22
23 {$mode objfpc}{$H+}
24
25 interface
26
27 uses
28 SysUtils,
29 // LazUtils
30 FileUtil,
31 // LCL
32 StdCtrls, Dialogs, EditBtn,
33 // CodeTools
34 SourceChanger,
35 // IdeIntf
36 IDEOptionsIntf, IDEOptEditorIntf,
37 // IDE
38 CodeToolsOptions, LazarusIDEStrConsts;
39
40 type
41
42 { TCodetoolsCodeCreationOptionsFrame }
43
44 TCodetoolsCodeCreationOptionsFrame = class(TAbstractIDEOptionsEditor)
45 ForwardProcsInsertPolicyComboBox: TComboBox;
46 OverrideStringTypesWithFirstParamTypeCheckBox: TCheckBox;
47 TemplateFileEdit: TFileNameEdit;
48 UsesInsertPolicyComboBox: TComboBox;
49 ForwardProcsKeepOrderCheckBox: TCheckBox;
50 ForwardProcsInsertPolicyLabel: TLabel;
51 UsesInsertPolicyLabel: TLabel;
52 TemplateFileLabel: TLabel;
53 UpdateMultiProcSignaturesCheckBox: TCheckBox;
54 UpdateOtherProcSignaturesCaseCheckBox: TCheckBox;
55 GroupLocalVariablesCheckBox: TCheckBox;
56 private
57 public
GetTitlenull58 function GetTitle: String; override;
59 procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
60 procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
61 procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
SupportedOptionsClassnull62 class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
63 end;
64
65 implementation
66
67 {$R *.lfm}
68
69 { TCodetoolsCodeCreationOptionsFrame }
70
TCodetoolsCodeCreationOptionsFrame.GetTitlenull71 function TCodetoolsCodeCreationOptionsFrame.GetTitle: String;
72 begin
73 Result := dlgCodeCreation;
74 end;
75
76 procedure TCodetoolsCodeCreationOptionsFrame.Setup(
77 ADialog: TAbstractOptionsEditorDialog);
78 begin
79 ForwardProcsInsertPolicyLabel.Caption:=dlgForwardProcsInsertPolicy;
80 with ForwardProcsInsertPolicyComboBox do begin
81 with Items do begin
82 BeginUpdate;
83 Add(dlgLast);
84 Add(dlgInFrontOfMethods);
85 Add(dlgBehindMethods);
86 EndUpdate;
87 end;
88 end;
89
90 ForwardProcsKeepOrderCheckBox.Caption:=dlgForwardProcsKeepOrder;
91
92 UsesInsertPolicyLabel.Caption:=lisNewUnitsAreAddedToUsesSections;
93 with UsesInsertPolicyComboBox do begin
94 with Items do begin
95 BeginUpdate;
96 Add(lisFirst);
97 Add(lisInFrontOfRelated);
98 Add(lisBehindRelated);
99 Add(dlgCDTLast);
100 Add(dlgAlphabetically);
101 EndUpdate;
102 end;
103 end;
104
105 UpdateMultiProcSignaturesCheckBox.Caption:=
106 lisCTOUpdateMultipleProcedureSignatures;
107 UpdateOtherProcSignaturesCaseCheckBox.Caption:=
108 lisUpdateOtherProcedureSignaturesWhenOnlyLetterCaseHa;
109 GroupLocalVariablesCheckBox.Caption:=
110 lisGroupLocalVariables;
111 OverrideStringTypesWithFirstParamTypeCheckBox.Caption:=
112 lisOverrideStringTypesWithFirstParamType;
113
114 TemplateFileLabel.Caption:=lisTemplateFile;
115 {$IFNDEF EnableCodeCompleteTemplates}
116 TemplateFileLabel.Enabled:=false;
117 TemplateFileEdit.Enabled:=false;
118 {$ENDIF}
119
120 TemplateFileEdit.DialogTitle:=lisChooseAFileWithCodeToolsTemplates;
121 TemplateFileEdit.Filter:=dlgFilterCodetoolsTemplateFile+' (*.xml)|*.xml|'+
122 dlgFilterAll+'|'+GetAllFilesMask;
123 end;
124
125 procedure TCodetoolsCodeCreationOptionsFrame.ReadSettings(
126 AOptions: TAbstractIDEOptions);
127 begin
128 with AOptions as TCodetoolsOptions do
129 begin
130 case ForwardProcBodyInsertPolicy of
131 fpipLast: ForwardProcsInsertPolicyComboBox.ItemIndex:=0;
132 fpipInFrontOfMethods: ForwardProcsInsertPolicyComboBox.ItemIndex:=1;
133 else
134 // fpipBehindMethods
135 ForwardProcsInsertPolicyComboBox.ItemIndex:=2;
136 end;
137
138 ForwardProcsKeepOrderCheckBox.Checked := KeepForwardProcOrder;
139
140 case UsesInsertPolicy of
141 uipFirst: UsesInsertPolicyComboBox.ItemIndex:=0;
142 uipInFrontOfRelated: UsesInsertPolicyComboBox.ItemIndex:=1;
143 uipBehindRelated: UsesInsertPolicyComboBox.ItemIndex:=2;
144 uipLast: UsesInsertPolicyComboBox.ItemIndex:=3;
145 else
146 //uipAlphabetically:
147 UsesInsertPolicyComboBox.ItemIndex:=4;
148 end;
149
150 UpdateMultiProcSignaturesCheckBox.Checked:=UpdateMultiProcSignatures;
151 UpdateOtherProcSignaturesCaseCheckBox.Checked:=UpdateOtherProcSignaturesCase;
152 GroupLocalVariablesCheckBox.Checked:=GroupLocalVariables;
153 OverrideStringTypesWithFirstParamTypeCheckBox.Checked:=OverrideStringTypesWithFirstParamType;
154
155 TemplateFileEdit.Text:=CodeCompletionTemplateFileName;
156 end;
157 end;
158
159 procedure TCodetoolsCodeCreationOptionsFrame.WriteSettings(
160 AOptions: TAbstractIDEOptions);
161 begin
162 with AOptions as TCodetoolsOptions do
163 begin
164 case ForwardProcsInsertPolicyComboBox.ItemIndex of
165 0: ForwardProcBodyInsertPolicy := fpipLast;
166 1: ForwardProcBodyInsertPolicy := fpipInFrontOfMethods;
167 2: ForwardProcBodyInsertPolicy := fpipBehindMethods;
168 end;
169
170 KeepForwardProcOrder := ForwardProcsKeepOrderCheckBox.Checked;
171
172 case UsesInsertPolicyComboBox.ItemIndex of
173 0: UsesInsertPolicy:=uipFirst;
174 1: UsesInsertPolicy:=uipInFrontOfRelated;
175 2: UsesInsertPolicy:=uipBehindRelated;
176 3: UsesInsertPolicy:=uipLast;
177 else UsesInsertPolicy:=uipAlphabetically;
178 end;
179
180 UpdateMultiProcSignatures:=UpdateMultiProcSignaturesCheckBox.Checked;
181 UpdateOtherProcSignaturesCase:=UpdateOtherProcSignaturesCaseCheckBox.Checked;
182 GroupLocalVariables:=GroupLocalVariablesCheckBox.Checked;
183 OverrideStringTypesWithFirstParamType:=OverrideStringTypesWithFirstParamTypeCheckBox.Checked;
184
185 CodeCompletionTemplateFileName:=TemplateFileEdit.Text;
186 end;
187 end;
188
TCodetoolsCodeCreationOptionsFrame.SupportedOptionsClassnull189 class function TCodetoolsCodeCreationOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
190 begin
191 Result := TCodeToolsOptions;
192 end;
193
194 initialization
195 RegisterIDEOptionsEditor(GroupCodetools, TCodetoolsCodeCreationOptionsFrame, CdtOptionsCodeCreation);
196 end.
197
198