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 BView; 19 20 /*----------------------------------------------------------------*/ 21 /*----- BPrintJob related structures -----------------------------*/ 22 23 struct print_file_header { 24 int32 version; 25 int32 page_count; 26 off_t first_page; 27 int32 _reserved_3_; 28 int32 _reserved_4_; 29 int32 _reserved_5_; 30 }; 31 32 struct _page_header_; 33 34 /*----------------------------------------------------------------*/ 35 /*----- BPrintJob class ------------------------------------------*/ 36 37 class BPrintJob { 38 public: 39 40 enum // These values are returned by PrinterType() 41 { 42 B_BW_PRINTER = 0, 43 B_COLOR_PRINTER 44 }; 45 46 47 BPrintJob(const char *job_name); 48 virtual ~BPrintJob(); 49 50 void BeginJob(); 51 void CommitJob(); 52 status_t ConfigJob(); 53 void CancelJob(); 54 55 status_t ConfigPage(); 56 void SpoolPage(); 57 58 bool CanContinue(); 59 60 virtual void DrawView(BView *a_view, BRect a_rect, BPoint where); 61 62 BMessage *Settings() /* const */ ; 63 void SetSettings(BMessage *a_msg); 64 bool IsSettingsMessageValid(BMessage *a_msg) const; 65 66 BRect PaperRect(); 67 BRect PrintableRect(); 68 void GetResolution(int32 *xdpi, int32 *ydpi); 69 70 int32 FirstPage() /* const */ ; 71 int32 LastPage() /* const */ ; 72 int32 PrinterType(void * = NULL) const; 73 74 75 /*----- Private or reserved -----------------------------------------*/ 76 private: 77 78 virtual void _ReservedPrintJob1(); 79 virtual void _ReservedPrintJob2(); 80 virtual void _ReservedPrintJob3(); 81 virtual void _ReservedPrintJob4(); 82 83 BPrintJob(const BPrintJob &); 84 BPrintJob &operator=(const BPrintJob &); 85 86 void RecurseView(BView *v, BPoint origin, BPicture *p, BRect r); 87 void MangleName(char *filename); 88 void HandlePageSetup(BMessage *setup); 89 bool HandlePrintSetup(BMessage *setup); 90 91 void NewPage(); 92 void EndLastPage(); 93 94 void AddSetupSpec(); 95 void AddPicture(BPicture *picture, BRect *rect, BPoint where); 96 97 char* GetCurrentPrinterName() const; 98 void LoadDefaultSettings(); 99 100 char * fPrintJobName; 101 int32 fPageNumber; 102 BFile * fSpoolFile; 103 print_file_header fCurrentHeader; 104 BRect fPaperSize; 105 BRect fUsableSize; 106 status_t fError; 107 char fSpoolFileName[256]; 108 BMessage *fSetupMessage; 109 BMessage *fDefaultSetupMessage; 110 char fAbort; 111 int32 fFirstPage; 112 int32 fLastPage; 113 short fXResolution; 114 short fYResolution; 115 _page_header_ * fCurrentPageHeader; 116 off_t fCurrentPageHeaderOffset; 117 uint32 _reserved[2]; 118 }; 119 120 /*-------------------------------------------------------------*/ 121 /*-------------------------------------------------------------*/ 122 123 #endif /* _PRINTSESSION_H */ 124