summaryrefslogtreecommitdiff
path: root/plugins/Chess4Net/ContinueUnit.pas
blob: d6a38a662fb0da22e25e851fc0b704a57a95c17d (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
////////////////////////////////////////////////////////////////////////////////
// All code below is exclusively owned by author of Chess4Net - Pavel Perminov
// (packpaul@mail.ru, packpaul1@gmail.com).
// Any changes, modifications, borrowing and adaptation are a subject for
// explicit permition from the owner.

unit ContinueUnit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  {Dialogs, }ExtCtrls, StdCtrls, TntStdCtrls,
  DialogUnit, ModalForm;

type
  TContinueHandler = procedure of object;

  TContinueForm = class(TModalForm)
    ContinueButton: TTntButton;
    ContinueLabel: TTntLabel;
    procedure ContinueButtonClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
//  dlgOwner: TDialogs;
    ContinueHandler: TContinueHandler;
    shuted: boolean;
    procedure FLocalize;
  protected
    function GetModalID: TModalFormID; override;  
  public
    procedure Shut;
    constructor Create(Owner: TForm; h: TContinueHandler = nil); reintroduce; overload;
//    constructor Create(dlgOwner: TDialogs; h: TContinueHandler); reintroduce; overload;
  end;

implementation

{$R *.dfm}

uses
  GlobalsUnit, LocalizerUnit;

////////////////////////////////////////////////////////////////////////////////
// TContinueForm

procedure TContinueForm.ContinueButtonClick(Sender: TObject);
begin
  Close;
end;


procedure TContinueForm.FormShow(Sender: TObject);
var
  frmOwner: TForm;
begin
  frmOwner := (Owner as TForm);
  Left:= frmOwner.Left + (frmOwner.Width - Width) div 2;
  Top:= frmOwner.Top + (frmOwner.Height - Height) div 2;
end;


constructor TContinueForm.Create(Owner: TForm; h: TContinueHandler = nil);
begin
  self.FormStyle := Owner.FormStyle;
  inherited Create(Owner);
  shuted := FALSE;
  ContinueHandler := h;
end;


procedure TContinueForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  if not shuted then
    begin
      ModalResult := ContinueButton.ModalResult;
      if Assigned(ContinueHandler) then
        ContinueHandler;
    end
  else
    ModalResult := mrNone;
end;


procedure TContinueForm.Shut;
begin
  shuted:= TRUE;
  Close;
end;


function TContinueForm.GetModalID: TModalFormID;
begin
  Result := mfContinue;
end;


procedure TContinueForm.FormCreate(Sender: TObject);
begin
  Caption := DIALOG_CAPTION;
  FLocalize;
end;


procedure TContinueForm.FLocalize;
begin
  with TLocalizer.Instance do
  begin
    ContinueLabel.Caption := GetLabel(22);
    ContinueButton.Caption := GetLabel(23);
  end;
end;

end.