1 unit frCompilerDirectReturns;
2
3 {(*}
4 (*------------------------------------------------------------------------------
5 Delphi Code formatter source code
6
7 The Original Code is frCompilerDirectReturns.pas, released April 2005.
8 The Initial Developer of the Original Code is Anthony Steele.
9 Portions created by Anthony Steele are Copyright (C) 1999-2008 Anthony Steele.
10 All Rights Reserved.
11 Contributor(s): Anthony Steele.
12
13 The contents of this file are subject to the Mozilla Public License Version 1.1
14 (the "License"). you may not use this file except in compliance with the License.
15 You may obtain a copy of the License at http://www.mozilla.org/NPL/
16
17 Software distributed under the License is distributed on an "AS IS" basis,
18 WITHOUT WARRANTY OF ANY KIND, either express or implied.
19 See the License for the specific language governing rights and limitations
20 under the License.
21
22 Alternatively, the contents of this file may be used under the terms of
23 the GNU General Public License Version 2 or later (the "GPL")
24 See http://www.gnu.org/licenses/gpl.html
25 ------------------------------------------------------------------------------*)
26 {*)}
27
28 {$I JcfGlobal.inc}
29
30 interface
31
32 uses
33 Classes, Graphics, Controls, Forms, StdCtrls, ExtCtrls,
34 IDEOptionsIntf, IDEOptEditorIntf;
35
36 type
37
38 { TfCompilerDirectReturns }
39
40 TfCompilerDirectReturns = class(TAbstractIDEOptionsEditor)
41 Label1: TLabel;
42 rgBeforeUses: TRadioGroup;
43 rgBeforeStatements: TRadioGroup;
44 rgBeforeGeneral: TRadioGroup;
45 rgAfterGeneral: TRadioGroup;
46 rgAfterStatements: TRadioGroup;
47 rgAfterUses: TRadioGroup;
48 Label2: TLabel;
49 procedure FrameResize(Sender:TObject);
50 public
51 constructor Create(AOwner: TComponent); override;
52
GetTitlenull53 function GetTitle: String; override;
54 procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
55 procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
56 procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
SupportedOptionsClassnull57 class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
58 end;
59
60 implementation
61
62 {$R *.lfm}
63
64 uses
65 JcfSettings, SettingsTypes, JcfUIConsts;
66
67 procedure TfCompilerDirectReturns.FrameResize(Sender:TObject);
68 begin
69 rgBeforeGeneral.Width := (Width-24) div 3;
70 rgBeforeStatements.Width := rgBeforeGeneral.Width;
71 rgAfterGeneral.Width := rgBeforeGeneral.Width;
72 rgAfterStatements.Width := rgBeforeGeneral.Width;
73 end;
74
75 constructor TfCompilerDirectReturns.Create(AOwner: TComponent);
76 begin
77 inherited;
78 // fiHelpContext := ?? ;
79 end;
80
GetTitlenull81 function TfCompilerDirectReturns.GetTitle: String;
82 begin
83 Result := lisCDCompilerDirectives;
84 end;
85
86 procedure TfCompilerDirectReturns.Setup(ADialog: TAbstractOptionsEditorDialog);
87 begin
88 Label1.Caption := lisCDUseANewLineBeforeCompilerDirectives;
89 rgBeforeUses.Caption := lisCDUsesClause;
90 rgBeforeUses.Items[0] := lisCaseBlocksAlways;
91 rgBeforeUses.Items[1] := lisCaseBlocksLeaveAsIs;
92 rgBeforeUses.Items[2] := lisCaseBlocksNever;
93
94 rgBeforeStatements.Caption := lisCDStatements;
95 rgBeforeStatements.Items[0] := lisCaseBlocksAlways;
96 rgBeforeStatements.Items[1] := lisCaseBlocksLeaveAsIs;
97 rgBeforeStatements.Items[2] := lisCaseBlocksNever;
98
99 rgBeforeGeneral.Caption := lisCDOtherPlaces;
100 rgBeforeGeneral.Items[0] := lisCaseBlocksAlways;
101 rgBeforeGeneral.Items[1] := lisCaseBlocksLeaveAsIs;
102 rgBeforeGeneral.Items[2] := lisCaseBlocksNever;
103
104 Label2.Caption := lisCDUseANewLineAfterCompilerDirectives;
105 rgAfterUses.Caption := lisCDUsesClause;
106 rgAfterUses.Items[0] := lisCaseBlocksAlways;
107 rgAfterUses.Items[1] := lisCaseBlocksLeaveAsIs;
108 rgAfterUses.Items[2] := lisCaseBlocksNever;
109
110 rgAfterStatements.Caption := lisCDStatements;
111 rgAfterStatements.Items[0] := lisCaseBlocksAlways;
112 rgAfterStatements.Items[1] := lisCaseBlocksLeaveAsIs;
113 rgAfterStatements.Items[2] := lisCaseBlocksNever;
114
115 rgAfterGeneral.Caption := lisCDOtherPlaces;
116 rgAfterGeneral.Items[0] := lisCaseBlocksAlways;
117 rgAfterGeneral.Items[1] := lisCaseBlocksLeaveAsIs;
118 rgAfterGeneral.Items[2] := lisCaseBlocksNever;
119 end;
120
121 procedure TfCompilerDirectReturns.ReadSettings(AOptions: TAbstractIDEOptions);
122 begin
123 with FormattingSettings.Returns do
124 begin
125 rgBeforeUses.ItemIndex := Ord(BeforeCompilerDirectUses);
126 rgBeforeStatements.ItemIndex := Ord(BeforeCompilerDirectStatements);
127 rgBeforeGeneral.ItemIndex := Ord(BeforeCompilerDirectGeneral);
128
129 rgAfterUses.ItemIndex := Ord(AfterCompilerDirectUses);
130 rgAfterStatements.ItemIndex := Ord(AfterCompilerDirectStatements);
131 rgAfterGeneral.ItemIndex := Ord(AfterCompilerDirectGeneral);
132 end;
133 end;
134
135 procedure TfCompilerDirectReturns.WriteSettings(AOptions: TAbstractIDEOptions);
136 begin
137 with FormattingSettings.Returns do
138 begin
139 BeforeCompilerDirectUses := TTriOptionStyle(rgBeforeUses.ItemIndex);
140 BeforeCompilerDirectStatements := TTriOptionStyle(rgBeforeStatements.ItemIndex);
141 BeforeCompilerDirectGeneral := TTriOptionStyle(rgBeforeGeneral.ItemIndex);
142
143 AfterCompilerDirectUses := TTriOptionStyle(rgAfterUses.ItemIndex);
144 AfterCompilerDirectStatements := TTriOptionStyle(rgAfterStatements.ItemIndex);
145 AfterCompilerDirectGeneral := TTriOptionStyle(rgAfterGeneral.ItemIndex);
146
147 end;
148 end;
149
TfCompilerDirectReturns.SupportedOptionsClassnull150 class function TfCompilerDirectReturns.SupportedOptionsClass: TAbstractIDEOptionsClass;
151 begin
152 Result := TFormattingSettings;
153 end;
154
155 initialization
156 RegisterIDEOptionsEditor(JCFOptionsGroup, TfCompilerDirectReturns, JCFOptionCompilerDirectives, JCFOptionLongLines);
157 end.
158