File: replacedialog.inc

package info (click to toggle)
lazarus 4.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 275,760 kB
  • sloc: pascal: 2,341,904; xml: 509,420; makefile: 348,726; cpp: 93,608; sh: 3,387; java: 609; perl: 297; sql: 222; ansic: 137
file content (660 lines) | stat: -rw-r--r-- 20,526 bytes parent folder | download | duplicates (6)
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
{%MainUnit ../dialogs.pp}
{******************************************************************************
                                  TFindDialog
 ******************************************************************************

 *****************************************************************************
  This file is part of the Lazarus Component Library (LCL)

  See the file COPYING.modifiedLGPL.txt, included in this distribution,
  for details about the license.
 *****************************************************************************
}


type

{ TReplaceDialogForm }
  TReplaceDialogForm = class(TForm)
    // Same order as in TReplaceDialog
	PanelButtons: TPanel;
	CancelButton: TButton;
	CaseSensitiveCheckBox: TCheckBox;
	DirectionRadioGroup: TRadioGroup;
    EditFind: TEdit;
	EntireScopeCheckBox: TCheckBox;
	FindMoreButton: TButton;
	TextLabel: TLabel;
	FlagPanel: TPanel;
	HelpButton: TButton;
	WholeWordsOnlyCheckBox: TCheckBox;

    EditReplace: TEdit;
    PromptOnReplaceCheckBox: TCheckBox;
    ReplaceAllButton: TButton;
    ReplaceButton: TButton;
    ReplaceLabel: TLabel;
  private
    FButtonsBottom: Boolean;
  public
    { public declarations }
    constructor CreateNew(aOwner: TComponent; Options: TFindOptions); reintroduce;
    procedure SetLayout (Options: TFindOptions);
  end;

constructor TReplaceDialogForm.CreateNew(aOwner: TComponent;
  Options: TFindOptions);
var
  Layout: boolean; // true = Buttons at bottom
begin
  inherited CreateNew(aOwner);
  Layout := frButtonsAtBottom in Options;
  if Layout then begin
    Left := 415;
    Height := 220;
    Top := 391;
    Width := 530;
    ClientHeight := 220;
    ClientWidth := 530;
    Constraints.MinHeight := 220;
    Constraints.MinWidth := 530;
    end
  else begin
    Left := 415;
    Height := 184;
    Top := 333;
    Width := 480;
    ClientHeight := 140;
    ClientWidth := 480;
    Constraints.MinHeight := 184;
    Constraints.MinWidth := 480;
  end;
  ActiveControl := EditFind;
  AutoSize := True;
  BorderIcons := [biSystemMenu, biHelp];
  Caption := 'Replace Text';
  //Position := poMainFormCenter;
  LCLVersion := '1.3';

  TextLabel := TLabel.Create(Self);
  with TextLabel do begin
    Left := 4;
    Height := 17;
    Top := 14;
    Width := 77;
    BorderSpacing.Left := 8;
    BorderSpacing.Right := 8;
    BorderSpacing.Top := 14;
    Caption := 'Text to find';
    FocusControl := EditFind;
    ParentColor := False;
    Parent := Self;
  end;
  ReplaceLabel := TLabel.Create(Self);
  with ReplaceLabel do begin
    Left := 4;
    Height := 17;
    Top := 45;
    Width := 87;
    BorderSpacing.Top := 14;
    BorderSpacing.Right := 8;
    Caption := 'Replace with';
    FocusControl := EditReplace;
    ParentColor := False;
    Parent := Self;
  end;
  EditFind := TEdit.Create(Self);
  with EditFind do begin
    Left := 89;
    Height := 27;
    Top := 9;
    Width := 288;
    TabOrder := 0;
    Text := 'EditFind';
    Parent := Self;
  end;
  EditReplace := TEdit.Create(Self);
  with EditReplace do begin
    Left := 99;
    Height := 27;
    Top := 40;
    Width := 278;
    BorderSpacing.Left := 8;
    TabOrder := 1;
    Text := 'EditReplace';
    Parent := Self;
  end;
  {
  DirectionRadioGroup := TRadioGroup.Create(Self);
  with DirectionRadioGroup do begin
    Left := 155;
    Height := 60;
    Top := 62;
    Width := 222;
    AutoFill := True;
    AutoSize := True;
    BorderSpacing.Left := 12;
    //BorderSpacing.Around := 0;
    Caption := 'Direction';
    ChildSizing.LeftRightSpacing := 6;
    ChildSizing.TopBottomSpacing := 6;
    ChildSizing.EnlargeHorizontal := crsHomogenousChildResize;
    ChildSizing.EnlargeVertical := crsHomogenousChildResize;
    ChildSizing.ShrinkHorizontal := crsScaleChilds;
    ChildSizing.ShrinkVertical := crsScaleChilds;
    ChildSizing.Layout := cclLeftToRightThenTopToBottom;
    ChildSizing.ControlsPerLine := 2;
    ClientHeight := 38;
    ClientWidth := 212;
    Columns := 2;
    Constraints.MaxHeight := 60;
    Items.Add('Forward');
    Items.Add('Backward');
    TabOrder := 2;
    Parent := Self;
  end;
  }
  FlagPanel := TPanel.Create(Self);
  With FlagPanel do begin
    Left := 4;
    Height := 114;
    Top := 62;
    Width := 151;
    AutoSize := True;
    BorderSpacing.Around := 6;
    BorderSpacing.Top := 16;
    BevelOuter := bvNone;
    ChildSizing.VerticalSpacing := 6;
    ChildSizing.Layout := cclLeftToRightThenTopToBottom;
    ChildSizing.ControlsPerLine := 1;
    ClientHeight := 114;
    ClientWidth := 151;
    Constraints.MinHeight := 114;
    TabOrder := 2;
    Parent := Self;
  end;
  // Flags Panel Objects
    WholeWordsOnlyCheckBox := TCheckBox.Create(Self);
    with WholeWordsOnlyCheckBox do begin
      Left := 0;
      Height := 23;
      Top := 0;
      Width := 142;
      Caption := 'Whole words only';
      TabOrder := 0;
      Parent := FlagPanel;
    end;
    CaseSensitiveCheckBox := TCheckBox.Create(Self);
    with CaseSensitiveCheckBox do begin
      Left := 0;
      Height := 23;
      Top := 29;
      Width := 142;
      Caption := 'Case sensitive';
      TabOrder := 1;
      Parent := FlagPanel;
    end;
    EntireScopeCheckBox := TCheckBox.Create(Self);
    with EntireScopeCheckBox do begin
      Left := 0;
      Height := 23;
      Top := 58;
      Width := 142;
      Caption := 'Search entire file';
      TabOrder := 2;
      Parent := FlagPanel;
    end;
    PromptOnReplaceCheckBox := TCheckBox.Create(Self);
    with PromptOnReplaceCheckBox do begin
      Left := 0;
      Height := 23;
      Top := 89;
      Width := 151;
      Caption := 'Prompt on replace';
      TabOrder := 3;
      Parent := FlagPanel;
    end;
  //End of Flags Panel objects

  DirectionRadioGroup := TRadioGroup.Create(Self);
  with DirectionRadioGroup do begin
    Left := 155;
    Height := 60;
    Top := 62;
    Width := 222;
    AutoFill := True;
    AutoSize := True;
    BorderSpacing.Left := 12;
    //BorderSpacing.Around := 0;
    Caption := 'Direction';
    ChildSizing.LeftRightSpacing := 6;
    ChildSizing.TopBottomSpacing := 6;
    ChildSizing.EnlargeHorizontal := crsHomogenousChildResize;
    ChildSizing.EnlargeVertical := crsHomogenousChildResize;
    ChildSizing.ShrinkHorizontal := crsScaleChilds;
    ChildSizing.ShrinkVertical := crsScaleChilds;
    ChildSizing.Layout := cclLeftToRightThenTopToBottom;
    ChildSizing.ControlsPerLine := 2;
    ClientHeight := 38;
    ClientWidth := 212;
    Columns := 2;
    Constraints.MaxHeight := 60;
    Items.Add('Forward');
    Items.Add('Backward');
    TabOrder := 3;
    Parent := Self;
  end;

  PanelButtons := TPanel.Create(Self);
  with PanelButtons do begin
    if Layout then begin
      Left := 0;
      Height := 29;
      Top := 191;
      Width := 530;
      Align := alBottom;
      BevelOuter := bvNone;
      ClientHeight := 29;
      ClientWidth := 530;
      TabOrder := 4;
      end
    else begin
      Left := 388;
      Height := 132;
      Top := 0;
      Width := 92;
      Align := alRight;
      BevelOuter := bvNone;
      ChildSizing.LeftRightSpacing := 6;
      ChildSizing.TopBottomSpacing := 6;
      ChildSizing.VerticalSpacing := 6;
      ClientHeight := 132;
      ClientWidth := 92;
      TabOrder := 3;
      end;
    Parent := Self;
    end;
  // PanelButtons Objects
    FindMoreButton := TButton.Create(Self);
    with FindMoreButton do begin
      Tag := 1;
      Left := 12;
      Height := 26;
      Top := 10;
      Width := 91;
      AutoSize := True;
      Caption := 'Find more';
      Constraints.MinWidth := 91;
      Default := True;
      TabOrder := 0;
      Parent := PanelButtons;
    end;
    ReplaceButton := TButton.Create(Self);
    with ReplaceButton do begin
      Tag := 2;
      Left := 12;
      Height := 26;
      Top := 46;
      Width := 91;
      AutoSize := True;
      Caption := 'Replace';
      Constraints.MinWidth := 91;
      Default := True;
      TabOrder := 2;
      Parent := PanelButtons;
    end;
    ReplaceAllButton := TButton.Create(Self);
    with ReplaceAllButton do begin
      Tag := 3;
      Left := 12;
      Height := 26;
      Top := 82;
      Width := 91;
      AutoSize := True;
      Caption := 'Replace all';
      Constraints.MinWidth := 91;
      Default := True;
      TabOrder := 2;
      Parent := PanelButtons;
    end;
    CancelButton := TButton.Create(Self);
    with CancelButton do begin
      Left := 12;
      Height := 26;
      Top := 122;
      Width := 91;
      AutoSize := True;
      Cancel := True;
      Caption := 'Cancel';
      Constraints.MinWidth := 91;
      ModalResult := 2;
      TabOrder := 1;
      Parent := PanelButtons;
    end;
    HelpButton := TButton.Create(Self);
    with HelpButton do begin
      Left := 12;
      Height := 26;
      Top := 158;
      Width := 91;
      AutoSize := True;
      Caption := 'Help';
      Constraints.MinWidth := 91;
      TabOrder := 3;
      Parent := PanelButtons;
    end;

    //EditFind.OnChange := @EditFindChange;
    SetLayout(Options);
end;

procedure TReplaceDialogForm.SetLayout(Options: TFindOptions);
var
  dlgWidth: Integer;
begin
  FButtonsBottom := frButtonsAtBottom in Options;
  if FButtonsBottom then begin
    if frShowHelp in Options then dlgWidth := 630
    else dlgWidth := 530;
    Height := 220;
    Width := dlgWidth;
    ClientHeight := 220;
    ClientWidth := dlgWidth;
    AutoSize := True;
    with PanelButtons do begin
      Left := 0;
      Height := 29;
      Top := 191;
      Width := dlgWidth;
      ClientHeight := 29;
      ClientWidth := dlgWidth;
      Align := alBottom;
      end;
    // Anchors
    TextLabel.AnchorSideLeft.Control := TControl(Owner);
    TextLabel.AnchorSideTop.Control := TControl(Owner);
    //TextLabel.Anchors := [akTop, akLeft];

    ReplaceLabel.AnchorSideLeft.Control := TextLabel;
    ReplaceLabel.AnchorSideTop.Control := TextLabel;
    ReplaceLabel.AnchorSideTop.Side := asrBottom;
    //ReplaceLabel.Anchors := [akTop, akLeft];

    EditFind.Width := 425;
    EditFind.AnchorSideLeft.Control := TextLabel;
    EditFind.AnchorSideLeft.Side := asrBottom;
    EditFind.AnchorSideTop.Control := TextLabel;
    EditFind.AnchorSideTop.Side := asrCenter;
    EditFind.AnchorSideRight.Control := TControl(Owner);
    EditFind.AnchorSideRight.Side := asrBottom;
    EditFind.Anchors := [akTop, akLeft, akRight];

    EditReplace.Width := 416;
    EditReplace.AnchorSideLeft.Control := ReplaceLabel;
    EditReplace.AnchorSideLeft.Side := asrBottom;
    EditReplace.AnchorSideTop.Control := ReplaceLabel;
    EditReplace.AnchorSideTop.Side := asrCenter;
    EditReplace.AnchorSideRight.Control := TControl(Owner);
    EditReplace.AnchorSideRight.Side := asrBottom;
    EditReplace.Anchors := [akTop, akLeft, akRight];

    //DirectionRadioGroup.Anchors := [akTop, akLeft];
    DirectionRadioGroup.AnchorSideLeft.Control := FlagPanel;
    DirectionRadioGroup.AnchorSideLeft.Side := asrBottom;
    DirectionRadioGroup.AnchorSideTop.Control := FlagPanel;

    FlagPanel.AnchorSideLeft.Control := TextLabel;
    FlagPanel.AnchorSideTop.Control := EditReplace;
    FlagPanel.AnchorSideTop.Side := asrBottom;
    FlagPanel.AnchorSideBottom.Side := asrBottom;

    FindMoreButton.Top := 0;
    FindMoreButton.Left := 439;
    FindMoreButton.AnchorSideTop.Control := PanelButtons;
    FindMoreButton.AnchorSideRight.Control := PanelButtons;
    FindMoreButton.AnchorSideRight.Side := asrBottom;
    FindMoreButton.Anchors := [akTop, akRight];
    FindMoreButton.BorderSpacing.Right := 6;

    ReplaceButton.Top := 0;
    ReplaceButton.Left := 309;
    ReplaceButton.BorderSpacing.Left := 12;
    ReplaceButton.AnchorSideLeft.Control := ReplaceAllButton;
    ReplaceButton.AnchorSideLeft.Side := asrBottom;
    ReplaceButton.AnchorSideTop.Control := PanelButtons;
    ReplaceButton.AnchorSideRight.Side := asrBottom;
    //ReplaceButton.Anchors := [akLeft,akTop];

    ReplaceAllButton.Top := 0;
    ReplaceAllButton.Left := 206;
    ReplaceAllButton.BorderSpacing.Left := 12;
    ReplaceAllButton.AnchorSideLeft.Control := CancelButton;
    ReplaceAllButton.AnchorSideLeft.Side := asrBottom;
    ReplaceAllButton.AnchorSideTop.Control := PanelButtons;
    ReplaceAllButton.AnchorSideRight.Side := asrBottom;
    //ReplaceAllButton.Anchors := [akLeft,akTop];

    CancelButton.Top := 0;
    CancelButton.Left := 103;
    CancelButton.BorderSpacing.Left := 12;
    CancelButton.AnchorSideLeft.Control := HelpButton;
    CancelButton.AnchorSideLeft.Side := asrBottom;
    CancelButton.AnchorSideTop.Control := PanelButtons;
    CancelButton.AnchorSideRight.Side := asrBottom;
    //CancelButton.Anchors := [akLeft,akTop];

    HelpButton.AnchorSideLeft.Control := PanelButtons;
    HelpButton.AnchorSideTop.Control := PanelButtons;
    HelpButton.AnchorSideRight.Control := PanelButtons;
    HelpButton.AnchorSideRight.Side := asrBottom;
    //HelpButton.Anchors := [akLeft,akRight,akTop];
    end
  else begin
    with PanelButtons do begin
      Height := 184;
      Top := 0;
      Width := 103;
      AutoSize := True;
      Align := alRight;
    end;
    // Anchors
    TextLabel.AnchorSideTop.Control := TControl(Owner);
    TextLabel.AnchorSideLeft.Control := TControl(Owner);

    ReplaceLabel.AnchorSideLeft.Control := TextLabel;
    ReplaceLabel.AnchorSideTop.Control := TextLabel;
    ReplaceLabel.AnchorSideTop.Side := asrBottom;

    EditFind.Anchors := [akTop, akLeft, akRight];
    EditFind.AnchorSideLeft.Control := TextLabel;
    EditFind.AnchorSideLeft.Side := asrBottom;
    EditFind.AnchorSideTop.Control := TextLabel;
    EditFind.AnchorSideTop.Side := asrCenter;
    EditFind.AnchorSideRight.Control := PanelButtons;

    EditReplace.Anchors := [akTop, akLeft, akRight];
    EditReplace.AnchorSideLeft.Control := ReplaceLabel;
    EditReplace.AnchorSideLeft.Side := asrBottom;
    EditReplace.AnchorSideTop.Control := ReplaceLabel;
    EditReplace.AnchorSideTop.Side := asrCenter;
    EditReplace.AnchorSideRight.Control := PanelButtons;

    DirectionRadioGroup.Anchors := [akTop, akLeft, akRight, akBottom];
    DirectionRadioGroup.AnchorSideLeft.Control := FlagPanel;
    DirectionRadioGroup.AnchorSideLeft.Side := asrBottom;
    DirectionRadioGroup.AnchorSideTop.Control := FlagPanel;
    DirectionRadioGroup.AnchorSideRight.Control := PanelButtons;
    DirectionRadioGroup.AnchorSideBottom.Control := FlagPanel;
    DirectionRadioGroup.AnchorSideBottom.Side := asrBottom;

    FlagPanel.AnchorSideLeft.Control := TextLabel;
    FlagPanel.AnchorSideTop.Control := ReplaceLabel;
    FlagPanel.AnchorSideTop.Side := asrBottom;

    FindMoreButton.BorderSpacing.Top := 10;
    FindMoreButton.Anchors := [akTop, akRight];
    FindMoreButton.AnchorSideTop.Control := PanelButtons;
    FindMoreButton.AnchorSideRight.Control := PanelButtons;
    FindMoreButton.AnchorSideRight.Side := asrBottom;

    ReplaceButton.BorderSpacing.Top := 10;
    ReplaceButton.AnchorSideLeft.Side := asrBottom;
    ReplaceButton.AnchorSideTop.Control := FindMoreButton;
    ReplaceButton.AnchorSideTop.Side := asrBottom;
    ReplaceButton.AnchorSideRight.Control := PanelButtons;
    ReplaceButton.AnchorSideRight.Side := asrBottom;
    ReplaceButton.Anchors := [akTop, akRight];

    ReplaceAllButton.BorderSpacing.Top := 10;
    ReplaceAllButton.AnchorSideLeft.Side := asrBottom;
    ReplaceAllButton.AnchorSideTop.Control := ReplaceButton;
    ReplaceAllButton.AnchorSideTop.Side := asrBottom;
    ReplaceAllButton.AnchorSideRight.Control := PanelButtons;
    ReplaceAllButton.AnchorSideRight.Side := asrBottom;
    ReplaceAllButton.Anchors := [akTop, akRight];

    CancelButton.BorderSpacing.Bottom := 10;
    CancelButton.AnchorSideLeft.Side := asrBottom;
    CancelButton.AnchorSideTop.Side := asrBottom;
    CancelButton.AnchorSideRight.Control := PanelButtons;
    CancelButton.AnchorSideRight.Side := asrBottom;
    CancelButton.AnchorSideBottom.Control := HelpButton;
    CancelButton.Anchors := [akRight, akBottom];

    HelpButton.AnchorSideLeft.Control := PanelButtons;
    HelpButton.AnchorSideRight.Control := PanelButtons;
    HelpButton.AnchorSideRight.Side := asrBottom;
    HelpButton.AnchorSideBottom.Control := PanelButtons;
    HelpButton.AnchorSideBottom.Side := asrBottom;
    HelpButton.Anchors := [akLeft, akRight, akBottom];
  end;
end;

{ TReplaceDialog }

procedure TReplaceDialog.ReplaceClick(Sender: TObject);
begin
  GetFormValues;
  //Delphi does it this way
  FOptions := FOptions + [frReplace] - [frReplaceAll, frFindNext];
  Replace;
end;

procedure TReplaceDialog.ReplaceAllClick(Sender: TObject);
begin
  GetFormValues;
  //Delphi does it this way
  FOptions := FOptions + [frReplaceAll] - [frFindNext, frReplace];
  Replace;
end;

function TReplaceDialog.CreateForm: TForm;
begin
  Result := TReplaceDialogForm.CreateNew(nil,Options);
  with TReplaceDialogForm(Result) do
  begin
    FindMoreButton.Caption := rsFindMore;
    ReplaceButton.Caption := rsReplace;
    ReplaceAllButton.Caption := rsReplaceAll;
    CancelButton.Caption := rsMbCancel;
    HelpButton.Caption := rsHelp;
    WholeWordsOnlyCheckBox.Caption := rsWholeWordsOnly;
    CaseSensitiveCheckBox.Caption := rsCaseSensitive;
    EntireScopeCheckBox.Caption := rsEntireScope;
    PromptOnReplaceCheckBox.Caption := rsPromptOnReplace;
    TextLabel.Caption := rsText;
    ReplaceLabel.Caption := rsReplace;
    DirectionRadioGroup.Caption := rsDirection;
    DirectionRadioGroup.Items[0] := rsForward;
    DirectionRadioGroup.Items[1] := rsBackward;
    if Result.Canvas.TextWidth(TextLabel.Caption) > Result.Canvas.TextWidth(ReplaceLabel.Caption) then
    begin
      EditReplace.AnchorSideLeft.Control := EditFind;
      EditReplace.AnchorSideLeft.Side := asrTop;
    end else begin
      EditFind.AnchorSideLeft.Control := EditReplace;
      EditFind.AnchorSideLeft.Side := asrTop;
    end;

    //Setting up button eventhandlers
    FindMoreButton.OnClick := @FindClick;
    ReplaceButton.OnClick := @ReplaceClick;
    ReplaceAllButton.OnClick := @ReplaceAllClick;
    CancelButton.OnClick := @CancelClick;
    HelpButton.OnClick := @HelpClick;
    PopupMode := pmAuto;
    // Init local property with default value
    Result.Top := FFormTop;
    Result.Left := FFormLeft;
  end;
end;

procedure TReplaceDialog.SetFormValues;
var
  dlg: TReplaceDialogForm;
begin
  dlg:=TReplaceDialogForm(FFindForm);
  dlg.EditFind.Text:=FFindText;
  Dlg.EditFind.SelectAll;
  Dlg.ActiveControl:=Dlg.EditFind;

  dlg.EditReplace.Text:=FReplaceText;

  dlg.WholeWordsOnlyCheckBox.Checked:=frWholeWord in Options;
  Dlg.EntireScopeCheckBox.Checked:=frEntireScope in Options;
  dlg.CaseSensitiveCheckBox.Checked:=frMatchCase in Options;
  dlg.PromptOnReplaceCheckBox.Checked := frPromptOnReplace in Options;
  Dlg.DirectionRadioGroup.ItemIndex:=ord(not(frDown in Options));

  dlg.WholeWordsOnlyCheckBox.Enabled:=not (frDisableWholeWord in Options);
  dlg.CaseSensitiveCheckBox.Enabled:=not (frDisableMatchCase in Options);
  dlg.DirectionRadioGroup.Enabled:=not (frDisableUpDown in Options);

  dlg.WholeWordsOnlyCheckBox.Visible:=not (frHideWholeWord in Options);
  dlg.CaseSensitiveCheckBox.Visible:=not (frHideMatchCase in Options);
  dlg.DirectionRadioGroup.Visible:=not (frHideUpDown in Options);
  dlg.HelpButton.Visible:=(frShowHelp in Options);
  Dlg.EntireScopeCheckBox.Visible := not (frHideEntireScope in Options);
  dlg.PromptOnReplaceCheckBox.Visible := not (frHidePromptOnReplace in Options);
end;

procedure TReplaceDialog.GetFormValues;
var
  Dlg: TReplaceDialogForm;
begin
  Dlg:=TReplaceDialogForm(FFindForm);
  if Dlg.DirectionRadioGroup.ItemIndex = 0 then
    FOptions:=FOptions + [frDown]
  else
    FOptions:=FOptions - [frDown];
  if Dlg.WholeWordsOnlyCheckBox.Checked then
    FOptions:=FOptions + [frWholeWord]
  else
    FOptions:=FOptions - [frWholeWord];
  if Dlg.CaseSensitiveCheckBox.Checked then
    FOptions:=FOptions + [frMatchCase]
  else
    FOptions:=FOptions - [frMatchCase];
  if Dlg.EntireScopeCheckBox.Checked then
    FOptions:=FOptions + [frEntireScope]
  else
    FOptions:=FOptions - [frEntireScope];
  if Dlg.PromptOnReplaceCheckBox.Checked then
    FOptions := FOptions + [frPromptOnReplace]
  else
    FOptions := FOptions - [frPromptOnReplace];
  FFindText := Dlg.EditFind.Text;
  FReplaceText := Dlg.EditReplace.Text;
end;

constructor TReplaceDialog.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FOptions += [frReplace, frReplaceAll, frHidePromptOnreplace];
end;

function TReplaceDialog.DefaultTitle: string; 
begin
  Result := rsReplace;
end;