diff --git a/components/gridprinter/docs/xml/gridprn.xml b/components/gridprinter/docs/xml/gridprn.xml index 4ee96a7eb..61dad795c 100644 --- a/components/gridprinter/docs/xml/gridprn.xml +++ b/components/gridprinter/docs/xml/gridprn.xml @@ -1,26 +1,194 @@ -Defines the page margins +Class defining the page margins Value for the left margin, in millimeters Value for the top margin, in millimeters - Value for the right margin, in millimeters + Determines whether one of the Lazarus print dialogs should be shown before printing begins. Value for the bottom margin Distance between header (top edge) to the top of the pageIt is not checked that the header overlaps with the body of the printed grid. Distance between the footer (bottom edge) and the bottom of the pageIt is not checked that the footer overlaps with the body of the printed grid. - Constructor of the TGridPrnMargins</prn> classStores the associated TGridPrinter instance for notification when the margins are changed. - + Constructor of the TGridPrnMargins class. Stores the associated GridPrinter in an internal variable (FOwner) so that it can be notified by the Changed() method when a header/footer property has changed. Notifies the associated TGridPrinter instance that margins have been changed. Defines how a large grid is wrapped over into multiple pages
  • poRowsFirst - completes first the rows, and then continues with the next block of rows
  • poColsFirst - completes first the coluumns, and then continues with the next block of columns.
-
Defines how the PrintScalingFactor is used
  • smManual - the current value of the PrintScalingFactor is applied directly.
  • smFitToWidth - the PrintScalingFactor is adjusted such that the number of pages specified by PrintScaleToNumHorPages fit on a single printed page.
  • smFitToHeight - the PrintScalingFactor is adjusted such that the number of pages specified by PrintScaleToNumVertPages fit on a single printed page.
  • + Defines how the PrintScalingFactor is used
    • smManual - the current value of the PrintScalingFactor is applied directly.
    • smFitToWidth - the PrintScalingFactor is adjusted such that the number of pages specified by PrintScaleToNumHorPages fits on a single printed page.
    • smFitToHeight - the PrintScalingFactor is adjusted such that the number of pages specified by PrintScaleToNumVertPages fits on a single printed page.
    Identifies the device which is used when the GridPrinter is printing
    • odPrinter - printer
    • odPreview - bitmap for the print preview
    + Determines whether an LCL printer dialog should be displayed before the GridPrinter begins printing
    • gpdNone - no dialog
    • gpdPageSetup - displays an LCL TPageSetupDialog
    • gpdPrintDialog - displays an LCL TPrintDialog
    • gpdPrinterSetup - displays an LCL TPrinterSetup dialog
    • +
    +
    +
    + Event fired when the GridPrinter is printing the specified cell. When a handler is provided it overrides the entire drawing process. + Event querying the text to be printed in the specified cell. + Event querying the total count of columns to be printed.Note: Fixed columns must be included in the returned value. + + Event querying the total count of rows to be printed.Note: Fixed rows must be included in the returned value. + + Event fired whenever the GridPrinter begins printing a new line. + Event fired whenever the GridPrinter has finished printing a line of cells. + Event fired whenver the GridPrinter begins a new page. + Identifies the section of the print header or footer.
    • hfsLeft - left-aligned section
    • hfsCenter - centered section
    • hfsRight - right-aligned section
    • +
    +
    +
    Enumeration of options to control the GridPrinter +
    • gpoCenterHor - centers the grid horizontally on the page
    • gpoCenterVert - centers the grid vertically on the page
    • gpoHorGridLines - prints horizontal lines between the grid rows
    • gpoVertGridLines - prints vertical lines between the grid columns
    • gpoFixedHorGridLines - prints horiztonal lines between the fixed grid rows
    • gpoFixedVertGridLines - prints vertical lines between the fixed grid columns
    • gpoHeaderBorderLines - prints dividing lines between grid row/column headers and the normal cells
    • gpoOuterBorderLines - prints lines around the outer border of the grid
    • +
    +
    +
    Set of options to control the GridPrinter +
    • gpoCenterHor - centers the grid horizontally on the page
    • gpoCenterVert - centers the grid vertically on the page
    • gpoHorGridLines - prints horizontal lines between the grid rows
    • gpoVertGridLines - prints vertical lines between the grid columns
    • gpoFixedHorGridLines - prints horiztonal lines between the fixed grid rows
    • gpoFixedVertGridLines - prints vertical lines between the fixed grid columns
    • gpoHeaderBorderLines - prints dividing lines between grid row/column headers and the normal cells
    • gpoOuterBorderLines - prints lines around the outer border of the grid
    • +
    +
    +
    Class representing the header/footer lines on the printed page + Notifies the GridPrinter that header/footer properties have changed. + Auxiliary method of the streaming mechanism. Is used to implement high-dpi support of the header/footer font size in the lfm file. + Auxiliary method of the streaming mechanism. Is used to store the header/footer font size in the lfm file so that high-dpi is supported. + Auxiliary method of the streaming mechanism. Is used to read the header/footer font size from the lfm file so that high-dpi is supported. + Constructor of the TGridPrnHeaderFooter class. Stores the associated GridPrinter in an internal variable (FOwner) so that it can be notified by the Changed() method when a header/footer property has changed. Creates an internal TFont instance to define the header/footer font. + Destructor of the TGridPrnHeaderFooter class. Destroys the internal TFont instance. + Internal TFont instance which defines the font of the header/footer. + Function returning true if the header/footer is shown on the page. For this it is required that the Visible property is true and that the Text is not an empty string. + Function returning true if there is no text to be displayed in any section of the header/footer. + Returns the color of the line underneath the header/above the footer. Normally this is given by the LineColor property. But when it has the value clDefault or the GridPrinter's Monochrome property is true the function returns the color clBlack. + Returns the line width, in printing device pixels, of the dividing line below the header/above the footer. When the GridPrinter's LineWidth property has a positive value it is scaled up to the current device resolution. Otherwise it returns the scaled width of 1 screen pixel wide line. + Returns the header/footer text in the section specified by AIndex after replacement of the symbols. + Extracts from the Text property the header/footer text in the section specified by AIndex.The text can contain the following symbols which are replaced during printing/preview generation by appropriate values: +
    • $DATE - Current date.
    • $PAGECOUNT - Total number of pages to be printed.
    • $PAGE - Number of the currently printed page. First page number is 1.
    • $FULL_FILENAME - Is replaced by the full path of the FileName property of the GridPrinter.
    • $FILENAME - Is replaced by the FileName property of the GridPrinter after removal of the file path.
    • $PATH - Is replaced by the path to the FileName property of the GridPrinter.
    • $TIME - Current time.
    • +
    +
    +
    Defines the text displayed in the header or footer.

    Each text is composed of three sections: a left-aligned part, a centered part, and a right-aligned part. These sections are separated by a string defined by the SectionSeparator property; normally this is the character '|'.

    + +The text can contain the following symbols which are replaced during printing/preview generation by appropriate values: +
    • $DATE - Current date.
    • $PAGECOUNT - Total number of pages to be printed.
    • $PAGE - Number of the currently printed page. First page number is 1.
    • $FULL_FILENAME - Is replaced by the full path of the FileName property of the GridPrinter.
    • $FILENAME - Is replaced by the FileName property of the GridPrinter after removal of the file path.
    • $PATH - Is replaced by the path to the FileName property of the GridPrinter.
    • $TIME - Current time.
    • +
    +
    +
    Allows to turn each header/footer ON and OFF. By default, both of them are visible (true). + Font size value stored in the lfm file. This is requires do make high-dpi scaling work correctly. + Color of the dividing line below the header/above the footer. Its default value (clDefault) will be interpreted as clBlack. + Width of the dividing line below the header / above the footer, in millimeters. A value <= 0 will be interpreted as 1 screen pixel scaled up to the current device resolution. + This property allows to switch the dividing line below the header / above the footer ON and OFF. By default, the dividing line is shown. + Defines the character(s) separating the left-aligned/centered/right-aligned sections of the header/footer Text. By default this is the character '|'. + TGridPrinter is a component to simplify printing of string grids or other descendants of TCustomGrid. Besides sending the grid to a printer it also creates a bitmap for a preview of the printout. In case of large grids, the output is wrapped into multiple pages. + Points to the grid to be printed. The component cannot work without a valid grid. + Ideally, this should be a TStringGrid, but other descendants of TCustomGrid can be printed as well when the appropriate event handlers are provided. + + When the GridPrinter runs in preview mode the application can be notified, for example, when some parameter has been changed so that the preview can repaint itself. + When this event has a handler it completely replaces the built-in code for printing a cell. Can be used for printing very specific grids + When the canvas for printing a cell has been prepared the user has the opportunity here to override the selection of colors, fonts, alignments etc. The event is similar to the equally-named event of the grid. The handler can be shared between grid and GridPrinter, it only must be guaranteed that the correct canvas is used in the code. + Fires when the GridPrinter begins a new page. + Fires when the GridPrinter starts printing a new line of cells. + Fires when the GridPrinter has finished printing a specific line. + In this event the application can tell the GridPrinter the number of rows to be printed. This is useful for printing a DBGrid which holds only a small portion of all rows of a dataset. + In this event the application can tell the GridPrinter the number of columns to be printed. + Whenever the GridPrinter needs to know the text in a specific cell it sends this event. The text to be printed can be passed in a parameter. Is mainly intended for non-standard grids which have a different cell technology from TStringGrid. + Fires before printing begins. The printer has not yet received its BeginDoc command. + Fires when printing is finished. + Defines the last page to be printed. Any value larger than the real page count prints to the last page. + + Determines whether one of the Lazarus print dialogs should be shown before printing begins.
    • gpdNone - no dialog
    • gpdPageSetup - displays an LCL TPageSetupDialog
    • gpdPrintDialog - displays an LCL TPrintDialog
    • gpdPrinterSetup - displays an LCL TPrinterSetup dialog
    • +
    +
    +
    Scaling factor for the printout. Default: 1.0.Call the method ScaleToPages() if you want to adjust the PrintScaleFactor such that the entire printout fits on a given number of pages. + + Large grids are wrapped into several pages. This property defines whether rows (poRowsFirst) or columns (poColsFirst) will be completed first. + Defines the page orientation: poPortrait, poLandscape, poReverseLandscape, poReversePortrait (declared in the Printers unit). + Options for fine-tuning the printout
    • gpoCenterHor - centers the grid horizontally on the page
    • gpoCenterVert - centers the grid vertically on the page
    • gpoHorGridLines - prints horizontal lines between the grid rows
    • gpoVertGridLines - prints vertical lines between the grid columns
    • gpoFixedHorGridLines - prints horiztonal lines between the fixed grid rows
    • gpoFixedVertGridLines - prints vertical lines between the fixed grid columns
    • gpoHeaderBorderLines - prints dividing lines between grid row/column headers and the normal cells
    • gpoOuterBorderLines - prints lines around the outer border of the grid
    • +
    +
    +
    Prints the grid only with black color. + Defines page and header/footer margins, in millimeters. + + Parameters for printing a header at the top of each page + + Parameters for printing a footer at the bottom of each page + + Linewidth of the inner grid lines, in millimeters. If not positive, the scaled value of the grid's GridLineWidth is used. + Color of the inner grid lines. + Defines the first page to be printed. Any value less than 1 is interpreted as "first page". + Linewidth of the dividing line between fixed and normal cells in the printout/preview, in millimeters. If not positive, the scaled value of the grid's GridLineWidth is used. + Line color of the dividing line between fixed and normal cells in the printout/preview. + Has no functional use inside the GridPrinter. But indicates the name of the file which is printed, if applicable.The filename can be displayed in the header or footer of the printout/preview where it is used to replace the symbols $FULL_FILENAME, $FILENAME, $PATH in the header/footer Text. + + Linewidth of the outer border of the printed grid, in millimeters. If not positive, the scaled value of the grid's GridLineWidth is used. + Line color of the outer border of the printed grid. + Height of the specified row, given in pixels of the current output device. Read-only. + Number of rows to be printed, including fixed rows (read-only). + Determines how the print output is scaled.
    • smManual - the current value of the PrintScalingFactor is applied directly.
    • smFitToWidth - the PrintScalingFactor is adjusted such that the number of pages specified by PrintScaleToNumHorPages fits on a single printed page.
    • smFitToHeight - the PrintScalingFactor is adjusted such that the number of pages specified by PrintScaleToNumVertPages fits on a single printed page.
    • +
    +
    +
    The PrintScalingFactor is adjusted such that this number of pages fits onto a single sheet of paper vertically. + The PrintScalingFactor is adjusted such that this number of pages fits onto a single sheet of paper horizontally. + Number of the page which is currently printed. Pages numbers begin with 1. (Read-only) + Total number of pages to be printed. (Read-only). + Distance, in pixels of the current output device, between cell text and cell border (read-only) + Pixel density of the current output device, in vertical direction (read-only) + Pixel density of the current output device, in horizontal direction (read-only) + Rectangle on the page, in pixels of the current output device, available for printing the grid. In other words: size of the page with margins subtracted. (Read-only) + Width of the page, in pixels of the current output device (read-only) + Height of the page, in pixels of the current output device (read-only). + Distance of the header top from the page top, in pixels of the current output device (read-only) + Distance of the footer bottom from the page bottom, in pixels of the current output device (read-only). + Width of the specified column, given in pixels of the current output device (printer or preview bitmap). Read-only. + Number of columns to be printed (including fixed columns). Read-only. + Canvas currently used by the GridPrinter. This is either the printer canvas or the canvas of the preview bitmap sent to the TGridPrintPreview component. + Fires the event OnUpdatePreview if the GridPrinter is in preview mode + General scaling function for conversion of vertical screen pixels to pixels on the printer or the preview bitmap. + General scaling function for conversion of horizontal screen pixels to pixels on the printer or the preview bitmap. + Scales the printout such that it fits on NumHor pages horizontally and NumVert pages vertically. When NumHorPages is 0 (or less) only the height is scaled according to NumVert. Similarly when NumVert is 0 (or less). + + Prints the grid (to the printer). Main method of the component. + Returns the text to be printed for the grid cell at the given row and column indices. + Creates the preview bitmap for the printout of the specified page. The bitmap is scaled by the given percentage relative to the original pager size (100).The bitmap is displayed by the TGridPrintPreviewDialog. + + Destructor of the TGridPrinter class. + Constructor of the TGridPrinter class + Indicates whether the currently active printing process goes to the printer (via Print method) or to the preview bitmap (via CreatePreviewBitmap method)
    • odPrinter - printer
    • odPreview - bitmap for the print preview
    • +
    +
    + +
    Selects the specified font for the given canvas and scales its size by the AScaleFactor which is determined from the output device resolution and the PrintScaleFactor. + Scales the grid's row heights which are in screen pixels to the required output resolution. The result are stored in the internal array FRowHeights accessible via the public property RowHeights. + Scales the grid's column widths which are in screen pixels to the required output resolution. The result are stored in the internal array FColWidhts accessible via the public property ColWidths. + Prints the row headers of the specified row. Row headers are the cells in the FixedCols of that row. The row is positioned at the given Y coordinate on the currently active canvas. X is the position of the left edge of the grid. Both X and Y are in output device pixels. + Calculates the output device coordinates of the left end of the first and the right end of the last fixed columns for the printed page containing cell columns between AStartCol and AEndCol + + Prints the cells between StartCol and EndCol and between StartRow and EndRow. The fixed cells belonging to these columns and rows are printed as well even if they are not immediately adjacent to the cell range. + Print the inner grid lines, the dividing lines between fixed and normal cells, and the outer border lines. + Prints the header text and its associated dividing line at the top of the page. + + + Prints the footer text and its associated dividing line at the bottom of the page. + Prints the headers of the columns between ACol1 and ACol2. Column headers are the cells in the FixedRows of these columns. The headers begin at the output device coordinate Y. + Prints a checkbox in the cell at column ACol and row ARow. The cell spans the rectangle ARect given in output device coordinates. ACheckState indicates whether the checkbox should be drawn as checked, unchecked or grayed. + Prints the cell at column ACol and row ARow. The cell is spanned by the rectangle ARect given in output device pixels.Before printing, the methode PrepareCanvas() is called in which the output canvas gets the required colors, font, text alignment etc. + + Prints the entire grid with row priority. This means that if the printout needs to be split into several pages the rows are completed first before the process advances to the next block of rows. + Prints the entire grid with column priority. This means that if the printout needs to be split into several pages the columns are completed first before the process advances to the next block of columns. + Prepares the canvas for printing the cell in column AColand row ARow. It is attempted to re-use the canvas parameters of the grid. The event OnPrepareCanvas is fired to give the application the opportunity to override these settings. + Preparation of the printing process. Determines the available resolution and the page size (method Measure()), and calculates the column/row indices at which page breaks will be needed (method LayoutPageBreaks()) + Inherited method which must be overridden to reset the Grid property to nil if the associated grid has been deleted from the form. + Sends a NewPage to the printer. Is ignored when the output goes to the preview bitmap. + Calculates the page margins, column widths and row heights in output device units which are needed for determining the pagebreaks. + Inherited method called when the form has been loaded from the lfm file. Is overridden to get the header/footer fontsize for LCL scaling. + Iterates over all cells of the grid and calculates the column and row indices at which page breaks must be introduced. Depending on the PrintOrder either rows or columns are first completed before the print continues with the next block of rows/columns. + Adjusts the specified pen color (used for drawing lines) to take care of the Monochrome setting of the GridPrinter and whether the operating system is in a dark mode. + Adjusts the specified font color (used for text ) to take care of the Monochrome setting of the GridPrinter and whether the operating system is in a dark mode. + Adjusts the specified brush color (used for filling areas) to take care of the Monochrome setting of the GridPrinter and whether the operating system is in a dark mode. + Main printing routine on the specified canvas. Fires the OnBeforePrint event, prints the grid by rows or columns, and fires the OnAfterPrint event. + Fires the event OnUpdatePreview after relevant changes if the output goes to the preview bitmap. + Fires the event OnPrepareCanvas immediately before printing a cell. The output canvas already has been prepared, and the application has the opportunity to modify these prepared canvas settings. + Fires the event OnPrintCell in which the user can provide its own printing code. If the argument Done is returned by the event handler as true nothing else is printed in this particular cell so that the user routine bypasses the default behaviour. Otherwise the process continues with the built-in printing routine. + Fires the event OnNewPage when a new page begins. The new page will contain the cells between AStartCol and AEndCol and between AStartRow and AEndRow, as well as the associated fixed cells (even if they are not adjacent to the cell block). + Fires the event OnNewLine if a new line is started. The row index of the new line is given by ARow. When printing a DBGrid, for example, this can be used to advance the dataset. + Fires the event OnLinePrinted when print of the given line is finished. The line is indicated by the row index ARow. + Calculates the output device coordinates of the upper end of the first and the lower end of the last fixed row for the printed page containing cell rows between AStartRow and AEndRow + + diff --git a/components/gridprinter/source/gridprn.pas b/components/gridprinter/source/gridprn.pas index d30277a38..7474dc4da 100644 --- a/components/gridprinter/source/gridprn.pas +++ b/components/gridprinter/source/gridprn.pas @@ -551,7 +551,7 @@ end; function TGridPrnHeaderFooter.RealLineWidth: Integer; begin - if FLineWidth = 0 then + if FLineWidth <= 0 then Result := FOwner.ScaleY(1) else Result := mm2px(FLineWidth/FOwner.PrintScaleFactor, FOwner.PixelsPerInchY);