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
|
unit frmAddressMaint;
{$mode objfpc}{$H+}
interface
uses
SysUtils, Classes, fpg_base, fpg_main, fpg_edit,
fpg_widget, fpg_form, fpg_label, fpg_button, fpg_combobox,
fpg_dialogs, fpg_menu,
model, tiModelMediator;
type
TAddressEditForm = class(TfpgForm)
private
{@VFD_HEAD_BEGIN: AddressEditForm}
cbType: TfpgComboBox;
edNo: TfpgEdit;
edStreet: TfpgEdit;
cbCity: TfpgComboBox;
edPhone1: TfpgEdit;
edPhone2: TfpgEdit;
edFax: TfpgEdit;
lblName1: TfpgLabel;
lblName2: TfpgLabel;
lblName3: TfpgLabel;
lblName4: TfpgLabel;
lblName5: TfpgLabel;
lblName6: TfpgLabel;
lblName7: TfpgLabel;
btnSave: TfpgButton;
btnCancel: TfpgButton;
{@VFD_HEAD_END: AddressEditForm}
FData: TAddress;
FMediator: TtiModelMediator;
procedure SetData(const AValue: TAddress);
procedure SetupMediators;
public
procedure AfterCreate; override;
property Data: TAddress read FData write SetData;
end;
{@VFD_NEWFORM_DECL}
function EditAddress(AData: TAddress): Boolean;
implementation
uses
contactmanager;
function EditAddress(AData: TAddress): Boolean;
var
frm: TAddressEditForm;
begin
frm:= TAddressEditForm.Create(nil);
try
frm.SetData(AData);
result:= frm.ShowModal = mrOK;
finally
frm.Free;
end;
end;
{@VFD_NEWFORM_IMPL}
procedure TAddressEditForm.SetData(const AValue: TAddress);
begin
if FData=AValue then exit;
FData:=AValue;
SetupMediators;
end;
procedure TAddressEditForm.SetupMediators;
begin
if not Assigned(FMediator) then
begin
FMediator := TtiModelMediator.Create(self);
FMediator.AddProperty('AddressType', cbType).ValueList := gContactManager.AddressTypeList;
FMediator.AddProperty('Nr', edNo);
FMediator.AddProperty('Street', edStreet);
FMediator.AddProperty('City', cbCity).ValueList := gContactManager.CityList;
FMediator.AddProperty('Telephone1', edPhone1);
FMediator.AddProperty('Telephone2', edPhone2);
FMediator.AddProperty('Fax', edFax);
end;
FMediator.Subject := FData;
FMediator.Active := True;
end;
procedure TAddressEditForm.AfterCreate;
begin
{@VFD_BODY_BEGIN: AddressEditForm}
Name := 'AddressEditForm';
SetPosition(300, 231, 296, 282);
WindowTitle := 'Address Edit Form';
cbType := TfpgComboBox.Create(self);
with cbType do
begin
Name := 'cbType';
SetPosition(8, 24, 272, 22);
FontDesc := '#List';
end;
edNo := TfpgEdit.Create(self);
with edNo do
begin
Name := 'edNo';
SetPosition(8, 68, 56, 22);
TabOrder := 1;
Text := '';
FontDesc := '#Edit1';
end;
edStreet := TfpgEdit.Create(self);
with edStreet do
begin
Name := 'edStreet';
SetPosition(76, 68, 204, 22);
TabOrder := 2;
Text := '';
FontDesc := '#Edit1';
end;
cbCity := TfpgComboBox.Create(self);
with cbCity do
begin
Name := 'cbCity';
SetPosition(8, 112, 272, 22);
FontDesc := '#List';
TabOrder := 3;
end;
edPhone1 := TfpgEdit.Create(self);
with edPhone1 do
begin
Name := 'edPhone1';
SetPosition(8, 160, 120, 22);
TabOrder := 4;
Text := '';
FontDesc := '#Edit1';
end;
edPhone2 := TfpgEdit.Create(self);
with edPhone2 do
begin
Name := 'edPhone2';
SetPosition(160, 160, 120, 22);
TabOrder := 5;
Text := '';
FontDesc := '#Edit1';
end;
edFax := TfpgEdit.Create(self);
with edFax do
begin
Name := 'edFax';
SetPosition(8, 204, 120, 22);
TabOrder := 6;
Text := '';
FontDesc := '#Edit1';
end;
lblName1 := TfpgLabel.Create(self);
with lblName1 do
begin
Name := 'lblName1';
SetPosition(76, 52, 120, 16);
FontDesc := '#Label1';
Hint := '';
Text := 'Street:';
end;
lblName2 := TfpgLabel.Create(self);
with lblName2 do
begin
Name := 'lblName2';
SetPosition(8, 52, 60, 16);
FontDesc := '#Label1';
Hint := '';
Text := 'Number:';
end;
lblName3 := TfpgLabel.Create(self);
with lblName3 do
begin
Name := 'lblName3';
SetPosition(8, 144, 120, 16);
FontDesc := '#Label1';
Hint := '';
Text := 'Telephone #1:';
end;
lblName4 := TfpgLabel.Create(self);
with lblName4 do
begin
Name := 'lblName4';
SetPosition(160, 144, 112, 16);
FontDesc := '#Label1';
Hint := '';
Text := 'Telephone #2:';
end;
lblName5 := TfpgLabel.Create(self);
with lblName5 do
begin
Name := 'lblName5';
SetPosition(8, 188, 80, 16);
FontDesc := '#Label1';
Hint := '';
Text := 'Fax:';
end;
lblName6 := TfpgLabel.Create(self);
with lblName6 do
begin
Name := 'lblName6';
SetPosition(8, 8, 80, 16);
FontDesc := '#Label1';
Hint := '';
Text := 'Type:';
end;
lblName7 := TfpgLabel.Create(self);
with lblName7 do
begin
Name := 'lblName7';
SetPosition(8, 96, 80, 16);
FontDesc := '#Label1';
Hint := '';
Text := 'City:';
end;
btnSave := TfpgButton.Create(self);
with btnSave do
begin
Name := 'btnSave';
SetPosition(124, 248, 80, 24);
Text := 'Save';
FontDesc := '#Label1';
Hint := '';
ImageName := '';
TabOrder := 7;
ModalResult := mrOK;
end;
btnCancel := TfpgButton.Create(self);
with btnCancel do
begin
Name := 'btnCancel';
SetPosition(208, 248, 80, 24);
Text := 'Cancel';
FontDesc := '#Label1';
Hint := '';
ImageName := '';
TabOrder := 8;
ModalResult := mrCancel;
end;
{@VFD_BODY_END: AddressEditForm}
end;
end.
|