source: cprs/branches/tmg-cprs/CPRS-Chart/fGraphSettings.pas@ 697

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

Initial upload of TMG-CPRS 1.0.26.69

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