source: cprs/trunk/CPRS-Chart/fGraphSettings.pas@ 1800

Last change on this file since 1800 was 1679, checked in by healthsevak, 10 years ago

Updating the working copy to CPRS version 28

File size: 27.8 KB
Line 
1unit fGraphSettings;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 ComCtrls, StdCtrls, ExtCtrls, CheckLst, Math, ORCtrls, ORFn, uCore, uGraphs, fBase508Form,
8 VA508AccessibilityManager;
9
10type
11 TfrmGraphSettings = class(TfrmBase508Form)
12 brnClear: TButton;
13 btnAll: TButton;
14 btnClose: TButton;
15 btnPersonal: TButton;
16 btnPersonalSave: TButton;
17 btnPublic: TButton;
18 btnPublicSave: TButton;
19 bvlBase: TBevel;
20 bvlDefaults: TBevel;
21 cboConversions: TORComboBox;
22 chklstOptions: TCheckListBox;
23 lblConversions: TLabel;
24 lblMaxGraphs: TLabel;
25 lblMaxGraphsRef: TLabel;
26 lblMaxSelect: TLabel;
27 lblMaxSelectRef: TLabel;
28 lblMinGraphHeight: TLabel;
29 lblMinGraphHeightRef: TLabel;
30 lblOptions: TLabel;
31 lblOptionsInfo: TLabel;
32 lblSave: TLabel;
33 lblShow: TLabel;
34 lblSources: TLabel;
35 lstATypes: TListBox;
36 lstSources: TCheckListBox;
37 lstSourcesCopy: TListBox;
38 spnMaxGraphs: TUpDown;
39 spnMaxSelect: TUpDown;
40 spnMinGraphHeight: TUpDown;
41 txtMaxGraphs: TEdit;
42 txtMaxSelect: TEdit;
43 txtMinGraphHeight: TEdit;
44 bvlMid: TBevel;
45 lstOptions: TListBox;
46 cboDateRangeOutpatient: TORComboBox;
47 cboDateRangeInpatient: TORComboBox;
48 lblOutpatient: TLabel;
49 lblInpatient: TLabel;
50 procedure FormCreate(Sender: TObject);
51 procedure FormShow(Sender: TObject);
52 procedure btnAllClick(Sender: TObject);
53 procedure btnCloseClick(Sender: TObject);
54 procedure btnPublicClick(Sender: TObject);
55 procedure CheckSetting(setting: string; turnon: boolean);
56 procedure chklstOptionsClickCheck(Sender: TObject);
57 procedure SaveClick(Sender: TObject);
58 procedure spnMaxGraphsClick(Sender: TObject; Button: TUDBtnType);
59 procedure txtMaxGraphsChange(Sender: TObject);
60 procedure txtMaxGraphsExit(Sender: TObject);
61 procedure txtMaxGraphsKeyPress(Sender: TObject; var Key: Char);
62 procedure spnMinGraphHeightClick(Sender: TObject; Button: TUDBtnType);
63 procedure spnMaxSelectClick(Sender: TObject; Button: TUDBtnType);
64 procedure txtMinGraphHeightChange(Sender: TObject);
65 procedure txtMaxSelectChange(Sender: TObject);
66 procedure txtMinGraphHeightExit(Sender: TObject);
67 procedure txtMaxSelectExit(Sender: TObject);
68 procedure txtMinGraphHeightKeyPress(Sender: TObject; var Key: Char);
69 procedure txtMaxSelectKeyPress(Sender: TObject; var Key: Char);
70 procedure AssignHints;
71 function DisplaySettings: string;
72 procedure FormClose(Sender: TObject; var Action: TCloseAction);
73
74 private
75 FHintPauseTime: integer;
76 public
77 procedure wmNCLButtonDown(var Msg: TWMNCLButtonDown); message WM_NCLBUTTONDOWN;
78 procedure ChangeSettings(aGraphSetting: TGraphSetting);
79 procedure ChangeSources(DisplaySource: TStrings);
80 procedure Conversion(conv: integer);
81 procedure SetSettings(aGraphSetting: TGraphSetting);
82 procedure SetSources(aList, DisplaySource: TStrings);
83 procedure GetTypeList(aList: TStrings);
84 end;
85
86var
87 frmGraphSettings: TfrmGraphSettings;
88
89 procedure DialogOptionsGraphSettings(topvalue, leftvalue, fontsize: integer;
90 var actiontype: boolean);
91 procedure DialogGraphSettings(fontsize: integer; var okbutton: boolean;
92 aGraphSetting: TGraphSetting; DisplaySource: TStrings; var conv: integer; var aSettings: string);
93 function FileNameX(filenum: string): string;
94
95implementation
96
97{$R *.DFM}
98
99uses
100 rGraphs, fGraphData, VAUtils;
101
102var
103 FPersonalSettings, FPublicSettings, FCloseSettings: string;
104
105procedure DialogOptionsGraphSettings(topvalue, leftvalue, fontsize: integer;
106 var actiontype: boolean);
107var
108 FGraphSetting: TGraphSetting;
109 FSources, AllTypes: TStrings;
110 i, conv: integer;
111 aSettings, dfntype, listline, settings, settings1: string;
112begin
113 settings := GetCurrentSetting;
114 settings1 := GetPublicSetting;
115 if settings1 = '' then
116 begin
117 ShowMsg(TXT_NOGRAPHING);
118 exit;
119 end;
120 settings1 := Piece(settings, '|', 1);
121 Alltypes := TStringList.Create;
122 FastAssign(GtslAllTypes, AllTypes);
123 for i := 0 to AllTypes.Count - 1 do
124 begin
125 listline := AllTypes[i];
126 dfntype := UpperCase(Piece(listline, '^', 1));
127 SetPiece(listline, '^', 1, dfntype);
128 AllTypes[i] := listline;
129 end;
130 FGraphSetting := GraphSettingsInit(settings);
131 FSources := TStringList.Create;
132 for i := 0 to BIG_NUMBER do
133 begin
134 dfntype := Piece(settings1, ';', i);
135 if length(dfntype) = 0 then break;
136 listline := dfntype + '^' + FileNameX(dfntype) + '^1';
137 FSources.Add(listline);
138 end;
139 conv := BIG_NUMBER; // indicates being called from Options
140 DialogGraphSettings(fontsize, actiontype, FGraphSetting, FSources, conv, aSettings);
141 FGraphSetting.Free;
142 FSources.Free;
143 AllTypes.Free;
144end;
145
146procedure DialogGraphSettings(fontsize: integer; var okbutton: boolean;
147 aGraphSetting: TGraphSetting; DisplaySource: TStrings; var conv: integer; var aSettings: string);
148var
149 t1, t2: string;
150 aList: TStrings;
151 frmGraphSettings: TfrmGraphSettings;
152begin
153 FCloseSettings := '';
154 okbutton := false;
155 aSettings := '';
156 aList := TStringList.Create;
157 frmGraphSettings := TfrmGraphSettings.Create(Application);
158 try
159 with frmGraphSettings do
160 begin
161 if displaysource.Count > 99999 then exit;
162 FastAssign(rpcGetGraphDateRange('OR_GRAPHS'), cboDateRangeOutpatient.Items);
163 if cboDateRangeOutpatient.Items.Count > 0 then
164 cboDateRangeOutpatient.Items.Delete(0);
165 FastAssign(cboDateRangeOutpatient.Items, cboDateRangeInpatient.Items);
166 FastAssign(rpcGetGraphSettings, aList);
167 t1 := GetPersonalSetting; t2 := GetPublicSetting; // t1 are personal, t2 public settings
168 FPersonalSettings := t1;
169 FPublicSettings := t2;
170 GetTypeList(aList);
171 SetSources(aList, DisplaySource);
172 SetSettings(aGraphSetting);
173 with spnMaxGraphs do
174 lblMaxGraphsRef.Caption := inttostr(Min) + ' to ' + inttostr(Max);
175 with spnMinGraphHeight do
176 lblMinGraphHeightRef.Caption := inttostr(Min) + ' to ' + inttostr(Max);
177 with spnMaxSelect do
178 lblMaxSelectRef.Caption := inttostr(Min) + ' to ' + inttostr(Max);
179 Conversion(conv);
180 ResizeAnchoredFormToFont(frmGraphSettings);
181 ShowModal;
182 okbutton := (btnClose.Tag = 1);
183 if okbutton then
184 begin
185 aSettings := FCloseSettings;
186 conv := cboConversions.ItemIndex;
187 ChangeSources(DisplaySource);
188 ChangeSettings(aGraphSetting);
189 end;
190 end;
191 finally
192 frmGraphSettings.Release;
193 aList.Free;
194 end;
195end;
196
197procedure TfrmGraphSettings.ChangeSettings(aGraphSetting: TGraphSetting);
198var
199 turnon: boolean;
200 i : integer;
201 value: string;
202begin
203 with aGraphSetting do
204 begin
205 MaxGraphs := spnMaxGraphs.Position;
206 MinGraphHeight := spnMinGraphHeight.Position;
207 MaxSelect := spnMaxSelect.Position;
208 MaxSelectMin := 1;
209 OptionSettings := '';
210 with chklstOptions do
211 for i := 0 to Items.Count - 1 do
212 begin
213 value := Piece(lstOptions.Items[i], '^', 2);
214 turnon := Checked[i];
215 if turnon then OptionSettings := OptionSettings + value;
216 if value = SETTING_VALUES then Values := turnon
217 else if value = SETTING_VZOOM then VerticalZoom := turnon
218 else if value = SETTING_HZOOM then HorizontalZoom := turnon
219 else if value = SETTING_3D then View3D := turnon
220 else if value = SETTING_LEGEND then Legend := turnon
221 else if value = SETTING_LINES then Lines := turnon
222 else if value = SETTING_DATES then Dates := turnon
223 else if value = SETTING_SORT then SortByType := turnon
224 else if value = SETTING_CLEAR then ClearBackground := turnon
225 else if value = SETTING_GRADIENT then Gradient := turnon
226 else if value = SETTING_HINTS then Hints := turnon
227 else if value = SETTING_FIXED then FixedDateRange := turnon
228 else if value = SETTING_TURBO then Turbo := turnon
229 else if value = SETTING_TOP then StayOnTop := turnon;
230 end;
231 if SortByType then SortColumn := 1 else SortColumn := 0;
232 DateRangeOutpatient := cboDateRangeOutpatient.ItemID;
233 DateRangeInpatient := cboDateRangeInpatient.ItemID;
234 end;
235end;
236
237procedure TfrmGraphSettings.ChangeSources(DisplaySource: TStrings);
238var
239 needtoadd: boolean;
240 i, j : integer;
241 filename, filenum, dsitem, dsnum: string;
242begin
243 with lstSources do
244 begin
245 for i := 0 to Items.Count - 1 do
246 begin
247 needtoadd := false;
248 if Checked[i] then
249 needtoadd := true;
250 filename := Piece(lstSourcesCopy.Items[i], '^', 1);
251 filenum := Piece(lstSourcesCopy.Items[i], '^', 2);
252 for j := 0 to DisplaySource.Count - 1 do
253 begin
254 dsitem := DisplaySource[j];
255 dsnum := Piece(dsitem, '^', 1);
256 if filenum = dsnum then
257 begin
258 needtoadd := false;
259 if Checked[i] then
260 DisplaySource[j] := filenum + '^' + filename + '^1'
261 else
262 DisplaySource[j] := filenum + '^' + filename + '^0';
263 break;
264 end;
265 end;
266 if needtoadd then
267 DisplaySource.Add('*^' + filenum + '^' + filename + '^1');
268 end;
269 end;
270end;
271
272procedure TfrmGraphSettings.Conversion(conv: integer);
273begin
274 if conv = BIG_NUMBER then
275 begin
276 lblOptionsInfo.Visible := true;
277 frmGraphSettings.Caption := 'Graph Settings - Defaults Only';
278 lblConversions.Enabled := false;
279 cboConversions.Enabled := false;
280 cboConversions.ItemIndex := 0;
281 cboConversions.Text := '';
282 end
283 else
284 with cboConversions do
285 begin
286 lblOptionsInfo.Visible := false;
287 frmGraphSettings.Caption := 'Graph Settings';
288 if btnPublicSave.Enabled = true then
289 begin
290 lblConversions.Enabled := true;
291 Enabled := true;
292 ItemIndex := conv;
293 Text := Items[ItemIndex];
294 end
295 else
296 begin
297 lblConversions.Enabled := false;
298 cboConversions.Enabled := false;
299 cboConversions.ItemIndex := 0;
300 cboConversions.Text := '';
301 end;
302 end;
303end;
304
305procedure TfrmGraphSettings.SetSettings(aGraphSetting: TGraphSetting);
306var
307 i : integer;
308 value: string;
309begin
310 with aGraphSetting do
311 begin
312 OptionSettings := '';
313 if Values then OptionSettings := OptionSettings + SETTING_VALUES;
314 if VerticalZoom then OptionSettings := OptionSettings + SETTING_VZOOM;
315 if HorizontalZoom then OptionSettings := OptionSettings + SETTING_HZOOM;
316 if View3D then OptionSettings := OptionSettings + SETTING_3D;
317 if Legend then OptionSettings := OptionSettings + SETTING_LEGEND;
318 if Lines then OptionSettings := OptionSettings + SETTING_LINES;
319 if Dates then OptionSettings := OptionSettings + SETTING_DATES;
320 if SortByType then OptionSettings := OptionSettings + SETTING_SORT;
321 if ClearBackground then OptionSettings := OptionSettings + SETTING_CLEAR;
322 if Gradient then OptionSettings := OptionSettings + SETTING_GRADIENT;
323 if Hints then OptionSettings := OptionSettings + SETTING_HINTS;
324 if StayOnTop then OptionSettings := OptionSettings + SETTING_TOP;
325 if FixedDateRange then OptionSettings := OptionSettings + SETTING_FIXED;
326 spnMaxGraphs.Position := MaxGraphs;
327 spnMinGraphHeight.Position := MinGraphHeight;
328 MaxSelect := Min(MaxSelectMax, MaxSelect);
329 if MaxSelect < MaxSelectMin then
330 MaxSelect := MaxSelectMin;
331 spnMaxSelect.Position := MaxSelect;
332 spnMaxSelect.Min := MaxSelectMin;
333 spnMaxSelect.Max := MaxSelectMax;
334 cboDateRangeOutpatient.SelectByID(DateRangeOutpatient);
335 cboDateRangeInpatient.SelectByID(DateRangeInpatient);
336 if SortByType then SortColumn := 1 else SortColumn := 0;
337 lstOptions.Tag := SortColumn;
338 if (SortColumn > 0) then
339 if Pos(SETTING_SORT, OptionSettings) = 0 then
340 OptionSettings := OptionSettings + SETTING_SORT;
341 if Turbo then
342 OptionSettings := OptionSettings + SETTING_TURBO;
343 if GraphPublicEditor or GraphTurboOn then
344 begin
345 lstOptions.Items.Add('Turbo^N');
346 chklstOptions.Items.Add('Turbo');
347 end;
348 for i := 0 to lstOptions.Items.Count - 1 do
349 begin
350 value := Piece(lstOptions.Items[i], '^', 2);
351 chklstOptions.Checked[i] := Pos(value, OptionSettings) > 0;
352 end;
353 end;
354end;
355
356procedure TfrmGraphSettings.SetSources(aList, DisplaySource: TStrings);
357var
358 i, j : integer;
359 listitem, filenum, filename, dsitem, dsnum, dsdisplay: string;
360begin
361 with lstSources.Items do
362 begin
363 Clear;
364 lstSourcesCopy.Items.Clear;
365 for i := 0 to aList.Count - 1 do
366 begin
367 listitem := aList[i];
368 filenum := Piece(listitem, '^', 1);
369 filename := Piece(listitem, '^', 2);
370 Add(filename);
371 lstSourcesCopy.Items.Add(filename + '^' + filenum);
372 end;
373 with lstSourcesCopy do
374 for i := 0 to Items.Count - 1 do
375 begin
376 listitem := Items[i];
377 filenum := Piece(listitem, '^', 2);
378 for j := 0 to DisplaySource.Count - 1 do
379 begin
380 dsitem := DisplaySource[j];
381 dsnum := Piece(dsitem, '^', 1);
382 dsdisplay := Piece(dsitem, '^', 3);
383 if filenum = dsnum then
384 begin
385 if dsdisplay = '1' then
386 lstSources.Checked[i] := true;
387 break;
388 end;
389 end;
390 end;
391 end;
392end;
393
394procedure TfrmGraphSettings.GetTypeList(aList: TStrings);
395var
396 i : integer;
397 dfntype, listline : string;
398begin
399 FastAssign(GtslAllTypes, aList);
400 for i := 0 to aList.Count -1 do
401 begin
402 listline := aList[i];
403 dfntype := UpperCase(Piece(listline, '^', 1));
404 SetPiece(listline, '^', 1, dfntype);
405 aList[i] := listline;
406 end;
407end;
408
409function FileNameX(filenum: string): string;
410var
411 i: integer;
412 typestring: string;
413 AllTypes: TStrings;
414begin
415 Result := '';
416 Alltypes := TStringList.Create;
417 for i := 0 to AllTypes.Count - 1 do
418 begin
419 typestring := AllTypes[i];
420 if Piece(typestring, '^', 1) = filenum then
421 begin
422 Result := Piece(AllTypes[i], '^', 2);
423 break;
424 end;
425 end;
426 if Result = '' then
427 begin
428 for i := 0 to AllTypes.Count - 1 do
429 begin
430 typestring := AllTypes[i];
431 if lowercase(Piece(typestring, '^', 1)) = filenum then
432 begin
433 Result := Piece(AllTypes[i], '^', 2);
434 break;
435 end;
436 end;
437 end;
438 Alltypes.Free;
439end;
440
441procedure TfrmGraphSettings.FormCreate(Sender: TObject);
442var
443 i: integer;
444begin
445 btnPublicSave.Enabled := GraphPublicEditor;
446 lblConversions.Enabled := btnPublicSave.Enabled;
447 cboConversions.Enabled := btnPublicSave.Enabled;
448 for i := 0 to lstOptions.Items.Count - 1 do
449 chklstOptions.Items.Add(Piece(lstOptions.Items[i], '^', 1));
450end;
451
452procedure TfrmGraphSettings.btnAllClick(Sender: TObject);
453var
454 i: integer;
455begin
456 for i := 0 to lstSources.Count - 1 do
457 lstSources.Checked[i] := (Sender = btnAll);
458end;
459
460procedure TfrmGraphSettings.btnCloseClick(Sender: TObject);
461begin
462 btnClose.Tag := 1; // forces check for changes
463 FCloseSettings := DisplaySettings;
464 Close;
465end;
466
467function TfrmGraphSettings.DisplaySettings: string;
468var
469 i: integer;
470 delim, settings, value: string;
471begin
472 settings := '';
473 delim := '';
474 for i := 0 to lstSourcesCopy.Items.Count - 1 do
475 if lstSources.Checked[i] then
476 begin
477 settings := settings + delim + Piece(lstSourcesCopy.Items[i], '^', 2);
478 delim := ';';
479 end;
480 settings := settings + '|';
481 delim := '';
482 for i := 0 to chklstOptions.Items.Count - 1 do
483 begin
484 value := '';
485 if chklstOptions.Checked[i] then value := Piece(lstOptions.Items[i], '^', 2);
486 settings := settings + value;
487 end;
488 settings := settings + '|' + inttostr(lstOptions.Tag); // sortorder
489 settings := settings + '|';
490 settings := settings + txtMaxGraphs.Text + '|';
491 settings := settings + txtMinGraphHeight.Text + '|';
492 settings := settings + '|'; // not used - reserved - set by server
493 settings := settings + txtMaxSelect.Text + '|';
494 settings := settings + Piece(FPublicSettings, '|', 8) + '|';
495 settings := settings + cboDateRangeOutpatient.ItemID + '|';
496 settings := settings + cboDateRangeInpatient.ItemID + '|';
497 Result := settings;
498end;
499
500procedure TfrmGraphSettings.btnPublicClick(Sender: TObject);
501var
502 i, j, k: integer;
503 dfntype, filename, settings, settings1, settings2, value: string;
504begin
505 if Sender = btnPublic then
506 settings := FPublicSettings
507 else
508 settings := FPersonalSettings;
509 settings1 := Piece(settings, '|', 1);
510 settings2 := Piece(settings, '|', 2); //piece 3 not used
511 spnMaxGraphs.Position := strtointdef(Piece(settings, '|', 4), 5);
512 spnMinGraphHeight.Position := strtointdef(Piece(settings, '|', 5), 90); //piece 6 not used
513 spnMaxSelect.Position := strtointdef(Piece(settings, '|', 7), 100);
514 spnMaxSelect.Max := strtointdef(Piece(settings, '|', 8), 1000);
515 spnMaxGraphs.Tag := spnMaxGraphs.Position;
516 spnMinGraphHeight.Tag := spnMinGraphHeight.Position;
517 spnMaxSelect.Tag := spnMaxSelect.Position;
518 cboDateRangeOutpatient.SelectByID(Piece(settings, '|', 9));
519 cboDateRangeInpatient.SelectByID(Piece(settings, '|', 10));
520 for i := 0 to lstOptions.Items.Count - 1 do
521 begin
522 value := Piece(lstOptions.Items[i], '^', 2);
523 chklstOptions.Checked[i] := Pos(value, settings2) > 0;
524 end;
525 for i := 0 to lstSources.Items.Count -1 do
526 lstSources.Checked[i] := false;
527 for i := 0 to BIG_NUMBER do
528 begin
529 dfntype := Piece(settings1, ';', i);
530 if length(dfntype) = 0 then break;
531 for j := 0 to lstSourcesCopy.Items.Count - 1 do
532 if dfntype = Piece(lstSourcesCopy.Items[j], '^', 2) then
533 begin
534 filename := Piece(lstSourcesCopy.Items[j], '^', 1);
535 for k := 0 to lstSources.Items.Count - 1 do
536 if filename = lstSources.Items[k] then
537 begin
538 lstSources.Checked[k] := true;
539 break;
540 end;
541 break;
542 end;
543 end;
544end;
545
546procedure TfrmGraphSettings.chklstOptionsClickCheck(Sender: TObject);
547var
548 value: string;
549begin
550 with chklstOptions do
551 begin
552 value := Piece(lstOptions.Items[ItemIndex], '^', 2);
553 if State[ItemIndex] = cbChecked then
554 if value = SETTING_CLEAR then
555 CheckSetting(SETTING_GRADIENT, false)
556 else if value = SETTING_GRADIENT then
557 CheckSetting(SETTING_CLEAR, false)
558 else if value = SETTING_VZOOM then
559 CheckSetting(SETTING_HZOOM, true);
560 if State[ItemIndex] = cbUnchecked then
561 if value = SETTING_HZOOM then
562 CheckSetting(SETTING_VZOOM, false);
563 end;
564end;
565
566procedure TfrmGraphSettings.CheckSetting(setting: string; turnon: boolean);
567var
568 i: integer;
569 value: string;
570begin
571 for i := 0 to lstOptions.Items.Count -1 do
572 begin
573 value := Piece(lstOptions.Items[i], '^', 2);
574 if value = setting then
575 begin
576 chklstOptions.Checked[i] := turnon;
577 break;
578 end;
579 end;
580end;
581
582procedure TfrmGraphSettings.SaveClick(Sender: TObject);
583var
584 info, settings: string;
585begin
586 if (Sender = btnPublicSave) then
587 info := 'This will change the PUBLIC default to these settings.'
588 else if (Sender = btnPersonalSave) then
589 info := 'This will change your personal default to these settings.';
590 info := info + #13 + 'Is this what you want to do?';
591 if MessageDlg(info, mtConfirmation, [mbYes, mbNo], 0) <> mrYes then
592 begin
593 ShowMsg('No changes were made.');
594 exit;
595 end;
596 settings := DisplaySettings;
597 if (Sender = btnPersonalSave) then
598 begin
599 rpcSetGraphSettings(settings, '0');
600 FPersonalSettings := settings;
601 end;
602 if (Sender = btnPublicSave) then
603 begin
604 SetPiece(settings, '|', 6, Piece(FPublicSettings, '|', 6)); // retain turbo setting
605 rpcSetGraphSettings(settings, '1');
606 FPublicSettings := settings;
607 end;
608end;
609
610procedure TfrmGraphSettings.spnMaxGraphsClick(Sender: TObject;
611 Button: TUDBtnType);
612begin
613 //txtMaxGraphs.SetFocus;
614 txtMaxGraphs.Tag := strtointdef(txtMaxGraphs.Text, spnMaxGraphs.Min);
615end;
616
617procedure TfrmGraphSettings.txtMaxGraphsChange(Sender: TObject);
618var
619 maxvalue, minvalue: integer;
620begin
621 maxvalue := spnMaxGraphs.Max;
622 minvalue := spnMaxGraphs.Min;
623 if strtointdef(txtMaxGraphs.Text, maxvalue) > maxvalue then
624 begin
625 beep;
626 InfoBox('Number must be < ' + inttostr(maxvalue), 'Warning', MB_OK or MB_ICONWARNING);
627 if strtointdef(txtMaxGraphs.Text, 0) > maxvalue then
628 txtMaxGraphs.Text := inttostr(maxvalue);
629 end;
630 if strtointdef(txtMaxGraphs.Text, minvalue) < minvalue then
631 begin
632 beep;
633 InfoBox('Number must be > ' + inttostr(minvalue), 'Warning', MB_OK or MB_ICONWARNING);
634 if strtointdef(txtMaxGraphs.Text, 0) < minvalue then
635 txtMaxGraphs.Text := inttostr(minvalue);
636 end;
637 spnMaxGraphsClick(self, btNext);
638end;
639
640procedure TfrmGraphSettings.txtMaxGraphsExit(Sender: TObject);
641begin
642 with txtMaxGraphs do
643 if Text = '' then
644 begin
645 Text := inttostr(spnMaxGraphs.Min);
646 spnMaxGraphsClick(self, btNext);
647 end
648 else if (copy(Text, 1, 1) = '0') and (length(Text) > 1) then
649 begin
650 Text := inttostr(strtointdef(Text, 0));
651 if Text = '0' then
652 Text := inttostr(spnMaxGraphs.Min);
653 spnMaxGraphsClick(self, btNext);
654 end;
655end;
656
657procedure TfrmGraphSettings.txtMaxGraphsKeyPress(Sender: TObject;
658 var Key: Char);
659begin
660 if Key = #13 then
661 begin
662 Perform(WM_NextDlgCtl, 0, 0);
663 exit;
664 end;
665 if not (Key in ['0'..'9', #8]) then
666 begin
667 Key := #0;
668 beep;
669 end;
670end;
671
672procedure TfrmGraphSettings.spnMinGraphHeightClick(Sender: TObject;
673 Button: TUDBtnType);
674begin
675 //txtMinGraphHeight.SetFocus;
676 txtMinGraphHeight.Tag := strtointdef(txtMinGraphHeight.Text, spnMinGraphHeight.Min);
677end;
678
679procedure TfrmGraphSettings.spnMaxSelectClick(Sender: TObject;
680 Button: TUDBtnType);
681begin
682 //txtMaxSelect.SetFocus;
683 txtMaxSelect.Tag := strtointdef(txtMaxSelect.Text, spnMaxSelect.Min);
684end;
685
686procedure TfrmGraphSettings.txtMinGraphHeightChange(Sender: TObject);
687var
688 maxvalue, minvalue: integer;
689begin
690 maxvalue := spnMinGraphHeight.Max;
691 minvalue := spnMinGraphHeight.Min;
692 if strtointdef(txtMinGraphHeight.Text, maxvalue) > maxvalue then
693 begin
694 beep;
695 InfoBox('Number must be < ' + inttostr(maxvalue), 'Warning', MB_OK or MB_ICONWARNING);
696 if strtointdef(txtMinGraphHeight.Text, 0) > maxvalue then
697 txtMinGraphHeight.Text := inttostr(maxvalue);
698 end;
699 if strtointdef(txtMinGraphHeight.Text, minvalue) < minvalue then
700 if txtMinGraphHeight.Hint = KEYPRESS_OFF then
701 begin
702 beep;
703 InfoBox('Number must be > ' + inttostr(minvalue), 'Warning', MB_OK or MB_ICONWARNING);
704 if strtointdef(txtMinGraphHeight.Text, 0) < minvalue then
705 txtMinGraphHeight.Text := inttostr(minvalue);
706 end;
707 spnMinGraphHeightClick(self, btNext);
708 txtMinGraphHeight.Hint := KEYPRESS_OFF;
709end;
710
711procedure TfrmGraphSettings.txtMaxSelectChange(Sender: TObject);
712var
713 maxvalue, minvalue: integer;
714begin
715 maxvalue := spnMaxSelect.Max;
716 minvalue := spnMaxSelect.Min;
717 if strtointdef(txtMaxSelect.Text, maxvalue) > maxvalue then
718 begin
719 beep;
720 InfoBox('Number must be < ' + inttostr(maxvalue), 'Warning', MB_OK or MB_ICONWARNING);
721 if strtointdef(txtMaxSelect.Text, 0) > maxvalue then
722 txtMaxSelect.Text := inttostr(maxvalue);
723 end;
724 if strtointdef(txtMaxSelect.Text, minvalue) < minvalue then
725 if txtMaxSelect.Hint = KEYPRESS_OFF then
726 begin
727 beep;
728 InfoBox('Number must be > ' + inttostr(minvalue), 'Warning', MB_OK or MB_ICONWARNING);
729 if strtointdef(txtMaxSelect.Text, 0) < minvalue then
730 txtMaxSelect.Text := inttostr(minvalue);
731 end;
732 spnMaxSelectClick(self, btNext);
733 txtMaxSelect.Hint := KEYPRESS_OFF;
734end;
735
736procedure TfrmGraphSettings.txtMinGraphHeightExit(Sender: TObject);
737begin
738 with txtMinGraphHeight do
739 if Text = '' then
740 begin
741 Text := inttostr(spnMinGraphHeight.Min);
742 spnMinGraphHeightClick(self, btNext);
743 end
744 else if (copy(Text, 1, 1) = '0') and (length(Text) > 1) then
745 begin
746 Text := inttostr(strtointdef(Text, 0));
747 if Text = '0' then
748 Text := inttostr(spnMinGraphHeight.Min);
749 spnMinGraphHeightClick(self, btNext);
750 end
751 else if strtointdef(txtMinGraphHeight.Text, spnMinGraphHeight.Min) < spnMinGraphHeight.Min then
752 begin
753 Text := inttostr(spnMinGraphHeight.Min);
754 spnMinGraphHeightClick(self, btNext);
755 end;
756end;
757
758procedure TfrmGraphSettings.txtMaxSelectExit(Sender: TObject);
759begin
760 with txtMaxSelect do
761 if Text = '' then
762 begin
763 Text := inttostr(spnMaxSelect.Min);
764 spnMaxSelectClick(self, btNext);
765 end
766 else if (copy(Text, 1, 1) = '0') and (length(Text) > 1) then
767 begin
768 Text := inttostr(strtointdef(Text, 0));
769 if Text = '0' then
770 Text := inttostr(spnMaxSelect.Min);
771 spnMaxSelectClick(self, btNext);
772 end
773 else if strtointdef(txtMaxSelect.Text, spnMaxSelect.Min) < spnMaxSelect.Min then
774 begin
775 Text := inttostr(spnMaxSelect.Min);
776 spnMaxSelectClick(self, btNext);
777 end;
778end;
779
780procedure TfrmGraphSettings.txtMinGraphHeightKeyPress(Sender: TObject;
781 var Key: Char);
782begin
783 txtMinGraphHeight.Hint := KEYPRESS_OFF;
784 if Key = #13 then
785 begin
786 Perform(WM_NextDlgCtl, 0, 0);
787 exit;
788 end;
789 if not (Key in ['0'..'9', #8]) then
790 begin
791 Key := #0;
792 beep;
793 exit;
794 end;
795 txtMinGraphHeight.Hint := KEYPRESS_ON;
796end;
797
798procedure TfrmGraphSettings.txtMaxSelectKeyPress(Sender: TObject;
799 var Key: Char);
800begin
801 txtMaxSelect.Hint := KEYPRESS_OFF;
802 if Key = #13 then
803 begin
804 Perform(WM_NextDlgCtl, 0, 0);
805 exit;
806 end;
807 if not (Key in ['0'..'9', #8]) then
808 begin
809 Key := #0;
810 beep;
811 exit;
812 end;
813 txtMaxSelect.Hint := KEYPRESS_ON;
814end;
815
816procedure TfrmGraphSettings.FormShow(Sender: TObject);
817begin
818 //if Caption = 'Graph Settings - Defaults Only' then
819 // btnPersonal.SetFocus;
820 FHintPauseTime := Application.HintHidePause;
821 Application.HintHidePause := 9000; // uses a longer hint pause time
822end;
823
824procedure TfrmGraphSettings.AssignHints;
825var
826 i: integer;
827begin // text defined in uGraphs
828 for i := 0 to ControlCount - 1 do with Controls[i] do
829 Controls[i].ShowHint := true;
830 lblSources.Hint := SHINT_SOURCES;
831 lstSources.Hint := SHINT_SOURCES;
832 lblOptions.Hint := SHINT_OPTIONS;
833 chklstOptions.Hint := SHINT_OPTIONS;
834 btnAll.Hint := SHINT_BTN_ALL;
835 brnClear.Hint := SHINT_BTN_CLEAR;
836 lblShow.Hint := SHINT_BTN_SHOW;
837 lblSave.Hint := SHINT_BTN_SAVE;
838 btnPersonal.Hint := SHINT_BTN_PER;
839 btnPersonalSave.Hint := SHINT_BTN_PERSAVE;
840 btnPublic.Hint := SHINT_BTN_PUB;
841 btnPublicSave.Hint := SHINT_BTN_PUBSAVE;
842 lblOptionsInfo.Hint := SHINT_BTN_CLOSE;
843 btnClose.Hint := SHINT_BTN_CLOSE;
844 lblMaxGraphs.Hint := SHINT_MAX;
845 txtMaxGraphs.Hint := SHINT_MAX;
846 spnMaxGraphs.Hint := SHINT_MAX;
847 lblMaxGraphsRef.Hint := SHINT_MAX ;
848 lblMinGraphHeight.Hint := SHINT_MIN;
849 txtMinGraphHeight.Hint := SHINT_MIN;
850 spnMinGraphHeight.Hint := SHINT_MIN;
851 lblMinGraphHeightRef.Hint := SHINT_MIN;
852 lblMaxSelect.Hint := SHINT_MAX_ITEMS;
853 txtMaxSelect.Hint := SHINT_MAX_ITEMS;
854 spnMaxSelect.Hint := SHINT_MAX_ITEMS;
855 lblMaxSelectRef.Hint := SHINT_MAX_ITEMS;
856 lblOutpatient.Hint := SHINT_OUTPT;
857 cboDateRangeOutpatient.Hint := SHINT_OUTPT;
858 lblInpatient.Hint := SHINT_INPT;
859 cboDateRangeInpatient.Hint := SHINT_INPT;
860 lblConversions.Hint := SHINT_FUNCTIONS;
861 cboConversions.Hint := SHINT_FUNCTIONS;
862end;
863
864procedure TfrmGraphSettings.wmNCLButtonDown(var Msg: TWMNCLButtonDown);
865begin // clicking the ? button will have controls show hints
866 if Msg.HitTest = HTHELP then
867 begin
868 Msg.Result := 0; // ignore biHelp border icon
869 AssignHints;
870 ShowMsg('Help is now available.' + #13 +
871 'By pausing over a list or control, hints will appear.');
872 end
873 else
874 inherited;
875end;
876
877procedure TfrmGraphSettings.FormClose(Sender: TObject;
878 var Action: TCloseAction);
879begin
880 Application.HintHidePause := FHintPauseTime;
881end;
882
883end.
Note: See TracBrowser for help on using the repository browser.