summaryrefslogtreecommitdiff
path: root/examples/apps/nanoedit/frm_find.pas
blob: 96bfe6fa3a25f0bdbaef76fc9423126bbca0efe4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
unit frm_find;

{$mode objfpc}{$H+}

interface

uses
  SysUtils, Classes, fpg_base, fpg_main, fpg_form, fpg_label,
  fpg_edit, fpg_button, fpg_checkbox, fpg_panel, fpg_radiobutton,
  fpg_textedit;

type

  TFindForm = class(TfpgForm)
  private
    {@VFD_HEAD_BEGIN: FindForm}
    Label1: TfpgLabel;
    FindEdit: TfpgEdit;
    btnFind: TfpgButton;
    btnCancel: TfpgButton;
    GroupBox1: TfpgGroupBox;
    chkWholeWord: TfpgCheckBox;
    chkCaseSensitive: TfpgCheckBox;
    rbForward: TfpgRadioButton;
    rbBackward: TfpgRadioButton;
    {@VFD_HEAD_END: FindForm}
    procedure btnFindClicked(Sender: TObject);
    function GetTextToFind: TfpgString;
    function GetIsForward: boolean;
    function GetFindOptions: TfpgFindOptions;
  public
    procedure AfterCreate; override;
    function Execute: boolean;
    property TextToFind: TfpgString read GetTextToFind;
    property IsForward: boolean read GetIsForward;
    property FindOptions: TfpgFindOptions read GetFindOptions;
  end;

{@VFD_NEWFORM_DECL}

implementation

{@VFD_NEWFORM_IMPL}

procedure TFindForm.btnFindClicked(Sender: TObject);
begin
  ModalResult := mrOK;
end;

function TFindForm.GetTextToFind: TfpgString;
begin
  Result := FindEdit.Text;
end;

function TFindForm.GetIsForward: boolean;
begin
  Result := rbForward.Checked;
end;

function TFindForm.GetFindOptions: TfpgFindOptions;
begin
  Result := [foEntireScope];
  if chkWholeWord.Checked then
    Result := Result + [foWholeWords];
  if chkCaseSensitive.Checked then
    Result := Result + [foMatchCase];
end;

procedure TFindForm.AfterCreate;
begin
  {%region 'Auto-generated GUI code' -fold}
  {@VFD_BODY_BEGIN: FindForm}
  Name := 'FindForm';
  SetPosition(292, 173, 429, 110);
  WindowTitle := 'Find';
  Hint := '';

  Label1 := TfpgLabel.Create(self);
  with Label1 do
  begin
    Name := 'Label1';
    SetPosition(4, 4, 280, 16);
    FontDesc := '#Label1';
    Hint := '';
    Text := 'Text to find:';
  end;

  FindEdit := TfpgEdit.Create(self);
  with FindEdit do
  begin
    Name := 'FindEdit';
    SetPosition(4, 20, 332, 24);
    Anchors := [anLeft,anRight,anTop];
    ExtraHint := '';
    FontDesc := '#Edit1';
    Hint := '';
    TabOrder := 2;
    Text := '';
  end;

  btnFind := TfpgButton.Create(self);
  with btnFind do
  begin
    Name := 'btnFind';
    SetPosition(345, 8, 80, 24);
    Anchors := [anRight,anTop];
    Text := 'Find';
    FontDesc := '#Label1';
    Hint := '';
    ImageName := '';
    TabOrder := 3;
    OnClick := @btnFindClicked;
  end;

  btnCancel := TfpgButton.Create(self);
  with btnCancel do
  begin
    Name := 'btnCancel';
    SetPosition(345, 36, 80, 24);
    Anchors := [anRight,anTop];
    Text := 'Cancel';
    FontDesc := '#Label1';
    Hint := '';
    ImageName := '';
    ModalResult := mrCancel;
    TabOrder := 4;
  end;

  GroupBox1 := TfpgGroupBox.Create(self);
  with GroupBox1 do
  begin
    Name := 'GroupBox1';
    SetPosition(160, 56, 176, 44);
    FontDesc := '#Label1';
    Hint := '';
    Text := 'Direction';
  end;

  chkWholeWord := TfpgCheckBox.Create(self);
  with chkWholeWord do
  begin
    Name := 'chkWholeWord';
    SetPosition(4, 52, 148, 20);
    FontDesc := '#Label1';
    Hint := '';
    TabOrder := 6;
    Text := 'Whole words only';
  end;

  chkCaseSensitive := TfpgCheckBox.Create(self);
  with chkCaseSensitive do
  begin
    Name := 'chkCaseSensitive';
    SetPosition(4, 72, 148, 20);
    FontDesc := '#Label1';
    Hint := '';
    TabOrder := 7;
    Text := 'Case sensitive';
  end;

  rbForward := TfpgRadioButton.Create(GroupBox1);
  with rbForward do
  begin
    Name := 'rbForward';
    SetPosition(8, 20, 76, 20);
    Checked := True;
    FontDesc := '#Label1';
    GroupIndex := 0;
    Hint := '';
    TabOrder := 1;
    Text := 'Forword';
  end;

  rbBackward := TfpgRadioButton.Create(GroupBox1);
  with rbBackward do
  begin
    Name := 'rbBackward';
    SetPosition(88, 20, 84, 20);
    FontDesc := '#Label1';
    GroupIndex := 0;
    Hint := '';
    TabOrder := 2;
    Text := 'Backward';
  end;

  {@VFD_BODY_END: FindForm}
  {%endregion}
end;

function TFindForm.Execute: boolean;
begin
  Result := ShowModal <> mrCancel;
end;


end.