source: cprs/branches/foia-cprs/CPRS-Chart/Options/fOptionsNotes.pas@ 497

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

Adding foia-cprs branch

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