xref: /haiku/headers/os/interface/PrintJob.h (revision cfc3fa87da824bdf593eb8b817a83b6376e77935)
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 
15 #include <BeBuild.h>
16 #include <Picture.h>
17 #include <Rect.h>
18 
19 
20 class BFile;
21 class BView;
22 
23 /*----------------------------------------------------------------*/
24 /*----- BPrintJob related structures -----------------------------*/
25 
26 struct	print_file_header {
27 	int32	version;
28 	int32	page_count;
29 	off_t	first_page;
30 	int32	_reserved_3_;
31 	int32	_reserved_4_;
32 	int32	_reserved_5_;
33 };
34 
35 
36 struct _page_header_;
37 
38 /*----------------------------------------------------------------*/
39 /*----- BPrintJob class ------------------------------------------*/
40 
41 class BPrintJob {
42 public:
43 			// These values are returned by PrinterType()
44 			enum {
45 						B_BW_PRINTER = 0,
46 						B_COLOR_PRINTER
47 			};
48 
49 
50 						BPrintJob(const char *job_name);
51 	virtual				~BPrintJob();
52 
53 			void		BeginJob();
54 			void		CommitJob();
55 			status_t	ConfigJob();
56 			void		CancelJob();
57 
58 			status_t	ConfigPage();
59 			void		SpoolPage();
60 
61 			bool		CanContinue();
62 
63 	virtual	void		DrawView(BView *a_view, BRect a_rect, BPoint where);
64 
65 			BMessage *	Settings()	/* const */ ;
66 			void		SetSettings(BMessage *a_msg);
67 			bool		IsSettingsMessageValid(BMessage *a_msg) const;
68 
69 			BRect		PaperRect();
70 			BRect		PrintableRect();
71 			void		GetResolution(int32 *xdpi, int32 *ydpi);
72 
73 			int32		FirstPage()	/* const */ ;
74 			int32		LastPage()	/* const */ ;
75 			int32		PrinterType(void * = NULL) const;
76 
77 
78 private:
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,
88 							BPicture *picture, BRect r);
89 			void		_GetMangledName(char *buffer, size_t bufferSize) const;
90 			void		_HandlePageSetup(BMessage *setup);
91 			bool		_HandlePrintSetup(BMessage *setup);
92 
93 			void		_NewPage();
94 			void		_EndLastPage();
95 
96 			void		_AddSetupSpec();
97 			void		_AddPicture(BPicture &picture, BRect &rect, BPoint &where);
98 
99 			char *		_GetCurrentPrinterName() const;
100 			void		_LoadDefaultSettings();
101 
102 private:
103 			char *				fPrintJobName;
104 			int32				_unused;
105 			BFile *				fSpoolFile;
106 			print_file_header	fSpoolFileHeader;
107 			BRect				fPaperSize;
108 			BRect				fUsableSize;
109 			status_t			fError;
110 			char				fSpoolFileName[256];
111 			BMessage *			fSetupMessage;
112 			BMessage *			fDefaultSetupMessage;
113 			char				fAbort;
114 			int32				fFirstPage;
115 			int32				fLastPage;
116 			short				fXResolution;
117 			short				fYResolution;
118 			_page_header_ *		fCurrentPageHeader;
119 			off_t				fCurrentPageHeaderOffset;
120 			uint32				_reserved[2];
121 };
122 
123 
124 #endif	// _PRINTSESSION_H
125