Rapid-Q Documentation by William Yu (c)1999 | Appendix A: PRINTER

# PRINTER Component

  This object is global, and need not be created. Please note that some printers do not support Draw or CopyRect. The printer component is mainly used for graphics, although it may also be suitable for text, please refer to LPRINT for text-only printing.
  Printer Properties

  Field | Type | R/W | Default

  Aborted | INTEGER | R |
  | Aborted determintes if the user aborted the print job.
  Capabilities.Copies | INTEGER | R |
  | Capabilities.Copies indicates whether the print is capable of printing multiple copies.
  Capabilities.Orientation | INTEGER | R |
  | Capabilities.Orientation indicates whether the print is capable of different orientations.
  Capabilities.Collate | INTEGER | R |
  | Capabilities.Collate indicates whether the print is capable of collating.
  Copies | INTEGER | RW |
  | Number of copies to print.
  CopyMode | INTEGER | RW | cmBlackNess
  Font | QFONT | W |
  Fonts | ARRAY of STRING | R |
  FontsCount | INTEGER | R |
  Handle | INTEGER | R |
  Orientation | INTEGER | RW |
  | Orientation determines if the print job prints vertically or horizontally on a page. Valid orientation values are: 0 = poPortrait (Vertical print) 1 = poLandscape (Horizontal print)
  PageHeight | INTEGER | R |
  PageNumber | INTEGER | R |
  PageWidth | INTEGER | R |
  PrinterIndex | INTEGER | RW |
  Printers | ARRAY of STRING | R |
  PrintersCount | INTEGER | R |
  Printing | INTEGER | R |
  Title | STRING | RW |
  | Title is the text that appears in the Print Manager and on network header pages.

  Printer Methods

  Method | Type | Description | Params

  Abort | SUB | Abort printing the document | 0
  BeginDoc | SUB | Starts new document to print | 0
  | BeginDoc sends a print job to the printer.
  EndDoc | SUB | Nothing is printed until this is called | 0
  | EndDoc will start the print job.
  NewPage | SUB | Start printing on a new page | 0
  Circle | SUB (x1%, y1%, x2%, y2%, c%, fill%) | Draw & Fill Circle | 6
  CopyRect | SUB (D, Image, S) | D and S are QRECTs, Image can be a QImage, QCanvas, or QBitmap | 3
  Draw | SUB (x%, y%, BMP) | Draw Bitmap on Canvas | 3
  FillRect | SUB (x1%, y1%, x2%, y2%, c%) | Draws & Fills a rectangle | 5
  Line | SUB (x1%, y1%, x2%, y2%, c%) | Draws a line | 5
  Paint | SUB (x%, y%, c%, borderc%) | Fill Region | 4
  Pset | SUB (x%, y%, c%) | Pixel plot | 3
  Rectangle | SUB (x1%, y1%, x2%, y2%, c%) | Draws a rectangle | 5
  RoundRect | SUB (x1%, y1%, x2%, y2%, x3%, y3%, c%) | Draws & Fills a rounded rectangle | 7
  StretchDraw | SUB (Rect AS QRECT, BMP) | Draw BMP and stretch to fit inside Rect | 2
  TextHeight | FUNCTION (Text$) AS WORD | Returns the height, in pixels, of Text$ string | 1
  TextWidth | FUNCTION (Text$) AS WORD | Returns the width, in pixels, of Text$ string | 1
  TextRect | SUB (Rect AS QRECT, x%, y%, S$, fc%, bc%) | Write text, and clip within region Rect | 6
  TextOut | SUB (x%, y%, S$, fc%, bc%) | Writes text to printer | 5

  Printer Examples

      DECLARE SUB ButtonClick

      SUB ComboBoxChange(Sender AS QComboBox)
        Printer.PrinterIndex = Sender.ItemIndex   '-- Change default printer
      END SUB

      DIM Font AS QFont
          Font.Color = &HFF0000
          Font.Name = "Arial"
          Font.Size = 20
      DIM Bitmap AS QBitmap
      Bitmap.BMP = "rapidq.bmp"

      CREATE Form AS QForm
        CREATE ComboBox AS QComboBox
          Left = 5
          Top = 5
          Width = 150
          OnChange = ComboBoxChange
        END CREATE
        CREATE Button AS QButton
          Caption = "&Print"
          Top = 3
          Left = 180
          OnClick = ButtonClick
        END CREATE
        CREATE GroupBox AS QGroupBox
          Caption = "Print Preview..."
          Top = 35
          Width = Form.ClientWidth
        END CREATE
        Center
      END CREATE

      FOR I = 0 TO Printer.PrintersCount-1
        ComboBox.AddItems(Printer.Printers(I))    '-- Add printer list to combobox
      NEXT
      ComboBox.ItemIndex = Printer.PrinterIndex

      Form.ShowModal

      SUB ButtonClick
        Printer.Orientation = 1   ' Landscape
        Printer.BeginDoc
        Printer.TextOut(1000,1000,"Hi World!",0,-1)
        Printer.Font = Font
        Printer.TextOut(10,10,"Does this print?",0,-1)
        Printer.Line(10,10,500,500,0)
        Printer.EndDoc
      END SUB

  Prev Component | Contents | Next Component