-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.pas
295 lines (250 loc) · 8.08 KB
/
gui.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
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
{ Triangolo }
{ Version 1.0 (Agavi) }
{ (c) Johannes W. Dietrich, 2012 - 2020 }
{ (c) Ruhr University of Bochum 2012 - 2020 }
{ GUI }
{ Source code released under the BSD License }
{ See the file "license.txt", included in this distribution, }
{ for details about the copyright. }
{ Current versions and additional information are available from }
{ http://triangolo.sf.net }
{ This program is distributed in the hope that it will be useful, }
{ but WITHOUT ANY WARRANTY; without even the implied warranty of }
{ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. }
unit GUI;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Spin, StdCtrls,
ExtCtrls, ComCtrls, Menus, DividerBevel, LCLType, ActnList, StdActns, Buttons,
Calculator, AboutWindow;
const
ResearchWarning1 = 'This version of Triangolo is provided for research use only. Usage for medical decision making is currently not recommended and is in any case on your own risk.';
ResearchWarning2 = 'Diese Version von Triangolo ist nur für Forschungszwecke bestimmt. Die Verwendung für medizinische Entscheidungen wird derzeit nicht empfohlen und geschieht in jedem Falle auf Ihre Verantwortung.';
type
{ TTriangoloMainForm }
TTriangoloMainForm = class(TForm)
ActionList1: TActionList;
AppleMenu: TMenuItem;
CloseMenuItem: TMenuItem;
CopyMenuItem: TMenuItem;
CutMenuItem: TMenuItem;
Divider11: TMenuItem;
Divider12: TMenuItem;
Divider21: TMenuItem;
DividerBevel1: TDividerBevel;
EditCopy1: TEditCopy;
EditCut1: TEditCut;
EditDelete1: TEditDelete;
EditMenu: TMenuItem;
EditPaste1: TEditPaste;
EditSelectAll1: TEditSelectAll;
EditUndo1: TEditUndo;
FileMenu: TMenuItem;
FinalLT4DoseEdit: TEdit;
FinalLT3DoseEdit: TEdit;
FinalLT4DoseGroupBox: TGroupBox;
FinalLT3DoseGroupBox: TGroupBox;
FinalLT4DoseLabel: TLabel;
FinalLT3DoseLabel: TLabel;
FinalLT4UnitLabel1: TLabel;
FinalLT3UnitLabel: TLabel;
HelpMenu: TMenuItem;
HintGroupBox: TGroupBox;
LogoImage: TImage;
MacAboutItem: TMenuItem;
MainMenu1: TMainMenu;
RecommendationMemo: TMemo;
MethodLabel: TLabel;
MethodComboBox: TComboBox;
IntialLT4UnitLabel: TLabel;
InitialLT4DoseLabel: TLabel;
NewMenuItem: TMenuItem;
OpenMenuItem: TMenuItem;
ParameterGroupBox: TGroupBox;
PasteMenuItem: TMenuItem;
QuitMenuItem: TMenuItem;
RedoMenuItem: TMenuItem;
SaveMenuItem: TMenuItem;
InitialLT4DoseSpinEdit: TSpinEdit;
StatusBar1: TStatusBar;
UndoMenuItem: TMenuItem;
WinAboutItem: TMenuItem;
procedure AdaptForPlatform;
procedure CalculateButtonClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Go(Sender: TObject);
procedure CloseMenuItemClick(Sender: TObject);
procedure EditCopy1Execute(Sender: TObject);
procedure EditCut1Execute(Sender: TObject);
procedure EditDelete1Execute(Sender: TObject);
procedure EditPaste1Execute(Sender: TObject);
procedure EditSelectAll1Execute(Sender: TObject);
procedure EditUndo1Execute(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure InitialLT4DoseFloatSpinEditChange(Sender: TObject);
procedure InitialLT4DoseFloatSpinEditEditingDone(Sender: TObject);
procedure InitialLT4DoseFloatSpinEditEnter(Sender: TObject);
procedure InitialLT4DoseSpinEditChange(Sender: TObject);
procedure InitialLT4DoseSpinEditEditingDone(Sender: TObject);
procedure InitialLT4DoseSpinEditEnter(Sender: TObject);
procedure LogoImageClick(Sender: TObject);
procedure MacAboutItemClick(Sender: TObject);
procedure MethodComboBoxChange(Sender: TObject);
procedure QuitMenuItemClick(Sender: TObject);
procedure CalculateSpeedButtonClick(Sender: TObject);
procedure WinAboutItemClick(Sender: TObject);
private
public
Recommendation: TDoseRecord;
end;
var
TriangoloMainForm: TTriangoloMainForm;
implementation
{$R *.lfm}
{ TTriangoloMainForm }
procedure TTriangoloMainForm.AdaptForPlatform;
{ Adapts Menus and Shortcuts to the interface style guidelines
of the respective operating system }
var
modifierKey: TShiftState;
begin
{$IFDEF LCLcarbon}
modifierKey := [ssMeta];
WinAboutItem.Visible := False;
AppleMenu.Visible := True;
{$ELSE}
{$IFDEF LCLCocoa}
modifierKey := [ssMeta];
WinAboutItem.Visible := False;
AppleMenu.Visible := True;
Color := clDefault;
InitialLT4DoseSpinEdit.Color := clDefault;
FinalLT4DoseEdit.Color := clDefault;
FinalLT3DoseEdit.Color := clDefault;
{$ELSE}
modifierKey := [ssCtrl];
WinAboutItem.Visible := True;
AppleMenu.Visible := False;
{$ENDIF}
{$ENDIF}
NewMenuItem.ShortCut := ShortCut(VK_N, modifierKey);
OpenMenuItem.ShortCut := ShortCut(VK_O, modifierKey);
CloseMenuItem.ShortCut := ShortCut(VK_W, modifierKey);
SaveMenuItem.ShortCut := ShortCut(VK_S, modifierKey);
QuitMenuItem.ShortCut := ShortCut(VK_Q, modifierKey);
UndoMenuItem.ShortCut := ShortCut(VK_Z, modifierKey);
RedoMenuItem.ShortCut := ShortCut(VK_Z, modifierKey + [ssShift]);
CutMenuItem.ShortCut := ShortCut(VK_X, modifierKey);
CopyMenuItem.ShortCut := ShortCut(VK_C, modifierKey);
PasteMenuItem.ShortCut := ShortCut(VK_V, modifierKey);
end;
procedure TTriangoloMainForm.CalculateButtonClick(Sender: TObject);
begin
Go(Sender);
end;
procedure TTriangoloMainForm.FormShow(Sender: TObject);
var
WarningString: String;
begin
WarningString := ResearchWarning1 + LineEnding + LineEnding + ResearchWarning2;
ShowMessage(WarningString);
end;
procedure TTriangoloMainForm.Go(Sender: TObject);
var
selectedMethod: TMethod;
begin
case MethodComboBox.ItemIndex of
0: selectedMethod := ETA_A;
1: selectedMethod := ETA_B1;
2: selectedMethod := ETA_B2;
3: selectedMethod := ETA_C;
otherwise
selectedMethod := None;
end;
Recommendation := FinalDose(InitialLT4DoseSpinEdit.Value, selectedMethod);
FinalLT4DoseEdit.Text := FloatToStrF(Recommendation.LT4Dose, ffNumber, 1, 1);
FinalLT3DoseEdit.Text := FloatToStrF(Recommendation.LT3Dose, ffNumber, 1, 1);
end;
procedure TTriangoloMainForm.CloseMenuItemClick(Sender: TObject);
begin
QuitMenuItemClick(Sender);
end;
procedure TTriangoloMainForm.EditCopy1Execute(Sender: TObject);
begin
InitialLT4DoseSpinEdit.CopyToClipboard;
end;
procedure TTriangoloMainForm.EditCut1Execute(Sender: TObject);
begin
InitialLT4DoseSpinEdit.Clear;
end;
procedure TTriangoloMainForm.EditDelete1Execute(Sender: TObject);
begin
InitialLT4DoseSpinEdit.Clear;
end;
procedure TTriangoloMainForm.EditPaste1Execute(Sender: TObject);
begin
InitialLT4DoseSpinEdit.PasteFromClipboard;
end;
procedure TTriangoloMainForm.EditSelectAll1Execute(Sender: TObject);
begin
InitialLT4DoseSpinEdit.SelectAll;
end;
procedure TTriangoloMainForm.EditUndo1Execute(Sender: TObject);
begin
InitialLT4DoseSpinEdit.Undo;
end;
procedure TTriangoloMainForm.FormCreate(Sender: TObject);
begin
AdaptForPlatform;
end;
procedure TTriangoloMainForm.InitialLT4DoseFloatSpinEditChange(Sender: TObject);
begin
Go(Sender);
end;
procedure TTriangoloMainForm.InitialLT4DoseFloatSpinEditEditingDone(
Sender: TObject);
begin
Go(Sender);
end;
procedure TTriangoloMainForm.InitialLT4DoseFloatSpinEditEnter(Sender: TObject);
begin
Go(Sender);
end;
procedure TTriangoloMainForm.InitialLT4DoseSpinEditChange(Sender: TObject);
begin
Go(Sender);
end;
procedure TTriangoloMainForm.InitialLT4DoseSpinEditEditingDone(Sender: TObject);
begin
Go(Sender);
end;
procedure TTriangoloMainForm.InitialLT4DoseSpinEditEnter(Sender: TObject);
begin
Go(Sender);
end;
procedure TTriangoloMainForm.LogoImageClick(Sender: TObject);
begin
AboutForm.ShowModal;
end;
procedure TTriangoloMainForm.MacAboutItemClick(Sender: TObject);
begin
AboutForm.ShowModal;
end;
procedure TTriangoloMainForm.MethodComboBoxChange(Sender: TObject);
begin
Go(Sender);
end;
procedure TTriangoloMainForm.QuitMenuItemClick(Sender: TObject);
begin
application.Terminate;
end;
procedure TTriangoloMainForm.CalculateSpeedButtonClick(Sender: TObject);
begin
Go(Sender);
end;
procedure TTriangoloMainForm.WinAboutItemClick(Sender: TObject);
begin
MacAboutItemClick(Sender);
end;
end.