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

Last change on this file since 842 was 830, checked in by Kevin Toppenberg, 14 years ago

Upgrading to version 27

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