source: cprs/trunk/CPRS-Chart/Templates/fTemplateView.pas@ 1710

Last change on this file since 1710 was 829, checked in by Kevin Toppenberg, 14 years ago

Upgrade to version 27

File size: 3.6 KB
Line 
1unit fTemplateView;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls, ComCtrls, ExtCtrls, Menus, ORFn, fBase508Form,
8 VA508AccessibilityManager;
9
10type
11 TfrmTemplateView = class(TfrmBase508Form)
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 procedure btnCloseClick(Sender: TObject);
22 procedure FormClose(Sender: TObject; var Action: TCloseAction);
23 procedure cbStayOnTopClick(Sender: TObject);
24 procedure FormDestroy(Sender: TObject);
25 procedure popViewPopup(Sender: TObject);
26 procedure Copy1Click(Sender: TObject);
27 procedure SelectAll1Click(Sender: TObject);
28 procedure btnPrintClick(Sender: TObject);
29 procedure AlignButtons();
30 procedure FormCreate(Sender: TObject);
31 private
32 end;
33
34procedure ShowTemplateData(Form: TForm; const Title, Text: string);
35
36var
37 frmTemplateView: TfrmTemplateView = nil;
38
39implementation
40
41uses fTemplateDialog, fRptBox, rMisc;
42
43{$R *.DFM}
44
45var
46 LastStayOnTop: boolean = FALSE;
47
48procedure ShowTemplateData(Form: TForm; const Title, Text: string);
49var
50 Cnt: integer;
51
52begin
53 if(not assigned(frmTemplateView)) then
54 frmTemplateView := TfrmTemplateView.Create(Application);
55 //Quick fix to work around glich in resize algorithm
56 frmTemplateView.AlignButtons();
57 frmTemplateView.reMain.Lines.Clear;
58 frmTemplateView.Caption := 'Template: ' + Title;
59 frmTemplateView.reMain.Lines.Text := Text;
60 Cnt := frmTemplateView.reMain.Lines.Count;
61 CheckBoilerplate4Fields(frmTemplateView.reMain.Lines, frmTemplateView.Caption, TRUE);
62 if (Cnt > 0) and (frmTemplateView.reMain.Lines.Count = 0) then
63 frmTemplateView.Close
64 else
65 begin
66 frmTemplateView.cbStayOnTop.Checked := LastStayOnTop;
67 frmTemplateView.ActiveControl := frmTemplateView.btnClose;
68 frmTemplateView.Show;
69 Application.ProcessMessages;
70 SendMessage(frmTemplateView.reMain.Handle, EM_LINESCROLL, 0, -1 * frmTemplateView.reMain.Lines.Count);
71 end;
72end;
73
74procedure TfrmTemplateView.btnCloseClick(Sender: TObject);
75begin
76 Close;
77end;
78
79procedure TfrmTemplateView.FormClose(Sender: TObject;
80 var Action: TCloseAction);
81begin
82 SaveUserBounds(frmTemplateView);
83 Action := caFree;
84end;
85
86procedure TfrmTemplateView.FormCreate(Sender: TObject);
87begin
88 inherited;
89 ResizeAnchoredFormToFont(Self);
90 SetFormPosition(Self);
91end;
92
93procedure TfrmTemplateView.cbStayOnTopClick(Sender: TObject);
94begin
95 if(cbStayOnTop.Checked) then
96 FormStyle := fsStayOnTop
97 else
98 FormStyle := fsNormal;
99 if(LastStayOnTop <> cbStayOnTop.Checked) then
100 LastStayOnTop := cbStayOnTop.Checked;
101end;
102
103procedure TfrmTemplateView.FormDestroy(Sender: TObject);
104begin
105 frmTemplateView := nil;
106end;
107
108procedure TfrmTemplateView.popViewPopup(Sender: TObject);
109begin
110 Copy1.Enabled := (reMain.SelLength > 0);
111 SelectAll1.Enabled := (reMain.Lines.Count > 0);
112end;
113
114procedure TfrmTemplateView.Copy1Click(Sender: TObject);
115begin
116 reMain.CopyToClipboard;
117end;
118
119procedure TfrmTemplateView.SelectAll1Click(Sender: TObject);
120begin
121 reMain.SelectAll;
122end;
123
124procedure TfrmTemplateView.btnPrintClick(Sender: TObject);
125begin
126 PrintStrings(Self, reMain.Lines, Caption, 'End of template');
127end;
128
129procedure TfrmTemplateView.AlignButtons;
130Const
131 BtnSpace = 8;
132begin
133 btnClose.Left := frmTemplateView.Width - btnClose.Width - BtnSpace;
134 btnPrint.Left := btnClose.Left - BtnSpace - btnPrint.Width;
135end;
136
137end.
Note: See TracBrowser for help on using the repository browser.