1 | //kt -- Modified with SourceScanner on 8/8/2007
|
---|
2 | unit fTemplateView;
|
---|
3 |
|
---|
4 | interface
|
---|
5 |
|
---|
6 | uses
|
---|
7 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
8 | StdCtrls, ComCtrls, ExtCtrls, Menus, ORFn, DKLang;
|
---|
9 |
|
---|
10 | type
|
---|
11 | TfrmTemplateView = class(TForm)
|
---|
12 | pnlBottom: TPanel;
|
---|
13 | reMain: TRichEdit;
|
---|
14 | btnClose: TButton;
|
---|
15 | cbStayOnTop: TCheckBox;
|
---|
16 | popView: TPopupMenu;
|
---|
17 | Copy1: TMenuItem;
|
---|
18 | N1: TMenuItem;
|
---|
19 | SelectAll1: TMenuItem;
|
---|
20 | btnPrint: TButton;
|
---|
21 | DKLanguageController1: TDKLanguageController;
|
---|
22 | procedure btnCloseClick(Sender: TObject);
|
---|
23 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
24 | procedure cbStayOnTopClick(Sender: TObject);
|
---|
25 | procedure FormDestroy(Sender: TObject);
|
---|
26 | procedure popViewPopup(Sender: TObject);
|
---|
27 | procedure Copy1Click(Sender: TObject);
|
---|
28 | procedure SelectAll1Click(Sender: TObject);
|
---|
29 | procedure btnPrintClick(Sender: TObject);
|
---|
30 | procedure FormCreate(Sender: TObject);
|
---|
31 | procedure FormShow(Sender: TObject);
|
---|
32 | private
|
---|
33 | end;
|
---|
34 |
|
---|
35 | procedure ShowTemplateData(Form: TForm; const Title, Text: string);
|
---|
36 |
|
---|
37 | var
|
---|
38 | frmTemplateView: TfrmTemplateView = nil;
|
---|
39 |
|
---|
40 | implementation
|
---|
41 |
|
---|
42 | uses fTemplateDialog, fRptBox, rMisc;
|
---|
43 |
|
---|
44 | {$R *.DFM}
|
---|
45 |
|
---|
46 | var
|
---|
47 | LastStayOnTop: boolean = FALSE;
|
---|
48 |
|
---|
49 | procedure ShowTemplateData(Form: TForm; const Title, Text: string);
|
---|
50 | var
|
---|
51 | Cnt: integer;
|
---|
52 |
|
---|
53 | begin
|
---|
54 | if(not assigned(frmTemplateView)) then
|
---|
55 | frmTemplateView := TfrmTemplateView.Create(Application);
|
---|
56 | ResizeAnchoredFormToFont(frmTemplateView);
|
---|
57 | frmTemplateView.reMain.Lines.Clear;
|
---|
58 | //frmTemplateView.Caption := 'Template: ' + Title; <-- original line. //kt 8/8/2007
|
---|
59 | frmTemplateView.Caption := DKLangConstW('fTemplateView_Templatex') + Title; //kt added 8/8/2007
|
---|
60 | frmTemplateView.reMain.Lines.Text := Text;
|
---|
61 | Cnt := frmTemplateView.reMain.Lines.Count;
|
---|
62 | CheckBoilerplate4Fields(frmTemplateView.reMain.Lines, frmTemplateView.Caption, TRUE);
|
---|
63 | if (Cnt > 0) and (frmTemplateView.reMain.Lines.Count = 0) then
|
---|
64 | frmTemplateView.Close
|
---|
65 | else
|
---|
66 | begin
|
---|
67 | frmTemplateView.cbStayOnTop.Checked := LastStayOnTop;
|
---|
68 | frmTemplateView.ActiveControl := frmTemplateView.btnClose;
|
---|
69 | frmTemplateView.Show;
|
---|
70 | Application.ProcessMessages;
|
---|
71 | SendMessage(frmTemplateView.reMain.Handle, EM_LINESCROLL, 0, -1 * frmTemplateView.reMain.Lines.Count);
|
---|
72 | end;
|
---|
73 | end;
|
---|
74 |
|
---|
75 | procedure TfrmTemplateView.btnCloseClick(Sender: TObject);
|
---|
76 | begin
|
---|
77 | Close;
|
---|
78 | end;
|
---|
79 |
|
---|
80 | procedure TfrmTemplateView.FormClose(Sender: TObject;
|
---|
81 | var Action: TCloseAction);
|
---|
82 | begin
|
---|
83 | SaveUserBounds(frmTemplateView);
|
---|
84 | Action := caFree;
|
---|
85 | end;
|
---|
86 |
|
---|
87 | procedure TfrmTemplateView.cbStayOnTopClick(Sender: TObject);
|
---|
88 | begin
|
---|
89 | if(cbStayOnTop.Checked) then
|
---|
90 | FormStyle := fsStayOnTop
|
---|
91 | else
|
---|
92 | FormStyle := fsNormal;
|
---|
93 | if(LastStayOnTop <> cbStayOnTop.Checked) then
|
---|
94 | LastStayOnTop := cbStayOnTop.Checked;
|
---|
95 | end;
|
---|
96 |
|
---|
97 | procedure TfrmTemplateView.FormDestroy(Sender: TObject);
|
---|
98 | begin
|
---|
99 | frmTemplateView := nil;
|
---|
100 | end;
|
---|
101 |
|
---|
102 | procedure TfrmTemplateView.popViewPopup(Sender: TObject);
|
---|
103 | begin
|
---|
104 | Copy1.Enabled := (reMain.SelLength > 0);
|
---|
105 | SelectAll1.Enabled := (reMain.Lines.Count > 0);
|
---|
106 | end;
|
---|
107 |
|
---|
108 | procedure TfrmTemplateView.Copy1Click(Sender: TObject);
|
---|
109 | begin
|
---|
110 | reMain.CopyToClipboard;
|
---|
111 | end;
|
---|
112 |
|
---|
113 | procedure TfrmTemplateView.SelectAll1Click(Sender: TObject);
|
---|
114 | begin
|
---|
115 | reMain.SelectAll;
|
---|
116 | end;
|
---|
117 |
|
---|
118 | procedure TfrmTemplateView.btnPrintClick(Sender: TObject);
|
---|
119 | begin
|
---|
120 | //PrintStrings(Self, reMain.Lines, Caption, 'End of template'); <-- original line. //kt 8/8/2007
|
---|
121 | PrintStrings(Self, reMain.Lines, Caption, DKLangConstW('fTemplateView_End_of_template')); //kt added 8/8/2007
|
---|
122 | end;
|
---|
123 |
|
---|
124 | procedure TfrmTemplateView.FormCreate(Sender: TObject);
|
---|
125 | begin
|
---|
126 | reMain.Color := ReadOnlyColor;
|
---|
127 | end;
|
---|
128 |
|
---|
129 | procedure TfrmTemplateView.FormShow(Sender: TObject);
|
---|
130 | begin
|
---|
131 | SetFormPosition(frmTemplateView);
|
---|
132 | end;
|
---|
133 |
|
---|
134 | end.
|
---|