home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 19.ddi / OWLINC.PAK / PRINTER.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  4.4 KB  |  149 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1992, 1993 by Borland International
  3. //   include\owl\printer.h
  4. //----------------------------------------------------------------------------
  5. #if !defined(__OWL_PRINTER_H)
  6. #define __OWL_PRINTER_H
  7.  
  8. #if !defined(__OWL_DIALOG_H)
  9.   #include <owl\dialog.h>
  10. #endif
  11. #if !defined(__OWL_PRINTDIA_H)
  12.   #include <owl\printdia.h>
  13. #endif
  14. #include <owl\printer.rh>
  15. class _OWLCLASS TPrintDC;
  16.  
  17. //
  18. //  class TPrinterAbortDlg
  19. //  ----- ----------------
  20. //
  21. class _OWLCLASS TPrinterAbortDlg : public TDialog {
  22.   public:
  23.     TPrinterAbortDlg(TWindow* parent, TResId resId, const char far* title,
  24.                      const char far* device, const char far* port);
  25.  
  26.   protected:
  27.     void     SetupWindow();
  28.     LRESULT  EvCommand(UINT id, HWND hWndCtl, UINT notifyCode);
  29. };
  30.  
  31. //
  32. // TPrintout banding flags
  33. //
  34. enum TPrintoutFlags {
  35.   pfGraphics = 0x01,     // Current band accepts graphics
  36.   pfText     = 0x02,     // Current band accepts text
  37.   pfBoth     = (pfGraphics|pfText)
  38. };
  39.  
  40. //
  41. //  class TPrintout
  42. //  ----- ---------
  43. //
  44. // TPrintout represents the physical printed document which is to
  45. // sent to a printer to be printed. TPrintout does the rendering of
  46. // the document onto the printer. For every document, or document
  47. // type, a corresponding TPrintout class should be created.
  48. //
  49. class _OWLCLASS TPrintout : public TStreamableBase {
  50.   public:
  51.     TPrintout(const char far* title);
  52.     virtual ~TPrintout();
  53.  
  54.     virtual void SetPrintParams(TPrintDC* dc, TSize pageSize);
  55.     virtual void GetDialogInfo(int& minPage,     int& maxPage,
  56.                                int& selFromPage, int& selToPage);
  57.     virtual void BeginPrinting();
  58.     virtual void BeginDocument(int startPage, int endPage, unsigned flags);
  59.     virtual BOOL HasPage(int pageNumber);
  60.     virtual void PrintPage(int page, TRect& rect, unsigned flags);
  61.     virtual void EndDocument();
  62.     virtual void EndPrinting();
  63.  
  64.     const char far* GetTitle() const {return Title;}
  65.     BOOL            WantBanding() const {return Banding;}
  66.     BOOL            WantForceAllBands() const {return ForceAllBands;}
  67.  
  68.   protected:
  69.     char far* Title;
  70.     BOOL      Banding;
  71.     BOOL      ForceAllBands;
  72.     TPrintDC* DC;
  73.     TSize     PageSize;
  74.  
  75.   private:
  76.     //
  77.     // hidden to prevent accidental copying or assignment
  78.     //
  79.     TPrintout(const TPrintout&);
  80.     TPrintout& operator =(const TPrintout&);
  81.  
  82.   DECLARE_STREAMABLE(_OWLCLASS, TPrintout, 1);
  83. };
  84.  
  85. //
  86. //  class TPrinter
  87. //  ----- --------
  88. //
  89. // TPrinter represent the physical printer device.  To print a
  90. // TPrintout, send the TPrintout to the TPrinter's Print function.
  91. //
  92. class _OWLCLASS TPrinter: public TStreamableBase {
  93.   public:
  94.     class _OWLCLASS_RTL TXPrinter : TXOwl {
  95.       public:
  96.         TXPrinter(UINT resId = IDS_PRINTERERROR);
  97.     };
  98.     TPrinter();
  99.     virtual ~TPrinter();
  100.  
  101.     virtual void ClearDevice();
  102.     virtual void Setup(TWindow* parent);
  103.     virtual BOOL Print(TWindow* parent, TPrintout& printout, BOOL prompt);
  104.     virtual void ReportError(TWindow* parent, TPrintout& printout);
  105.  
  106.     TPrintDialog::TData& GetSetup() {return *Data;}
  107.  
  108.     static void  SetUserAbort(BOOL abort=TRUE) {UserAbort=abort;}
  109.     static BOOL  GetUserAbort() {return UserAbort;}
  110.  
  111.   protected:
  112.     int                  Error;          // < 0 if error occurred during print
  113.     TPrintDialog::TData* Data;           // Printer setup information
  114.  
  115.     virtual void GetDefaultPrinter();
  116.     virtual void SetPrinter(const char* driver, const char* device,
  117.                             const char* output);
  118.  
  119.     virtual BOOL     ExecPrintDialog(TWindow* parent);
  120.     virtual TWindow* CreateAbortWindow(TWindow* parent, TPrintout& printout);
  121.  
  122.     //
  123.     // Helper function used by Print
  124.     //
  125.     void         CalcBandingFlags(TPrintDC& prnDC);
  126.     
  127.     //
  128.     // Variables used by CalcBandingFlags and Print
  129.     //
  130.     BOOL     UseBandInfo;
  131.     unsigned Flags;
  132.     BOOL     FirstBand;
  133.     TRect    BandRect;
  134.     TSize    PageSize;
  135.  
  136.   private:
  137.     static BOOL UserAbort;    // Set by printing dialog if user cancels
  138.  
  139.     //
  140.     // hidden to prevent accidental copying or assignment
  141.     //
  142.     TPrinter(const TPrinter&);
  143.     TPrinter& operator =(const TPrinter&);
  144.  
  145.   DECLARE_STREAMABLE(_OWLCLASS, TPrinter, 1);
  146. };
  147.  
  148. #endif  // __OWL_PRINTER_H
  149.