![]() |
|
![]() |
//
// There are two general types of routines in this package. One set of routines
// is used during the creating of the output report. That output can either be
// directly sent to an HWnd or it can be logged to a special type of file with
// a .GDL extension. That file can later be used to bring the output report
// back up for viewing or printing. The second set of routines deals with
// handling those already existing files.
//
const
Arial : pchar = 'Arial';
BookmanOldStyle : pchar = 'Courier';
ComicSansMS : pchar = 'Comic Sans MS';
Courier : pchar = 'Courier';
CourierNew : pchar = 'Courier New';
Garamond : pchar = 'Garamond';
Impact : pchar = 'Impact';
MSSansSerif : pchar = 'MS Sans Serif';
Tahoma : pchar = 'Tahoma';
TimesNewRoman : pchar = 'Times New Roman';
DeviceNoError = 0;
DeviceInvalidFont = 1; // invalid font requested
DeviceCancel = 2; // user canceled print job
DeviceNoDefault = 3; // no default printer defined for PC
DeviceAlreadyOpen = 4; // there is already a device open
DeviceInvalidLog = 5; // file is not a valid log
DeviceLogError = 6; // error writing or reading log file
DeviceOldLogVersion = 7; // version of the log is old or invalid
DeviceInvalidRequest = 8; // requested item out of range, etc.
DeviceInvalidPaper = 9; // requested paper structure was not filled
// Color constants
DarkBlue = 8388608; // RGB (0, 0, 128) Low Intensity Blue
DarkGreen = 32768; // RGB (0, 128, 0) Low Intensity Green
DarkRed = 128; // RGB (128, 0, 0) Low Intensity Red
DarkCyan = 8421376; // RGB (0, 128, 128) Low Intensity Cyan
DarkMagenta = 8388736; // RGB (128, 0, 128) Low Intensity Magenta
DarkYellow = 32896; // RGB (128, 128, 0) Low Intensity Yellow
DarkGray = 8421504; // RGB (128, 128, 128) High Intensity Black
Black = 0; // RGB (0, 0, 0) Low Intensity Black
Gray = 12632256; // RGB (192, 192, 192) Low Intensity White
Blue = 16711680; // RGB (0, 0, 255) High Intensity Blue
Green = 65280; // RGB (0, 255, 0) High Intensity Green
Red = 255; // RGB (255, 0, 0) High Intensity Red
Cyan = 16776960; // RGB (0, 255, 255) High Intensity Cyan
Magenta = 16711935; // RGB (255, 0, 255) High Intensity Magenta
Yellow = 65535; // RGB (255, 255, 0) High Intensity Yellow
White = 16777215; // RGB (255, 255, 255) High Intensity White
Default = high (integer);
// Line Thickness constants
UltraThinLine = 0.0;
ThinLine = 0.0125;
UltraFineLine = 0.025;
FineLine = 0.0375;
ThinMediumLine = 0.05;
MediumLine = 0.0625;
ThickMediumLine = 0.075;
ThickLine = 0.0875;
UltraThickLine = 0.1;
LargeLine = 0.1125;
UltraLargeLine = 0.125;
// pen styles
SolidPen = Windows.PS_SOLID;
DashPen = Windows.PS_DASH;
DotPen = Windows.PS_DOT;
DashDotPen = Windows.PS_DASHDOT;
DashDotDotPen = Windows.PS_DASHDOTDOT;
NoPen = Windows.PS_NULL;
InsideFramePen = Windows.PS_INSIDEFRAME;
// brush styles
HatchedBrush = Windows.BS_HATCHED;
HollowBrush = Windows.BS_HOLLOW;
SolidBrush = Windows.BS_SOLID;
// brush hatch kinds
HorzHatch = Windows.HS_HORIZONTAL;
VertHatch = Windows.HS_VERTICAL;
FDiagonalHatch = Windows.HS_FDIAGONAL;
BDiagonalHatch = Windows.HS_BDIAGONAL;
CrossHatch = Windows.HS_CROSS;
DiagonalCrossHatch = Windows.HS_DIAGCROSS;
type
OrientationType = (Portrait,
Landscape);
VertJustifyType = (TopJustify,
VertCenterJustify,
BottomJustify);
HorzJustifyType = (LeftJustify,
HorzCenterJustify,
RightJustify);
LineThicknessType = type ModSys.FLOAT32;
FontFormatType = (Normal,
Bold,
Underline,
BoldUnderline,
Italics,
BoldItalic,
UnderlineItalic,
BoldUnderlineItalic,
Outline,
BoldOutline,
ItalicOutline,
BoldItalicOutline);
RectType = packed record
Left : integer;
Right : integer;
Top : integer;
Bottom : integer;
end;
PointType = packed record
XVal : integer;
YVal : integer;
end;
SizeType = packed record
width : integer;
height : integer;
end;
ColorType = Windows.COLORREF;
PrintInfoType = packed record
PrinterOpen : boolean; // printer has been opened
pageSize : SizeType; // width and height of full page area
PrintableOffset : SizeType; // offset of printable area from full page edge
PrintableRect : RectType; // rectangle of printable area
MarginRect : RectType; // rect of printable area minus margins
XPixelsPerInch : integer; // # of horz. pixels per inch
YPixelsPerInch : integer; // # of vert. pixels per inch
CurrentPageCount : cardinal; // current page count
HorzJustify : HorzJustifyType; // horz text justification
VertJustify : VertJustifyType; // vert text justification
AvgCharWidth : integer; // average character width for font
CharHeight : integer; // character height for font
FontSize : integer; // font size
FontFormat : FontFormatType; // font format
CharsPerLine : integer; // # characters per line (only valid with fixed font)
LinesPerPage : integer; // # lines per page (only valid with fixed font)
FixedFont : boolean; // font is a fixed font
FontName : array [0 .. Windows.LF_FACESIZE - 1] of char;
Orientation : OrientationType; // Orientation of output
end;
StandardPrintType = packed record
ShowPrintDialog : boolean;
PrinterDialogTitle : array [0 .. 99] of char; // Title line of Printer dialog box
ShowPrintSelected : boolean; // Show the Print Selected radio button
ShowPrintPageNums : boolean; // Show the Print Page Nums radio button
MarkAllPages : boolean; // Select the print all button
MarkSelectedPages : boolean; // Select the print selected button
MarkPageNums : boolean; // Select the print pages button
StartingPageNum : cardinal; // Starting page num to show
EndingPageNum : cardinal; // Ending page num to show
MinPageNum : cardinal; // Min page number to allow
MaxPageNum : cardinal; // Max page number to allow
ShowPrintToFile : boolean; // Show the Print to file check box
ShowPrintProgress : boolean; // While printing show a progress dialog
UserPrinted : boolean; // Was printing completed?
RangePrinted : boolean; // Did user select to print a range?
RangeStart : cardinal; // Starting page of range print.
RangeEnd : cardinal; // Ending page of range print.
end;
ViewRecordType = packed record
LogFile : SageSpec.LongPathType; // Name of log file. Must end in .GDL
StartPage : cardinal; // Page to start on
Title : array [0 .. 99] of char; // Title to show on window
ShowTitle : boolean; // Show the title bar?
ShowMinMax : boolean; // Show the min and max buttons?
ShowSystemMenu : boolean; // Show the system menu? (upper left)
ShowMenu : boolean; // Show the menu?
ShowOpenFile : boolean; // Show an Open File menu option?
ShowToolbar : boolean; // Show a toolbar?
ZoomPercent : cardinal; // Zoom setting 100 = 1x, 110 = 1.1x (zoom in), 75 = .75x (zoom out)
SkipFactor : cardinal; // Number of records to move when using skip buttons.
BackgroundBmp : array [0 .. 255] of char; // Name of BMP to show in background.
WindowLoc : PointType; // Window starting location - Upper left
XSize : integer; // X size of the window
YSize : integer; // Y size of the window
Sizeable : boolean; // Is window sizeable
StandardPrint : StandardPrintType; // Standard list of printer settings.
CurrentHwnd : Windows.Hwnd; // Hwnd of the current window to bring back to top
end;
PrintRecordType = packed record
LogFile : SageSpec.LongPathType;
StandardPrint : StandardPrintType; // Standard list of printer settings.
end;
PaintRecordType = packed record
LogFile : SageSpec.LongPathType;
Hwnd : Windows.Hwnd;
MinPageNum : cardinal;
MaxPageNum : cardinal;
ZoomFactor : ModSys.FLOAT32;
XShift : integer;
YShift : integer;
PaintRect : RectType;
end;
StatsRecordType = packed record
DevicePageXWidth : integer; // Full X width device is capable of
DevicePageYWidth : integer; // Full Y width device is capable of
DevicePrintableXOffset : integer; // Offset of Printable area from page edge
DevicePrintableYOffset : integer; // Offset of Printable area from page edge
DevicePrintableXWidth : integer; // Printable area X width of device
DevicePrintableYWidth : integer; // Printable area Y width of device
DeviceXRes : integer; // Pixels per inch in X device is capable of
DeviceYRes : integer; // Pixels per inch in Y device is capable of
DeviceTopMargin : integer; // Pixels used for top margin
DeviceBottomMargin : integer; // Pixels used for bottom margin
DeviceLeftMargin : integer; // Pixels used for left margin
DeviceRightMargin : integer; // Pixels used for right margin
NumPages : cardinal; // Number of pages in log
DeviceOrientation : OrientationType; // Orientation of output
end;
//
// Use of Paper, PaperWidth and PaperHeight fields:
// Paper - a unique type that represents a paper size. This can be set from
// the types listed in the Windows spec (i.e. DMPAPER_LETTER) or can be found in
// the PaperData structure returned from either the GetDefaultPaperData or
// GetTypePaperData routines. PaperWidth - is the inch measurement of a custom
// size you are setting. PaperHeight - is the inch measurement of a custom height
// you are setting.
//
// if PaperNumber is <> Windows.DMPAPER_FIRST and <> Windows.DMPAPER_USER6 then PaperWidth
// and PaperHeight are ignored. It is assumed that you are setting a valued PaperNumber.
//
// if PaperNumber is Windows.DMPAPER_FIRST and PaperWidth = 0 and PaperHeight = 0 then
// you are telling the printer to just use whatever is the default paper set for it.
//
// if Paper is Windows.DMPAPER_USER and PaperWidth > 0.0 and PaperHeight > 0.0 then the
// assumption is that you are trying to set a custom paper size. That value
// will be passed on the the printer as the size to use.
//
PrintSettingsRecordType = packed record
StandardPrint : StandardPrintType;
Paper : cardinal; // Paper type to use. Use Windows.DMPAPER_FIRST to default.
PaperWidth : ModSys.FLOAT32; // Width of custom paper size in inches
PaperHeight : ModSys.FLOAT32; // Height of custom paper size in inches
Orientation : OrientationType; // Orientation of output
end;
PaperRecordType = packed record
PaperName : array [0 .. 63] of char; // Name used for this paper size
Paper : cardinal; // Type used to represent papers, see list of Windows.DMPAPER_ values
width : ModSys.FLOAT32; // Width in inches of this paper
Length : ModSys.FLOAT32; // Length in inches of this paper
end;
GDLRecordType = packed record
AsciiFileName : SageSpec.LongPathType;
GDLFileName : SageSpec.LongPathType;
Paper : cardinal;
PageInchWidth : ModSys.FLOAT32;
PageInchHeight : ModSys.FLOAT32;
Orientation : OrientationType;
TopMargin : ModSys.FLOAT32;
BottomMargin : ModSys.FLOAT32;
LeftMargin : ModSys.FLOAT32;
RightMargin : ModSys.FLOAT32;
IgnoreFirstFF : boolean;
showProgress : boolean;
ProgressTitle : array [0 .. 39] of char;
ShowLineSizeWarning : boolean;
PrinterUseOnly : boolean;
end;
PenStyleType = integer;
BrushStyleType = Windows.UINT;
BrushHatchType = type ModSys.INT32;
//
// When declaring a variable of type GDIHandleType ALWAYS initialize
// variable to EmptyGdiHandle. (i.e. MyHandle : GDIPrint.GDIHandleType = GDIPrint.EmptyGdiHandle;)
//
type
GDIRecPtrType = pointer;
type
GDIHandleType = packed record
RecPtr : GDIRecPtrType;
DeviceError : cardinal;
end;
// Callback routine to give you control when print is requested inside of viewer
PrintProcType = procedure
(var PrintRec : PrintRecordType; // Record passed to PrintLog routine
var Printed : boolean); stdcall;
// Forced user printed setting
const
EmptyStandardPrint : StandardPrintType = (ShowPrintDialog : True;
PrinterDialogTitle : '';
ShowPrintSelected : False;
ShowPrintPageNums : True;
MarkAllPages : True;
MarkSelectedPages : False;
MarkPageNums : False;
StartingPageNum : 1;
EndingPageNum : high (cardinal);
MinPageNum : 1;
MaxPageNum : high (cardinal);
ShowPrintToFile : True;
ShowPrintProgress : True;
UserPrinted : False;
RangePrinted : False;
RangeStart : 0;
RangeEnd : 0);
EmptyViewRec : ViewRecordType = (LogFile : '';
StartPage : 0;
Title : '';
ShowTitle : True;
ShowMinMax : True;
ShowSystemMenu : False;
ShowMenu : True;
ShowOpenFile : True;
ShowToolbar : True;
ZoomPercent : 100;
SkipFactor : 10;
BackgroundBmp : '';
WindowLoc : (XVal : 0;
YVal : 0);
XSize : 0;
YSize : 0;
Sizeable : True;
StandardPrint : (ShowPrintDialog : True;
PrinterDialogTitle : '';
ShowPrintSelected : False;
ShowPrintPageNums : True;
MarkAllPages : True;
MarkSelectedPages : False;
MarkPageNums : False;
StartingPageNum : 1;
EndingPageNum : high (cardinal);
MinPageNum : 1;
MaxPageNum : high (cardinal);
ShowPrintToFile : True;
ShowPrintProgress : True;
UserPrinted : False;
RangePrinted : False;
RangeStart : 0;
RangeEnd : 0);
CurrentHwnd : SageSpec.NULL_HWND);
EmptyPrintRec : PrintRecordType = (LogFile : '';
StandardPrint : (ShowPrintDialog : True;
PrinterDialogTitle : '';
ShowPrintSelected : False;
ShowPrintPageNums : True;
MarkAllPages : True;
MarkSelectedPages : False;
MarkPageNums : False;
StartingPageNum : 1;
EndingPageNum : high (cardinal);
MinPageNum : 1;
MaxPageNum : high (cardinal);
ShowPrintToFile : True;
ShowPrintProgress : True;
UserPrinted : False;
RangePrinted : False;
RangeStart : 0;
RangeEnd : 0));
EmptyPaintRec : PaintRecordType = (LogFile : '';
Hwnd : SageSpec.NULL_HWND;
MinPageNum : 1;
MaxPageNum : 1;
ZoomFactor : 1.0;
XShift : 0;
YShift : 0;
PaintRect : (Left : 0;
Right : 0;
Top : 0;
Bottom : 0));
EmptyPrintSettings : PrintSettingsRecordType = (StandardPrint : (ShowPrintDialog : True;
PrinterDialogTitle : '';
ShowPrintSelected : False;
ShowPrintPageNums : True;
MarkAllPages : True;
MarkSelectedPages : False;
MarkPageNums : False;
StartingPageNum : 1;
EndingPageNum : high (cardinal);
MinPageNum : 1;
MaxPageNum : high (cardinal);
ShowPrintToFile : True;
ShowPrintProgress : True;
UserPrinted : False;
RangePrinted : False;
RangeStart : 0;
RangeEnd : 0);
Paper : Windows.DMPAPER_LETTER;
PaperWidth : 0.0;
PaperHeight : 0.0;
Orientation : Portrait);
EmptyGDLRec : GDLRecordType = (AsciiFileName : '';
GDLFileName : '';
Paper : Windows.DMPAPER_LETTER;
PageInchWidth : 0.0;
PageInchHeight : 0.0;
Orientation : Portrait;
TopMargin : 0.3;
BottomMargin : 0.0;
LeftMargin : 0.0;
RightMargin : 0.0;
IgnoreFirstFF : True;
showProgress : True;
ProgressTitle : '';
ShowLineSizeWarning : True;
PrinterUseOnly : False);
EmptyGdiHandle : GDIHandleType = (RecPtr : nil;
DeviceError : DeviceNoError);
procedure GetDeviceError
(var GdiHandle : GDIHandleType;
var Error : cardinal); stdcall;
exports GetDeviceError name 'GdiPrint_GetDeviceError';
// returns the device error
procedure GetDefaultPrinterDeviceName
(var GdiHandle : GDIHandleType;
var DeviceName : array of char;
var PortName : array of char;
var Success : boolean); stdcall;
exports GetDefaultPrinterDeviceName name 'GdiPrint_GetDefaultPrinterDeviceName';
// Return the name of the default printer or an error if one is not set.
procedure GetErrorMessage
(const ErrorCode : cardinal;
var Message : array of char); stdcall;
exports GetErrorMessage name 'GdiPrint_GetErrorMessage';
// Returns a message corresponding to the error code.
procedure GetPrintInfo
(var GdiHandle : GDIHandleType;
var info : PrintInfoType); stdcall;
exports GetPrintInfo name 'GdiPrint_GetPrintInfo';
// returns the print information record
procedure NumDefaultPapersAvailable
(var GdiHandle : GDIHandleType;
var NumPapers : cardinal); stdcall;
exports NumDefaultPapersAvailable name 'GdiPrint_NumDefaultPapersAvailable';
// Returns the number of paper sizes available for the default printer
procedure GetDefaultPaperData
(var GdiHandle : GDIHandleType;
const EntryNum : cardinal;
var PaperData : PaperRecordType); stdcall;
exports GetDefaultPaperData name 'GdiPrint_GetDefaultPaperData';
// Get data about default printer paper. Entries are 1 .. NumDefaultPapersAvailable
procedure GetTypePaperData
(var GdiHandle : GDIHandleType;
const Paper : cardinal;
var PaperData : PaperRecordType); stdcall;
exports GetTypePaperData name 'GdiPrint_GetTypePaperData';
// Get data about printer paper using a paper type
procedure OpenPrinter
(var GdiHandle : GDIHandleType;
var PrinterSettings : PrintSettingsRecordType;
var OpenSuccess : boolean); stdcall;
exports OpenPrinter name 'GdiPrint_OpenPrinter';
// opens the printer and sets up the print information
procedure OpenWindow
(var GdiHandle : GDIHandleType;
const Hwnd : Windows.Hwnd); stdcall;
exports OpenWindow name 'GdiPrint_OpenWindow';
// opens a window for output (this hWnd must must have been created and showing)
procedure OpenLog
(var GdiHandle : GDIHandleType;
const LogFile : array of char;
const Execute : boolean); overload; stdcall;
exports OpenLog (var GdiHandle : GDIHandleType;
const LogFile : array of char;
const Execute : boolean) name 'GdiPrint_OpenLog';
// opens a log file for output of print commands. LogFile must end in .GDL
procedure OpenLog
(var GdiHandle : GDIHandleType;
const LogFile : string;
const Execute : boolean); overload; stdcall;
exports OpenLog (var GdiHandle : GDIHandleType;
const LogFile : string;
const Execute : boolean) name 'GdiPrint_STROpenLog';
// See documentation of OpenLog.
procedure Close
(var GdiHandle : GDIHandleType); stdcall;
exports Close name 'GdiPrint_Close';
// Closes the printer and cleans up any memory (printer/window/Log
procedure PrinterSetup
(var GdiHandle : GDIHandleType;
var Success : boolean); stdcall;
exports PrinterSetup name 'GdiPrint_PrinterSetup';
// calls the Printer setup common dialog
procedure StartNewPage
(var GdiHandle : GDIHandleType); stdcall;
exports StartNewPage name 'GdiPrint_StartNewPage';
// Starts a new page on the printer (not required for first page)
procedure EndCurrentPage
(var GdiHandle : GDIHandleType); stdcall;
exports EndCurrentPage name 'GdiPrint_EndCurrentPage';
//
// Closes the current page (allowing the printer to print out that page) and
// increments the CurrentPageCount
//
procedure AbortPrinting
(var GdiHandle : GDIHandleType); stdcall;
exports AbortPrinting name 'GdiPrint_AbortPrinting';
// aborts the print job
procedure SetFont
(var GdiHandle : GDIHandleType;
const FontName : array of char;
const FontSize : integer;
const FontFormat : FontFormatType); overload; stdcall;
exports SetFont (var GdiHandle : GDIHandleType;
const FontName : array of char;
const FontSize : integer;
const FontFormat : FontFormatType) name 'GdiPrint_SetFont';
// sets the current font to the new defined parameters
procedure SetFont
(var GdiHandle : GDIHandleType;
const FontName : string;
const FontSize : integer;
const FontFormat : FontFormatType); overload; stdcall;
exports SetFont (var GdiHandle : GDIHandleType;
const FontName : string;
const FontSize : integer;
const FontFormat : FontFormatType) name 'GDIPrint_STRSetFont';
// See documentation of SetFont.
procedure SetFixedFont
(var GdiHandle : GDIHandleType;
const CharsPerLine : integer;
const LinesPerPage : integer;
const FontFormat : FontFormatType); stdcall;
exports SetFixedFont name 'GdiPrint_SetFixedFont';
procedure SetMargins
(var GdiHandle : GDIHandleType;
const Top : ModSys.FLOAT32;
const Bottom : ModSys.FLOAT32;
const Left : ModSys.FLOAT32;
const Right : ModSys.FLOAT32); stdcall;
exports SetMargins name 'GdiPrint_SetMargins';
// Sets the MarginRect (uses the PageRect for default settings)
procedure PixelsToInches
(var GdiHandle : GDIHandleType;
const PixelValue : integer;
var InchValue : ModSys.FLOAT32); stdcall;
exports PixelsToInches name 'GdiPrint_PixelsToInches';
// this is based upon the XPixelsPerInch value
procedure InchesToPixels
(var GdiHandle : GDIHandleType;
const InchValue : ModSys.FLOAT32;
var PixelValue : integer); stdcall;
exports InchesToPixels name 'GdiPrint_InchesToPixels';
// this is based upon the XPixelsPerInch value
procedure PixelsToInchesY
(var GdiHandle : GDIHandleType;
const PixelValue : integer;
var InchValue : ModSys.FLOAT32); stdcall;
exports PixelsToInchesY name 'GdiPrint_PixelsToInchesY';
// this is based upon the YPixelsPerInch value
procedure InchesToPixelsY
(var GdiHandle : GDIHandleType;
const InchValue : ModSys.FLOAT32;
var PixelValue : integer); stdcall;
exports InchesToPixelsY name 'GdiPrint_InchesToPixelsY';
// this is based upon the YPixelsPerInch value
procedure SetTextJustification
(var GdiHandle : GDIHandleType;
const HorzJustify : HorzJustifyType;
const VertJustify : VertJustifyType); stdcall;
exports SetTextJustification name 'GdiPrint_SetTextJustification';
// Sets the justification of where the text will be printed in a rectangle
procedure SetTextRotation
(var GdiHandle : GDIHandleType;
const degree : cardinal); stdcall;
exports SetTextRotation name 'GdiPrint_SetTextRotation';
// Sets the direction (rotation) of the printed text (0 - 360) counter clockwise
function GetTextColor
(const GdiHandle : GDIHandleType) : ColorType; stdcall;
exports GetTextColor name 'GdiPrint_GetTextColor';
function GetTextBGColor
(const GdiHandle : GDIHandleType) : ColorType; stdcall;
exports GetTextBGColor name 'GdiPrint_GetTextBGColor';
procedure SetTextColor
(var GdiHandle : GDIHandleType;
const Color : ColorType); stdcall;
exports SetTextColor name 'GdiPrint_SetTextColor';
procedure SetTextBGColor
(var GdiHandle : GDIHandleType;
const Color : ColorType); stdcall;
exports SetTextBGColor name 'GdiPrint_SetTextBGColor';
procedure PrintText
(var GdiHandle : GDIHandleType;
const RECT : RectType;
const Text : array of char); overload; stdcall;
exports PrintText (var GdiHandle : GDIHandleType;
const RECT : RectType;
const Text : array of char) name 'GdiPrint_PrintText';
//
// Prints the text in the given rectangle area in the currently
// selected font, font size, and text justification
//
procedure PrintText
(var GdiHandle : GDIHandleType;
const RECT : RectType;
const Text : string); overload; stdcall;
exports PrintText (var GdiHandle : GDIHandleType;
const RECT : RectType;
const Text : string) name 'GdiPrint_STRPrintText';
// STRPrintText - See documentation of PrintText.
procedure PrintTextPoint
(var GdiHandle : GDIHandleType;
const Point : PointType;
const Text : array of char); stdcall;
exports PrintTextPoint name 'GdiPrint_PrintTextPoint';
// Prints the text at the selected point using the currently selected font
procedure PrintLine
(var GdiHandle : GDIHandleType;
const RECT : RectType;
const thickness : LineThicknessType); stdcall;
exports PrintLine name 'GdiPrint_PrintLine';
// Prints a line with the given rectangle points and line thickness
procedure PrintEllipse
(var GdiHandle : GDIHandleType;
const RECT : RectType;
const thickness : LineThicknessType); stdcall;
exports PrintEllipse name 'GdiPrint_PrintEllipse';
// Prints an ellipse inside the given rectangle points and line thickness
procedure PrintRect
(var GdiHandle : GDIHandleType;
const RECT : RectType;
const thickness : LineThicknessType); stdcall;
exports PrintRect name 'GdiPrint_PrintRect';
// Prints a rectangle with the given rectangle points and line thickness
procedure PrintFilledRect
(var GdiHandle : GDIHandleType;
const RECT : RectType); stdcall;
exports PrintFilledRect name 'GdiPrint_PrintFilledRect';
// Prints a rectangle with the current pen and filled with current brush
procedure SetPenKind
(var GdiHandle : GDIHandleType;
const penStyle : PenStyleType;
const thickness : LineThicknessType;
const Color : ColorType); stdcall;
exports SetPenKind name 'GdiPrint_SetPenKind';
// Sets the current pen style (used with PrintFilledRect)
procedure SetBrushKind
(var GdiHandle : GDIHandleType;
const brushStyle : BrushStyleType;
const brushHatch : BrushHatchType;
const Color : ColorType); stdcall;
exports SetBrushKind name 'GdiPrint_SetBrushKind';
// Sets the current brush style (used with PrintFilledRect)
procedure GetCharWidthAndHeight
(var GdiHandle : GDIHandleType;
const ACHAR : char;
var TextWidth : integer;
var TextHeight : integer); stdcall;
exports GetCharWidthAndHeight name 'GdiPrint_GetCharWidthAndHeight';
//
// Retrieves the width and height of a character in the current font
// and font size.
//
procedure GetStringWidthAndHeight
(var GdiHandle : GDIHandleType;
const Str : array of char;
var TextWidth : integer;
var TextHeight : integer); overload; stdcall;
exports GetStringWidthAndHeight (var GdiHandle : GDIHandleType;
const Str : array of char;
var TextWidth : integer;
var TextHeight : integer) name 'GdiPrint_GetStringWidthAndHeight';
//
// Retrieves the width and height of a string in the current font
// and font size.
//
procedure GetStringWidthAndHeight
(var GdiHandle : GDIHandleType;
const Str : string;
var TextWidth : integer;
var TextHeight : integer); overload; stdcall;
exports GetStringWidthAndHeight (var GdiHandle : GDIHandleType;
const Str : string;
var TextWidth : integer;
var TextHeight : integer) name 'GdiPrint_STRGetStringWidthAndHeight';
// STRGetStringWidthAndHeight - See documentation of GetStringWidthAndHeight.
procedure GetMaxTextChars
(var GdiHandle : GDIHandleType;
const Str : array of char;
const strLen : integer;
const RECT : RectType;
var numCharsFit : integer); stdcall;
exports GetMaxTextChars name 'GdiPrint_GetMaxTextChars';
//
// Retrieves the number of characters of the given string that will fit in
// the rectangle. This is based upon the current font and font size.
//
procedure OutputBMPFile
(var GdiHandle : GDIHandleType;
const bmpFileName : array of char;
const rectArea : RectType); overload; stdcall;
exports OutputBMPFile (var GdiHandle : GDIHandleType;
const bmpFileName : array of char;
const rectArea : RectType) name 'GdiPrint_OutputBMPFile';
// Prints the given bitmap file in the defined rectangle.
procedure OutputBMPFile
(var GdiHandle : GDIHandleType;
const bmpFileName : string;
const rectArea : RectType); overload; stdcall;
exports OutputBMPFile (var GdiHandle : GDIHandleType;
const bmpFileName : string;
const rectArea : RectType) name 'GdiPrint_STROutputBMPFile';
// STROutputBMPFile - See documentation of OutputBMPFile.
procedure ClosestPaper
(var GdiHandle : GDIHandleType;
const DesiredWidth : ModSys.FLOAT32;
const DesiredLength : ModSys.FLOAT32;
var Paper : cardinal); stdcall;
exports ClosestPaper name 'GdiPrint_ClosestPaper';
// Finds the closest paper matching the desired size.
procedure SetStandardPaper; stdcall; exports SetStandardPaper name 'GdiPrint_SetStandardPaper'; // Sets the printer back to standard letter size paper 8.5 x 11.0
procedure PaintLog
(var PaintRec : PaintRecordType); stdcall;
exports PaintLog name 'GdiPrint_PaintLog';
// Paints a portion of a log to an output device. LogFile must end in .GDL
procedure ViewLog
(const AppHandle : Windows.Hwnd;
var ViewData : ViewRecordType;
const PrintProc : PrintProcType); stdcall;
exports ViewLog name 'GdiPrint_ViewLog';
//
// Opens a log file for view. This routine allows the user to view the
// data in the log in a window. The user can choose to print the log
// while viewing.
//
// When this routine returns some of the values in the ViewData record have
// been updated to reflect the changes the user may have made.
//
// The PrintProc is called if the user decides to print from within the viewer.
// This gives you an interecept and allows you to do other things. The two
// parameters are a PrintRec that has been set up so that if you simply want
// to let the system handle the printing for you then the following routine
// would work:
//
// procedure PrintCallbackProc
// (var PrintRec : GDIPrint.PrintRecordType;
// var ForcePrintedTrue : boolean);
//
// begin
// GDIPrint.PrintLog (PrintRec);
//
// end; // PrintCallbackProc
//
//
// If you wanted to do something different for printing then you can do the following:
//
// procedure PrintCallbackProc
// (var PrintRec : GDIPrint.PrintRecordType;
// var ForcePrintedTrue : boolean);
//
// begin
// ----- whatever you want here ----
//
// ---- Set the force flag to true to make the system think printing was done
// ForcePrintedTrue := True;
//
// end; // PrintCallbackProc
//
//
// Setting the ForcePrintedTrue value will cause the ViewRec that eventually comes back
// from this routine to show that printing was done. If you call the GDIPrint.PrintLog
// routine you should NEVER set the value to true or it will override whatever the
// user actually did.
//
procedure PrintLog
(var PrintData : PrintRecordType); stdcall;
exports PrintLog name 'GdiPrint_PrintLog';
// opens a log file for printing. LogFile must end in .GDL
procedure GetLogStats
(const LogFile : array of char;
var StatsRecord : StatsRecordType;
var DeviceError : cardinal); stdcall;
exports GetLogStats name 'GdiPrint_GetLogStats';
//*
// GetLogStats - Get some statistics about the log file.
//
//
// This procedure returns information about the original device that was
// opened for writing. It also returns the number of pages present in
// the file.
//
// CALLING SEQUENCE -
//
// GetLogStats (LogFile, StatsRecord, DeviceError)
//
// ENTRY -
//
// LogFile : array of char
// The name of the file to check. LogFile must end in .GDL
//
// EXIT -
//
// StatsRecord : StatsRecordType
// See the documentation of the record structure at top of file.
//
// DeviceError : cardinal
// Can be checked to see if an error occurred while getting the stats.
//
procedure AsciiToGdl
(const GDLRecord : GDLRecordType;
var Success : boolean); stdcall;
exports AsciiToGdl name 'GdiPrint_AsciiToGdl';
//*
// AsciiToGdl - Converts an ASCII file to the equivalent GDL file.
//
//
// This procedure will convert an ASCII file to the equivalent GDL file.
// The GDL file can then be used to view or print the content. To print the
// GDL file call the GDIPrint.PrintLog routine. To use the GDL view to
// view and/or print the file call the GDIPrint.ViewLog routine.
//
// CALLING SEQUENCE -
//
// AsciiToGdl (GDLRecord, Success)
//
// ENTRY -
//
// GDLRecord : GDLRecordType
// Record containing the following fields -
//
// GDLRecord.AsciiFileName : array of char
// The name of a ASCII file containing the text to be converted.
//
// GDLRecord.GDLFileName : array of char
// The name of the file to contain the GDL commands to reproduce the
// ASCII file contents in a Windows environment.
//
// GDLRecord.Paper : cardinal
// Type type of paper to use. Set to Windows.DMPAPER_USER if using a custom size.
// If and only if that value is set are the PageInchWidth and PageInchHeight
// params used.
//
// GDLRecord.PageInchWidth : ModSys.FLOAT32
// The width in inches of the paper this is to be placed on.
//
// GDLRecord.PageInchHeight : ModSys.FLOAT32
// The height in inches of the paper this is to be placed on.
//
// GDLRecord.Orientation : OrientationType
// Portrait - Pages will be in portrait orientation.
// Landscape - Pages will be in landscape orientation.
//
// GDLRecord.IgnoreFirstFF : boolean
// Some DOS style ASCII reports started the report with a FormFeed character
// to make sure that the first page was set to the top of form. If your
// report has this and you don't set this flag you will end up with a blank
// page at the start of your report. This flag has no effect if an ASCIIX.FF
// is not found in the first few bytes of the first line of the report.
//
// GDLRecord.ShowProgress : boolean
// Show a message stating that conversion is on what page.
//
// GDLRecord.PrinterUseOnly : boolean
// This field controls the granularity of the translation. If going to a
// printer only then the text is converted a word (or solid line of characters)
// at a time. However when using the viewer that can cause some items such
// as a long line of dashes to not be shown correctly, typically they will show
// as shorter in total length than they really are. If those same dashes are
// converted a character at a time rather than as a single line then the viewer
// can show them very accurately placed on the page. However the trade off is
// speed. When this flag is False so that the conversion is a character at a
// time it does take a bit longer and the converted file will be larger. If
// you really are going to use the resultant file for printing only you should
// definately set this field to True to gain speed on the translations.
// If you are going to the viewer you have the choice of setting this flag.
// Setting it to False would be preferable in order to get a better WYSIWYG
// effect on screen. Neither setting of this field has any effect on the final
// printed copy, only on the copy shown in the viewer.
//
// EXIT -
//
// Success : boolean
// True - File was successfully converted to GDL.
// False - An error prevented the files conversion.
//
// EXAMPLE -
//
// var
// ViewData : GDIPrint.ViewRecordType;
//
// begin
// GDLRecord.AsciiFileName := 'MyRpt.txt';
// GDLRecord.GDLFileName := 'MyRpt.gdl';
// GDLRecord.Paper := GDIPrint.DMPAPER_USER;
// GDLRecord.PageInchWidth := 3.5;
// GDLRecord.PageInchHeight := 12.0;
// GDLRecord.Orientation := GDIPrint.Portrait;
// GDLRecord.TopMargin := 0.3;
// GDLRecord.BottomMargin := 0.0;
// GDLRecord.LeftMargin := 0.0;
// GDLRecord.RightMargin := 0.0;
// GDLRecord.IgnoreFirstFF := True;
// GDLRecord.ShowProgress := True;
// GDLRecord.ShowLineSizeWarning := True;
// GDLRecord.PrinterUseOnly := False;
//
// GDIPrint.AsciiToGdl (GDLRecord,
// Success);
//
// Also this routine will commonly be used in conjuction with the GDIPrint.ViewLog
// routine in order to build a Windows friendly file viewer/printer. In order to
// view the just converted file the following code can be used to call the viewer.
//
// ViewData.LogFile := 'MyRpt.gdl';
// ViewData.StartPage := 1;
// ViewData.Title := 'My Very Important Report';
// ViewData.ShowTitle := True;
// ViewData.ShowMinMax := False;
// ViewData.ShowSystemMenu := False;
// ViewData.ShowMenu := True;
// ViewData.ShowOpenFile := False;
// ViewData.ShowToolbar := True;
// ViewData.ZoomPercent := 100;
// ViewData.BackgroundBmp[0] := ASCIIX.nul;
// ViewData.WindowLoc.X := 10;
// ViewData.WindowLoc.Y := 10;
// ViewData.XSize := 1024;
// ViewData.YSize := 768;
// ViewData.Sizeable := True;
// ViewData.AllowPrintRange := True;
// ViewData.ShowPrintProgress := True;
// ViewData.UserPrinted := False;
//
// GDIPrint.ViewLog (ViewData);
//
// if (ViewData.UserPrinted) then begin
// ......
//
procedure UnderlineRect
(var GdiHandle : GDIHandleType;
const SourceRect : RectType); stdcall;
exports UnderlineRect name 'GDIPrint_UnderlineRect';
//*
// UnderlineRect - Draw an underline for the given rect area.
//
//
// This procedure draws an underline in the given rect area. This
// is useful for making text appear to be underlined.
//
// CALLING SEQUENCE -
//
// UnderlineRect (GdiHandle, SourceRect)
//
// ENTRY -
//
// GdiHandle : GDIHandleType
// A handle to the current GDI output.
//
// SourceRect : RectType
// A rect to use as the boundaries of the underline drawing.
//
procedure GetSizeOf
(var GdiHandle : GDIHandleType;
const Str : array of char;
var StrSize : ModSys.INT32); stdcall;
exports GetSizeOf name 'GDIPrint_GetSizeOf';
//*
// GetSizeOf - Get the width of the rect needed to contain the string.
//
//
// This procedure calculates the width needed for a rect to contain this
// text when it is drawn.
//
// CALLING SEQUENCE -
//
// GetSizeOf (GdiHandle, Str, StrSize)
//
// ENTRY -
//
// GdiHandle : GDIHandleType
// A handle to the current GDI output.
//
// Str : array of char
// The string to be used in the calculation.
//
// EXIT -
//
// StrSize : ModSys.INT32
// The width of a rect that will contain the given string.
//
procedure GetNextBlockLine
(var GdiHandle : GDIHandleType;
const Relation : string;
const Field : string;
const Reset : boolean;
const PrintRect : RectType;
var Value : array of char;
var EndOfData : boolean); stdcall;
exports GetNextBlockLine name 'GDIPrint_GetNextBlockLine';
//*
// GetNextBlockLine - Get data for the rect from a block data field.
//
//
// This procedure gets data from a block data field using the given rect.
// The rect is used to control how much data is pulled out, in other words
// only as much data as will fit within the rect.
//
// CALLING SEQUENCE -
//
// GetNextBlockLine (GdiHandle, Relation, Field, Reset, PrintRect,
// Value, EndOfData)
//
// ENTRY -
//
// GdiHandle : GDIHandleType
// A handle to the current GDI output.
//
// Relation : array of char
// The relation of the field to be used.
//
// Field : array of char
// The block field containing the data.
//
// Reset : boolean
// True - Reset and start at the first of the data again.
// False - Continue getting the data from the byte just
// past the last one read before this.
//
// PrintRect : RectType
// The rect that is used to contain the data.
//
// EXIT -
//
// Value : array of char
// The next string from the block data that will fit within the rect.
//
// EndOfData : boolean
// True - This is the last of the block data.
// False - There is more block data after this.
//
procedure GetNextBufferLine
(var GdiHandle : GDIHandleType;
const Buffer : array of char;
const Reset : boolean;
const PrintRect : RectType;
var Value : array of char;
var EndOfData : boolean); stdcall;
exports GetNextBufferLine name 'GDIPrint_GetNextBufferLine';
//*
// GetNextBufferLine - Get data for the rect from a buffer.
//
//
// This procedure gets data from a buffer using the given rect. The
// rect is used to control how much data is pulled out, in other words
// only as much data as will fit within the rect.
//
// CALLING SEQUENCE -
//
// GetNextBufferLine (GdiHandle, Buffer, Reset, PrintRect,
// Value, EndOfData)
//
// ENTRY -
//
// GdiHandle : GDIHandleType
// A handle to the current GDI output.
//
// Buffer : array of char
// The buffer to be used.
//
// Reset : boolean
// True - Reset and start at the first of the data again.
// False - Continue getting the data from the byte just
// past the last one read before this.
//
// PrintRect : RectType
// The rect that is used to contain the data.
//
// EXIT -
//
// Value : array of char
// The next string from the block data that will fit within the rect.
//
// EndOfData : boolean
// True - This is the last of the block data.
// False - There is more block data after this.
//
Send mail to
warren.merrill@inl.gov
with questions or comments about this web site.
Copyright © 1989-2006 Battelle Energy Alliance