source: cprs/branches/tmg-cprs/CPRS-Chart/Templates/fTemplateFields.pas@ 1156

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

Initial upload of TMG-CPRS 1.0.26.69

File size: 4.3 KB
Line 
1//kt -- Modified with SourceScanner on 8/8/2007
2unit fTemplateFields;
3
4interface
5
6uses
7 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
8 ORCtrls, ComCtrls, StdCtrls, ExtCtrls, DKLang;
9
10type
11 TfrmTemplateFields = class(TForm)
12 pnlBottom: TPanel;
13 btnCancel: TButton;
14 cboObjects: TORComboBox;
15 btnInsert: TButton;
16 lblReq: TStaticText;
17 btnPreview: TButton;
18 DKLanguageController1: TDKLanguageController;
19 procedure FormShow(Sender: TObject);
20 procedure FormCreate(Sender: TObject);
21 procedure cboObjectsNeedData(Sender: TObject; const StartFrom: String;
22 Direction, InsertAt: Integer);
23 procedure cboObjectsDblClick(Sender: TObject);
24 procedure btnCancelClick(Sender: TObject);
25 procedure FormClose(Sender: TObject; var Action: TCloseAction);
26 procedure btnInsertClick(Sender: TObject);
27 procedure btnPreviewClick(Sender: TObject);
28 procedure cboObjectsChange(Sender: TObject);
29 private
30{ Fre: TRichEdit;}
31 Fre: TCustomEdit;
32 FAutoLongLines: TNotifyEvent;
33 procedure InsertField;
34{ procedure Setre(const Value: TRichEdit);}
35 procedure Setre(const Value: TCustomEdit);
36 public
37 procedure UpdateStatus;
38{ property re: TRichEdit read Fre write Setre;}
39 property re: TCustomEdit read Fre write Setre;
40 property AutoLongLines: TNotifyEvent read FAutoLongLines write FAutoLongLines;
41 end;
42
43implementation
44
45uses
46 ORFn, rTemplates, uTemplateFields, fTemplateDialog, ORClasses;
47
48{$R *.DFM}
49
50procedure TfrmTemplateFields.FormShow(Sender: TObject);
51begin
52 cboObjects.SelectAll;
53 cboObjects.SetFocus;
54end;
55
56procedure TfrmTemplateFields.FormCreate(Sender: TObject);
57begin
58 cboObjects.InitLongList('');
59 cboObjects.ItemHeight := 15;
60 ResizeAnchoredFormToFont(self);
61 //ResizeAnchoredFormToFont doesn't work right on the button positions for some reason.
62 btnCancel.Left := pnlBottom.ClientWidth - btnCancel.Width;
63 btnInsert.Left := btnCancel.Left - btnInsert.Width - 8;
64end;
65
66procedure TfrmTemplateFields.cboObjectsNeedData(Sender: TObject;
67 const StartFrom: String; Direction, InsertAt: Integer);
68var
69 tmp: TStrings;
70
71begin
72 tmp := SubSetOfTemplateFields(StartFrom, Direction);
73 ConvertCodes2Text(tmp, FALSE);
74 cboObjects.ForDataUse(tmp);
75end;
76
77procedure TfrmTemplateFields.InsertField;
78var
79 cnt: integer;
80
81begin
82 if assigned(Fre) and (not TORExposedCustomEdit(Fre).ReadOnly) and (cboObjects.ItemIndex >= 0) then
83 begin
84 if Fre is TRichEdit then
85 cnt := TRichEdit(FRe).Lines.Count
86 else
87 cnt :=0;
88 Fre.SelText := TemplateFieldBeginSignature +
89 Piece(cboObjects.Items[cboObjects.ItemIndex],U,2)+
90 TemplateFieldEndSignature;
91 if Fre is TRichEdit then
92 if(assigned(FAutoLongLines) and (cnt <> TRichEdit(FRe).Lines.Count)) then
93 FAutoLongLines(Self);
94 end;
95end;
96
97procedure TfrmTemplateFields.cboObjectsDblClick(Sender: TObject);
98begin
99 if btnInsert.Enabled then
100 InsertField;
101end;
102
103procedure TfrmTemplateFields.btnCancelClick(Sender: TObject);
104begin
105 Close;
106end;
107
108procedure TfrmTemplateFields.FormClose(Sender: TObject;
109 var Action: TCloseAction);
110begin
111 Action := caHide;
112end;
113
114procedure TfrmTemplateFields.Setre(const Value: TCustomEdit);
115begin
116 Fre := Value;
117 UpdateStatus;
118end;
119
120procedure TfrmTemplateFields.UpdateStatus;
121begin
122 btnInsert.Enabled := (not TORExposedCustomEdit(re).ReadOnly);
123end;
124
125procedure TfrmTemplateFields.btnInsertClick(Sender: TObject);
126begin
127 InsertField;
128end;
129
130procedure TfrmTemplateFields.btnPreviewClick(Sender: TObject);
131var
132 tmp, txt: string;
133
134
135begin
136 if(cboObjects.ItemIndex >= 0) then
137 begin
138 FormStyle := fsNormal;
139 try
140 txt := Piece(cboObjects.Items[cboObjects.ItemIndex],U,2);
141 tmp := TemplateFieldBeginSignature + txt + TemplateFieldEndSignature;
142// CheckBoilerplate4Fields(tmp, 'Preview Template Field: ' + txt, TRUE); <-- original line. //kt 8/8/2007
143 CheckBoilerplate4Fields(tmp, DKLangConstW('fTemplateFields_Preview_Template_Fieldx') + txt, TRUE); //kt added 8/8/2007
144 finally
145 FormStyle := fsStayOnTop;
146 end;
147 end;
148end;
149
150procedure TfrmTemplateFields.cboObjectsChange(Sender: TObject);
151begin
152 btnPreview.Enabled := (cboObjects.ItemIndex >= 0)
153end;
154
155end.
Note: See TracBrowser for help on using the repository browser.