1 {(*}
2 (*------------------------------------------------------------------------------
3  Delphi Code formatter source code
4 
5 The Original Code is frReplace.pas, released April 2000.
6 The Initial Developer of the Original Code is Anthony Steele.
7 Portions created by Anthony Steele are Copyright (C) 1999-2008 Anthony Steele.
8 All Rights Reserved.
9 Contributor(s): Anthony Steele.
10 
11 The contents of this file are subject to the Mozilla Public License Version 1.1
12 (the "License"). you may not use this file except in compliance with the License.
13 You may obtain a copy of the License at http://www.mozilla.org/NPL/
14 
15 Software distributed under the License is distributed on an "AS IS" basis,
16 WITHOUT WARRANTY OF ANY KIND, either express or implied.
17 See the License for the specific language governing rights and limitations
18 under the License.
19 
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 or later (the "GPL")
22 See http://www.gnu.org/licenses/gpl.html
23 ------------------------------------------------------------------------------*)
24 {*)}
25 
26 unit frReplace;
27 
28 {$I JcfGlobal.inc}
29 
30 interface
31 
32 uses
33   Classes, StdCtrls,
34   IDEOptionsIntf, IDEOptEditorIntf;
35 
36 type
37 
38   { TfReplace }
39 
40   TfReplace = class(TAbstractIDEOptionsEditor)
41     cbEnable: TCheckBox;
42     mWords: TMemo;
43     lblWordList: TLabel;
44     procedure cbEnableClick(Sender: TObject);
45     procedure FrameResize(Sender: TObject);
46   public
47     constructor Create(AOwner: TComponent); override;
48 
GetTitlenull49     function GetTitle: String; override;
50     procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
51     procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
52     procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
SupportedOptionsClassnull53     class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
54   end;
55 
56 implementation
57 
58 {$R *.lfm}
59 
60 uses
61   JcfSettings, JcfUIConsts;
62 
63 { TfReplace }
64 
65 constructor TfReplace.Create(AOwner: TComponent);
66 begin
67   inherited;
68   //fiHelpContext := HELP_CLARIFY_FIND_AND_REPLACE;
69 end;
70 
TfReplace.GetTitlenull71 function TfReplace.GetTitle: String;
72 begin
73   Result := lisFindReplaceFindAndReplace;
74 end;
75 
76 procedure TfReplace.Setup(ADialog: TAbstractOptionsEditorDialog);
77 begin
78   cbEnable.Caption := lisFindReplaceEnableFindAndReplace;
79   lblWordList.Caption := lisFindReplaceWordList;
80 end;
81 
82 procedure TfReplace.ReadSettings(AOptions: TAbstractIDEOptions);
83 begin
84   with FormattingSettings.Replace do
85   begin
86     cbEnable.Checked := Enabled;
87     mWords.Lines.Assign(Words);
88   end;
89   cbEnableClick(nil);
90 end;
91 
92 procedure TfReplace.WriteSettings(AOptions: TAbstractIDEOptions);
93 begin
94   with FormattingSettings.Replace do
95   begin
96     Enabled := cbEnable.Checked;
97     Words.Assign(mWords.Lines);
98     SplitWords;
99   end;
100 end;
101 
TfReplace.SupportedOptionsClassnull102 class function TfReplace.SupportedOptionsClass: TAbstractIDEOptionsClass;
103 begin
104   Result := TFormattingSettings;
105 end;
106 
107 {-------------------------------------------------------------------------------
108   event handlers }
109 
110 procedure TfReplace.cbEnableClick(Sender: TObject);
111 begin
112   mWords.Enabled := cbEnable.Checked;
113 end;
114 
115 procedure TfReplace.FrameResize(Sender: TObject);
116 const
117   PAD = 4;
118 begin
119   mWords.Height := ClientHeight - (lblWordList.Top + lblWordList.Height + PAD);
120 end;
121 
122 initialization
123   RegisterIDEOptionsEditor(JCFOptionsGroup, TfReplace, JCFOptionFindAndReplace, JCFOptionClarify);
124 end.
125