source: cprs/branches/tmg-cprs/CPRS-Chart/fOptionsNotes.pas@ 1154

Last change on this file since 1154 was 729, checked in by Kevin Toppenberg, 15 years ago

Added functions to Templates, and Images tab

File size: 10.0 KB
RevLine 
[729]1//kt -- Modified with SourceScanner on 8/8/2007
2unit fOptionsNotes;
3
4interface
5
6{ //kt 8/09 The following objects were addeded to the *FORM* of this unit
7
8 object lblHTMLViewSize: TLabel
9 Left = 8
10 Top = 144
11 Width = 159
12 Height = 13
13 Caption = 'Formatted Text (HTML) View Size'
14 end
15 object cboHTMLViewSize: TComboBox
16 Left = 8
17 Top = 162
18 Width = 153
19 Height = 21
20 ItemHeight = 13
21 TabOrder = 6
22 Text = '<View Size>'
23 OnClick = cboHTMLViewSizeClick
24 Items.Strings = (
25 'Smallest'
26 'Small'
27 'Medium'
28 'Large'
29 'Largest')
30 end
31 object cbDefaultHTMLMode: TCheckBox
32 Left = 8
33 Top = 112
34 Width = 225
35 Height = 17
36 Caption = 'Start notes in Formatted (HTML) Mode'
37 TabOrder = 7
38 OnClick = cbDefaultHTMLModeClick
39}
40
41
42uses
43 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
44 StdCtrls, ExtCtrls, ORCtrls, ORFn, ComCtrls, DKLang;
45
46type
47 TfrmOptionsNotes = class(TForm)
48 lblAutoSave1: TLabel;
49 lblCosigner: TLabel;
50 txtAutoSave: TCaptionEdit;
51 spnAutoSave: TUpDown;
52 chkVerifyNote: TCheckBox;
53 chkAskSubject: TCheckBox;
54 cboCosigner: TORComboBox;
55 pnlBottom: TPanel;
56 bvlBottom: TBevel;
57 btnOK: TButton;
58 btnCancel: TButton;
59 lblAutoSave2: TLabel;
60 cboHTMLViewSize: TComboBox; //kt 8/09
61 lblHTMLViewSize: TLabel; //kt 8/09
62 cbDefaultHTMLMode: TCheckBox; //kt 8/09
63 DKLanguageController1: TDKLanguageController; //kt
64 procedure FormShow(Sender: TObject);
65 procedure btnOKClick(Sender: TObject);
66 procedure txtAutoSaveChange(Sender: TObject);
67 procedure txtAutoSaveKeyPress(Sender: TObject; var Key: Char);
68 procedure txtAutoSaveExit(Sender: TObject);
69 procedure spnAutoSaveClick(Sender: TObject; Button: TUDBtnType);
70 procedure cboCosignerNeedData(Sender: TObject; const StartFrom: String;
71 Direction, InsertAt: Integer);
72 procedure cboCosignerExit(Sender: TObject);
73 procedure FormCreate(Sender: TObject); //kt 8/09
74 procedure cbDefaultHTMLModeClick(Sender: TObject); //kt 8/09
75 procedure cboHTMLViewSizeChange(Sender: TObject); //kt 8/09
76 private
77 { Private declarations }
78 public
79 { Public declarations }
80 end;
81
82var
83 frmOptionsNotes: TfrmOptionsNotes;
84 DefaultEditHTMLMode : boolean; //kt 8/09
85 FHTMLEditTextSize : integer; //kt 8/09
86
87procedure DialogOptionsNotes(topvalue, leftvalue, fontsize: integer; var actiontype: Integer);
88procedure SetDefaultEditHTMLMode(Value : boolean); //kt 8/09
89procedure Loaded; //kt 8/09
90
91implementation
92
93{$R *.DFM}
94
95uses
96 uCore, //kt 8/09
97 Registry, //kt 8/09
98 uTMGOptions, //kt 2/10/10
99 rOptions, uOptions, rCore, rTIU, rDCSumm, uTemplates;
100
101const
102 DEFAULT_HTML_EDIT_MODE = 'Edit-in-HTML default mode'; //kt 8/09
103 DEFAULT_HTML_TEXT_SIZE = 'Edit-in-HTML default text size'; //kt 8/09
104
105procedure SetRegHTMLViewSize(Size : integer); forward; //kt 8/09
106
107procedure DialogOptionsNotes(topvalue, leftvalue, fontsize: integer; var actiontype: Integer);
108// create the form and make it modal, return an action
109var
110 frmOptionsNotes: TfrmOptionsNotes;
111begin
112 frmOptionsNotes := TfrmOptionsNotes.Create(Application);
113 actiontype := 0;
114 try
115 with frmOptionsNotes do
116 begin
117 if (topvalue < 0) or (leftvalue < 0) then
118 Position := poScreenCenter
119 else
120 begin
121 Position := poDesigned;
122 Top := topvalue;
123 Left := leftvalue;
124 end;
125 ResizeAnchoredFormToFont(frmOptionsNotes);
126 ShowModal;
127 actiontype := btnOK.Tag;
128 end;
129 finally
130 frmOptionsNotes.Release;
131 end;
132end;
133
134procedure TfrmOptionsNotes.FormShow(Sender: TObject);
135// displays defaults
136// opening tab^use last tab^autosave seconds^verify note title
137var
138 autosave, verify: integer;
139 cosigner: Int64;
140 values, cosignername: string;
141begin
142 values := rpcGetOther;
143 autosave := strtointdef(Piece(values, '^', 3), -1);
144 verify := strtointdef(Piece(values, '^', 4), 0);
145 chkVerifyNote.Checked := verify = 1;
146 chkVerifyNote.Tag := verify;
147 spnAutoSave.Position := autosave;
148 spnAutoSave.Tag := autosave;
149
150 values := rpcGetDefaultCosigner;
151 cosigner := strtoint64def(Piece(values, '^', 1), 0);
152 cosignername := Piece(values, '^', 2);
153 cboCosigner.Items.Add('0^<none>');
154 cboCosigner.InitLongList(cosignername);
155 cboCosigner.SelectByIEN(cosigner);
156 cboCosigner.Tag := cosigner;
157 chkAskSubject.Checked := rpcGetSubject;
158 if chkAskSubject.Checked then chkAskSubject.Tag := 1;
159 cbDefaultHTMLMode.Checked := DefaultEditHTMLMode; //kt
160end;
161
162procedure TfrmOptionsNotes.btnOKClick(Sender: TObject);
163// only saves values if they have been changed
164// opening tab^use last tab^autosave seconds^verify note title
165var
166 values: string;
167begin
168 values := '';
169 values := values + '^';
170 values := values + '^';
171 if spnAutoSave.Position <> spnAutoSave.Tag then
172 values := values + inttostr(spnAutoSave.Position);
173 values := values + '^';
174 if chkVerifyNote.Checked then
175 if chkVerifyNote.Tag <> 1 then
176 values := values + '1';
177 if not chkVerifyNote.Checked then
178 if chkVerifyNote.Tag <> 0 then
179 values := values + '0';
180 rpcSetOther(values);
181 with chkAskSubject do
182 if (Checked and (Tag = 0)) or (not Checked and (Tag = 1)) then
183 rpcSetSubject(Checked);
184 with cboCosigner do
185 if Tag <> ItemIEN then
186 rpcSetDefaultCosigner(ItemIEN);
187 ResetTIUPreferences;
188 ResetDCSummPreferences;
189end;
190
191procedure TfrmOptionsNotes.txtAutoSaveChange(Sender: TObject);
192var
193 maxvalue: integer;
194begin
195 maxvalue := spnAutoSave.Max;
196 with txtAutoSave do
197 begin
198 if strtointdef(Text, maxvalue) > maxvalue then
199 begin
200 beep;
201// InfoBox('Number must be < ' + inttostr(maxvalue), 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
202 InfoBox(DKLangConstW('fOptionsNotes_Number_must_be_x')+' ' + inttostr(maxvalue), DKLangConstW('fOptionsNotes_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
203 if strtointdef(Text, 0) > maxvalue then
204 Text := inttostr(maxvalue);
205 end;
206 end;
207 spnAutoSaveClick(self, btNext);
208end;
209
210procedure TfrmOptionsNotes.txtAutoSaveKeyPress(Sender: TObject;
211 var Key: Char);
212begin
213 if Key = #13 then
214 begin
215 Perform(WM_NextDlgCtl, 0, 0);
216 exit;
217 end;
218 if not (Key in ['0'..'9', #8]) then
219 begin
220 Key := #0;
221 beep;
222 end;
223end;
224
225procedure TfrmOptionsNotes.txtAutoSaveExit(Sender: TObject);
226begin
227 with txtAutoSave do
228 begin
229 if Text = '' then
230 begin
231 Text := '0';
232 spnAutoSaveClick(self, btNext);
233 end
234 else if (Copy(Text, 1, 1) = '0') and (length(Text) > 1) then
235 begin
236 Text := inttostr(strtointdef(Text, 0));
237 spnAutoSaveClick(self, btNext);
238 end;
239 end;
240end;
241
242procedure TfrmOptionsNotes.spnAutoSaveClick(Sender: TObject;
243 Button: TUDBtnType);
244begin
245 txtAutoSave.SetFocus;
246 txtAutoSave.Tag := strtointdef(txtAutoSave.Text, 0);
247end;
248
249procedure TfrmOptionsNotes.cboCosignerNeedData(Sender: TObject;
250 const StartFrom: String; Direction, InsertAt: Integer);
251begin
252 cboCosigner.ForDataUse(rpcGetCosigners(StartFrom, Direction));
253end;
254
255procedure TfrmOptionsNotes.cboCosignerExit(Sender: TObject);
256begin
257 with cboCosigner do
258 if (Text = '') or (ItemIndex = -1) then
259 begin
260 ItemIndex := 0;
261 Text := DisplayText[0];
262 end;
263end;
264
265
266procedure SetRegHTMLViewSize(Size : integer);
267//kt added entire function 8/09
268//NOTE: The only way to affect the view size of the HTML renderer (IE) is to
269// change a system-wide setting in the registry. Then CPRS has to be
270// restarted for changes to take effect.
271var
272 FontSizeData : array[0..3] of byte;
273 ZoomReg : TRegistry;
274begin
275 if (Size < 0) or (Size > 255) then exit;
276 ZoomReg := TRegistry.Create;
277 FontSizeData[0] := Lo(Size); FontSizeData[1] := 0; FontSizeData[2] := 0; FontSizeData[3] := 0;
278 try
279 ZoomReg.Rootkey := HKEY_CURRENT_USER;
280 if ZoomReg.OpenKey('\Software\Microsoft\Internet Explorer\International\Scripts\3', False) then begin
281 ZoomReg.WriteBinaryData('IEFontSize',FontSizeData,SizeOf(FontSizeData));
282 end;
283 finally
284 ZoomReg.Free;
285 end;
286end;
287
288procedure SetDefaultEditHTMLMode(Value : boolean);
289//kt added entire function 8/09
290begin
291 if Value <> DefaultEditHTMLMode then begin
292 uTMGOptions.WriteBool(DEFAULT_HTML_EDIT_MODE,Value);
293 DefaultEditHTMLMode := Value;
294 end;
295 uTemplates.bUsingHTMLMode := Value; //test line //elh 1/22/10
296end;
297
298procedure TfrmOptionsNotes.cbDefaultHTMLModeClick(Sender: TObject);
299//kt added entire function 8/09
300begin
301 SetDefaultEditHTMLMode(cbDefaultHTMLMode.Checked);
302end;
303
304procedure TfrmOptionsNotes.cboHTMLViewSizeChange(Sender: TObject);
305//kt added entire function 8/09
306begin
307 SetRegHTMLViewSize(cboHTMLViewSize.ItemIndex);
308 uTMGOptions.WriteInteger(DEFAULT_HTML_TEXT_SIZE,cboHTMLViewSize.ItemIndex);
309 MessageDlg('Formated text size change will take '+#10+#13+
310 'effect next time CPRS is restarted.',mtInformation,[mbOK],0);
311end;
312
313procedure Loaded;
314//kt added entire function 8/09
315begin
316 //Code was put in global access space because object is not instantiated until
317 //after user shows options (which could be never)
318 DefaultEditHTMLMode := uTMGOptions.ReadBool(DEFAULT_HTML_EDIT_MODE,false);
319 uTemplates.bUsingHTMLMode := DefaultEditHTMLMode;
320 FHTMLEditTextSize := uTMGOptions.ReadInteger(DEFAULT_HTML_TEXT_SIZE,2);
321 SetRegHTMLViewSize(FHTMLEditTextSize);
322end;
323
324procedure TfrmOptionsNotes.FormCreate(Sender: TObject);
325//kt added entire function 8/09
326//NOTE: form is not created until first time needed.
327begin
328 //NOTE: FHTMLEditTextSize is set in Loaded function (has to be called after sign on (so User.Name is available)
329 if (FHTMLEditTextSize > -1) and (FHTMLEditTextSize < cboHTMLViewSize.Items.Count) then begin
330 cboHTMLViewSize.ItemIndex := FHTMLEditTextSize;
331 cboHTMLViewSize.Text := cboHTMLViewSize.Items[FHTMLEditTextSize];
332 SetRegHTMLViewSize(cboHTMLViewSize.ItemIndex);
333 end;
334end;
335
336end.
Note: See TracBrowser for help on using the repository browser.