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