home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / OWLINC.PAK / PRINTER.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  5KB  |  159 lines

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