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