Attribute VB_Name = "REPORT" '________________________________________________________________________________________ ' ' File: REPORT.BAS ' ' Author: Roberto Raso ' Date: 13th July 1995 '________________________________________________________________________________________ ' ' Purpose: Simple report printing system. ' Format is described below: ' ' ________________________ ' Header lines ' ... ' ________________________ ' Blank line x SECT_SEP ' ________________________ ' Column headers/titles ' ________________________ ' Table lines, to fit space ' ... ' ________________________ ' Blank line x SECT_SEP ' ________________________ ' Current page number ' ________________________ '________________________________________________________________________________________ '________________________________ ' ' Constant/Global declarations. '________________________________ Option Explicit Const MODULE_NAME = "REPORT.BAS" Const TEST_CHAR = "A" Global Const COL_ALIGN_LEFT = 0 Global Const COL_ALIGN_CENTRE = 1 Global Const COL_ALIGN_RIGHT = 2 Global Const COL_WIDTH_COL = -1 Global Const COL_WIDTH_TABLE = -2 Global Const COL_WIDTH_MAX = -3 Global Const PORTRAIT = 1 Global Const LANDSCAPE = 2 Const SECT_SEP = 1 Const FONT_SCALE = 0.75 '________________________________ ' ' Data type declarations. '________________________________ Type ColStyle strName As String fWidth As Single fLInset As Single fRInset As Single nAlign As Integer End Type Type Graph 'Describes the graph that is going to be used 'on the first page of the report. fXOrig As Single 'X-axis origin value. fYOrig As Single 'Y-axis origin value. fXLim As Single 'X-axis value at axis end. fYLim As Single 'Y-axis value at axis end. nHeight As Integer 'Height of graph, as lines of text. bCon As Integer 'True if the graph is continuum type graph. End Type Type GPoint 'A point on a graph fX As Single fy As Single End Type Type PageScale 'Describes information about the page scale 'See ScaleLeft, ScaleTop, ScaleWidth and ScaleHeight fLeft As Single fTop As Single fWidth As Single fHeight As Single End Type Type AnnoPoint 'Use to position an annotation for the graph fX As Single fy As Single strAnno As String 'The piece of annotation required at fX, fY. End Type Type OrientStructure Orientation As Long Pad As String * 16 End Type '________________________________ ' ' Function declarations. '________________________________ Declare Function Escape% Lib "GDI" (ByVal hdc%, ByVal nEsc%, ByVal nLen%, lpData As OrientStructure, lpOut As Any) '________________________________ ' ' Variable declarations. '________________________________ Dim nHdrLines As Integer Dim nTblCols As Integer Dim nTblRows As Integer Dim nTblRowsGraph As Integer Dim nPages As Integer Dim nRowsPerPage As Integer Dim nRowsPerPageGraph As Integer Dim bGraphMode As Integer Dim nGraphLines As Integer Dim fTextHeight As Single Dim asReportStyle() As ColStyle '________________________________________________________________________________________ ' ' Process: ColStyleFormat ' ' Author: Roberto Raso ' Date: 13th July 1995 ' ' Purpose: Formats the supplied column style to fit the printer. ' ' Parameters: asColStyle() is an array that describes how each column should be laid out. ' astrTableField(column, row) is a 2-D array of the fields that should be printed. ' ' Return: Void. '________________________________________________________________________________________ Private Sub ColStyleFormat(asColStyle() As ColStyle, astrTableField() As String) Dim nCol As Integer Dim fMaxColWidth As Single Dim fWidth As Single ReDim asReportStyle(nTblCols) For nCol = 0 To nTblCols asReportStyle(nCol) = asColStyle(nCol) asReportStyle(nCol).fLInset = fTextHeight asReportStyle(nCol).fRInset = fTextHeight If asReportStyle(nCol).fWidth = COL_WIDTH_COL Then asReportStyle(nCol).fWidth = Printer.TextWidth(asReportStyle(nCol).strName) + asReportStyle(nCol).fLInset + asReportStyle(nCol).fRInset ElseIf asReportStyle(nCol).fWidth = COL_WIDTH_TABLE Then asReportStyle(nCol).fWidth = TableColMaxWidth(nCol, astrTableField()) + asReportStyle(nCol).fLInset + asReportStyle(nCol).fRInset ElseIf asReportStyle(nCol).fWidth = COL_WIDTH_MAX Then fWidth = Printer.TextWidth(asReportStyle(nCol).strName) fMaxColWidth = TableColMaxWidth(nCol, astrTableField()) If fMaxColWidth > fWidth Then asReportStyle(nCol).fWidth = fMaxColWidth + asReportStyle(nCol).fLInset + asReportStyle(nCol).fRInset Else asReportStyle(nCol).fWidth = fWidth + asReportStyle(nCol).fLInset + asReportStyle(nCol).fRInset End If End If Next nCol End Sub '________________________________________________________________________________________ ' ' Process: FieldOffSet ' ' Author: Roberto Raso ' Date: 13th July 1995 ' ' Purpose: Sets the position of the text that will be printed ' in a field, within that field. ' ' Parameters: sColStyle describes how the field should be displayed. ' strField is the text that will be printed in the field. ' ' Return: The offset from the edge of the field where printing ' is to start. '________________________________________________________________________________________ Private Function FieldOffSet(sColStyle As ColStyle, strField As String) As Single Dim fTextOffSet As Single Select Case sColStyle.nAlign Case COL_ALIGN_CENTRE fTextOffSet = sColStyle.fWidth - sColStyle.fLInset - sColStyle.fRInset fTextOffSet = fTextOffSet - Printer.TextWidth(strField) fTextOffSet = sColStyle.fLInset + fTextOffSet / 2 Case COL_ALIGN_RIGHT fTextOffSet = sColStyle.fWidth - sColStyle.fRInset - Printer.TextWidth(strField) Case Else fTextOffSet = sColStyle.fLInset End Select FieldOffSet = fTextOffSet End Function '________________________________________________________________________________________ ' ' Process: FooterPrint ' ' Author: Roberto Raso ' Date: 13th July 1995 ' ' Purpose: Prints the footer at the bottom of the page. ' ' Parameters: None. ' ' Return: None. '________________________________________________________________________________________ Private Sub FooterPrint() Dim fXPos As Single Dim fYPos As Single Dim strFooterText As String fYPos = Printer.ScaleHeight - fTextHeight strFooterText = "Page " + CStr(Printer.Page) + " of " + CStr(nPages) fXPos = Printer.ScaleWidth / 2 - Printer.TextWidth(strFooterText) / 2 Printer.CurrentX = fXPos Printer.CurrentY = fYPos Printer.Print strFooterText End Sub '________________________________________________________________________________________ ' ' Process: GraphAnnotate ' ' Author: Roberto Raso ' Date: 8th August 1995 ' ' Purpose: Annotate the selected peaks. ' ' Parameters: sGraph describes how the graph is going to be put onto the page. ' asGPoint() an array of X-Y co-ordinates. ' asAnno() is an array of points to annotate. ' ' Return: Void. '________________________________________________________________________________________ Sub GraphAnnotate(sGraph As Graph, asGPoint() As GPoint, asAnno() As AnnoPoint) Dim bDone As Integer Dim n1stPoint As Integer Dim nLstPoint As Integer Dim nPoint As Integer Dim nChkPoint As Integer Dim fFontOld As Single Dim strAnno As String fFontOld = Printer.FontSize On Error GoTo NoAnnotation n1stPoint = LBound(asAnno) nLstPoint = UBound(asAnno) Printer.FontSize = fFontOld * FONT_SCALE For nPoint = n1stPoint To nLstPoint bDone = False For nChkPoint = n1stPoint To nPoint - 1 If asAnno(nPoint).fX = asAnno(nChkPoint).fX Then bDone = True End If Next nChkPoint If bDone = False Then strAnno = asAnno(nPoint).strAnno Printer.CurrentX = asAnno(nPoint).fX - Printer.TextWidth(strAnno) / 2 Printer.CurrentY = asAnno(nPoint).fy - Printer.TextHeight(strAnno) Printer.Print strAnno End If Next nPoint NoAnnotation: Printer.FontSize = fFontOld Exit Sub End Sub '________________________________________________________________________________________ ' ' Process: GraphBaselineDraw ' ' Author: David Varley ' Date: 9th July 1996 ' ' Purpose: Draws the graph on the page. ' ' Parameters: asPKDFullPeak() describes peaks. ' asChroPt() is chro trace. ' sVGRawFile is Rawfile desc. ' ' Return: Void. '________________________________________________________________________________________ Sub GraphBaselineDraw(asPKDFullPeak() As PKD_FULL_PEAK, asChroPt() As CHROMATOGRAM, sVGRawFile As VGRAWFILE, fAlignTime As Single) Dim n1stPoint As Integer Dim nLstPoint As Integer Dim nPeaks As Integer Dim nPeak As Integer n1stPoint = LBound(asChroPt) nLstPoint = UBound(asChroPt) nPeaks = UBound(asPKDFullPeak) + 1 For nPeak = 0 To nPeaks - 1 'asPKDFullPeak(nPeak).fStart 'asPKDFullPeak(nPeak).fStartHt 'X top of peak , require Y bit as well 'asPKDFullPeak(nPeak).fTop 'asPKDFullPeak(nPeak).fEnd 'asPKDFullPeak(nPeak).fEndHt If (asChroPt(n1stPoint + asPKDFullPeak(nPeak).fEnd - 1).Intensity <> asPKDFullPeak(nPeak).fEndHt) Then If (asPKDFullPeak(nPeak).fEnd > 0 And asChroPt(n1stPoint + asPKDFullPeak(nPeak).fEnd - 1).Intensity > 0) Then Printer.Line (DmRawScanToTime(sVGRawFile, CLng(asPKDFullPeak(nPeak).fEnd)) + fAlignTime, asPKDFullPeak(nPeak).fEndHt)-(DmRawScanToTime(sVGRawFile, CLng(asPKDFullPeak(nPeak).fEnd)) + fAlignTime, asChroPt(n1stPoint + asPKDFullPeak(nPeak).fEnd - 1).Intensity) End If End If Printer.Line (DmRawScanToTime(sVGRawFile, CLng(asPKDFullPeak(nPeak).fStart)) + fAlignTime, asPKDFullPeak(nPeak).fStartHt)-(DmRawScanToTime(sVGRawFile, CLng(asPKDFullPeak(nPeak).fEnd)) + fAlignTime, asPKDFullPeak(nPeak).fEndHt) Next nPeak End Sub '________________________________________________________________________________________ ' ' Process: GraphDraw ' ' Author: Roberto Raso ' Date: 4th August 1995 ' ' Purpose: Draws the graph on the page. ' ' Parameters: sGraph describes how the graph is going to be put onto the page. ' asGPoint() an array of X-Y co-ordinates. ' asAnno() is an array of points to annotate. ' ' Return: Void. '________________________________________________________________________________________ Sub GraphDraw(sGraph As Graph, asGPoint() As GPoint, asAnno() As AnnoPoint) Dim n1stPoint As Integer Dim nLstPoint As Integer Dim nPoint As Integer Dim sLstPoint As GPoint Dim asAnnoChecked() As Integer n1stPoint = LBound(asGPoint) nLstPoint = UBound(asGPoint) sLstPoint = asGPoint(n1stPoint) For nPoint = n1stPoint To nLstPoint If sGraph.bCon <> False Then Printer.Line (sLstPoint.fX, sLstPoint.fy)-(asGPoint(nPoint).fX, asGPoint(nPoint).fy) sLstPoint = asGPoint(nPoint) Else Printer.Line (asGPoint(nPoint).fX, sGraph.fYOrig)-Step(0, asGPoint(nPoint).fy) End If Next nPoint Call GraphAnnotate(sGraph, asGPoint(), asAnno()) End Sub '________________________________________________________________________________________ ' ' Process: GraphReportPrint ' ' Author: Roberto Raso ' Date: 4th August 1995 ' ' Purpose: Main call to print out a report with a graph on the first page. ' ' Parameters: sGraph describes how the graph is going to be put onto the page. ' asGPoint() is an array of points that will be used for plotting. ' asAnno() is an array of points to annotate. ' astrHeader() is an array of lines for the report header. ' asColStyle() is an array that describes how each column should be laid out. ' astrTableField(column, row) is a 2-D array of the fields that should be printed. ' ' Return: True if successful. '________________________________________________________________________________________ Function GraphReportPrint(sGraph As Graph, asGPoint() As GPoint, asAnno() As AnnoPoint, astrHeader() As String, asColStyle() As ColStyle, astrTableField() As String) As Integer Dim sOrigPageScale As PageScale Dim nLinesPerPage As Integer Dim nPage As Integer Dim nTableBlockStart As Integer 'On Error GoTo GraphReportPrintError nHdrLines = UBound(astrHeader) nTblCols = UBound(astrTableField, 1) nTblRows = UBound(astrTableField, 2) fTextHeight = Printer.TextHeight(TEST_CHAR) bGraphMode = True nGraphLines = sGraph.nHeight nPages = PagesCount() If UBound(asColStyle) <> nTblCols Then GraphReportPrint = False Exit Function End If Call ColStyleFormat(asColStyle(), astrTableField()) nPages = PagesCount() Printer.ScaleMode = 1 Call ReportHeaderPrint(astrHeader()) nLinesPerPage = Int(GraphScaleSet(sGraph, sOrigPageScale, astrHeader())) Call GraphDraw(sGraph, asGPoint(), asAnno()) Printer.ScaleMode = 1 Printer.ScaleLeft = sOrigPageScale.fLeft Printer.ScaleTop = sOrigPageScale.fTop Printer.ScaleWidth = sOrigPageScale.fWidth Printer.ScaleHeight = sOrigPageScale.fHeight nTableBlockStart = 0 Call ReportHeaderPrint(astrHeader()) TableHeaderPrint nTableBlockStart = TableBlockPrint(nTableBlockStart, astrTableField()) + 1 FooterPrint 'Printer.NewPage If nPages >= 2 Then For nPage = 2 To nPages Call ReportHeaderPrint(astrHeader()) TableHeaderPrint nTableBlockStart = TableBlockPrint(nTableBlockStart, astrTableField()) + 1 FooterPrint If nPage <> nPages Then Printer.NewPage End If Next nPage End If Printer.EndDoc GraphReportPrintError: If Err Then GraphReportPrint = False Else GraphReportPrint = True End If Exit Function End Function '________________________________________________________________________________________ ' ' Process: GraphScaleDraw ' ' Author: Roberto Raso ' Date: 8th August 1995 ' ' Purpose: Draws the Scale on the page for drawing a graph. ' ' Parameters: sGraph describes how the graph is going to be put onto the page. ' ' Return: Void. '________________________________________________________________________________________ Sub GraphScaleDraw(sGraph As Graph) Dim nPoint As Integer Dim fDiv As Single Dim fSubDiv As Single Dim fSubDivStart As Single Dim fXStartDiv As Single Dim fDivLen As Single Dim fDivPos As Single Dim fOldFontSize As Single Dim strAnno As String fOldFontSize = Printer.FontSize Printer.Line (sGraph.fXOrig, sGraph.fYOrig)-(sGraph.fXLim, sGraph.fYOrig) Printer.Line (sGraph.fXOrig, sGraph.fYOrig)-(sGraph.fXOrig, sGraph.fYLim) 'Y-Axis divisions fDiv = (sGraph.fYLim - sGraph.fYOrig) / 10 fDivLen = Printer.TextWidth(TEST_CHAR) / 2 Printer.FontSize = fOldFontSize * FONT_SCALE For nPoint = 0 To 10 Printer.Line (sGraph.fXOrig, sGraph.fYOrig + nPoint * fDiv)-Step(-fDivLen, 0) Next nPoint strAnno = CStr(sGraph.fYOrig) Printer.CurrentX = sGraph.fXOrig - Printer.TextWidth(strAnno) - fDivLen Printer.CurrentY = sGraph.fYOrig - Printer.TextHeight(strAnno) / 2 Printer.Print strAnno strAnno = CStr(sGraph.fYLim) Printer.CurrentX = sGraph.fXOrig - Printer.TextWidth(strAnno) - fDivLen Printer.CurrentY = sGraph.fYLim - Printer.TextHeight(strAnno) / 2 Printer.Print strAnno Printer.FontSize = fOldFontSize 'X-Axis divisions fDiv = (sGraph.fXLim - sGraph.fXOrig) / 10 nPoint = Int(Log(fDiv) / Log(10)) If fDiv < 10 ^ nPoint Then fDiv = 10 ^ nPoint fSubDiv = fDiv / 10 ElseIf fDiv < 2 * 10 ^ nPoint Then fDiv = 2 * 10 ^ nPoint fSubDiv = fDiv / 2 ElseIf fDiv < 5 * 10 ^ nPoint Then fDiv = 5 * 10 ^ nPoint fSubDiv = fDiv / 5 Else fDiv = 10 ^ (nPoint + 1) fSubDiv = fDiv / 10 End If If Int(sGraph.fXOrig / fSubDiv) = sGraph.fXOrig / fSubDiv Then fXStartDiv = sGraph.fXOrig Else fXStartDiv = (Int(sGraph.fXOrig / fSubDiv) + 1) * fSubDiv End If fDivLen = -Printer.TextHeight(TEST_CHAR) / 2 Printer.FontSize = fOldFontSize * FONT_SCALE fDivPos = fXStartDiv Do While fDivPos >= sGraph.fXOrig And fDivPos <= sGraph.fXLim Printer.Line (fDivPos, sGraph.fYOrig)-Step(0, -fDivLen / 2) fDivPos = fDivPos + fSubDiv Loop For nPoint = 0 To 10 fDivPos = fXStartDiv + fDiv * nPoint Printer.Line (fDivPos, sGraph.fYOrig)-Step(0, -fDivLen) strAnno = CStr(fDivPos) Printer.CurrentX = fDivPos - Printer.TextWidth(strAnno) / 2 Printer.CurrentY = sGraph.fYOrig - fDivLen Printer.Print strAnno fDivPos = fDivPos + fSubDiv Next nPoint Printer.FontSize = fOldFontSize End Sub '________________________________________________________________________________________ ' ' Process: GraphScaleSet ' ' Author: Roberto Raso ' Date: 4th August 1995 ' ' Purpose: Sets the Scale on the page for drawing a graph. ' ' Parameters: sGraph describes how the graph is going to be put onto the page. ' sOrigPageScale is the original page scale that will be saved. ' astrHeader() is an array of lines for the report header. ' ' Return: Total number of lines on a page. '________________________________________________________________________________________ Function GraphScaleSet(sGraph As Graph, sOrigPageScale As PageScale, astrHeader() As String) As Single Dim fCharHeight As Single Dim fPageLines As Single Dim fGUnitsPerScale As Single Dim fLMargin As Single Dim fRMargin As Single Dim fGraphWidth As Single Dim fTemp1 As Single Dim fTemp2 As Single Dim fTemp3 As Single Dim fTemp4 As Single Printer.ScaleMode = 1 sOrigPageScale.fLeft = Printer.ScaleLeft sOrigPageScale.fTop = Printer.ScaleTop sOrigPageScale.fWidth = Printer.ScaleWidth sOrigPageScale.fHeight = Printer.ScaleHeight fCharHeight = Printer.TextHeight(TEST_CHAR) sOrigPageScale.fTop = 0 fLMargin = Printer.TextWidth(CStr(sGraph.fYLim)) + 2 * fCharHeight fRMargin = Printer.TextWidth(CStr(sGraph.fXLim)) + fCharHeight fGraphWidth = sOrigPageScale.fWidth - fLMargin - fRMargin fGUnitsPerScale = (sGraph.fXLim - sGraph.fXOrig) / fGraphWidth fPageLines = sOrigPageScale.fHeight / fCharHeight fTemp1 = -(sGraph.fYLim - sGraph.fYOrig) / (sGraph.nHeight - 1) * fPageLines fTemp2 = sGraph.fXLim - sGraph.fXOrig + fGUnitsPerScale * (fLMargin + fRMargin) fTemp3 = sGraph.fXOrig - fGUnitsPerScale * fLMargin fTemp4 = (sGraph.fYLim - sGraph.fYOrig) / sGraph.nHeight * (UBound(astrHeader) + 1 + 2 * SECT_SEP) + sGraph.fYLim 'Printer.ScaleHeight = -(sGraph.fYLim - sGraph.fYOrig) / (sGraph.nHeight - 1) * fPageLines 'Printer.ScaleLeft = sGraph.fXOrig - fGUnitsPerScale * fLMargin 'Printer.ScaleTop = (sGraph.fYLim - sGraph.fYOrig) / sGraph.nHeight * (UBound(astrHeader) + 1 + 2 * SECT_SEP) + sGraph.fYLim 'Printer.ScaleWidth = sGraph.fXLim - sGraph.fXOrig + fGUnitsPerScale * (fLMargin + fRMargin) Printer.Scale (fTemp3, fTemp4)-(fTemp3 + fTemp2, fTemp4 + fTemp1) GraphScaleSet = fPageLines Call GraphScaleDraw(sGraph) End Function '________________________________________________________________________________________ ' ' Process: PagesCount ' ' Author: Roberto Raso ' Date: 13th July 1995 ' ' Purpose: Calculates the number of pages to generate the report ' and also sets the number of rows per page. ' ' Parameters: None. ' ' Return: Void. '________________________________________________________________________________________ Private Function PagesCount() As Integer Dim nPages As Integer Dim nRowsRem As Integer Dim fHeightUsed As Single Dim fTableMaxHeight As Single Dim fPages As Single fHeightUsed = fTextHeight * (nHdrLines + 2 + 2 * SECT_SEP) fTableMaxHeight = Printer.ScaleHeight - fHeightUsed nRowsPerPage = Int(fTableMaxHeight / fTextHeight) nRowsPerPageGraph = nRowsPerPage - nGraphLines - 2 * SECT_SEP If bGraphMode <> False Then nRowsRem = nTblRows + 1 - nRowsPerPageGraph If nRowsRem < 0 Then nRowsRem = 0 End If fPages = 1 Else nRowsRem = nTblRows + 1 fPages = 0 End If fPages = fPages + nRowsRem / nRowsPerPage nPages = Int(fPages) If nPages = fPages Then PagesCount = nPages Else PagesCount = nPages + 1 End If End Function '________________________________________________________________________________________ ' ' Process: ReportHeaderPrint ' ' Author: Roberto Raso ' Date: 13th July 1995 ' ' Purpose: Prints a header on to a page. ' ' Parameters: astrHeader() is an array of lines for the report header. ' ' Return: Void. '________________________________________________________________________________________ Private Sub ReportHeaderPrint(astrHeader() As String) Dim nHdrLine As Integer Dim fXPos As Single Dim fYPos As Single fTextHeight = Printer.TextHeight(TEST_CHAR) fXPos = fTextHeight fYPos = 0 For nHdrLine = 0 To nHdrLines Printer.CurrentX = fXPos Printer.CurrentY = fYPos Printer.Print astrHeader(nHdrLine) fYPos = fYPos + fTextHeight Next nHdrLine End Sub ' '________________________________________________________________________________________ ' ' Process: ReportPrint ' ' Author: Roberto Raso ' Date: 13th July 1995 ' ' Purpose: Main call to print out a simple report. ' ' Parameters: astrHeader() is an array of lines for the report header. ' asColStyle() is an array that describes how each column should be laid out. ' astrTableField(column, row) is a 2-D array of the fields that should be printed. ' ' Return: True if successful. '________________________________________________________________________________________ Function ReportPrint(astrHeader() As String, asColStyle() As ColStyle, astrTableField() As String) As Integer Dim nPage As Integer Dim nTableBlockStart As Integer ' On Error GoTo ReportPrintError nHdrLines = UBound(astrHeader) nTblCols = UBound(astrTableField, 1) nTblRows = UBound(astrTableField, 2) fTextHeight = Printer.TextHeight(TEST_CHAR) bGraphMode = False nGraphLines = 0 ' If UBound(asColStyle) <> nTblCols Then ReportPrint = False Exit Function End If ' Call ColStyleFormat(asColStyle(), astrTableField()) nPages = PagesCount() nTableBlockStart = 0 ' For nPage = 1 To nPages Call ReportHeaderPrint(astrHeader()) TableHeaderPrint nTableBlockStart = TableBlockPrint(nTableBlockStart, astrTableField()) + 1 FooterPrint Printer.NewPage Next nPage ' Printer.EndDoc ReportPrintError: ' If Err Then ReportPrint = False Else ReportPrint = True End If ' Exit Function End Function ' '________________________________________________________________________________________ ' ' Process: ReportPrintGraph ' ' Author: David Varley ' Date: 8th July 1996 ' ' Purpose: Main call to print out a simple report with graph. ' ' Parameters: astrHeader() is an array of lines for the report header. ' asColStyle() is an array that describes how each column should be laid out. ' astrTableField(column, row) is a 2-D array of the fields that should be printed. ' ' Return: True if successful. '________________________________________________________________________________________ Function ReportPrintGraph(asPKDFullPeak() As PKD_FULL_PEAK, asChroPt() As CHROMATOGRAM, sVGRawFile As VGRAWFILE, sGraph As Graph, asGPoint() As GPoint, asAnno() As AnnoPoint, astrHeader() As String, asColStyle() As ColStyle, astrTableField() As String, fAlignTime As Single) As Integer Dim sOrigPageScale As PageScale Dim nLinesPerPage As Integer Dim nPage As Integer Dim nTableBlockStart As Integer 'On Error GoTo GraphReportPrintError nHdrLines = UBound(astrHeader) nTblCols = UBound(astrTableField, 1) nTblRows = UBound(astrTableField, 2) fTextHeight = Printer.TextHeight(TEST_CHAR) bGraphMode = True nGraphLines = sGraph.nHeight nPages = PagesCount() If UBound(asColStyle) <> nTblCols Then ReportPrintGraph = False Exit Function End If Call ColStyleFormat(asColStyle(), astrTableField()) nPages = PagesCount() Call ReportHeaderPrint(astrHeader()) nLinesPerPage = Int(GraphScaleSet(sGraph, sOrigPageScale, astrHeader())) Call GraphBaselineDraw(asPKDFullPeak(), asChroPt(), sVGRawFile, fAlignTime) Call GraphDraw(sGraph, asGPoint(), asAnno()) Printer.ScaleLeft = sOrigPageScale.fLeft Printer.ScaleTop = sOrigPageScale.fTop Printer.ScaleWidth = sOrigPageScale.fWidth Printer.ScaleHeight = sOrigPageScale.fHeight nTableBlockStart = 0 Call ReportHeaderPrint(astrHeader()) TableHeaderPrint nTableBlockStart = TableBlockPrint(nTableBlockStart, astrTableField()) + 1 ' FooterPrint Printer.NewPage For nPage = 2 To nPages Call ReportHeaderPrint(astrHeader()) TableHeaderPrint nTableBlockStart = TableBlockPrint(nTableBlockStart, astrTableField()) + 1 ' FooterPrint Printer.NewPage Next nPage Printer.EndDoc ReportPrintGraphError: If Err Then ReportPrintGraph = False Else ReportPrintGraph = True End If Exit Function End Function Sub SetPaperOrientation(nOrientation As Integer) Const GETSETPAPERORIENT = 30 Dim Orient As OrientStructure Dim x As Integer 'Start the printer Printer.Print "" 'Specify the orientation Orient.Orientation = nOrientation 'Send escape sequence to change orientation x = Escape(Printer.hdc, GETSETPAPERORIENT, Len(Orient), Orient, Null) 'The EndDoc will now re-initialize the printer Printer.EndDoc End Sub '________________________________________________________________________________________ ' ' Process: SummaryBlockPrint ' ' Author: Jon Cottrell ' Date: 15th May 1996 ' ' Purpose: Prints a block from the main table. ' ' Parameters: nTableBlockStart is the index to start printing from. ' astrTableField(column, row) is a 2-D array of the fields that should be printed. ' ' Return: Last row index printed. '________________________________________________________________________________________ Private Function SummaryBlockPrint(nLineCount As Integer, astrTableField() As String) As Integer Dim nCol As Integer Dim nRow As Integer Dim fXPos As Single Dim fYPos As Single Dim fOffSet As Single fYPos = fTextHeight * nLineCount For nRow = 0 To nTblRows fXPos = 0 For nCol = 0 To nTblCols fOffSet = FieldOffSet(asReportStyle(nCol), astrTableField(nCol, nRow)) Printer.CurrentY = fYPos Printer.CurrentX = fXPos + fOffSet Printer.Print astrTableField(nCol, nRow) fXPos = fXPos + asReportStyle(nCol).fWidth Next nCol nLineCount = nLineCount + 1 If nRowsPerPage - nLineCount < 2 Then Printer.NewPage nLineCount = 0 End If fYPos = nLineCount * fTextHeight Next nRow SummaryBlockPrint = True End Function '________________________________________________________________________________________ ' ' Process: SummaryReportHeaderPrint ' ' Author: Jon Cottrell ' Date: 15th May 1996 ' ' Purpose: Prints a header on to a page. ' ' Parameters: astrHeader() is an array of lines for the report header. ' ' Return: Void. '________________________________________________________________________________________ Sub SummaryReportHeaderPrint(nLineCount As Integer, astrHeader() As String) Dim nHdrLine As Integer Dim fXPos As Single Dim fYPos As Single fTextHeight = Printer.TextHeight(TEST_CHAR) fXPos = fTextHeight fYPos = fTextHeight * nLineCount nHdrLines = UBound(astrHeader) For nHdrLine = 0 To nHdrLines Printer.CurrentX = fXPos Printer.CurrentY = fYPos Printer.Print astrHeader(nHdrLine) fYPos = fYPos + fTextHeight nLineCount = nLineCount + 1 Next nHdrLine End Sub '________________________________________________________________________________________ ' ' Process: SummaryReportPrint ' ' Author: Jon Cottrell ' Date: 14th May 1996 ' ' Purpose: Main call to print out a summary report. ' ' Parameters: astrHeader() is an array of lines for the report header. ' asColStyle() is an array that describes how each column should be laid out. ' astrTableField(column, row) is a 2-D array of the fields that should be printed. ' ' Return: True if successful. '________________________________________________________________________________________ Function SummaryReportPrint(bSetCols As Integer, nLineCount As Integer, astrHeader() As String, asColStyle() As ColStyle, astrTableField() As String) As Integer Dim bSuccess As Integer On Error GoTo SummaryReportPrintError nHdrLines = UBound(astrHeader) nTblCols = UBound(astrTableField, 1) nTblRows = UBound(astrTableField, 2) fTextHeight = Printer.TextHeight(TEST_CHAR) nRowsPerPage = Int(Printer.ScaleHeight / fTextHeight) bGraphMode = False nGraphLines = 0 If UBound(asColStyle) <> nTblCols Then SummaryReportPrint = False Exit Function End If If bSetCols Then Call ColStyleFormat(asColStyle(), astrTableField()) If nRowsPerPage - nLineCount < 6 Then Printer.NewPage nLineCount = 0 End If Call SummaryReportHeaderPrint(nLineCount, astrHeader()) Call SummaryTableHeaderPrint(nLineCount) bSuccess = SummaryBlockPrint(nLineCount, astrTableField()) nLineCount = nLineCount + 2 SummaryReportPrintError: If Err Then SummaryReportPrint = False Else SummaryReportPrint = True End If Exit Function End Function '________________________________________________________________________________________ ' ' Process: SummaryTableHeaderPrint ' ' Author: Jon Cottrell ' Date: 15th May 1996 ' ' Purpose: Prints a table header on to a page. ' ' Parameters: Line number to start printing. ' ' Return: Void. '________________________________________________________________________________________ Private Sub SummaryTableHeaderPrint(nLineCount As Integer) Dim nCol As Integer Dim fXPos As Single Dim fYPos As Single Dim fOffSet As Single Printer.FontUnderline = True fXPos = 0 fYPos = fTextHeight * nLineCount For nCol = 0 To nTblCols fOffSet = FieldOffSet(asReportStyle(nCol), asReportStyle(nCol).strName) Printer.CurrentY = fYPos Printer.CurrentX = fXPos + fOffSet Printer.Print asReportStyle(nCol).strName fXPos = fXPos + asReportStyle(nCol).fWidth Next nCol Printer.FontUnderline = False nLineCount = nLineCount + 1 End Sub '________________________________________________________________________________________ ' ' Process: TableBlockPrint ' ' Author: Roberto Raso ' Date: 13th July 1995 ' ' Purpose: Prints a block from the main table. ' ' Parameters: nTableBlockStart is the index to start printing from. ' astrTableField(column, row) is a 2-D array of the fields that should be printed. ' ' Return: Last row index printed. '________________________________________________________________________________________ Private Function TableBlockPrint(nTableBlockStart As Integer, astrTableField() As String) As Integer Dim nCol As Integer Dim nRow As Integer Dim nTableBlockEnd As Integer Dim fXPos As Single Dim fYPos As Single Dim fOffSet As Single If bGraphMode <> False And Printer.Page = 1 Then fYPos = fTextHeight * (nHdrLines + 2 + SECT_SEP + nGraphLines + 2 * SECT_SEP) If nTableBlockStart + nRowsPerPageGraph > nTblRows Then nTableBlockEnd = nTblRows Else nTableBlockEnd = nTableBlockStart + nRowsPerPageGraph - 1 End If Else fYPos = fTextHeight * (nHdrLines + 2 + SECT_SEP) If nTableBlockStart + nRowsPerPage > nTblRows Then nTableBlockEnd = nTblRows Else nTableBlockEnd = nTableBlockStart + nRowsPerPage - 1 End If End If For nRow = nTableBlockStart To nTableBlockEnd fXPos = 0 For nCol = 0 To nTblCols fOffSet = FieldOffSet(asReportStyle(nCol), astrTableField(nCol, nRow)) Printer.CurrentY = fYPos Printer.CurrentX = fXPos + fOffSet Printer.Print astrTableField(nCol, nRow) fXPos = fXPos + asReportStyle(nCol).fWidth Next nCol fYPos = fYPos + fTextHeight Next nRow TableBlockPrint = nTableBlockEnd End Function '________________________________________________________________________________________ ' ' Process: TableColMaxWidth ' ' Author: Roberto Raso ' Date: 13th July 1995 ' ' Purpose: Gets the maximum width of text for a particular column in ' the table. ' ' Parameters: nCol is the column to check in the table. ' ' Return: The maximum width of the text. '________________________________________________________________________________________ Private Function TableColMaxWidth(nCol As Integer, astrTableField() As String) As Single Dim nTblRow As Integer Dim fTextWidth As Single Dim fWidthMax As Single fWidthMax = 0 For nTblRow = 0 To nTblRows fTextWidth = Printer.TextWidth(astrTableField(nCol, nTblRow)) If fTextWidth > fWidthMax Then fWidthMax = fTextWidth End If Next nTblRow TableColMaxWidth = fWidthMax End Function '________________________________________________________________________________________ ' ' Process: TableHeaderPrint ' ' Author: Roberto Raso ' Date: 13th July 1995 ' ' Purpose: Prints a table header on to a page. ' ' Parameters: None. ' ' Return: Void. '________________________________________________________________________________________ Sub TableHeaderPrint() Dim nCol As Integer Dim fXPos As Single Dim fYPos As Single Dim fOffSet As Single Printer.FontUnderline = True fXPos = 0 If bGraphMode <> False And Printer.Page = 1 Then fYPos = fTextHeight * (nHdrLines + 1 + SECT_SEP + nGraphLines + 2 * SECT_SEP) Else fYPos = fTextHeight * (nHdrLines + 1 + SECT_SEP) End If For nCol = 0 To nTblCols fOffSet = FieldOffSet(asReportStyle(nCol), asReportStyle(nCol).strName) Printer.CurrentY = fYPos Printer.CurrentX = fXPos + fOffSet Printer.Print asReportStyle(nCol).strName fXPos = fXPos + asReportStyle(nCol).fWidth Next nCol Printer.FontUnderline = False End Sub