source: cprs/branches/foia-cprs/CPRS-Chart/fGraphSettings.pas@ 711

Last change on this file since 711 was 460, checked in by Kevin Toppenberg, 16 years ago

Uploading from OR_30_258

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