home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / cprog / blx21.zip / OWLPRT.ARJ / PRTPAS.ARJ / PRINTER.TXT < prev    next >
Text File  |  1992-02-24  |  4KB  |  117 lines

  1. unit Printer;
  2. {$R PRINTER.RES}
  3. {$S-}
  4.  
  5. interface
  6.  
  7. uses WinTypes, WinProcs, WObjects;
  8.  
  9. { TPrinter states }
  10. const
  11.   ps_Ok = 0;
  12.   ps_InvalidDevice = -1;     { Device parameters (to set device)
  13. invalid }
  14.   ps_Unassociated = -2;      { Object not associated with a printer }
  15.  
  16. { TPrintout banding flags }
  17. const
  18.   pf_Graphics  = $01;        { Current band only accepts text }
  19.   pf_Text      = $02;        { Current band only accepts graphics }
  20.   pf_Both      = $03;        { Current band accepts both text and
  21. graphics }
  22.  
  23. { TPrintout represents the physical printed document which is to
  24.   sent to a printer to be printed. TPrintout does the rendering of
  25.   the document onto the printer.  For every document, or document
  26.   type, a cooresponding TPrintout class should be created. }
  27.  
  28. type
  29.   PPrintout = ^TPrintout;
  30.   TPrintout = object(TObject)
  31.     Title: PChar;
  32.     Banding: Boolean;
  33.     ForceAllBands: Boolean;
  34.     constructor Init(ATitle: PChar);
  35.     destructor Done; virtual;
  36.     procedure PrintPage(DC: HDC; Page: Word; Size: TPoint; var Rect:
  37. TRect;
  38.       Flags: Word); virtual;
  39.     function IsNextPage: Boolean; virtual;
  40.    end;
  41.  
  42. { TPrinter represent the physical printer device.  To print a
  43.   TPrintout, send the TPrintout to the TPrinter's Print method. }
  44.  
  45.   PPrinter = ^TPrinter;
  46.   TPrinter = object(TObject)
  47.     Device, Driver, Port: PChar;        { Printer device description }
  48.     Status: Integer;                    { Device status, error is <> ps_Ok }
  49.     Error: Integer;                     { < 0 if error occured during print }
  50.     DeviceModule: THandle;              { Handle to printer driver module }
  51.     DeviceMode: TDeviceMode;            { Function pointer to DevMode }
  52.     ExtDeviceMode: TExtDeviceMode;      { Function pointer to ExtDevMode }
  53.     DevSettings: PDevMode;              { Local copy of printer settings }
  54.     DevSettingSize: Integer;            { Size of the printer settings }
  55.     constructor Init;
  56.     destructor Done; virtual;
  57.     procedure ClearDevice;
  58.     procedure Configure(Window: PWindowsObject);
  59.     function GetDC: HDC; virtual;
  60.     function InitAbortDialog(Parent: PWindowsObject;
  61.       Title: PChar): PDialog; virtual;
  62.     function InitSetupDialog(Parent: PWindowsObject): PDialog;
  63. virtual;
  64.     procedure ReportError(Printout: PPrintout); virtual;
  65.     procedure SetDevice(ADevice, ADriver, APort: PChar);
  66.     procedure Setup(Parent: PWindowsObject);
  67.     function Print(ParentWin: PWindowsObject; Printout: PPrintout):
  68. Boolean;
  69.   end;
  70.  
  71. { TPrinterSetupDlg is a dialog to modify which printer a TPrinter
  72.   object is attached to.  It displays the all the active printers
  73.   in the system allowing the user to select the desired printer.
  74.   The dialog also allow the user to call up the printer's
  75.   "setup" dialog for further configuration of the printer. }
  76.  
  77. const
  78.   id_Combo = 100;
  79.   id_Setup = 101;
  80.  
  81. type
  82.   PPrinterSetupDlg = ^TPrinterSetupDlg;
  83.   TPrinterSetupDlg = object(TDialog)
  84.     Printer: PPrinter;
  85.     constructor Init(AParent: PWindowsObject; TemplateName: PChar;
  86.       APrinter: PPrinter);
  87.     destructor Done; virtual;
  88.     procedure TransferData(TransferFlag: Word); virtual;
  89.     procedure IDSetup(var Msg: TMessage);
  90.       virtual id_First + id_Setup;
  91.     procedure Cancel(var Msg: TMessage);
  92.       virtual id_First + id_Cancel;
  93.   private
  94.     OldDevice, OldDriver, OldPort: PChar;
  95.     DeviceCollection: PCollection;
  96.   end;
  97.  
  98. const
  99.   id_Title  = 101;
  100.   id_Device = 102;
  101.   id_Port   = 103;
  102.  
  103. type
  104.   PPrinterAbortDlg = ^TPrinterAbortDlg;
  105.   TPrinterAbortDlg = object(TDialog)
  106.     constructor Init(AParent: PWindowsObject; Template, Title,
  107.       Device, Port: PChar);
  108.     procedure SetupWindow; virtual;
  109.     procedure WMCommand(var Msg: TMessage);
  110.       virtual wm_First + wm_Command;
  111.   end;
  112.  
  113. implementation
  114.  
  115. end.
  116.  
  117.