Class TLinePrinter (unit LinePrnt) |
Inherits from
TComponent
constructor Create(Owner: TComponent);
- =============================================================================} { Public stuff for TLinePrinter.
procedure AbortDoc;
procedure BeginDoc;
Fire the event handler if it exists.
destructor Destroy;
Make this explicitly nil so UpdateProgressDlg
can tell if it needs to Create or Free itself.
procedure EndDoc;
Make sure the new page processing fires on BeginDoc.
function NewLine: Cardinal;
function NewPage: Cardinal;
Fire the event handler if it exists.
function PrevLine: Boolean;
This function returns whether it was successful.
procedure PrintLines(const LinesAsTable: Boolean);
If we're not printing the Header or Footer, go to a new line.
procedure Refresh;
Lines.
procedure WriteLine(const Line: String);
procedure WriteLineCenter(const Line: String);
procedure WriteLineRight(const Line: String);
Now print the line.
procedure WriteTableLine(const Line: String);
procedure DoNewPageProcessing;
=============================================================================} { Private and Protected stuff for TLinePrinter.
function ExpandLogicalFields(S: String): String;
function GetClippedLine(const Line: String; const Width: TPixels): String;
If the next character isn't whitespace, slide back to the nearest.
function MeasureUnitsToPixelsH(const M: TMeasurement): TPixels;
function MeasureUnitsToPixelsV(const M: TMeasurement): TPixels;
function PixelsToMeasureUnitsH(const P: TPixels): TMeasurement;
function PixelsToMeasureUnitsV(const P: TPixels): TMeasurement;
procedure SetPixelsPerInch;
Protected declarations
procedure SplitLineAndPrint(const Line: String);
Print the PageBorders.
procedure UpdateProgressDlg(const Status: String);
function GetAborted: Boolean;
function GetAvailablePageHeight: TMeasurement;
function GetAvailablePageWidth: TMeasurement;
function GetFont: TFont;
function GetGutterBottom: TMeasurement;
function GetGutterLeft: TMeasurement;
function GetGutterRight: TMeasurement;
function GetGutterTop: TMeasurement;
If it is visible, close it.
function GetOrientation: TPrinterOrientation;
function GetPageNumber: Cardinal;
function GetPhysicalPageHeight: TMeasurement;
function GetPhysicalPageWidth: TMeasurement;
function GetPrintableHeight: TMeasurement;
function GetPrintableWidth: TMeasurement;
function GetPrinting: Boolean;
function GetTitle: String;
Force fLineSpace to be updated.
function PixelPrintHeight: TPixels;
function PixelPrintWidth: TPixels;
procedure SetAlignment(Value: TAlignment);
procedure SetBorderOffset(Value: TMeasurement);
procedure SetDefaultColWidth(Value: TMeasurement);
procedure SetFont(Value: TFont);
procedure SetFooter(Value: String);
procedure SetFooterFormat(Value: String);
procedure SetHeader(Value: String);
procedure SetHeaderFormat(Value: String);
procedure SetLines(Value: TStrings);
procedure SetLineSpacing(Value: TLineSpacing);
Update the margins if the units have changed.
procedure SetMarginBottom(Value: TMeasurement);
procedure SetMarginLeft(Value: TMeasurement);
procedure SetMarginRight(Value: TMeasurement);
procedure SetMarginTop(Value: TMeasurement);
This routine gets us around the Delphi tiny font bug.
procedure SetMeasureUnit(Value: TMeasureUnit);
procedure SetOrientation(Value: TPrinterOrientation);
procedure SetPageBorders(Value: TPageBorders);
procedure SetShowProgress(Value: Boolean);
procedure SetTableFormat(Value: String);
procedure SetTabSize(Value: Cardinal);
procedure SetTitle(Value: String);
procedure SetWordWrap(Value: Boolean);
function StartingBottom: TPixels;
function StartingLeft: TPixels;
function StartingRight: TPixels;
function StartingTop: TPixels;
property Alignment : TAlignment
property BorderOffset : TMeasurement
property DefaultColWidth : TMeasurement
property Font : TFont
property Footer : String
property FooterFormat : String
property Header : String
property HeaderFormat : String
property Lines : TStrings
property LineSpacing : TLineSpacing
property MarginBottom : TMeasurement
property MarginLeft : TMeasurement
property MarginRight : TMeasurement
property MarginTop : TMeasurement
Published declarations
property MeasureUnit : TMeasureUnit
property Orientation : TPrinterOrientation
property PageBorders : TPageBorders
property ShowProgress : Boolean
property TableFormat : String
property TabSize : Cardinal
property Title : String
property WordWrap : Boolean
property Aborted : Boolean
Public declarations
property AvailablePageHeight : TMeasurement
This is the Printer.
property AvailablePageWidth : TMeasurement
property Canvas : TCanvas
property GutterBottom : TMeasurement
property GutterLeft : TMeasurement
property GutterRight : TMeasurement
property GutterTop : TMeasurement
property LineNumber : Cardinal
property PageNumber : Cardinal
property PhysicalPageHeight : TMeasurement
This is how large the piece of paper physically is.
property PhysicalPageWidth : TMeasurement
property PrintableHeight : TMeasurement
This is the printable area determined by the margins.
property PrintableWidth : TMeasurement
property Printing : Boolean
event OnAbortDoc : TNotifyEvent
event OnBeginDoc : TNotifyEvent
event OnEndDoc : TNotifyEvent
event OnNewLine : TNotifyEvent
event OnNewPage : TNotifyEvent
fAlignment : TAlignment;
fBorderOffset : TMeasurement;
fCanvas : TCanvas;
fCurrentX : Integer;
These X,Y are relative to the printable space.
fCurrentY : Integer;
fDefaultColWidth : TMeasurement;
fFooter : String;
fFooterFormat : String;
fHeader : String;
fHeaderFormat : String;
fLineNumber : Cardinal;
fLines : TStrings;
fLineSpace : TPixels;
fLineSpacing : TLineSpacing;
fMarginBottom : TMeasurement;
fMarginLeft : TMeasurement;
fMarginRight : TMeasurement;
fMarginTop : TMeasurement;
fMeasureUnit : TMeasureUnit;
fOnAbortDoc : TNotifyEvent;
fOnBeginDoc : TNotifyEvent;
fOnEndDoc : TNotifyEvent;
fOnNewLine : TNotifyEvent;
fOnNewPage : TNotifyEvent;
fPageBorders : TPageBorders;
fPrinter : TPrinter;
Private declarations
fPrntProgDlg : TPrntProgDlg;
fShowProgress : Boolean;
fTableFormat : String;
fTabSize : Cardinal;
fTextMetrics : TTextMetric;
fWordWrap : Boolean;
constructor Create(Owner: TComponent);
=============================================================================} { Public stuff for TLinePrinter. } {=============================================================================
procedure AbortDoc;
procedure BeginDoc;
Fire the event handler if it exists.
destructor Destroy;
Make this explicitly nil so UpdateProgressDlg
can tell if it needs to Create or Free itself.
procedure EndDoc;
Make sure the new page processing fires on BeginDoc.
function NewLine: Cardinal;
function NewPage: Cardinal;
Fire the event handler if it exists.
function PrevLine: Boolean;
This function returns whether it was successful.
procedure PrintLines(const LinesAsTable: Boolean);
If we're not printing the Header or Footer, go to a new line.
procedure Refresh;
Lines.Clear;
procedure WriteLine(const Line: String);
procedure WriteLineCenter(const Line: String);
procedure WriteLineRight(const Line: String);
Now print the line.
procedure WriteTableLine(const Line: String);
procedure DoNewPageProcessing;
=============================================================================} { Private and Protected stuff for TLinePrinter. } {=============================================================================
function ExpandLogicalFields(S: String): String;
function GetClippedLine(const Line: String; const Width: TPixels): String;
If the next character isn't whitespace, slide back to the nearest.
Also, like most word processors do, I'm going to delete the
first leading whitespace character left in the next-line buffer after
the delete/newline (if one exists).
function MeasureUnitsToPixelsH(const M: TMeasurement): TPixels;
function MeasureUnitsToPixelsV(const M: TMeasurement): TPixels;
function PixelsToMeasureUnitsH(const P: TPixels): TMeasurement;
function PixelsToMeasureUnitsV(const P: TPixels): TMeasurement;
procedure SetPixelsPerInch;
Protected declarations
procedure SplitLineAndPrint(const Line: String);
Print the PageBorders.
procedure UpdateProgressDlg(const Status: String);
function GetAborted: Boolean;
function GetAvailablePageHeight: TMeasurement;
function GetAvailablePageWidth: TMeasurement;
function GetFont: TFont;
function GetGutterBottom: TMeasurement;
function GetGutterLeft: TMeasurement;
function GetGutterRight: TMeasurement;
function GetGutterTop: TMeasurement;
If it is visible, close it.
function GetOrientation: TPrinterOrientation;
function GetPageNumber: Cardinal;
function GetPhysicalPageHeight: TMeasurement;
function GetPhysicalPageWidth: TMeasurement;
function GetPrintableHeight: TMeasurement;
function GetPrintableWidth: TMeasurement;
function GetPrinting: Boolean;
function GetTitle: String;
Force fLineSpace to be updated.
function PixelPrintHeight: TPixels;
function PixelPrintWidth: TPixels;
procedure SetAlignment(Value: TAlignment);
procedure SetBorderOffset(Value: TMeasurement);
procedure SetDefaultColWidth(Value: TMeasurement);
procedure SetFont(Value: TFont);
procedure SetFooter(Value: String);
procedure SetFooterFormat(Value: String);
procedure SetHeader(Value: String);
procedure SetHeaderFormat(Value: String);
procedure SetLines(Value: TStrings);
procedure SetLineSpacing(Value: TLineSpacing);
Update the margins if the units have changed.
procedure SetMarginBottom(Value: TMeasurement);
procedure SetMarginLeft(Value: TMeasurement);
procedure SetMarginRight(Value: TMeasurement);
procedure SetMarginTop(Value: TMeasurement);
This routine gets us around the Delphi tiny font bug.
procedure SetMeasureUnit(Value: TMeasureUnit);
procedure SetOrientation(Value: TPrinterOrientation);
procedure SetPageBorders(Value: TPageBorders);
procedure SetShowProgress(Value: Boolean);
procedure SetTableFormat(Value: String);
procedure SetTabSize(Value: Cardinal);
procedure SetTitle(Value: String);
procedure SetWordWrap(Value: Boolean);
function StartingBottom: TPixels;
function StartingLeft: TPixels;
function StartingRight: TPixels;
function StartingTop: TPixels;
property Alignment : TAlignment
property BorderOffset : TMeasurement
property DefaultColWidth : TMeasurement
property Font : TFont
property Footer : String
property FooterFormat : String
property Header : String
property HeaderFormat : String
property Lines : TStrings
property LineSpacing : TLineSpacing
property MarginBottom : TMeasurement
property MarginLeft : TMeasurement
property MarginRight : TMeasurement
property MarginTop : TMeasurement
Published declarations
property MeasureUnit : TMeasureUnit
property Orientation : TPrinterOrientation
property PageBorders : TPageBorders
property ShowProgress : Boolean
property TableFormat : String
property TabSize : Cardinal
property Title : String
property WordWrap : Boolean
property Aborted : Boolean
Public declarations
property AvailablePageHeight : TMeasurement
This is the Printer.PageHeight/Width property converted to TMeasurement. It's the largest available printable space per page.
property AvailablePageWidth : TMeasurement
property Canvas : TCanvas
property GutterBottom : TMeasurement
property GutterLeft : TMeasurement
property GutterRight : TMeasurement
property GutterTop : TMeasurement
property LineNumber : Cardinal
property PageNumber : Cardinal
property PhysicalPageHeight : TMeasurement
This is how large the piece of paper physically is.
property PhysicalPageWidth : TMeasurement
property PrintableHeight : TMeasurement
This is the printable area determined by the margins.
property PrintableWidth : TMeasurement
property Printing : Boolean
event OnAbortDoc : TNotifyEvent
event OnBeginDoc : TNotifyEvent
event OnEndDoc : TNotifyEvent
event OnNewLine : TNotifyEvent
event OnNewPage : TNotifyEvent
fAlignment : TAlignment;
fBorderOffset : TMeasurement;
fCanvas : TCanvas;
fCurrentX : Integer;
These X,Y are relative to the printable space.
They should normally be bounded by the Margins.
So 0,0 is the left,top corner of the printable space.
fCurrentY is negative only when printing the header.
fCurrentY : Integer;
fDefaultColWidth : TMeasurement;
fFooter : String;
fFooterFormat : String;
fHeader : String;
fHeaderFormat : String;
fLineNumber : Cardinal;
fLines : TStrings;
fLineSpace : TPixels;
fLineSpacing : TLineSpacing;
fMarginBottom : TMeasurement;
fMarginLeft : TMeasurement;
fMarginRight : TMeasurement;
fMarginTop : TMeasurement;
fMeasureUnit : TMeasureUnit;
fOnAbortDoc : TNotifyEvent;
fOnBeginDoc : TNotifyEvent;
fOnEndDoc : TNotifyEvent;
fOnNewLine : TNotifyEvent;
fOnNewPage : TNotifyEvent;
fPageBorders : TPageBorders;
fPrinter : TPrinter;
Private declarations
fPrntProgDlg : TPrntProgDlg;
fShowProgress : Boolean;
fTableFormat : String;
fTabSize : Cardinal;
fTextMetrics : TTextMetric;
fWordWrap : Boolean;