1 | //kt -- Modified with SourceScanner on 8/8/2007
|
---|
2 | unit fTemplateFields;
|
---|
3 |
|
---|
4 | interface
|
---|
5 |
|
---|
6 | uses
|
---|
7 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
8 | ORCtrls, ComCtrls, StdCtrls, ExtCtrls, DKLang;
|
---|
9 |
|
---|
10 | type
|
---|
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 |
|
---|
43 | implementation
|
---|
44 |
|
---|
45 | uses
|
---|
46 | ORFn, rTemplates, uTemplateFields, fTemplateDialog, ORClasses;
|
---|
47 |
|
---|
48 | {$R *.DFM}
|
---|
49 |
|
---|
50 | procedure TfrmTemplateFields.FormShow(Sender: TObject);
|
---|
51 | begin
|
---|
52 | cboObjects.SelectAll;
|
---|
53 | cboObjects.SetFocus;
|
---|
54 | end;
|
---|
55 |
|
---|
56 | procedure TfrmTemplateFields.FormCreate(Sender: TObject);
|
---|
57 | begin
|
---|
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;
|
---|
64 | end;
|
---|
65 |
|
---|
66 | procedure TfrmTemplateFields.cboObjectsNeedData(Sender: TObject;
|
---|
67 | const StartFrom: String; Direction, InsertAt: Integer);
|
---|
68 | var
|
---|
69 | tmp: TStrings;
|
---|
70 |
|
---|
71 | begin
|
---|
72 | tmp := SubSetOfTemplateFields(StartFrom, Direction);
|
---|
73 | ConvertCodes2Text(tmp, FALSE);
|
---|
74 | cboObjects.ForDataUse(tmp);
|
---|
75 | end;
|
---|
76 |
|
---|
77 | procedure TfrmTemplateFields.InsertField;
|
---|
78 | var
|
---|
79 | cnt: integer;
|
---|
80 |
|
---|
81 | begin
|
---|
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;
|
---|
95 | end;
|
---|
96 |
|
---|
97 | procedure TfrmTemplateFields.cboObjectsDblClick(Sender: TObject);
|
---|
98 | begin
|
---|
99 | if btnInsert.Enabled then
|
---|
100 | InsertField;
|
---|
101 | end;
|
---|
102 |
|
---|
103 | procedure TfrmTemplateFields.btnCancelClick(Sender: TObject);
|
---|
104 | begin
|
---|
105 | Close;
|
---|
106 | end;
|
---|
107 |
|
---|
108 | procedure TfrmTemplateFields.FormClose(Sender: TObject;
|
---|
109 | var Action: TCloseAction);
|
---|
110 | begin
|
---|
111 | Action := caHide;
|
---|
112 | end;
|
---|
113 |
|
---|
114 | procedure TfrmTemplateFields.Setre(const Value: TCustomEdit);
|
---|
115 | begin
|
---|
116 | Fre := Value;
|
---|
117 | UpdateStatus;
|
---|
118 | end;
|
---|
119 |
|
---|
120 | procedure TfrmTemplateFields.UpdateStatus;
|
---|
121 | begin
|
---|
122 | btnInsert.Enabled := (not TORExposedCustomEdit(re).ReadOnly);
|
---|
123 | end;
|
---|
124 |
|
---|
125 | procedure TfrmTemplateFields.btnInsertClick(Sender: TObject);
|
---|
126 | begin
|
---|
127 | InsertField;
|
---|
128 | end;
|
---|
129 |
|
---|
130 | procedure TfrmTemplateFields.btnPreviewClick(Sender: TObject);
|
---|
131 | var
|
---|
132 | tmp, txt: string;
|
---|
133 |
|
---|
134 |
|
---|
135 | begin
|
---|
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;
|
---|
148 | end;
|
---|
149 |
|
---|
150 | procedure TfrmTemplateFields.cboObjectsChange(Sender: TObject);
|
---|
151 | begin
|
---|
152 | btnPreview.Enabled := (cboObjects.ItemIndex >= 0)
|
---|
153 | end;
|
---|
154 |
|
---|
155 | end.
|
---|