source: cprs/branches/tmg-cprs/CPRS-Chart/Templates/fTemplateFieldEditor.pas@ 484

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

Initial upload of TMG-CPRS 1.0.26.69

File size: 42.1 KB
Line 
1//kt -- Modified with SourceScanner on 8/8/2007
2unit fTemplateFieldEditor;
3
4interface
5
6uses
7 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
8 ORCtrls, StdCtrls, ExtCtrls, Menus, ComCtrls, uTemplateFields, ORFn,
9 ToolWin, MenuBar, ORClasses, ORDtTm, DKLang;
10
11type
12 TfrmTemplateFieldEditor = class(TForm)
13 pnlBottom: TPanel;
14 btnOK: TButton;
15 btnCancel: TButton;
16 pnlObjs: TPanel;
17 cbxObjs: TORComboBox;
18 lblObjs: TLabel;
19 splLeft: TSplitter;
20 pnlRight: TPanel;
21 pnlPreview: TPanel;
22 lblNotes: TLabel;
23 pnlObjInfo: TPanel;
24 lblName: TLabel;
25 lblS2: TLabel;
26 lblLM: TLabel;
27 edtName: TCaptionEdit;
28 splBottom: TSplitter;
29 lblS1: TLabel;
30 edtLMText: TCaptionEdit;
31 cbxType: TORComboBox;
32 lblType: TLabel;
33 reNotes: TRichEdit;
34 btnApply: TButton;
35 btnPreview: TButton;
36 mnuMain: TMainMenu;
37 mnuAction: TMenuItem;
38 mnuNew: TMenuItem;
39 mnuCopy: TMenuItem;
40 cbHide: TCheckBox;
41 pnlTop: TPanel;
42 MenuBar1: TMenuBar;
43 btnNew: TButton;
44 btnCopy: TButton;
45 mnuDelete: TMenuItem;
46 btnDelete: TButton;
47 mnuPreview: TMenuItem;
48 popText: TPopupMenu;
49 mnuBPUndo: TMenuItem;
50 N8: TMenuItem;
51 mnuBPCut: TMenuItem;
52 mnuBPCopy: TMenuItem;
53 mnuBPPaste: TMenuItem;
54 mnuBPSelectAll: TMenuItem;
55 N2: TMenuItem;
56 mnuBPCheckGrammar: TMenuItem;
57 mnuBPSpellCheck: TMenuItem;
58 lblTextLen: TLabel;
59 edtTextLen: TCaptionEdit;
60 udTextLen: TUpDown;
61 pnlSwap: TPanel;
62 edtDefault: TCaptionEdit;
63 pnlNum: TPanel;
64 edtURL: TCaptionEdit;
65 udDefNum: TUpDown;
66 edtDefNum: TCaptionEdit;
67 udMinVal: TUpDown;
68 edtMinVal: TCaptionEdit;
69 lblMin: TLabel;
70 udInc: TUpDown;
71 edtInc: TCaptionEdit;
72 lblInc: TLabel;
73 lblMaxVal: TLabel;
74 edtMaxVal: TCaptionEdit;
75 udMaxVal: TUpDown;
76 reItems: TRichEdit;
77 lblLength: TLabel;
78 edtLen: TCaptionEdit;
79 udLen: TUpDown;
80 cbxDefault: TORComboBox;
81 lblS3: TLabel;
82 gbIndent: TGroupBox;
83 lblIndent: TLabel;
84 edtIndent: TCaptionEdit;
85 udIndent: TUpDown;
86 udPad: TUpDown;
87 edtPad: TCaptionEdit;
88 lblPad: TLabel;
89 gbMisc: TGroupBox;
90 cbActive: TCheckBox;
91 cbRequired: TCheckBox;
92 cbSepLines: TCheckBox;
93 pnlDate: TPanel;
94 edtDateDef: TCaptionEdit;
95 cbxDateType: TORComboBox;
96 lblDateType: TLabel;
97 cbExclude: TCheckBox;
98 lblReq: TStaticText;
99 lblLine: TLabel;
100 lblCol: TLabel;
101 N14: TMenuItem;
102 mnuInsertTemplateField: TMenuItem;
103 DKLanguageController1: TDKLanguageController;
104 procedure cbxObjsNeedData(Sender: TObject; const StartFrom: String;
105 Direction, InsertAt: Integer);
106 procedure FormCreate(Sender: TObject);
107 procedure cbxObjsChange(Sender: TObject);
108 procedure edtNameChange(Sender: TObject);
109 procedure cbxTypeChange(Sender: TObject);
110 procedure edtLenChange(Sender: TObject);
111 procedure edtDefaultChange(Sender: TObject);
112 procedure cbxDefaultChange(Sender: TObject);
113 procedure edtLMTextChange(Sender: TObject);
114 procedure cbActiveClick(Sender: TObject);
115 procedure mnuNewClick(Sender: TObject);
116 procedure btnOKClick(Sender: TObject);
117 procedure btnApplyClick(Sender: TObject);
118 procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
119 procedure btnCancelClick(Sender: TObject);
120 procedure reItemsChange(Sender: TObject);
121 procedure cbHideClick(Sender: TObject);
122 procedure edtNameExit(Sender: TObject);
123 procedure mnuCopyClick(Sender: TObject);
124 procedure mnuDeleteClick(Sender: TObject);
125 procedure btnPreviewClick(Sender: TObject);
126 procedure mnuActionClick(Sender: TObject);
127 procedure cbRequiredClick(Sender: TObject);
128 procedure pnlObjsResize(Sender: TObject);
129 procedure FormDestroy(Sender: TObject);
130 procedure cbxObjsSynonymCheck(Sender: TObject; const Text: String;
131 var IsSynonym: Boolean);
132 procedure popTextPopup(Sender: TObject);
133 procedure mnuBPUndoClick(Sender: TObject);
134 procedure mnuBPCutClick(Sender: TObject);
135 procedure mnuBPCopyClick(Sender: TObject);
136 procedure mnuBPPasteClick(Sender: TObject);
137 procedure mnuBPSelectAllClick(Sender: TObject);
138 procedure mnuBPCheckGrammarClick(Sender: TObject);
139 procedure mnuBPSpellCheckClick(Sender: TObject);
140 procedure cbSepLinesClick(Sender: TObject);
141 procedure edtpopControlEnter(Sender: TObject);
142 procedure cbxObjsKeyDown(Sender: TObject; var Key: Word;
143 Shift: TShiftState);
144 procedure edtTextLenChange(Sender: TObject);
145 procedure edtDefNumChange(Sender: TObject);
146 procedure edtMinValChange(Sender: TObject);
147 procedure edtMaxValChange(Sender: TObject);
148 procedure edtIncChange(Sender: TObject);
149 procedure edtURLChange(Sender: TObject);
150 procedure edtPadChange(Sender: TObject);
151 procedure edtIndentChange(Sender: TObject);
152 procedure reNotesChange(Sender: TObject);
153 procedure cbxDateTypeChange(Sender: TObject);
154 procedure cbExcludeClick(Sender: TObject);
155 procedure FormResize(Sender: TObject);
156 procedure reItemsResizeRequest(Sender: TObject; Rect: TRect);
157 procedure reItemsSelectionChange(Sender: TObject);
158 procedure mnuInsertTemplateFieldClick(Sender: TObject);
159 procedure ControlExit(Sender: TObject);
160 procedure reNotesKeyUp(Sender: TObject; var Key: Word;
161 Shift: TShiftState);
162 private
163 //kt Begin Mod (change Consts to Vars) 8/8/2007
164 DefTxt : string; //kt
165 //kt End Mod -------------------
166 CopyFld, FFld: TTemplateField;
167 FUpdating: boolean;
168 FReloadChanges: boolean;
169 FChangesPending: boolean;
170 FDeleted: TORStringList;
171 FHideSynonyms: boolean;
172 FLastRect: TRect;
173 procedure UpdateControls;
174 procedure SyncItems(DoUpdate: boolean = TRUE);
175 function SaveChanges: boolean;
176 procedure ResetListEntry;
177 procedure VerifyName;
178 procedure EnableButtons;
179 procedure SetFld(const Value: TTemplateField);
180 procedure SetHideSynonyms(const Value: boolean);
181 function GetPopupControl: TCustomEdit;
182 public
183 { Public declarations }
184 end;
185
186function EditDialogFields: boolean;
187
188implementation
189
190uses rTemplates, fTemplateDialog, Clipbrd, uSpell, uConst,
191 fTemplateFields;
192
193{$R *.DFM}
194
195{ TfrmDlgObjEditor }
196
197var
198 frmTemplateFields: TfrmTemplateFields = nil;
199
200
201function EditDialogFields: boolean;
202var
203 frmTemplateFieldEditor: TfrmTemplateFieldEditor;
204
205begin
206 frmTemplateFieldEditor := TfrmTemplateFieldEditor.Create(Application);
207 try
208 frmTemplateFieldEditor.ShowModal;
209 Result := frmTemplateFieldEditor.FReloadChanges;
210 finally
211 frmTemplateFieldEditor.Free;
212 end;
213end;
214
215procedure TfrmTemplateFieldEditor.UpdateControls;
216//const
217//DefTxt = 'Default:'; <-- original line. //kt 8/8/2007
218
219var
220 ok, edt, txt, tmp: boolean;
221 Y, idx, Max: integer;
222 wpTxt: string;
223 DefTxt : string; //kt
224
225 procedure SetLbl(const Text: string);
226 var
227 lbl: TLabel;
228
229 begin
230 inc(idx);
231 case idx of
232 1: lbl := lblS1;
233 2: lbl := lblS2;
234 3: lbl := lblS3;
235 else
236 lbl := nil;
237 end;
238 if assigned(lbl) then
239 lbl.Caption := Text;
240 end;
241
242 procedure SetY(Control: TControl; const Text: string);
243 begin
244 if (Control.Visible) then
245 begin
246 Control.Top := Y;
247 inc(Y, Control.Height);
248 SetLbl(Text);
249 end;
250 end;
251
252begin
253 DefTxt := DKLangConstW('fTemplateFieldEditor_Defaultx'); //kt
254 if(not FUpdating) then
255 begin
256 FUpdating := TRUE;
257 try
258 Y := 0;
259 idx := 0;
260 ok := assigned(FFld);
261 if(ok) then
262 begin
263 edt := (FFld.FldType in EditLenTypes);
264 txt := (FFld.FldType in EditDfltTypes);
265 end
266 else
267 begin
268 edt := FALSE;
269 txt := FALSE;
270 end;
271 lblName.Enabled := ok;
272 edtName.Enabled := ok;
273 lblType.Enabled := ok;
274 cbxType.Enabled := ok;
275 lblLM.Enabled := ok;
276 edtLMText.Enabled := ok;
277 cbActive.Enabled := ok;
278
279 gbMisc.Enabled := ok;
280 lblNotes.Enabled := ok;
281 reNotes.Enabled := ok;
282 if(ok) then
283 begin
284 edtName.Text := FFld.FldName;
285 cbxType.ItemIndex := ord(FFld.FldType);
286 edtLMText.Text := FFld.LMText;
287 cbActive.Checked := FFld.Inactive;
288 reNotes.Lines.Text := FFld.Notes;
289 end
290 else
291 begin
292 edtName.Text := '';
293 cbxType.ItemIndex := -1;
294 edtLMText.Text := '';
295 cbActive.Checked := FALSE;
296 reNotes.Clear;
297 end;
298
299 tmp := ok and (not (FFld.FldType in NoRequired));
300 cbRequired.Enabled := tmp;
301 if tmp then
302 cbRequired.Checked := FFld.Required
303 else
304 cbRequired.Checked := FALSE;
305
306 pnlSwap.DisableAlign;
307 try
308 tmp := ok and (FFld.FldType in SepLinesTypes);
309 cbSepLines.Enabled := tmp;
310 if tmp then
311 cbSepLines.Checked := FFld.SepLines
312 else
313 cbSepLines.Checked := FALSE;
314
315 tmp := ok and (FFld.FldType in ExcludeText);
316 cbExclude.Enabled := tmp;
317 if tmp then
318 cbExclude.Checked := FFld.SepLines
319 else
320 cbExclude.Checked := FALSE;
321
322 lblLength.Enabled := edt;
323 if ok and (FFld.FldType = dftWP) then
324 begin
325// lblTextLen.Caption := 'Num Lines:'; <-- original line. //kt 8/8/2007
326 lblTextLen.Caption := DKLangConstW('fTemplateFieldEditor_Num_Linesx'); //kt added 8/8/2007
327 udLen.Min := 5;
328 udLen.Max := 74;
329 udTextLen.Min := 2;
330 udTextLen.Max := MaxTFWPLines;
331 end
332 else
333 begin
334 udLen.Min := 1;
335 udLen.Max := 70;
336 udTextLen.Min := 0;
337 udTextLen.Max := 240;
338// lblTextLen.Caption := 'Text Len:'; <-- original line. //kt 8/8/2007
339 lblTextLen.Caption := DKLangConstW('fTemplateFieldEditor_Text_Lenx'); //kt added 8/8/2007
340 end;
341
342 lblTextLen.Enabled := edt;
343 edtTextLen.Enabled := edt;
344 udTextLen.Enabled := edt;
345 edtLen.Enabled := edt;
346 udLen.Enabled := edt;
347
348 edtDefault.Visible := txt;
349 SetY(edtDefault, DefTxt);
350 Max := MaxTFEdtLen;
351
352 if(edt) then
353 begin
354 udLen.Associate := edtLen;
355 udLen.Position := FFld.MaxLen;
356 udTextLen.Associate := edtTextLen;
357 udTextLen.Position := FFld.TextLen;
358 if txt then
359 Max := FFld.MaxLen;
360 end
361 else
362 begin
363 udLen.Associate := nil;
364 edtLen.Text := '';
365 udTextLen.Associate := nil;
366 edtTextLen.Text := '';
367 end;
368
369 if txt then
370 begin
371 edtDefault.MaxLength := Max;
372 edtDefault.Text := copy(FFld.EditDefault, 1, Max);
373 end;
374
375 gbIndent.Enabled := ok;
376 lblIndent.Enabled := ok;
377 edtIndent.Enabled := ok;
378 udIndent.Enabled := ok;
379 if ok then
380 begin
381 udIndent.Associate := edtIndent;
382 udIndent.Position := FFld.Indent;
383 end
384 else
385 begin
386 udIndent.Associate := nil;
387 edtIndent.Text := '';
388 end;
389
390 tmp := ok and (not cbExclude.Checked);
391 lblPad.Enabled := tmp;
392 edtPad.Enabled := tmp;
393 udPad.Enabled := tmp;
394 if tmp then
395 begin
396 udPad.Associate := edtPad;
397 udPad.Position := FFld.Pad;
398 end
399 else
400 begin
401 udPad.Associate := nil;
402 edtPad.Text := '';
403 end;
404
405 tmp := ok and (FFld.FldType = dftNumber);
406 pnlNum.Visible := tmp;
407 SetY(pnlNum, DefTxt);
408 if tmp then
409 begin
410 udDefNum.Position := StrToIntDef(FFld.EditDefault, 0);
411 udMinVal.Position := FFld.MinVal;
412 udMaxVal.Position := FFld.MaxVal;
413 udInc.Position := FFld.Increment;
414 end;
415
416 tmp := ok and (FFld.FldType = dftDate);
417 pnlDate.Visible := tmp;
418 SetY(pnlDate, DefTxt);
419 if tmp then
420 begin
421 edtDateDef.Text := FFld.EditDefault;
422 cbxDateType.SelectByID(TemplateFieldDateCodes[FFld.DateType]);
423 end;
424
425 tmp := ok and (FFld.FldType in ItemDfltTypes);
426 cbxDefault.Visible := tmp;
427 SetY(cbxDefault, DefTxt);
428
429 tmp := ok and (FFld.FldType = dftHyperlink);
430 edtURL.Visible := tmp;
431// SetY(edtURL, 'Address:'); <-- original line. //kt 8/8/2007
432 SetY(edtURL, DKLangConstW('fTemplateFieldEditor_Addressx')); //kt added 8/8/2007
433 if tmp then
434 edtURL.Text := FFld.URL;
435
436 tmp := ok and (FFld.FldType in FldItemTypes);
437 reItems.Visible := tmp;
438 lblLine.Visible := tmp;
439 lblCol.Visible := tmp;
440 if tmp then
441 begin
442 if FFld.FldType = dftWP then
443 wpTxt := DefTxt
444 else
445// wpTxt := 'Items:'; <-- original line. //kt 8/8/2007
446 wpTxt := DKLangConstW('fTemplateFieldEditor_Itemsx'); //kt added 8/8/2007
447 end
448 else
449 wpTxt := '';
450 SetY(reItems, wpTxt);
451 if tmp then
452 reItems.Lines.Text := FFld.Items
453 else
454 reItems.Clear;
455 finally
456 pnlSwap.EnableAlign;
457 end;
458
459 SetLbl('');
460 SetLbl('');
461 SetLbl('');
462 SyncItems(FALSE);
463 FormResize(Self);
464 finally
465 FUpdating := FALSE;
466 end;
467 end;
468end;
469
470procedure TfrmTemplateFieldEditor.SyncItems(DoUpdate: boolean = TRUE);
471var
472 i, idx, Siz, Max1, Max2: integer;
473 ChangeSizes: boolean;
474
475begin
476 if DoUpdate and FUpdating then
477 exit;
478 Max1 := 0;
479 Max2 := 0;
480 ChangeSizes := FALSE;
481 FUpdating := TRUE;
482 try
483 cbxDefault.Items.Assign(reItems.Lines);
484 idx := -1;
485 if(assigned(FFld)) and reItems.Visible and cbxDefault.Visible then
486 begin
487 ChangeSizes := TRUE;
488 for i := 0 to reItems.Lines.Count-1 do
489 begin
490 Siz := length(StripEmbedded(reItems.Lines[i]));
491 if Max1 < Siz then
492 Max1 := Siz;
493 if(idx < 0) and (FFld.ItemDefault = reItems.Lines[i]) then
494 idx := i;
495 end;
496 Max2 := Max1;
497 if Max1 > MaxTFEdtLen then
498 Max1 := MaxTFEdtLen;
499 end;
500 cbxDefault.ItemIndex := idx;
501 finally
502 FUpdating := FALSE;
503 end;
504 if ChangeSizes and DoUpdate then
505 begin
506 udLen.Position := Max1;
507 if (not udTextLen.Enabled) or
508 ((udTextLen.Position > 0) and (udTextLen.Position < Max2)) then
509 udTextLen.Position := Max2;
510 end;
511end;
512
513procedure TfrmTemplateFieldEditor.cbxObjsNeedData(Sender: TObject;
514 const StartFrom: String; Direction, InsertAt: Integer);
515var
516 tmp: TORStringList;
517 i, idx: integer;
518
519begin
520 tmp := TORStringList.Create;
521 try
522 tmp.Assign(SubSetOfTemplateFields(StartFrom, Direction));
523 for i := 0 to FDeleted.Count-1 do
524 begin
525 idx := tmp.IndexOfPiece(Piece(FDeleted[i],U,1), U, 1);
526 if(idx >= 0) then
527 tmp.delete(idx);
528 end;
529 ConvertCodes2Text(tmp, TRUE);
530 cbxObjs.ForDataUse(tmp);
531 finally
532 tmp.Free;
533 end;
534end;
535
536procedure TfrmTemplateFieldEditor.FormCreate(Sender: TObject);
537var
538 i: integer;
539 Child: TControl;
540 Overage: integer;
541begin
542 FDeleted := TORStringList.Create;
543 FHideSynonyms := TRUE;
544 cbxObjs.InitLongList('');
545 cbxObjs.ItemHeight := 15;
546 UpdateControls;
547 ResizeAnchoredFormToFont(self);
548 //ResizeAnchoredFormToFont does the pnlObjInfo panel wrong. So we fix it here.
549 gbMisc.Top := pnlObjInfo.ClientHeight - gbMisc.Height - 5;
550 gbIndent.Top := gbMisc.Top;
551 edtLMText.Top := gbMisc.Top - edtLMText.Height - 2;
552 lblLM.Top := edtLMText.Top + 5;
553 pnlSwap.Height := lblLM.Top - pnlSwap.Top;
554 Overage := edtName.Left + edtName.Width - pnlObjInfo.ClientWidth - 4;
555 for i := 0 to pnlObjInfo.ControlCount-1 do begin
556 Child := pnlObjInfo.Controls[i];
557 if (akRight in Child.Anchors) then begin
558 if (akLeft in Child.Anchors) then
559 Child.Width := Child.Width - Overage
560 else
561 Child.Left := Child.Left - Overage;
562 end;
563 end;
564end;
565
566procedure TfrmTemplateFieldEditor.cbxObjsChange(Sender: TObject);
567begin
568 if(cbxObjs.ItemIEN <> 0) then
569 SetFld(GetTemplateField(cbxObjs.ItemID, TRUE))
570 else
571 SetFld(nil);
572 UpdateControls;
573end;
574
575procedure TfrmTemplateFieldEditor.edtNameChange(Sender: TObject);
576var
577 ok: boolean;
578
579begin
580 if(not FUpdating) and (assigned(FFld)) then
581 begin
582 if (not FFld.NameChanged) and (not FFld.NewField) then
583 begin
584 ok := InfoBox('*** WARNING ***' + CRLF + CRLF +
585// 'This template field has been saved, and may have been used in one or more' + CRLF + <-- original line. //kt 8/8/2007
586 DKLangConstW('fTemplateFieldEditor_This_template_field_has_been_savedx_and_may_have_been_used_in_one_or_more') + CRLF + //kt added 8/8/2007
587// 'boilerplates. Boilerplates can be found in templates, titles, reasons for request' + CRLF + <-- original line. //kt 8/8/2007
588 DKLangConstW('fTemplateFieldEditor_boilerplatesx__Boilerplates_can_be_found_in_templatesx_titlesx_reasons_for_request') + CRLF + //kt added 8/8/2007
589// 'and reminder dialogs. Renaming this template field will cause any boilerplates' + CRLF + <-- original line. //kt 8/8/2007
590 DKLangConstW('fTemplateFieldEditor_and_reminder_dialogsx__Renaming_this_template_field_will_cause_any_boilerplates') + CRLF + //kt added 8/8/2007
591// 'that use it to no longer function correctly.' + CRLF + CRLF + <-- original line. //kt 8/8/2007
592 DKLangConstW('fTemplateFieldEditor_that_use_it_to_no_longer_function_correctlyx') + CRLF + CRLF + //kt added 8/8/2007
593// 'Are you sure you want to rename the ' + FFld.FldName + ' template field?', <-- original line. //kt 8/8/2007
594 DKLangConstW('fTemplateFieldEditor_Are_you_sure_you_want_to_rename_the')+' ' + FFld.FldName + DKLangConstW('fTemplateFieldEditor_template_fieldx'), //kt added 8/8/2007
595// 'Warning', MB_YESNO or MB_ICONWARNING) = IDYES; <-- original line. //kt 8/8/2007
596 DKLangConstW('fTemplateFieldEditor_Warning'), MB_YESNO or MB_ICONWARNING) = IDYES; //kt added 8/8/2007
597 if ok then
598// InfoBox('Template field will be renamed when OK or Apply is pressed.', 'Information', MB_OK or MB_ICONINFORMATION) <-- original line. //kt 8/8/2007
599 InfoBox(DKLangConstW('fTemplateFieldEditor_Template_field_will_be_renamed_when_OK_or_Apply_is_pressedx'), DKLangConstW('fTemplateFieldEditor_Information'), MB_OK or MB_ICONINFORMATION) //kt added 8/8/2007
600 else
601 begin
602 FUpdating := TRUE;
603 try
604 edtName.Text := FFld.FldName;
605 finally
606 FUpdating := FALSE;
607 end;
608 end;
609 end
610 else
611 ok := TRUE;
612 if ok then
613 begin
614 FFld.FldName := edtName.Text;
615 edtName.Text := FFld.FldName;
616 FChangesPending := TRUE;
617 ResetListEntry;
618 end;
619 end;
620end;
621
622procedure TfrmTemplateFieldEditor.cbxTypeChange(Sender: TObject);
623begin
624 if(not FUpdating) and (assigned(FFld)) then
625 begin
626 if(cbxType.ItemIndex < 0) then
627 begin
628 FUpdating := TRUE;
629 try
630 cbxType.ItemIndex := 0;
631 finally
632 FUpdating := FALSE;
633 end;
634 end;
635 FFld.FldType := TTemplateFieldType(cbxType.ItemIndex);
636 end;
637 EnableButtons;
638 UpdateControls;
639end;
640
641procedure TfrmTemplateFieldEditor.edtLenChange(Sender: TObject);
642var
643 v: integer;
644 ok: boolean;
645
646begin
647 EnsureText(edtLen, udLen);
648 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType in (EditLenTypes))) then
649 begin
650 EnsureText(edtLen, udLen);
651 FFld.MaxLen := udLen.Position;
652 udLen.Position := FFld.MaxLen;
653 if edtDefault.Visible then
654 begin
655 edtDefault.MaxLength := FFld.MaxLen;
656 edtDefault.Text := copy(edtDefault.Text,1,FFld.MaxLen);
657 end;
658 case FFLd.FldType of
659 dftEditBox: ok := TRUE;
660 dftComboBox: ok := (udTextLen.Position > 0);
661 else ok := FALSE;
662 end;
663 if ok then
664 begin
665 v := udLen.Position;
666 if udTextLen.Position < v then
667 udTextLen.Position := v;
668 end;
669 end;
670end;
671
672procedure TfrmTemplateFieldEditor.edtDefaultChange(Sender: TObject);
673begin
674 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType in EditDfltType2)) then
675 begin
676 FFld.EditDefault := TEdit(Sender).Text;
677 TEdit(Sender).Text := FFld.EditDefault;
678 end;
679end;
680
681procedure TfrmTemplateFieldEditor.cbxDefaultChange(Sender: TObject);
682begin
683 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType in ItemDfltTypes)) then
684 begin
685 FFld.ItemDefault := cbxDefault.Text;
686 SyncItems;
687 end;
688end;
689
690procedure TfrmTemplateFieldEditor.edtLMTextChange(Sender: TObject);
691begin
692 if((not FUpdating) and (assigned(FFld))) then
693 begin
694 FFld.LMText := edtLMText.Text;
695 edtLMText.Text := FFld.LMText;
696 end;
697end;
698
699procedure TfrmTemplateFieldEditor.cbActiveClick(Sender: TObject);
700begin
701 if((not FUpdating) and (assigned(FFld))) then
702 begin
703 FFld.Inactive := cbActive.Checked;
704 cbActive.Checked := FFld.Inactive;
705 FChangesPending := TRUE;
706 //ResetListEntry;
707 end;
708end;
709
710procedure TfrmTemplateFieldEditor.mnuNewClick(Sender: TObject);
711begin
712 SetFld(TTemplateField.Create(nil));
713 if(assigned(FFld)) then
714 begin
715 FChangesPending := TRUE;
716 if cbxObjs.ShortCount = 0 then
717 begin
718 cbxObjs.Items.Insert(0,LLS_LINE);
719 cbxObjs.Items.Insert(1,'');
720 end;
721 if(assigned(CopyFld)) then
722 FFld.Assign(CopyFld);
723 cbxObjs.Items.Insert(0,FFld.ID + U + FFld.FldName);
724 cbxObjs.SelectByID(FFld.ID);
725 cbxObjsChange(nil);
726 if(assigned(FFld)) then
727 edtName.SetFocus;
728 end
729 else
730 UpdateControls;
731end;
732
733procedure TfrmTemplateFieldEditor.btnOKClick(Sender: TObject);
734begin
735 SaveChanges;
736end;
737
738procedure TfrmTemplateFieldEditor.btnApplyClick(Sender: TObject);
739var
740 tmp: string;
741begin
742 SaveChanges;
743 cbxObjs.Clear;
744 if assigned(FFld) then
745 tmp := FFld.FldName
746 else
747 tmp := '';
748 cbxObjs.InitLongList(tmp);
749 cbxObjs.ItemIndex := 0;
750 cbxObjsChange(cbxObjs);
751end;
752
753procedure TfrmTemplateFieldEditor.FormCloseQuery(Sender: TObject;
754 var CanClose: Boolean);
755var
756 ans: word;
757
758begin
759 if(AnyTemplateFieldsModified) then
760 begin
761// ans := InfoBox('Save Changes?', 'Confirmation', MB_YESNOCANCEL or MB_ICONQUESTION); <-- original line. //kt 8/8/2007
762 ans := InfoBox(DKLangConstW('fTemplateFieldEditor_Save_Changesx'), DKLangConstW('fTemplateFieldEditor_Confirmation'), MB_YESNOCANCEL or MB_ICONQUESTION); //kt added 8/8/2007
763 if(ans = IDCANCEL) then
764 CanClose := FALSE
765 else
766 if(ans = IDYES) then
767 CanClose := SaveChanges;
768 end;
769end;
770
771procedure TfrmTemplateFieldEditor.btnCancelClick(Sender: TObject);
772var
773 i: integer;
774
775begin
776 for i := 0 to FDeleted.Count-1 do
777 UnlockTemplateField(Piece(FDeleted[i],U,1));
778 FDeleted.Clear;
779 ClearModifiedTemplateFields;
780end;
781
782function TfrmTemplateFieldEditor.SaveChanges: boolean;
783var
784 ans: word;
785 Errors: string;
786 i: integer;
787
788begin
789 for i := 0 to FDeleted.Count-1 do
790 DeleteTemplateField(Piece(FDeleted[i],U,1));
791 FDeleted.Clear;
792 Result := TRUE;
793 Errors := SaveTemplateFieldErrors;
794 if(Errors <> '') then
795 begin
796// ans := InfoBox(Errors + CRLF + CRLF + 'Cancel changes to these Template Fields?', <-- original line. //kt 8/8/2007
797 ans := InfoBox(Errors + CRLF + CRLF + DKLangConstW('fTemplateFieldEditor_Cancel_changes_to_these_Template_Fieldsx'), //kt added 8/8/2007
798// 'Confirmation', MB_YESNO or MB_ICONQUESTION); <-- original line. //kt 8/8/2007
799 DKLangConstW('fTemplateFieldEditor_Confirmation'), MB_YESNO or MB_ICONQUESTION); //kt added 8/8/2007
800 if(ans = IDYES) then
801 ClearModifiedTemplateFields
802 else
803 Result := FALSE;
804 end;
805 if(FChangesPending) then
806 FReloadChanges := TRUE;
807end;
808
809procedure TfrmTemplateFieldEditor.reItemsChange(Sender: TObject);
810begin
811 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType in FldItemTypes)) then
812 begin
813 FFld.Items := reItems.Lines.Text;
814 SyncItems;
815 end;
816end;
817
818procedure TfrmTemplateFieldEditor.cbHideClick(Sender: TObject);
819begin
820 SetHideSynonyms(cbHide.Checked);
821end;
822
823procedure TfrmTemplateFieldEditor.edtNameExit(Sender: TObject);
824begin
825 if (ActiveControl <> btnCancel) and (ActiveControl <> btnDelete) then
826 VerifyName;
827end;
828
829procedure TfrmTemplateFieldEditor.VerifyName;
830var
831 bad: boolean;
832
833begin
834 if assigned(FFld) then
835 begin
836 if FDeleted.IndexOfPiece(FFld.FldName, U, 2) >= 0 then
837 begin
838// ShowMessage('Template field can not be named the same as a deleted' + CRLF + <-- original line. //kt 8/8/2007
839 ShowMessage(DKLangConstW('fTemplateFieldEditor_Template_field_can_not_be_named_the_same_as_a_deleted') + CRLF + //kt added 8/8/2007
840// 'field until OK or Apply has been pressed.'); <-- original line. //kt 8/8/2007
841 DKLangConstW('fTemplateFieldEditor_field_until_OK_or_Apply_has_been_pressedx')); //kt added 8/8/2007
842 bad := TRUE;
843 end
844 else
845 bad := TemplateFieldNameProblem(FFld);
846 if bad then
847 edtName.SetFocus;
848 end;
849end;
850
851procedure TfrmTemplateFieldEditor.mnuCopyClick(Sender: TObject);
852begin
853 if assigned(FFld) then
854 begin
855 CopyFld := FFld;
856 try
857 mnuNewClick(nil);
858 finally
859 CopyFld := nil;
860 end;
861 end;
862end;
863
864procedure TfrmTemplateFieldEditor.SetFld(const Value: TTemplateField);
865begin
866 FFld := Value;
867 EnableButtons;
868end;
869
870procedure TfrmTemplateFieldEditor.mnuDeleteClick(Sender: TObject);
871var
872 idx: integer;
873 ok: boolean;
874 Answer: word;
875 txt: string;
876 btns: TMsgDlgButtons;
877
878begin
879 if assigned(FFld) then
880 begin
881 ok := (FFld.NewField);
882 if not ok then
883 begin
884 btns := [mbYes, mbNo];
885 if FFld.Inactive then
886 txt := ''
887 else
888 begin
889// txt := ' Rather than deleting, you may want' + CRLF + <-- original line. //kt 8/8/2007
890 txt := DKLangConstW('fTemplateFieldEditor_Rather_than_deletingx_you_may_want') + CRLF + //kt added 8/8/2007
891// 'to inactivate this template field instead. You may inactivate this template by' + CRLF + <-- original line. //kt 8/8/2007
892 DKLangConstW('fTemplateFieldEditor_to_inactivate_this_template_field_insteadx__You_may_inactivate_this_template_by') + CRLF + //kt added 8/8/2007
893// 'pressing the Ignore button now.'; <-- original line. //kt 8/8/2007
894 DKLangConstW('fTemplateFieldEditor_pressing_the_Ignore_button_nowx'); //kt added 8/8/2007
895 include(btns, mbIgnore);
896 end;
897 Answer := MessageDlg('*** WARNING ***' + CRLF + CRLF +
898// 'This template field has been saved, and may have been used in one or more' + CRLF + <-- original line. //kt 8/8/2007
899 DKLangConstW('fTemplateFieldEditor_This_template_field_has_been_savedx_and_may_have_been_used_in_one_or_more') + CRLF + //kt added 8/8/2007
900// 'boilerplates. Boilerplates can be found in templates, titles, reasons for request' + CRLF + <-- original line. //kt 8/8/2007
901 DKLangConstW('fTemplateFieldEditor_boilerplatesx__Boilerplates_can_be_found_in_templatesx_titlesx_reasons_for_request') + CRLF + //kt added 8/8/2007
902// 'and reminder dialogs. Deleting this template field will cause any boilerplates' + CRLF + <-- original line. //kt 8/8/2007
903 DKLangConstW('fTemplateFieldEditor_and_reminder_dialogsx__Deleting_this_template_field_will_cause_any_boilerplates') + CRLF + //kt added 8/8/2007
904// 'that use it to no longer function correctly.' + txt + CRLF + CRLF + <-- original line. //kt 8/8/2007
905 DKLangConstW('fTemplateFieldEditor_that_use_it_to_no_longer_function_correctlyx') + txt + CRLF + CRLF + //kt added 8/8/2007
906// 'Are you sure you want to delete the ' + FFld.FldName + ' template field?', <-- original line. //kt 8/8/2007
907 DKLangConstW('fTemplateFieldEditor_Are_you_sure_you_want_to_delete_the')+' ' + FFld.FldName + DKLangConstW('fTemplateFieldEditor_template_fieldx'), //kt added 8/8/2007
908 mtWarning, btns, 0);
909 ok := (Answer = mrYes);
910 if(Answer = mrIgnore) then
911 cbActive.Checked := TRUE;
912 end;
913 if ok then
914 begin
915 if(FFld.NewField or FFld.CanModify) then
916 begin
917 if FFld.NewField then
918 begin
919 idx := cbxObjs.ItemIndex;
920 cbxObjs.ItemIndex := -1;
921 cbxObjs.Items.Delete(idx);
922 if cbxObjs.Items[0] = LLS_LINE then
923 begin
924 cbxObjs.Items.Delete(1);
925 cbxObjs.Items.Delete(0);
926 end;
927 end
928 else
929 begin
930 FDeleted.Add(FFld.ID + U + FFld.FldName);
931 cbxObjs.ItemIndex := -1;
932 end;
933 end;
934 FFld.Free;
935 SetFld(nil);
936 UpdateControls;
937 cbxObjs.InitLongList('');
938 FChangesPending := TRUE;
939 end;
940 end;
941end;
942
943procedure TfrmTemplateFieldEditor.ResetListEntry;
944var
945 txt: string;
946
947begin
948 if(assigned(FFld) and FFld.NewField and (cbxObjs.ItemIndex >= 0)) then
949 begin
950 txt := FFld.ID + U + FFld.FldName;
951 //if(FFld.Inactive) then
952 //txt := txt + ' <Inactive>';
953 cbxObjs.Items[cbxObjs.ItemIndex] := txt;
954 cbxObjs.ItemIndex := cbxObjs.ItemIndex;
955 end;
956end;
957
958procedure TfrmTemplateFieldEditor.btnPreviewClick(Sender: TObject);
959var
960 TmpSL: TStringList;
961
962begin
963 if(assigned(FFld)) then
964 begin
965 TmpSL := TStringList.Create;
966 try
967 TmpSL.Add(TemplateFieldBeginSignature + FFld.FldName + TemplateFieldEndSignature);
968// CheckBoilerplate4Fields(TmpSL, 'Preview Template Field: ' + FFld.FldName, TRUE); <-- original line. //kt 8/8/2007
969 CheckBoilerplate4Fields(TmpSL, DKLangConstW('fTemplateFieldEditor_Preview_Template_Fieldx') + FFld.FldName, TRUE); //kt added 8/8/2007
970 finally
971 TmpSL.Free;
972 end;
973 end;
974end;
975
976procedure TfrmTemplateFieldEditor.EnableButtons;
977begin
978 btnCopy.Enabled := assigned(FFld);
979 mnuCopy.Enabled := btnCopy.Enabled;
980 btnDelete.Enabled := btnCopy.Enabled; // (assigned(FFld) and FFld.NewField);
981 mnuDelete.Enabled := btnDelete.Enabled;
982 btnPreview.Enabled := assigned(FFld) and (FFld.FldType <> dftUnknown);
983 mnuPreview.Enabled := btnPreview.Enabled;
984end;
985
986procedure TfrmTemplateFieldEditor.mnuActionClick(Sender: TObject);
987begin
988 EnableButtons;
989end;
990
991procedure TfrmTemplateFieldEditor.cbRequiredClick(Sender: TObject);
992begin
993 if((not FUpdating) and (assigned(FFld))) then
994 begin
995 FFld.Required := cbRequired.Checked;
996 cbRequired.Checked := FFld.Required;
997 end;
998end;
999
1000procedure TfrmTemplateFieldEditor.pnlObjsResize(Sender: TObject);
1001begin
1002 btnPreview.Left := pnlRight.Left;
1003end;
1004
1005procedure TfrmTemplateFieldEditor.FormDestroy(Sender: TObject);
1006begin
1007 FDeleted.Free;
1008 if(assigned(frmTemplateFields)) then begin
1009 frmTemplateFields.FRee;
1010 frmTemplateFields := nil;
1011 end; {if}
1012
1013end;
1014
1015procedure TfrmTemplateFieldEditor.SetHideSynonyms(const Value: boolean);
1016begin
1017 FHideSynonyms := Value;
1018 cbxObjs.HideSynonyms := FALSE; // Refresh Display
1019 cbxObjs.HideSynonyms := TRUE;
1020end;
1021
1022procedure TfrmTemplateFieldEditor.cbxObjsSynonymCheck(Sender: TObject;
1023 const Text: String; var IsSynonym: Boolean);
1024begin
1025 if not FHideSynonyms then
1026 IsSynonym := FALSE;
1027 if(FDeleted.Count > 0) and (FDeleted.IndexOfPiece(Text,U,2) >= 0) then
1028 IsSynonym := TRUE;
1029end;
1030
1031procedure TfrmTemplateFieldEditor.popTextPopup(Sender: TObject);
1032var
1033 HasText, CanEdit, isre: boolean;
1034 ce: TCustomEdit;
1035 ShowTempField: boolean;
1036
1037begin
1038 ce := GetPopupControl;
1039 if assigned(ce) then
1040 begin
1041 isre := (ce is TRichEdit);
1042 CanEdit := (not TORExposedCustomEdit(ce).ReadOnly);
1043 mnuBPUndo.Enabled := (CanEdit and (ce.Perform(EM_CANUNDO, 0, 0) <> 0));
1044 if isre then
1045 HasText := (TRichEdit(ce).Lines.Count > 0)
1046 else
1047 HasText := (Text <> '');
1048 mnuBPSelectAll.Enabled := HasText;
1049 mnuBPCopy.Enabled := HasText and (ce.SelLength > 0);
1050 mnuBPPaste.Enabled := (CanEdit and Clipboard.HasFormat(CF_TEXT));
1051 mnuBPCut.Enabled := (CanEdit and HasText and (ce.SelLength > 0));
1052 ShowTempField := FALSE;
1053 if CanEdit then
1054 if (not assigned(frmTemplateFields)) or
1055 (assigned(frmTemplateFields) and not frmTemplateFields.Visible) then
1056 if (ce = reItems) or
1057 (ce = edtDefault) then
1058 ShowTempField := TRUE;
1059 mnuInsertTemplateField.Enabled := ShowTempField;
1060 end
1061 else
1062 begin
1063 isre := FALSE;
1064 HasText := FALSE;
1065 CanEdit := FALSE;
1066 mnuBPPaste.Enabled := FALSE;
1067 mnuBPCopy.Enabled := FALSE;
1068 mnuBPCut.Enabled := FALSE;
1069 mnuBPSelectAll.Enabled := FALSE;
1070 mnuBPUndo.Enabled := FALSE;
1071 mnuInsertTemplateField.Enabled := FALSE;
1072 end;
1073
1074 mnuBPSpellCheck.Visible := isre;
1075 mnuBPCheckGrammar.Visible := isre;
1076
1077 if isre and HasText and CanEdit then
1078 begin
1079 mnuBPSpellCheck.Enabled := SpellCheckAvailable;
1080 mnuBPCheckGrammar.Enabled := SpellCheckAvailable;
1081 end
1082 else
1083 begin
1084 mnuBPSpellCheck.Enabled := FALSE;
1085 mnuBPCheckGrammar.Enabled := FALSE;
1086 end;
1087end;
1088
1089function TfrmTemplateFieldEditor.GetPopupControl: TCustomEdit;
1090begin
1091 if assigned(popText.PopupComponent) and (popText.PopupComponent is TCustomEdit) then
1092 Result := TCustomEdit(popText.PopupComponent)
1093 else
1094 Result := nil;
1095end;
1096
1097procedure TfrmTemplateFieldEditor.mnuBPUndoClick(Sender: TObject);
1098var
1099 ce: TCustomEdit;
1100
1101begin
1102 ce := GetPopupControl;
1103 if assigned(ce) then
1104 ce.Perform(EM_UNDO, 0, 0);
1105end;
1106
1107procedure TfrmTemplateFieldEditor.mnuBPCutClick(Sender: TObject);
1108var
1109 ce: TCustomEdit;
1110
1111begin
1112 ce := GetPopupControl;
1113 if assigned(ce) then
1114 ce.CutToClipboard;
1115end;
1116
1117procedure TfrmTemplateFieldEditor.mnuBPCopyClick(Sender: TObject);
1118var
1119 ce: TCustomEdit;
1120
1121begin
1122 ce := GetPopupControl;
1123 if assigned(ce) then
1124 ce.CopyToClipboard;
1125end;
1126
1127procedure TfrmTemplateFieldEditor.mnuBPPasteClick(Sender: TObject);
1128var
1129 ce: TCustomEdit;
1130
1131begin
1132 ce := GetPopupControl;
1133 if assigned(ce) then
1134 ce.SelText := Clipboard.AsText;
1135end;
1136
1137procedure TfrmTemplateFieldEditor.mnuBPSelectAllClick(Sender: TObject);
1138var
1139 ce: TCustomEdit;
1140
1141begin
1142 ce := GetPopupControl;
1143 if assigned(ce) then
1144 ce.SelectAll;
1145end;
1146
1147procedure TfrmTemplateFieldEditor.mnuBPCheckGrammarClick(Sender: TObject);
1148var
1149 ce: TCustomEdit;
1150
1151begin
1152 ce := GetPopupControl;
1153 if(assigned(ce) and (ce is TRichEdit)) then
1154 GrammarCheckForControl(TRichEdit(ce));
1155end;
1156
1157procedure TfrmTemplateFieldEditor.mnuBPSpellCheckClick(Sender: TObject);
1158var
1159 ce: TCustomEdit;
1160
1161begin
1162 ce := GetPopupControl;
1163 if(assigned(ce) and (ce is TRichEdit)) then
1164 SpellCheckForControl(TRichEdit(ce));
1165end;
1166
1167procedure TfrmTemplateFieldEditor.cbSepLinesClick(Sender: TObject);
1168begin
1169 if((not FUpdating) and (assigned(FFld))) then
1170 begin
1171 FFld.SepLines := cbSepLines.Checked;
1172 cbSepLines.Checked := FFld.SepLines;
1173 end;
1174end;
1175
1176procedure TfrmTemplateFieldEditor.edtpopControlEnter(Sender: TObject);
1177begin
1178 popText.PopupComponent := TComponent(Sender);
1179 if assigned(frmTemplateFields) then
1180 begin
1181 if ((Sender = reItems) or (Sender = edtDefault)) then
1182 begin
1183 frmTemplateFields.btnInsert.Enabled := TRUE;
1184 if Sender = reItems then
1185 frmTemplateFields.re := reItems
1186 else
1187 frmTemplateFields.re := edtDefault;
1188 end
1189 else
1190 frmTemplateFields.btnInsert.Enabled := FALSE;
1191 end;
1192end;
1193
1194procedure TfrmTemplateFieldEditor.cbxObjsKeyDown(Sender: TObject;
1195 var Key: Word; Shift: TShiftState);
1196begin
1197 if(Key = VK_DELETE) and btnDelete.Enabled then
1198 mnuDeleteClick(btnDelete);
1199end;
1200
1201procedure TfrmTemplateFieldEditor.edtTextLenChange(Sender: TObject);
1202var
1203 v: integer;
1204
1205begin
1206 EnsureText(edtTextLen, udTextLen);
1207 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType in EditLenTypes)) then
1208 begin
1209 FFld.TextLen := udTextLen.Position;
1210 udTextLen.Position := FFld.TextLen;
1211 if FFld.FldType = dftEditBox then
1212 begin
1213 v := udTextLen.Position;
1214 if udLen.Position > v then
1215 udLen.Position := v;
1216 end;
1217 end;
1218end;
1219
1220procedure TfrmTemplateFieldEditor.edtDefNumChange(Sender: TObject);
1221var
1222 v: integer;
1223
1224begin
1225 EnsureText(edtDefNum, udDefNum);
1226 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType = dftNumber)) then
1227 begin
1228 FFld.EditDefault := IntToStr(udDefNum.Position);
1229 udDefNum.Position := StrToIntDef(FFld.EditDefault, 0);
1230 v := udDefNum.Position;
1231 if udMinVal.Position > v then
1232 udMinVal.Position := v;
1233 if udMaxVal.Position < v then
1234 udMaxVal.Position := v;
1235 end;
1236end;
1237
1238procedure TfrmTemplateFieldEditor.edtMinValChange(Sender: TObject);
1239var
1240 v: integer;
1241
1242begin
1243 EnsureText(edtMinVal, udMinVal);
1244 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType = dftNumber)) then
1245 begin
1246 FFld.MinVal := udMinVal.Position;
1247 udMinVal.Position := FFld.MinVal;
1248 v := udMinVal.Position;
1249 if udDefNum.Position < v then
1250 udDefNum.Position := v;
1251 if udMaxVal.Position < v then
1252 udMaxVal.Position := v;
1253 end;
1254end;
1255
1256procedure TfrmTemplateFieldEditor.edtMaxValChange(Sender: TObject);
1257var
1258 v: integer;
1259
1260begin
1261 EnsureText(edtMaxVal, udMaxVal);
1262 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType = dftNumber)) then
1263 begin
1264 FFld.MaxVal := udMaxVal.Position;
1265 udMaxVal.Position := FFld.MaxVal;
1266 v := udMaxVal.Position;
1267 if udDefNum.Position > v then
1268 udDefNum.Position := v;
1269 if udMinVal.Position > v then
1270 udMinVal.Position := v;
1271 end;
1272end;
1273
1274procedure TfrmTemplateFieldEditor.edtIncChange(Sender: TObject);
1275begin
1276 EnsureText(edtInc, udInc);
1277 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType = dftNumber)) then
1278 begin
1279 FFld.Increment := udInc.Position;
1280 udInc.Position := FFld.Increment;
1281 end;
1282end;
1283
1284procedure TfrmTemplateFieldEditor.edtURLChange(Sender: TObject);
1285begin
1286 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType = dftHyperlink)) then
1287 begin
1288 FFld.URL := edtURL.Text;
1289 edtURL.Text := FFld.URL;
1290 end;
1291end;
1292
1293procedure TfrmTemplateFieldEditor.edtPadChange(Sender: TObject);
1294begin
1295 EnsureText(edtPad, udPad);
1296 if((not FUpdating) and (assigned(FFld))) then
1297 begin
1298 FFld.Pad := udPad.Position;
1299 udPad.Position := FFld.Pad;
1300 end;
1301end;
1302
1303procedure TfrmTemplateFieldEditor.edtIndentChange(Sender: TObject);
1304begin
1305 EnsureText(edtIndent, udIndent);
1306 if((not FUpdating) and (assigned(FFld))) then
1307 begin
1308 FFld.Indent := udIndent.Position;
1309 udIndent.Position := FFld.Indent;
1310 end;
1311end;
1312
1313procedure TfrmTemplateFieldEditor.reNotesChange(Sender: TObject);
1314begin
1315 if((not FUpdating) and (assigned(FFld)) and FFld.CanModify) then
1316 FFld.Notes := reNotes.Lines.Text;
1317end;
1318
1319procedure TfrmTemplateFieldEditor.cbxDateTypeChange(Sender: TObject);
1320begin
1321 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType = dftDate)) then
1322 begin
1323 if cbxDateType.ItemIndex >= 0 then
1324 FFld.DateType := TTmplFldDateType(cbxDateType.ItemIndex + 1)
1325 else
1326 FFld.DateType := dtDate;
1327 cbxDateType.SelectByID(TemplateFieldDateCodes[FFld.DateType]);
1328 end;
1329
1330end;
1331
1332procedure TfrmTemplateFieldEditor.cbExcludeClick(Sender: TObject);
1333begin
1334 if((not FUpdating) and (assigned(FFld))) then
1335 begin
1336 FFld.SepLines := cbExclude.Checked;
1337 cbExclude.Checked := FFld.SepLines;
1338 UpdateControls;
1339 end;
1340end;
1341
1342procedure TfrmTemplateFieldEditor.FormResize(Sender: TObject);
1343begin
1344 LimitEditWidth(reItems, 240);
1345 LimitEditWidth(reNotes, MAX_ENTRY_WIDTH);
1346end;
1347
1348procedure TfrmTemplateFieldEditor.reItemsResizeRequest(Sender: TObject;
1349 Rect: TRect);
1350var
1351 R: TRect;
1352
1353begin
1354 R := TRichEdit(Sender).ClientRect;
1355 if (FLastRect.Right <> R.Right) or
1356 (FLastRect.Bottom <> R.Bottom) or
1357 (FLastRect.Left <> R.Left) or
1358 (FLastRect.Top <> R.Top) then
1359 begin
1360 FLastRect := R;
1361 FormResize(Self);
1362 end;
1363end;
1364
1365procedure TfrmTemplateFieldEditor.reItemsSelectionChange(Sender: TObject);
1366var
1367 p: TPoint;
1368
1369begin
1370 if lblLine.Visible then
1371 begin
1372 p := reItems.CaretPos;
1373// lblLine.Caption := 'Line: ' + inttostr(p.y + 1); <-- original line. //kt 8/8/2007
1374 lblLine.Caption := DKLangConstW('fTemplateFieldEditor_Linex') + inttostr(p.y + 1); //kt added 8/8/2007
1375// lblCol.Caption := 'Col: ' + inttostr(p.x + 1); <-- original line. //kt 8/8/2007
1376 lblCol.Caption := DKLangConstW('fTemplateFieldEditor_Colx') + inttostr(p.x + 1); //kt added 8/8/2007
1377 end;
1378end;
1379
1380procedure TfrmTemplateFieldEditor.mnuInsertTemplateFieldClick(Sender: TObject);
1381var
1382 iCon: TCustomEdit;
1383 ShowButton: boolean;
1384begin
1385 iCon := GetPopupControl;
1386 if iCon <> nil then
1387 begin
1388 if iCon.Name <> ActiveControl.Name then
1389 begin
1390 ActiveControl := iCon;
1391 iCon.SelStart := iCon.SelLength;
1392 end;
1393 if (not assigned(frmTemplateFields)) then
1394 begin
1395 frmTemplateFields := TfrmTemplateFields.Create(Self);
1396 frmTemplateFields.Font := Font;
1397 end;
1398 ShowButton := False;
1399 if iCon = reItems then
1400 begin
1401 frmTemplateFields.re := reItems;
1402 ShowButton := TRUE;
1403 end
1404 else if iCon = edtDefault then
1405 begin
1406 frmTemplateFields.re := edtDefault;
1407 ShowButton := TRUE;
1408 end;
1409 frmTemplateFields.btnInsert.Enabled := ShowButton;
1410
1411 frmTemplateFields.Show;
1412 end
1413
1414end;
1415
1416procedure TfrmTemplateFieldEditor.ControlExit(Sender: TObject);
1417begin
1418 if assigned(frmTemplateFields) then
1419 frmTemplateFields.btnInsert.Enabled := FALSE;
1420end;
1421
1422procedure TfrmTemplateFieldEditor.reNotesKeyUp(Sender: TObject;
1423 var Key: Word; Shift: TShiftState);
1424begin
1425 if (Key = VK_TAB) then
1426 begin
1427 if ssShift in Shift then
1428 begin
1429 FindNextControl(Sender as TWinControl, False, True, False).SetFocus; //previous control
1430 Key := 0;
1431 end
1432 else if ssCtrl in Shift then
1433 begin
1434 FindNextControl(Sender as TWinControl, True, True, False).SetFocus; //next control
1435 Key := 0;
1436 end;
1437 end;
1438 if (key = VK_ESCAPE) then begin
1439 FindNextControl(Sender as TWinControl, False, True, False).SetFocus; //previous control
1440 key := 0;
1441 end;
1442end;
1443
1444end.
Note: See TracBrowser for help on using the repository browser.