You've already forked lazarus-ccr
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7885 8e941d3f-bd1b-0410-a28a-d453659cc2b4
133 lines
3.4 KiB
ObjectPascal
133 lines
3.4 KiB
ObjectPascal
unit OutPutUnit;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
|
ExtCtrls, Buttons, StdCtrls, Printers, clipbrd, PrintersDlgs;
|
|
|
|
type
|
|
|
|
{ TOutputFrm }
|
|
|
|
TOutputFrm = class(TForm)
|
|
PrintDialog1: TPrintDialog;
|
|
RichEdit: TMemo;
|
|
ReturnBtn: TButton;
|
|
PrintBtn: TButton;
|
|
PasteBtn: TButton;
|
|
CopyBtn: TButton;
|
|
CutBtn: TButton;
|
|
FontBtn: TButton;
|
|
FontDialog1: TFontDialog;
|
|
OpenFileBtn: TButton;
|
|
SaveFileBtn: TButton;
|
|
OpenDialog1: TOpenDialog;
|
|
Panel1: TPanel;
|
|
SaveDialog1: TSaveDialog;
|
|
procedure CopyBtnClick(Sender: TObject);
|
|
procedure CutBtnClick(Sender: TObject);
|
|
procedure FontBtnClick(Sender: TObject);
|
|
procedure OpenFileBtnClick(Sender: TObject);
|
|
procedure PasteBtnClick(Sender: TObject);
|
|
procedure PrintBtnClick(Sender: TObject);
|
|
procedure SaveFileBtnClick(Sender: TObject);
|
|
private
|
|
{ private declarations }
|
|
public
|
|
{ public declarations }
|
|
end;
|
|
|
|
var
|
|
OutputFrm: TOutputFrm;
|
|
|
|
implementation
|
|
|
|
{ TOutputFrm }
|
|
|
|
procedure TOutputFrm.PrintBtnClick(Sender: TObject);
|
|
VAR
|
|
aline : string;
|
|
NoLines, i, X, Y, txthi : integer;
|
|
begin
|
|
Printer.Orientation := poPortrait;
|
|
NoLines := OutPutFrm.RichEdit.Lines.Count;
|
|
X := 5; // left margin
|
|
Y := 5; // top margin
|
|
PrintDialog1.MinPage := 1;
|
|
PrintDialog1.MaxPage := 1;
|
|
PrintDialog1.ToPage := 1;
|
|
PrintDialog1.Options := [poPageNums];
|
|
Printer.Copies := PrintDialog1.Copies;
|
|
if FontDialog1.Execute then
|
|
begin
|
|
Printer.Canvas.Font := FontDialog1.Font;
|
|
Printer.Canvas.Font.Height := FontDialog1.Font.Height;
|
|
end;
|
|
if PrintDialog1.Execute then
|
|
begin
|
|
// Printer.Canvas.Font.Height := 50;
|
|
Printer.Canvas.Font.Height := Printer.PageHeight div 80;
|
|
txthi := Printer.Canvas.Font.Height;
|
|
Printer.BeginDoc;
|
|
for i := 0 to NoLines-1 do
|
|
begin
|
|
aline := OutPutFrm.RichEdit.Lines[i];
|
|
Printer.Canvas.TextOut(X,Y,aline);
|
|
// txthi := Printer.Canvas.Font.Height;
|
|
Y := Y + abs(txthi);
|
|
if Y >= Printer.PageHeight - 10 then
|
|
begin
|
|
Printer.NewPage;
|
|
Y := 5;
|
|
end;
|
|
end;
|
|
Printer.EndDoc;
|
|
end;
|
|
end;
|
|
|
|
procedure TOutputFrm.OpenFileBtnClick(Sender: TObject);
|
|
begin
|
|
OpenDialog1.Filter := 'LazStats text files (*.txt)|*.TXT|All files (*.*)|*.*';
|
|
OpenDialog1.FilterIndex := 1; {text file}
|
|
if OpenDialog1.Execute then RichEdit.Lines.LoadFromFile(OpenDialog1.FileName);
|
|
end;
|
|
|
|
procedure TOutputFrm.PasteBtnClick(Sender: TObject);
|
|
begin
|
|
RichEdit.PasteFromClipboard;
|
|
end;
|
|
|
|
procedure TOutputFrm.CutBtnClick(Sender: TObject);
|
|
begin
|
|
RichEdit.CutToClipboard;
|
|
end;
|
|
|
|
procedure TOutputFrm.FontBtnClick(Sender: TObject);
|
|
begin
|
|
FontDialog1.Execute;
|
|
RichEdit.Font := FontDialog1.Font;
|
|
// RichEdit.SelAttributes.Assign(FontDialog1.Font);
|
|
end;
|
|
|
|
procedure TOutputFrm.CopyBtnClick(Sender: TObject);
|
|
begin
|
|
RichEdit.CopyToClipboard;
|
|
end;
|
|
|
|
procedure TOutputFrm.SaveFileBtnClick(Sender: TObject);
|
|
begin
|
|
SaveDialog1.Filter := 'LazStats text files (*.txt|*.TXT|All files (*.*)|*.*';
|
|
SaveDialog1.FilterIndex := 1; {text file}
|
|
SaveDialog1.Title := 'Print to File: ';
|
|
if SaveDialog1.Execute then RichEdit.Lines.SaveToFile(SaveDialog1.FileName);
|
|
end;
|
|
|
|
initialization
|
|
{$I outputunit.lrs}
|
|
|
|
end.
|
|
|