1 /* 2 * Copyright 2009, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _PRINTSESSION_H 6 #define _PRINTSESSION_H 7 8 9 #include <Picture.h> 10 11 12 class BFile; 13 class BView; 14 15 struct print_file_header { 16 int32 version; 17 int32 page_count; 18 off_t first_page; 19 20 int32 _reserved[3]; 21 } _PACKED; 22 23 struct _page_header_; 24 25 26 class BPrintJob { 27 public: 28 // Values returned by PrinterType() 29 enum { 30 B_BW_PRINTER = 0, 31 B_COLOR_PRINTER 32 }; 33 34 35 BPrintJob(const char* name); 36 virtual ~BPrintJob(); 37 38 void BeginJob(); 39 void CommitJob(); 40 status_t ConfigJob(); 41 void CancelJob(); 42 43 status_t ConfigPage(); 44 void SpoolPage(); 45 46 bool CanContinue(); 47 48 virtual void DrawView(BView* view, BRect rect, 49 BPoint where); 50 51 BMessage* Settings(); // TODO: const 52 void SetSettings(BMessage* archive); 53 bool IsSettingsMessageValid( 54 BMessage* archive) const; 55 56 BRect PaperRect(); 57 BRect PrintableRect(); 58 void GetResolution(int32* xDPI, int32* yDPI); 59 60 int32 FirstPage(); // TODO: const 61 int32 LastPage(); // TODO: const 62 int32 PrinterType(void* type = NULL) const; 63 64 65 private: 66 // FBC padding and forbidden methods 67 virtual void _ReservedPrintJob1(); 68 virtual void _ReservedPrintJob2(); 69 virtual void _ReservedPrintJob3(); 70 virtual void _ReservedPrintJob4(); 71 72 BPrintJob(const BPrintJob& other); 73 BPrintJob& operator=(const BPrintJob& other); 74 75 private: 76 void _RecurseView(BView* view, BPoint origin, 77 BPicture* picture, BRect rect); 78 void _GetMangledName(char* buffer, 79 size_t bufferSize) const; 80 void _HandlePageSetup(BMessage* setup); 81 bool _HandlePrintSetup(BMessage* setup); 82 83 void _NewPage(); 84 void _EndLastPage(); 85 86 void _AddSetupSpec(); 87 void _AddPicture(BPicture& picture, BRect& rect, 88 BPoint& where); 89 90 char* _GetCurrentPrinterName() const; 91 void _LoadDefaultSettings(); 92 93 private: 94 char* fPrintJobName; 95 96 int32 _unused; 97 98 BFile* fSpoolFile; 99 print_file_header fSpoolFileHeader; 100 BRect fPaperSize; 101 BRect fUsableSize; 102 status_t fError; 103 char fSpoolFileName[256]; 104 BMessage* fSetupMessage; 105 BMessage* fDefaultSetupMessage; 106 char fAbort; 107 int32 fFirstPage; 108 int32 fLastPage; 109 short fXResolution; 110 short fYResolution; 111 _page_header_* fCurrentPageHeader; 112 off_t fCurrentPageHeaderOffset; 113 114 uint32 _reserved[2]; 115 }; 116 117 #endif // _PRINTSESSION_H 118