1 /******************************************************************************* 2 / 3 / File: PrintJob.h 4 / 5 / Description: BPrintJob runs a printing session. 6 / 7 / Copyright 1996-98, Be Incorporated, All Rights Reserved 8 / 9 *******************************************************************************/ 10 11 #ifndef _PRINTSESSION_H 12 #define _PRINTSESSION_H 13 14 #include <BeBuild.h> 15 #include <Picture.h> /* For convenience */ 16 #include <Rect.h> 17 18 class BFile; 19 class BView; 20 21 /*----------------------------------------------------------------*/ 22 /*----- BPrintJob related structures -----------------------------*/ 23 24 struct print_file_header { 25 int32 version; 26 int32 page_count; 27 off_t first_page; 28 int32 _reserved_3_; 29 int32 _reserved_4_; 30 int32 _reserved_5_; 31 }; 32 33 struct _page_header_; 34 35 /*----------------------------------------------------------------*/ 36 /*----- BPrintJob class ------------------------------------------*/ 37 38 class BPrintJob { 39 public: 40 41 enum // These values are returned by PrinterType() 42 { 43 B_BW_PRINTER = 0, 44 B_COLOR_PRINTER 45 }; 46 47 48 BPrintJob(const char *job_name); 49 virtual ~BPrintJob(); 50 51 void BeginJob(); 52 void CommitJob(); 53 status_t ConfigJob(); 54 void CancelJob(); 55 56 status_t ConfigPage(); 57 void SpoolPage(); 58 59 bool CanContinue(); 60 61 virtual void DrawView(BView *a_view, BRect a_rect, BPoint where); 62 63 BMessage *Settings() /* const */ ; 64 void SetSettings(BMessage *a_msg); 65 bool IsSettingsMessageValid(BMessage *a_msg) const; 66 67 BRect PaperRect(); 68 BRect PrintableRect(); 69 void GetResolution(int32 *xdpi, int32 *ydpi); 70 71 int32 FirstPage() /* const */ ; 72 int32 LastPage() /* const */ ; 73 int32 PrinterType(void * = NULL) const; 74 75 76 /*----- Private or reserved -----------------------------------------*/ 77 private: 78 79 virtual void _ReservedPrintJob1(); 80 virtual void _ReservedPrintJob2(); 81 virtual void _ReservedPrintJob3(); 82 virtual void _ReservedPrintJob4(); 83 84 BPrintJob(const BPrintJob &); 85 BPrintJob &operator=(const BPrintJob &); 86 87 void _RecurseView(BView *view, BPoint origin, BPicture *p, BRect r); 88 void _GetMangledName(char *buffer, size_t bufferSize) const; 89 void _HandlePageSetup(BMessage *setup); 90 bool _HandlePrintSetup(BMessage *setup); 91 92 void _NewPage(); 93 void _EndLastPage(); 94 95 void _AddSetupSpec(); 96 void _AddPicture(BPicture &picture, BRect &rect, BPoint &where); 97 98 char* _GetCurrentPrinterName() const; 99 void _LoadDefaultSettings(); 100 101 char * fPrintJobName; 102 int32 fPageNumber; 103 BFile * fSpoolFile; 104 print_file_header fCurrentHeader; 105 BRect fPaperSize; 106 BRect fUsableSize; 107 status_t fError; 108 char fSpoolFileName[256]; 109 BMessage *fSetupMessage; 110 BMessage *fDefaultSetupMessage; 111 char fAbort; 112 int32 fFirstPage; 113 int32 fLastPage; 114 short fXResolution; 115 short fYResolution; 116 _page_header_ * fCurrentPageHeader; 117 off_t fCurrentPageHeaderOffset; 118 uint32 _reserved[2]; 119 }; 120 121 /*-------------------------------------------------------------*/ 122 /*-------------------------------------------------------------*/ 123 124 #endif /* _PRINTSESSION_H */ 125