Class TPrintwwGrid (unit PrtwwGrd) |
Inherits from
TComponent
constructor Create(AOwner:TComponent);
destructor Destroy;
*tj* added
procedure Print;
Print the Grid to EITHER a File or a Printer; no dialog used
procedure PrintDialog;
used for BOTH File and Printer output; always gives std dialog
procedure SaveToFile;
only used for File output } { Call this function ONLY if you know beforehand that the user
will want to print to a File.
procedure SetName(const Value: TComponentName);
function AllPageFilled: boolean;
procedure CalcPrinterPositions;
function ColHeaderHeight: longint;
return the height of the column header in pixels
function ColHeaderWidth(const ColHeaderStr: String): longint;
--------------------------------------------------------------------} { From here down, most procs/fun's are only used for printer output.
function GetOrientation : TPrinterOrientation;
This convoluted code is from EDSPRINT.
function GetPrintMgrTitle: String;
function GetwwDBGrid: TwwDBGrid;
Same as: FwwDBGrid.
procedure InitializePrinter;
end case
procedure PageJump;
restore orig font
function PrepareAlign(Field: TField; Col: integer): longint;
end case
function RealToStr(x: Real): String;
*tj* (* Display metric/sizing info here for debugging.
function RealWidth: longint;
return the real width of the paper in units of "# of chars" using
the current font
function SetAlign(align:TAlignment; Left, Right: longint): longint;
end with
procedure SetColHeaderFont(Value: TFont);
procedure SetLinesFont(Value: TFont);
function SetPagePosX(PagePos: TPageNumberPos;
Left, Right: longint): longint;
end of "with Printer.
function SetPagePosY(PagePos: TPageNumberPos;
Top, Bottom: longint): longint;
end of "with Printer.
procedure SetPixelsPerInch;
This is mostly a bug fix function to make up for weaknesses in Delphi's
TPrinter object.
procedure SetPrintMgrTitle(const TmpStr: String);
procedure SetTitleFont(Value: TFont);
procedure SetwwDBGrid(Value: TwwDBGrid);
procedure WriteAllToFile;
percent of vert char hgt ----------------------------------------------------------------} { only used for file output
procedure WriteColHdrsToPrinter(PosY: longint);
This procedure prints column headers.
procedure WriteRecordToPrinter;
Print all columns of one detail line to the printer
procedure WriteTitleToPrinter;
Note that the Windows printer interface gives you a "full-page"
paradigm.
property Border : boolean
property BottomMargin : integer
property ColHeaderFont : TFont
property ColLines : boolean
property ColScale : integer
property DateLabel : String
property DatePos : TPageNumberPos
property EndPage : longint
property FromPage : longint
property FullPage : boolean
property HorizontalGap : integer
property LeftMargin : integer
property LinesFont : TFont
property Orientation : TPrinterOrientation
property PageNumberLabel : String
property PageNumberPos : TPageNumberPos
property PrintFileDir : String
property PrintFileName : String
RS 29.
property PrintMgrTitle : String
property PrintToFile : boolean
property RightMargin : integer
property RowLines : boolean
property Title : String
property TitleAlignment : TAlignment
property TitleFont : TFont
*tj* added
property TopMargin : integer
property VerticalGapPct : integer
property wwDBGrid : TwwDBGrid
DetailLineCharHeight : longint;
DetailLineCharWidth : longint;
FBorder : boolean;
FBottomMargin : integer;
FColHeaderFont : TFont;
FColLines : boolean;
FColScale : integer;
FDateLabel : String;
FDatePos : TPageNumberPos;
FEndPage : longint;
FFromPage : longint;
FFullPage : Boolean;
FHorizGap : integer;
FirstRecordY : longint;
FLeftMargin : integer;
FLinesFont : TFont;
*tj* added
FOrientation : TPrinterOrientation;
FPageNLabel : String;
FPageNPos : TPageNumberPos;
FPrintFileDir : String;
FPrintFileName : String;
FPrintMgrTitle : String;
FPrintToFile : boolean;
FRightMargin : integer;
FRowLines : boolean;
FTitle : String;
FTitleAlign : TAlignment;
FTitleFont : TFont;
FTopMargin : integer;
FVertGap : integer;
number of pixels bet.
FwwDBGrid : TwwDBGrid;
NPositions : integer;
OutFileName : TFileName;
new property RS 29.
Positions : array[1..MaxCols] of longint;
PrinterPageNo : longint;
RecCounter : longint;
constructor Create(AOwner:TComponent);
destructor Destroy;
*tj* added
procedure Print;
Print the Grid to EITHER a File or a Printer; no dialog used
procedure PrintDialog;
used for BOTH File and Printer output; always gives std dialog
procedure SaveToFile;
only used for File output } { Call this function ONLY if you know beforehand that the user
will want to print to a File. This will prompt the user for
a filename. If you don't want to prompt the user for a name (if
you just want to use the dflt name specified in Object inspector),
then do this: set property "PrintToFile" to TRUE, and call method
"Print", instead of this one.
procedure SetName(const Value: TComponentName);
function AllPageFilled: boolean;
procedure CalcPrinterPositions;
function ColHeaderHeight: longint;
return the height of the column header in pixels
function ColHeaderWidth(const ColHeaderStr: String): longint;
--------------------------------------------------------------------} { From here down, most procs/fun's are only used for printer output. } { return the width of a column header in pixels
function GetOrientation : TPrinterOrientation;
This convoluted code is from EDSPRINT.PAS. We just want to get
the actual printer orientation currently in effect. Note that the
"Orientation" property of TPrinter is write-only (at least in
Delphi v1 it is). } { Call this function once, after user is done with print dialog,
but before BeginDoc
function GetPrintMgrTitle: String;
function GetwwDBGrid: TwwDBGrid;
Same as: FwwDBGrid.Assign(Value);
procedure InitializePrinter;
end case
procedure PageJump;
restore orig font
function PrepareAlign(Field: TField; Col: integer): longint;
end case
function RealToStr(x: Real): String;
*tj* (* Display metric/sizing info here for debugging.
Here's some typical metrics:
Printer = HP4, network laser printer, max res=600 DPI
Arial, 8 point, style=normal
paper width=8 inches, Portrait Orientation
paper height=11.5 inches
300 DPI 600 DPI
------------------------------------------------------
pg wid=2400 | pg wid=4800
pg hgt=3168 | pg hgt=6336
Font PPI=300 | Font PPI=600
using FontMetrics:
avg char wid=15 | avg char wid=30
max char wid=35 | max char wid=70
using Printer.Canvas.TextWidth:
'W' char wid=34 | 'W' char wid=63
Sample text using Printer.Canvas.TextWidth:
width samp text=394 | width samp text=824
ShowMessage('printer page width: ' + IntToStr(Printer.PageWidth));
ShowMessage('printer page height: ' + IntToStr(Printer.PageHeight));
ShowMessage('Font PPI: ' + IntToStr(Printer.Canvas.Font.PixelsPerInch));
ShowMessage('Font name, size: ' + Printer.Canvas.Font.Name + ', '
+ IntToStr(Printer.Canvas.Font.Size));
ShowMessage('max char width (TextMetrics): '
+ IntToStr(TextMetrics.tmMaxCharWidth));
ShowMessage('max char width (Canvas.TextWidth - auto scaled): '
+ IntToStr(Printer.Canvas.TextWidth('W')));
ShowMessage('Avg char width (TextMetrics): '
+ IntToStr(TextMetrics.tmAveCharWidth));
ShowMessage('Avg char width (Canvas.TextWidth - auto scaled): '
+ IntToStr(Printer.Canvas.TextWidth('j')));
ShowMessage('Width of sample text: ' +
IntToStr(Printer.Canvas.TextWidth('this is sample text for sizing')));
function RealWidth: longint;
return the real width of the paper in units of "# of chars" using
the current font
function SetAlign(align:TAlignment; Left, Right: longint): longint;
end with
procedure SetColHeaderFont(Value: TFont);
procedure SetLinesFont(Value: TFont);
function SetPagePosX(PagePos: TPageNumberPos;
Left, Right: longint): longint;
end of "with Printer.Canvas"
function SetPagePosY(PagePos: TPageNumberPos;
Top, Bottom: longint): longint;
end of "with Printer.Canvas"
procedure SetPixelsPerInch;
This is mostly a bug fix function to make up for weaknesses in Delphi's
TPrinter object. TPrinter scales the font based on printer's PixelsPerInch.
However, the bug prevented it from scaling correctly bec. it didn't have the
printer's handle when it tried to get the PixelsPerInch. Here, we force
it to get the handle, then we set PixelsPerInch, then we reassign the font
size back to force it to get scaled again (this time correctly).
This code causes no trouble with Delphi v2.01, but it may only be NEEDED
on Delphi v1.xx (most pgmmers use it on v2.xx also).
You must call this immed. after you change the printer font!
procedure SetPrintMgrTitle(const TmpStr: String);
procedure SetTitleFont(Value: TFont);
procedure SetwwDBGrid(Value: TwwDBGrid);
procedure WriteAllToFile;
percent of vert char hgt
----------------------------------------------------------------} { only used for file output
procedure WriteColHdrsToPrinter(PosY: longint);
This procedure prints column headers. This is similar to
WriteRecordToPrinter, but this one accepts the Y position as an
argument, and prints headers instead of data.
procedure WriteRecordToPrinter;
Print all columns of one detail line to the printer
procedure WriteTitleToPrinter;
Note that the Windows printer interface gives you a "full-page"
paradigm. We can print to any part of the current page, similar
in concept to using cursor positioning codes on a CRT. This
procedure will print the main title, column headers, and footer
line, as-needed.
property Border : boolean
property BottomMargin : integer
property ColHeaderFont : TFont
property ColLines : boolean
property ColScale : integer
property DateLabel : String
property DatePos : TPageNumberPos
property EndPage : longint
property FromPage : longint
property FullPage : boolean
property HorizontalGap : integer
property LeftMargin : integer
property LinesFont : TFont
property Orientation : TPrinterOrientation
property PageNumberLabel : String
property PageNumberPos : TPageNumberPos
property PrintFileDir : String
property PrintFileName : String
RS 29.11.1996
property PrintMgrTitle : String
property PrintToFile : boolean
property RightMargin : integer
property RowLines : boolean
property Title : String
property TitleAlignment : TAlignment
property TitleFont : TFont
*tj* added
property TopMargin : integer
property VerticalGapPct : integer
property wwDBGrid : TwwDBGrid
DetailLineCharHeight : longint;
DetailLineCharWidth : longint;
FBorder : boolean;
FBottomMargin : integer;
FColHeaderFont : TFont;
FColLines : boolean;
FColScale : integer;
FDateLabel : String;
FDatePos : TPageNumberPos;
FEndPage : longint;
FFromPage : longint;
FFullPage : Boolean;
FHorizGap : integer;
FirstRecordY : longint;
FLeftMargin : integer;
FLinesFont : TFont;
*tj* added
FOrientation : TPrinterOrientation;
FPageNLabel : String;
FPageNPos : TPageNumberPos;
FPrintFileDir : String;
FPrintFileName : String;
FPrintMgrTitle : String;
FPrintToFile : boolean;
FRightMargin : integer;
FRowLines : boolean;
FTitle : String;
FTitleAlign : TAlignment;
FTitleFont : TFont;
FTopMargin : integer;
FVertGap : integer;
number of pixels bet. grid columns
FwwDBGrid : TwwDBGrid;
NPositions : integer;
OutFileName : TFileName;
new property RS 29.11.1996
Positions : array[1..MaxCols] of longint;
PrinterPageNo : longint;
RecCounter : longint;