-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathview.pas
99 lines (77 loc) · 1.95 KB
/
view.pas
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
unit View;
{$mode objfpc}{$H+}
interface
uses
Classes, Sysutils, Fileutil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ViewInterface;
type
{ Tform1 }
Tform1 = class(Tform, IView)
Button1 : Tbutton;
DateISOEdit : Tedit;
DateUnixEdit : Tedit;
Label1 : Tlabel;
Label2 : Tlabel;
procedure Button1Click(Sender : TObject);
procedure DateISOEditEditingDone(Sender : TObject);
procedure DateUnixEditEditingDone(Sender : TObject);
private
FOnCalculate : TNotifyEvent;
{ private declarations }
public
{ public declarations }
procedure SetISODate( Date : string );
function GetISODate : string;
procedure SetUnixDate( Date : integer );
function GetUnixDate : integer;
procedure SetOnCalculate( Func : TNotifyEvent );
function GetOnCalculate : TNotifyEvent;
property OnCalculate : TNotifyEvent read GetOnCalculate write SetOnCalculate;
end;
var
Form1 : Tform1;
implementation
{$R *.lfm}
{ Tform1 }
procedure Tform1.DateISOEditEditingDone(Sender : TObject);
begin
if DateISOEdit.Text <> '' then
DateUnixEdit.Text := '';
end;
procedure Tform1.Button1Click(Sender : TObject);
begin
if Assigned(OnCalculate) then
OnCalculate(self);
end;
procedure Tform1.DateUnixEditEditingDone(Sender : TObject);
begin
if DateUnixEdit.Text <> '' then
DateISOEdit.Text := '';
end;
procedure Tform1.SetISODate(Date : string);
begin
WriteLn('SetISODate ', Date);
DateISOEdit.Text := TCaption(Date);
end;
function Tform1.GetISODate : string;
begin
Result := DateISOEdit.Text;
end;
procedure Tform1.SetUnixDate(Date : integer);
begin
WriteLn('SetUnixDate ', Date);
DateUnixEdit.Text := TCaption(IntToStr(Date));
end;
function Tform1.GetUnixDate : integer;
begin
Result := StrToInt(DateUnixEdit.Text);
end;
procedure Tform1.SetOnCalculate(Func : TNotifyEvent);
begin
FOnCalculate := Func;
end;
function Tform1.GetOnCalculate : TNotifyEvent;
begin
Result := FOnCalculate;
end;
end.