2002-11-27 02:03:14 +03:00
|
|
|
/*
|
|
|
|
* GraphicsDriver.h
|
|
|
|
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GRAPHICSDRIVER_H
|
|
|
|
#define __GRAPHICSDRIVER_H
|
|
|
|
|
2010-12-08 13:22:40 +03:00
|
|
|
|
2002-11-27 02:03:14 +03:00
|
|
|
#include "JobData.h"
|
2005-02-06 21:22:40 +03:00
|
|
|
#include "PrinterData.h"
|
2002-11-27 02:03:14 +03:00
|
|
|
#include "PrintProcess.h"
|
2004-01-28 00:22:16 +03:00
|
|
|
#include "SpoolMetaData.h"
|
2002-11-27 02:03:14 +03:00
|
|
|
#include "Transport.h"
|
2007-01-20 18:52:37 +03:00
|
|
|
#include "StatusWindow.h"
|
2002-11-27 02:03:14 +03:00
|
|
|
|
2010-12-08 13:22:40 +03:00
|
|
|
|
2002-11-27 02:03:14 +03:00
|
|
|
class BView;
|
|
|
|
class BBitmap;
|
|
|
|
class BMessage;
|
|
|
|
class PrinterData;
|
|
|
|
class PrinterCap;
|
|
|
|
|
2010-12-08 13:22:40 +03:00
|
|
|
|
2002-11-27 02:03:14 +03:00
|
|
|
class GraphicsDriver {
|
|
|
|
public:
|
2010-12-08 13:22:40 +03:00
|
|
|
GraphicsDriver(BMessage* message, PrinterData* printerData,
|
|
|
|
const PrinterCap *printerCap);
|
|
|
|
virtual ~GraphicsDriver();
|
|
|
|
|
|
|
|
const JobData* GetJobData(BFile* spoolFile);
|
2010-12-10 13:47:19 +03:00
|
|
|
BMessage* TakeJob(BFile* spoolFile);
|
2010-12-08 13:22:40 +03:00
|
|
|
static BPoint GetScale(int32 nup, BRect physicalRect, float scaling);
|
|
|
|
static BPoint GetOffset(int32 nup, int index,
|
|
|
|
JobData::Orientation orientation, const BPoint* scale,
|
|
|
|
BRect scaledPhysicalRect, BRect scaledPrintableRect,
|
|
|
|
BRect physicalRect);
|
2002-11-27 02:03:14 +03:00
|
|
|
|
|
|
|
protected:
|
2010-12-08 13:22:40 +03:00
|
|
|
GraphicsDriver(const GraphicsDriver &);
|
|
|
|
|
|
|
|
GraphicsDriver& operator = (const GraphicsDriver &);
|
|
|
|
|
|
|
|
virtual bool StartDocument();
|
|
|
|
virtual bool StartPage(int page_number);
|
|
|
|
virtual bool NextBand(BBitmap* bitmap, BPoint* offset);
|
|
|
|
virtual bool EndPage(int page_number);
|
|
|
|
virtual bool EndDocument(bool success);
|
|
|
|
|
|
|
|
void WriteSpoolData(const void* buffer, size_t size)
|
2019-04-14 21:06:10 +03:00
|
|
|
/* throw (TransportException) */;
|
2010-12-08 13:22:40 +03:00
|
|
|
void WriteSpoolString(const char* buffer, ...)
|
2019-04-14 21:06:10 +03:00
|
|
|
/* throw (TransportException) */;
|
2010-12-08 13:22:40 +03:00
|
|
|
void WriteSpoolChar(char c)
|
2019-04-14 21:06:10 +03:00
|
|
|
/* throw (TransportException) */;
|
2010-12-08 13:22:40 +03:00
|
|
|
|
2018-06-03 17:41:06 +03:00
|
|
|
void ReadSpoolData(void* buffer, size_t size)
|
2019-04-14 21:06:10 +03:00
|
|
|
/* throw (TransportException) */;
|
2018-06-03 17:41:06 +03:00
|
|
|
int ReadSpoolChar()
|
2019-04-14 21:06:10 +03:00
|
|
|
/* throw (TransportException) */;
|
2018-06-03 17:41:06 +03:00
|
|
|
|
2010-12-08 13:22:40 +03:00
|
|
|
static void ConvertToRGB24(const void* src, void* dst, int width,
|
|
|
|
color_space cs);
|
|
|
|
static void ConvertToGray(const void* src, void* dst, int width,
|
|
|
|
color_space cs);
|
|
|
|
|
|
|
|
const JobData* GetJobData() const;
|
|
|
|
const PrinterData* GetPrinterData() const;
|
|
|
|
const PrinterCap* GetPrinterCap() const;
|
|
|
|
const SpoolMetaData* GetSpoolMetaData() const;
|
|
|
|
int GetProtocolClass() const;
|
|
|
|
|
|
|
|
int GetPageHeight() const;
|
2002-11-27 02:03:14 +03:00
|
|
|
|
|
|
|
private:
|
2010-12-08 13:22:40 +03:00
|
|
|
bool _SetupData(BFile* file);
|
|
|
|
void _SetupBitmap();
|
|
|
|
void _CleanupData();
|
|
|
|
void _CleanupBitmap();
|
|
|
|
bool _PrintPage(PageDataList* pages);
|
2010-12-10 13:47:19 +03:00
|
|
|
bool _PrintBand(BBitmap* band, BPoint* offset);
|
|
|
|
void _RotateInto(BBitmap* target, const BBitmap* source);
|
2010-12-08 13:22:40 +03:00
|
|
|
bool _CollectPages(SpoolData* spoolData, PageDataList* pages);
|
|
|
|
bool _SkipPages(SpoolData* spoolData);
|
|
|
|
bool _PrintDocument(SpoolData* spoolData);
|
2010-12-10 13:47:19 +03:00
|
|
|
bool _PrintJob(BFile* file);
|
|
|
|
|
|
|
|
bool _NeedRotateBitmapBand() const;
|
|
|
|
|
2010-12-08 13:22:40 +03:00
|
|
|
static void _ConvertRGB32ToRGB24(const void* src, void* dst, int width);
|
|
|
|
static void _ConvertCMAP8ToRGB24(const void* src, void* dst, int width);
|
|
|
|
static uint8 _ConvertToGray(uint8 r, uint8 g, uint8 b);
|
|
|
|
static void _ConvertRGB32ToGray(const void* src, void* dst, int width);
|
|
|
|
static void _ConvertCMAP8ToGray(const void* src, void* dst, int width);
|
|
|
|
|
|
|
|
BMessage* fMessage;
|
|
|
|
BView* fView;
|
|
|
|
BBitmap* fBitmap;
|
2010-12-10 13:47:19 +03:00
|
|
|
BBitmap* fRotatedBitmap;
|
2010-12-08 13:22:40 +03:00
|
|
|
Transport* fTransport;
|
|
|
|
JobData* fOrgJobData;
|
|
|
|
JobData* fRealJobData;
|
|
|
|
PrinterData* fPrinterData;
|
|
|
|
const PrinterCap* fPrinterCap;
|
|
|
|
SpoolMetaData* fSpoolMetaData;
|
|
|
|
|
|
|
|
int fPageWidth;
|
|
|
|
int fPageHeight;
|
|
|
|
int fBandWidth;
|
|
|
|
int fBandHeight;
|
|
|
|
int fPixelDepth;
|
|
|
|
int fBandCount;
|
|
|
|
int fInternalCopies;
|
|
|
|
|
|
|
|
uint32 fPageCount;
|
2007-01-20 18:52:37 +03:00
|
|
|
|
2010-12-08 13:22:40 +03:00
|
|
|
StatusWindow* fStatusWindow;
|
2002-11-27 02:03:14 +03:00
|
|
|
};
|
|
|
|
|
2010-12-08 13:22:40 +03:00
|
|
|
|
|
|
|
inline const JobData*
|
|
|
|
GraphicsDriver::GetJobData() const
|
2002-11-27 02:03:14 +03:00
|
|
|
{
|
2004-01-30 20:10:36 +03:00
|
|
|
return fRealJobData;
|
2002-11-27 02:03:14 +03:00
|
|
|
}
|
|
|
|
|
2010-12-08 13:22:40 +03:00
|
|
|
|
|
|
|
inline const PrinterData*
|
|
|
|
GraphicsDriver::GetPrinterData() const
|
2002-11-27 02:03:14 +03:00
|
|
|
{
|
2004-01-30 20:10:36 +03:00
|
|
|
return fPrinterData;
|
2002-11-27 02:03:14 +03:00
|
|
|
}
|
|
|
|
|
2010-12-08 13:22:40 +03:00
|
|
|
|
|
|
|
inline const PrinterCap*
|
|
|
|
GraphicsDriver::GetPrinterCap() const
|
2002-11-27 02:03:14 +03:00
|
|
|
{
|
2004-01-30 20:10:36 +03:00
|
|
|
return fPrinterCap;
|
2002-11-27 02:03:14 +03:00
|
|
|
}
|
|
|
|
|
2010-12-08 13:22:40 +03:00
|
|
|
|
|
|
|
inline const SpoolMetaData*
|
|
|
|
GraphicsDriver::GetSpoolMetaData() const
|
2004-01-28 00:22:16 +03:00
|
|
|
{
|
2004-01-30 20:10:36 +03:00
|
|
|
return fSpoolMetaData;
|
2004-01-28 00:22:16 +03:00
|
|
|
}
|
|
|
|
|
2010-12-08 13:22:40 +03:00
|
|
|
|
|
|
|
inline int
|
|
|
|
GraphicsDriver::GetProtocolClass() const
|
2005-02-06 21:22:40 +03:00
|
|
|
{
|
2010-12-08 23:07:22 +03:00
|
|
|
return fPrinterData->GetProtocolClass();
|
2005-02-06 21:22:40 +03:00
|
|
|
}
|
|
|
|
|
2010-12-08 13:22:40 +03:00
|
|
|
|
|
|
|
inline int
|
|
|
|
GraphicsDriver::GetPageHeight() const
|
2002-11-27 02:03:14 +03:00
|
|
|
{
|
2010-12-10 13:47:19 +03:00
|
|
|
if (!_NeedRotateBitmapBand())
|
|
|
|
return fPageHeight;
|
|
|
|
return fPageWidth;
|
2002-11-27 02:03:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* __GRAPHICSDRIVER_H */
|