1 unit formfind;
2 
3 {$mode objfpc}{$H+}
4 
5 interface
6 
7 uses
8   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ButtonPanel,
9   StdCtrls;
10 
11 type
12 
13   { TfmFind }
14 
15   TfmFind = class(TForm)
16     bCount: TButton;
17     bMarkAll: TButton;
18     bFind: TButton;
19     bCancel: TButton;
20     bRep: TButton;
21     bRepAll: TButton;
22     chkInSel: TCheckBox;
23     chkFromCaret: TCheckBox;
24     chkConfirm: TCheckBox;
25     chkRep: TCheckBox;
26     chkRegex: TCheckBox;
27     chkBack: TCheckBox;
28     chkCase: TCheckBox;
29     chkWords: TCheckBox;
30     edFind: TEdit;
31     edRep: TEdit;
32     Label1: TLabel;
33     procedure chkRegexChange(Sender: TObject);
34     procedure chkRepChange(Sender: TObject);
35     procedure FormShow(Sender: TObject);
36   private
37     procedure Update; reintroduce;
38     { private declarations }
39   public
40     { public declarations }
41   end;
42 
43 var
44   fmFind: TfmFind;
45 
46 implementation
47 
48 {$R *.lfm}
49 
50 { TfmFind }
51 
52 procedure TfmFind.chkRegexChange(Sender: TObject);
53 begin
54   Update;
55 end;
56 
57 procedure TfmFind.chkRepChange(Sender: TObject);
58 begin
59   Update;
60 end;
61 
62 procedure TfmFind.FormShow(Sender: TObject);
63 begin
64   Update;
65 end;
66 
67 procedure TfmFind.Update;
68 var
69   rep: boolean;
70 begin
71   rep:= chkRep.Checked;
72 
73   chkWords.Enabled:= not chkRegex.Checked;
74   chkBack.Enabled:= not chkRegex.Checked;
75   chkConfirm.Enabled:= rep;
76   edRep.Enabled:= rep;
77   bFind.Visible:= not rep;
78   bRep.Visible:= rep;
79   bRepAll.Visible:= rep;
80 
81   if rep then
82     Caption:= 'Replace'
83   else
84     Caption:= 'Find';
85 
86   if rep then
87     bRep.Default:= true
88   else
89     bFind.Default:= true;
90 end;
91 
92 end.
93 
94