source: cprs/trunk/CPRS-Chart/Options/fOptionsNotes.pas@ 839

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

Upgrade to version 27

File size: 5.5 KB
Line 
1unit fOptionsNotes;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls, ExtCtrls, ORCtrls, ORFn, ComCtrls, fBase508Form,
8 VA508AccessibilityManager;
9
10type
11 TfrmOptionsNotes = class(TfrmBase508Form)
12 lblAutoSave1: TLabel;
13 lblCosigner: TLabel;
14 txtAutoSave: TCaptionEdit;
15 spnAutoSave: TUpDown;
16 chkVerifyNote: TCheckBox;
17 chkAskSubject: TCheckBox;
18 cboCosigner: TORComboBox;
19 pnlBottom: TPanel;
20 bvlBottom: TBevel;
21 btnOK: TButton;
22 btnCancel: TButton;
23 lblAutoSave2: TLabel;
24 procedure FormShow(Sender: TObject);
25 procedure btnOKClick(Sender: TObject);
26 procedure txtAutoSaveChange(Sender: TObject);
27 procedure txtAutoSaveKeyPress(Sender: TObject; var Key: Char);
28 procedure txtAutoSaveExit(Sender: TObject);
29 procedure spnAutoSaveClick(Sender: TObject; Button: TUDBtnType);
30 procedure cboCosignerNeedData(Sender: TObject; const StartFrom: String;
31 Direction, InsertAt: Integer);
32 procedure cboCosignerExit(Sender: TObject);
33 private
34 { Private declarations }
35 public
36 { Public declarations }
37 end;
38
39var
40 frmOptionsNotes: TfrmOptionsNotes;
41
42procedure DialogOptionsNotes(topvalue, leftvalue, fontsize: integer; var actiontype: Integer);
43
44implementation
45
46{$R *.DFM}
47
48uses
49 rOptions, uOptions, rCore, rTIU, rDCSumm;
50
51procedure DialogOptionsNotes(topvalue, leftvalue, fontsize: integer; var actiontype: Integer);
52// create the form and make it modal, return an action
53var
54 frmOptionsNotes: TfrmOptionsNotes;
55begin
56 frmOptionsNotes := TfrmOptionsNotes.Create(Application);
57 actiontype := 0;
58 try
59 with frmOptionsNotes do
60 begin
61 if (topvalue < 0) or (leftvalue < 0) then
62 Position := poScreenCenter
63 else
64 begin
65 Position := poDesigned;
66 Top := topvalue;
67 Left := leftvalue;
68 end;
69 ResizeAnchoredFormToFont(frmOptionsNotes);
70 ShowModal;
71 actiontype := btnOK.Tag;
72 end;
73 finally
74 frmOptionsNotes.Release;
75 end;
76end;
77
78procedure TfrmOptionsNotes.FormShow(Sender: TObject);
79// displays defaults
80// opening tab^use last tab^autosave seconds^verify note title
81var
82 autosave, verify: integer;
83 cosigner: Int64;
84 values, cosignername: string;
85begin
86 values := rpcGetOther;
87 autosave := strtointdef(Piece(values, '^', 3), -1);
88 verify := strtointdef(Piece(values, '^', 4), 0);
89 chkVerifyNote.Checked := verify = 1;
90 chkVerifyNote.Tag := verify;
91 spnAutoSave.Position := autosave;
92 spnAutoSave.Tag := autosave;
93
94 values := rpcGetDefaultCosigner;
95 cosigner := strtoint64def(Piece(values, '^', 1), 0);
96 cosignername := Piece(values, '^', 2);
97 cboCosigner.Items.Add('0^<none>');
98 cboCosigner.InitLongList(cosignername);
99 cboCosigner.SelectByIEN(cosigner);
100 cboCosigner.Tag := cosigner;
101 chkAskSubject.Checked := rpcGetSubject;
102 if chkAskSubject.Checked then chkAskSubject.Tag := 1;
103end;
104
105procedure TfrmOptionsNotes.btnOKClick(Sender: TObject);
106// only saves values if they have been changed
107// opening tab^use last tab^autosave seconds^verify note title
108var
109 values: string;
110begin
111 values := '';
112 values := values + '^';
113 values := values + '^';
114 if spnAutoSave.Position <> spnAutoSave.Tag then
115 values := values + inttostr(spnAutoSave.Position);
116 values := values + '^';
117 if chkVerifyNote.Checked then
118 if chkVerifyNote.Tag <> 1 then
119 values := values + '1';
120 if not chkVerifyNote.Checked then
121 if chkVerifyNote.Tag <> 0 then
122 values := values + '0';
123 rpcSetOther(values);
124 with chkAskSubject do
125 if (Checked and (Tag = 0)) or (not Checked and (Tag = 1)) then
126 rpcSetSubject(Checked);
127 with cboCosigner do
128 if Tag <> ItemIEN then
129 rpcSetDefaultCosigner(ItemIEN);
130 ResetTIUPreferences;
131 ResetDCSummPreferences;
132end;
133
134procedure TfrmOptionsNotes.txtAutoSaveChange(Sender: TObject);
135var
136 maxvalue: integer;
137begin
138 maxvalue := spnAutoSave.Max;
139 with txtAutoSave do
140 begin
141 if strtointdef(Text, maxvalue) > maxvalue then
142 begin
143 beep;
144 InfoBox('Number must be < ' + inttostr(maxvalue), 'Warning', MB_OK or MB_ICONWARNING);
145 if strtointdef(Text, 0) > maxvalue then
146 Text := inttostr(maxvalue);
147 end;
148 end;
149 spnAutoSaveClick(self, btNext);
150end;
151
152procedure TfrmOptionsNotes.txtAutoSaveKeyPress(Sender: TObject;
153 var Key: Char);
154begin
155 if Key = #13 then
156 begin
157 Perform(WM_NextDlgCtl, 0, 0);
158 exit;
159 end;
160 if not (Key in ['0'..'9', #8]) then
161 begin
162 Key := #0;
163 beep;
164 end;
165end;
166
167procedure TfrmOptionsNotes.txtAutoSaveExit(Sender: TObject);
168begin
169 with txtAutoSave do
170 begin
171 if Text = '' then
172 begin
173 Text := '0';
174 spnAutoSaveClick(self, btNext);
175 end
176 else if (Copy(Text, 1, 1) = '0') and (length(Text) > 1) then
177 begin
178 Text := inttostr(strtointdef(Text, 0));
179 spnAutoSaveClick(self, btNext);
180 end;
181 end;
182end;
183
184procedure TfrmOptionsNotes.spnAutoSaveClick(Sender: TObject;
185 Button: TUDBtnType);
186begin
187 txtAutoSave.SetFocus;
188 txtAutoSave.Tag := strtointdef(txtAutoSave.Text, 0);
189end;
190
191procedure TfrmOptionsNotes.cboCosignerNeedData(Sender: TObject;
192 const StartFrom: String; Direction, InsertAt: Integer);
193begin
194 cboCosigner.ForDataUse(rpcGetCosigners(StartFrom, Direction));
195end;
196
197procedure TfrmOptionsNotes.cboCosignerExit(Sender: TObject);
198begin
199 with cboCosigner do
200 if (Text = '') or (ItemIndex = -1) then
201 begin
202 ItemIndex := 0;
203 Text := DisplayText[0];
204 end;
205end;
206
207end.
Note: See TracBrowser for help on using the repository browser.