2009-08-26 22:56:44 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Haiku, Inc. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2002-07-09 16:24:59 +04:00
|
|
|
#ifndef _PRINTSESSION_H
|
|
|
|
#define _PRINTSESSION_H
|
|
|
|
|
2008-03-30 21:42:13 +04:00
|
|
|
|
|
|
|
#include <Picture.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2008-03-30 21:42:13 +04:00
|
|
|
|
2007-10-16 00:13:55 +04:00
|
|
|
class BFile;
|
2002-07-09 16:24:59 +04:00
|
|
|
class BView;
|
|
|
|
|
2009-08-26 22:56:44 +04:00
|
|
|
struct print_file_header {
|
2002-07-09 16:24:59 +04:00
|
|
|
int32 version;
|
|
|
|
int32 page_count;
|
|
|
|
off_t first_page;
|
|
|
|
|
2009-08-26 22:56:44 +04:00
|
|
|
int32 _reserved[3];
|
|
|
|
};
|
2008-03-30 21:42:13 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
struct _page_header_;
|
|
|
|
|
|
|
|
|
|
|
|
class BPrintJob {
|
|
|
|
public:
|
2009-08-26 22:56:44 +04:00
|
|
|
// Values returned by PrinterType()
|
|
|
|
enum {
|
|
|
|
B_BW_PRINTER = 0,
|
|
|
|
B_COLOR_PRINTER
|
|
|
|
};
|
2008-03-30 21:42:13 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 22:56:44 +04:00
|
|
|
BPrintJob(const char* name);
|
|
|
|
virtual ~BPrintJob();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 22:56:44 +04:00
|
|
|
void BeginJob();
|
|
|
|
void CommitJob();
|
|
|
|
status_t ConfigJob();
|
|
|
|
void CancelJob();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 22:56:44 +04:00
|
|
|
status_t ConfigPage();
|
|
|
|
void SpoolPage();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 22:56:44 +04:00
|
|
|
bool CanContinue();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 22:56:44 +04:00
|
|
|
virtual void DrawView(BView* view, BRect rect,
|
|
|
|
BPoint where);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 22:56:44 +04:00
|
|
|
BMessage* Settings(); // TODO: const
|
|
|
|
void SetSettings(BMessage* archive);
|
|
|
|
bool IsSettingsMessageValid(
|
|
|
|
BMessage* archive) const;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 22:56:44 +04:00
|
|
|
BRect PaperRect();
|
|
|
|
BRect PrintableRect();
|
|
|
|
void GetResolution(int32* xDPI, int32* yDPI);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 22:56:44 +04:00
|
|
|
int32 FirstPage(); // TODO: const
|
|
|
|
int32 LastPage(); // TODO: const
|
|
|
|
int32 PrinterType(void* type = NULL) const;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
2009-08-26 22:56:44 +04:00
|
|
|
// FBC padding and forbidden methods
|
|
|
|
virtual void _ReservedPrintJob1();
|
|
|
|
virtual void _ReservedPrintJob2();
|
|
|
|
virtual void _ReservedPrintJob3();
|
|
|
|
virtual void _ReservedPrintJob4();
|
2008-03-30 21:42:13 +04:00
|
|
|
|
2009-08-26 22:56:44 +04:00
|
|
|
BPrintJob(const BPrintJob& other);
|
|
|
|
BPrintJob& operator=(const BPrintJob& other);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-26 22:56:44 +04:00
|
|
|
private:
|
|
|
|
void _RecurseView(BView* view, BPoint origin,
|
|
|
|
BPicture* picture, BRect rect);
|
|
|
|
void _GetMangledName(char* buffer,
|
|
|
|
size_t bufferSize) const;
|
|
|
|
void _HandlePageSetup(BMessage* setup);
|
|
|
|
bool _HandlePrintSetup(BMessage* setup);
|
2008-03-30 21:42:13 +04:00
|
|
|
|
2009-08-26 22:56:44 +04:00
|
|
|
void _NewPage();
|
|
|
|
void _EndLastPage();
|
2008-03-30 21:42:13 +04:00
|
|
|
|
2009-08-26 22:56:44 +04:00
|
|
|
void _AddSetupSpec();
|
|
|
|
void _AddPicture(BPicture& picture, BRect& rect,
|
|
|
|
BPoint& where);
|
2008-03-30 21:42:13 +04:00
|
|
|
|
2009-08-26 22:56:44 +04:00
|
|
|
char* _GetCurrentPrinterName() const;
|
|
|
|
void _LoadDefaultSettings();
|
2008-03-30 21:42:13 +04:00
|
|
|
|
|
|
|
private:
|
2009-08-26 22:56:44 +04:00
|
|
|
char* fPrintJobName;
|
|
|
|
|
2008-03-31 00:24:58 +04:00
|
|
|
int32 _unused;
|
2009-08-26 22:56:44 +04:00
|
|
|
|
|
|
|
BFile* fSpoolFile;
|
2008-03-31 00:24:58 +04:00
|
|
|
print_file_header fSpoolFileHeader;
|
2008-03-30 21:42:13 +04:00
|
|
|
BRect fPaperSize;
|
|
|
|
BRect fUsableSize;
|
|
|
|
status_t fError;
|
|
|
|
char fSpoolFileName[256];
|
2009-08-26 22:56:44 +04:00
|
|
|
BMessage* fSetupMessage;
|
|
|
|
BMessage* fDefaultSetupMessage;
|
2008-03-30 21:42:13 +04:00
|
|
|
char fAbort;
|
|
|
|
int32 fFirstPage;
|
|
|
|
int32 fLastPage;
|
|
|
|
short fXResolution;
|
|
|
|
short fYResolution;
|
2009-08-26 22:56:44 +04:00
|
|
|
_page_header_* fCurrentPageHeader;
|
2008-03-30 21:42:13 +04:00
|
|
|
off_t fCurrentPageHeaderOffset;
|
2009-08-26 22:56:44 +04:00
|
|
|
|
2008-03-30 21:42:13 +04:00
|
|
|
uint32 _reserved[2];
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
2009-08-26 22:56:44 +04:00
|
|
|
#endif // _PRINTSESSION_H
|