Implemented Floyd Steinberg dithering and made it default.

Renamed many constants and fields according to Open BeOS coding style guide.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6433 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Pfeiffer
2004-01-30 17:10:36 +00:00
parent 7ea239b20d
commit 2f6e49a929
25 changed files with 972 additions and 1095 deletions
+28 -26
View File
@@ -17,7 +17,9 @@ class BMessage;
class PrinterData; class PrinterData;
class PrinterCap; class PrinterCap;
#define GDF_ROTATE_BAND_BITMAP 0x01 enum {
kGDFRotateBandBitmap = 1
};
class GraphicsDriver { class GraphicsDriver {
public: public:
@@ -67,64 +69,64 @@ private:
static void rgb32_to_gray(void* src, void* dst, int width); static void rgb32_to_gray(void* src, void* dst, int width);
static void cmap8_to_gray(void* src, void* dst, int width); static void cmap8_to_gray(void* src, void* dst, int width);
uint32 __flags; uint32 fFlags;
BMessage *__msg; BMessage *fMsg;
BView *__view; BView *fView;
BBitmap *__bitmap; BBitmap *fBitmap;
Transport *__transport; Transport *fTransport;
JobData *__org_job_data; JobData *fOrgJobData;
JobData *__real_job_data; JobData *fRealJobData;
PrinterData *__printer_data; PrinterData *fPrinterData;
const PrinterCap *__printer_cap; const PrinterCap *fPrinterCap;
SpoolMetaData *__spool_meta_data; SpoolMetaData *fSpoolMetaData;
int __page_width; int fPageWidth;
int __page_height; int fPageHeight;
int __band_width; int fBandWidth;
int __band_height; int fBandHeight;
int __pixel_depth; int fPixelDepth;
int __band_count; int fBandCount;
int __internal_copies; int fInternalCopies;
}; };
inline const JobData *GraphicsDriver::getJobData() const inline const JobData *GraphicsDriver::getJobData() const
{ {
return __real_job_data; return fRealJobData;
} }
inline const PrinterData *GraphicsDriver::getPrinterData() const inline const PrinterData *GraphicsDriver::getPrinterData() const
{ {
return __printer_data; return fPrinterData;
} }
inline const PrinterCap *GraphicsDriver::getPrinterCap() const inline const PrinterCap *GraphicsDriver::getPrinterCap() const
{ {
return __printer_cap; return fPrinterCap;
} }
inline const SpoolMetaData *GraphicsDriver::getSpoolMetaData() const inline const SpoolMetaData *GraphicsDriver::getSpoolMetaData() const
{ {
return __spool_meta_data; return fSpoolMetaData;
} }
inline int GraphicsDriver::getPageWidth() const inline int GraphicsDriver::getPageWidth() const
{ {
return __page_width; return fPageWidth;
} }
inline int GraphicsDriver::getPageHeight() const inline int GraphicsDriver::getPageHeight() const
{ {
return __page_height; return fPageHeight;
} }
inline int GraphicsDriver::getBandWidth() const inline int GraphicsDriver::getBandWidth() const
{ {
return __band_width; return fBandWidth;
} }
inline int GraphicsDriver::getBandHeight() const inline int GraphicsDriver::getBandHeight() const
{ {
return __band_height; return fBandHeight;
} }
#endif /* __GRAPHICSDRIVER_H */ #endif /* __GRAPHICSDRIVER_H */
+234 -235
View File
@@ -15,220 +15,219 @@ class PrinterCap;
class JobData { class JobData {
public: public:
enum ORIENTATION { enum Orientation {
PORTRAIT, kPortrait,
LANDSCAPE kLandscape
}; };
enum PAPER { enum Paper {
LETTER = 1, // 1 Letter 8 1/2 x 11 in kLetter = 1, // 1 Letter 8 1/2 x 11 in
LETTERSMALL, // 2 Letter Small 8 1/2 x 11 in kLetterSmall, // 2 Letter Small 8 1/2 x 11 in
TABLOID, // 3 Tabloid 11 x 17 in kTabloid, // 3 Tabloid 11 x 17 in
LEDGER, // 4 Ledger 17 x 11 in kLedger, // 4 Ledger 17 x 11 in
LEGAL, // 5 Legal 8 1/2 x 14 in kLegal, // 5 Legal 8 1/2 x 14 in
STATEMENT, // 6 Statement 5 1/2 x 8 1/2 in kStatement, // 6 Statement 5 1/2 x 8 1/2 in
EXECUTIVE, // 7 Executive 7 1/4 x 10 1/2 in kExecutive, // 7 Executive 7 1/4 x 10 1/2 in
A3, // 8 A3 297 x 420 mm kA3, // 8 A3 297 x 420 mm
A4, // 9 A4 210 x 297 mm kA4, // 9 A4 210 x 297 mm
A4SMALL, // 10 A4 Small 210 x 297 mm kA4Small, // 10 A4 Small 210 x 297 mm
A5, // 11 A5 148 x 210 mm kA5, // 11 A5 148 x 210 mm
B4, // 12 B4 (JIS) 250 x 354 kB4, // 12 B4 (JIS) 250 x 354
B5, // 13 B5 (JIS) 182 x 257 mm kB5, // 13 B5 (JIS) 182 x 257 mm
FOLIO, // 14 Folio 8 1/2 x 13 in kFolio, // 14 Folio 8 1/2 x 13 in
QUARTO, // 15 Quarto 215 x 275 mm kQuarto, // 15 Quarto 215 x 275 mm
P_10X14, // 16 10x14 in k10X14, // 16 10x14 in
P_11X17, // 17 11x17 in k11X17, // 17 11x17 in
NOTE, // 18 Note 8 1/2 x 11 in kNote, // 18 Note 8 1/2 x 11 in
ENV_9, // 19 Envelope #9 3 7/8 x 8 7/8 kEnv9, // 19 Envelope #9 3 7/8 x 8 7/8
ENV_10, // 20 Envelope #10 4 1/8 x 9 1/2 kEnv10, // 20 Envelope #10 4 1/8 x 9 1/2
ENV_11, // 21 Envelope #11 4 1/2 x 10 3/8 kEnv11, // 21 Envelope #11 4 1/2 x 10 3/8
ENV_12, // 22 Envelope #12 4 \276 x 11 kEnv12, // 22 Envelope #12 4 \276 x 11
ENV_14, // 23 Envelope #14 5 x 11 1/2 kEnv14, // 23 Envelope #14 5 x 11 1/2
CSHEET, // 24 C size sheet kCSheet, // 24 C size sheet
DSHEET, // 25 D size sheet kDSheet, // 25 D size sheet
ESHEET, // 26 E size sheet kESheet, // 26 E size sheet
ENV_DL, // 27 Envelope DL 110 x 220mm kEnvDL, // 27 Envelope DL 110 x 220mm
ENV_C5, // 28 Envelope C5 162 x 229 mm kEnvC5, // 28 Envelope C5 162 x 229 mm
ENV_C3, // 29 Envelope C3 324 x 458 mm kEnvC3, // 29 Envelope C3 324 x 458 mm
ENV_C4, // 30 Envelope C4 229 x 324 mm kEnvC4, // 30 Envelope C4 229 x 324 mm
ENV_C6, // 31 Envelope C6 114 x 162 mm kEnvC6, // 31 Envelope C6 114 x 162 mm
ENV_C65, // 32 Envelope C65 114 x 229 mm kEnvC65, // 32 Envelope C65 114 x 229 mm
ENV_B4, // 33 Envelope B4 250 x 353 mm kEnvB4, // 33 Envelope B4 250 x 353 mm
ENV_B5, // 34 Envelope B5 176 x 250 mm kEnvB5, // 34 Envelope B5 176 x 250 mm
ENV_B6, // 35 Envelope B6 176 x 125 mm kEnvB6, // 35 Envelope B6 176 x 125 mm
ENV_ITALY, // 36 Envelope 110 x 230 mm kEnvItaly, // 36 Envelope 110 x 230 mm
ENV_MONARCH, // 37 Envelope Monarch 3.875 x 7.5 in kEnvMonarch, // 37 Envelope Monarch 3.875 x 7.5 in
ENV_PERSONAL, // 38 6 3/4 Envelope 3 5/8 x 6 1/2 in kEnvPersonal, // 38 6 3/4 Envelope 3 5/8 x 6 1/2 in
FANFOLD_US, // 39 US Std Fanfold 14 7/8 x 11 in kFanFoldUS, // 39 US Std Fanfold 14 7/8 x 11 in
FANFOLD_STD_GERMAN, // 40 German Std Fanfold 8 1/2 x 12 in kFanFoldStdGerman, // 40 German Std Fanfold 8 1/2 x 12 in
FANFOLD_LGL_GERMAN, // 41 German Legal Fanfold 8 1/2 x 13 in kFanFoldLglGerman, // 41 German Legal Fanfold 8 1/2 x 13 in
ISO_B4, // 42 B4 (ISO) 250 x 353 mm kIsoB4, // 42 B4 (ISO) 250 x 353 mm
JAPANESE_POSTCARD, // 43 Japanese Postcard 100 x 148 mm kJapanesePostcard, // 43 Japanese Postcard 100 x 148 mm
P_9X11, // 44 9 x 11 in k9X11, // 44 9 x 11 in
P_10X11, // 45 10 x 11 in k10X11, // 45 10 x 11 in
P_15X11, // 46 15 x 11 in k15X11, // 46 15 x 11 in
ENV_INVITE, // 47 Envelope Invite 220 x 220 mm kEnvInvite, // 47 Envelope Invite 220 x 220 mm
RESERVED_48, // 48 RESERVED--DO NOT USE kReserved48, // 48 RESERVED--DO NOT USE
RESERVED_49, // 49 RESERVED--DO NOT USE kReserved49, // 49 RESERVED--DO NOT USE
LETTER_EXTRA, // 50 Letter Extra 9 \275 x 12 in kLetterExtra, // 50 Letter Extra 9 \275 x 12 in
LEGAL_EXTRA, // 51 Legal Extra 9 \275 x 15 in kLegalExtra, // 51 Legal Extra 9 \275 x 15 in
TABLOID_EXTRA, // 52 Tabloid Extra 11.69 x 18 in kTabloidExtra, // 52 Tabloid Extra 11.69 x 18 in
A4_EXTRA, // 53 A4 Extra 9.27 x 12.69 in kA4Extra, // 53 A4 Extra 9.27 x 12.69 in
LETTER_TRANSVERSE, // 54 Letter Transverse 8 \275 x 11 in kLetterTransverse, // 54 Letter Transverse 8 \275 x 11 in
A4_TRANSVERSE, // 55 A4 Transverse 210 x 297 mm kA4Transverse, // 55 A4 Transverse 210 x 297 mm
LETTER_EXTRA_TRANSVERSE,// 56 Letter Extra Transverse 9\275 x 12 in kLetterExtraTransverse, // 56 Letter Extra Transverse 9\275 x 12 in
A_PLUS, // 57 SuperA/SuperA/A4 227 x 356 mm kAPlus, // 57 SuperA/SuperA/A4 227 x 356 mm
B_PLUS, // 58 SuperB/SuperB/A3 305 x 487 mm kBPlus, // 58 SuperB/SuperB/A3 305 x 487 mm
LETTER_PLUS, // 59 Letter Plus 8.5 x 12.69 in kLetterPlus, // 59 Letter Plus 8.5 x 12.69 in
A4_PLUS, // 60 A4 Plus 210 x 330 mm kA4Plus, // 60 A4 Plus 210 x 330 mm
A5_TRANSVERSE, // 61 A5 Transverse 148 x 210 mm kA5Transverse, // 61 A5 Transverse 148 x 210 mm
B5_TRANSVERSE, // 62 B5 (JIS) Transverse 182 x 257 mm kB5Transverse, // 62 B5 (JIS) Transverse 182 x 257 mm
A3_EXTRA, // 63 A3 Extra 322 x 445 mm kA3Extra, // 63 A3 Extra 322 x 445 mm
A5_EXTRA, // 64 A5 Extra 174 x 235 mm kA5Extra, // 64 A5 Extra 174 x 235 mm
B5_EXTRA, // 65 B5 (ISO) Extra 201 x 276 mm kB5Extra, // 65 B5 (ISO) Extra 201 x 276 mm
A2, // 66 A2 420 x 594 mm kA2, // 66 A2 420 x 594 mm
A3_TRANSVERSE, // 67 A3 Transverse 297 x 420 mm kA3Transverse, // 67 A3 Transverse 297 x 420 mm
A3_EXTRA_TRANSVERSE, // 68 A3 Extra Transverse 322 x 445 mm kA3ExtraTransverse, // 68 A3 Extra Transverse 322 x 445 mm
DBL_JAPANESE_POSTCARD, // 69 Japanese Double Postcard 200 x 148 mm kDBLJapanesePostcard, // 69 Japanese Double Postcard 200 x 148 mm
A6, // 70 A6 105 x 148 mm kA6, // 70 A6 105 x 148 mm
JENV_KAKU2, // 71 Japanese Envelope Kaku #2 kJEnvKaku2, // 71 Japanese Envelope Kaku #2
JENV_KAKU3, // 72 Japanese Envelope Kaku #3 kJEnvKaku3, // 72 Japanese Envelope Kaku #3
JENV_CHOU3, // 73 Japanese Envelope Chou #3 kJEnvChou3, // 73 Japanese Envelope Chou #3
JENV_CHOU4, // 74 Japanese Envelope Chou #4 kJEnvChou4, // 74 Japanese Envelope Chou #4
LETTER_ROTATED, // 75 Letter Rotated 11 x 8 1/2 11 in kLetterRotated, // 75 Letter Rotated 11 x 8 1/2 11 in
A3_ROTATED, // 76 A3 Rotated 420 x 297 mm kA3Rotated, // 76 A3 Rotated 420 x 297 mm
A4_ROTATED, // 77 A4 Rotated 297 x 210 mm kA4Rotated, // 77 A4 Rotated 297 x 210 mm
A5_ROTATED, // 78 A5 Rotated 210 x 148 mm kA5Rotated, // 78 A5 Rotated 210 x 148 mm
B4_JIS_ROTATED, // 79 B4 (JIS) Rotated 364 x 257 mm kB4JISRotated, // 79 B4 (JIS) Rotated 364 x 257 mm
B5_JIS_ROTATED, // 80 B5 (JIS) Rotated 257 x 182 mm kB5JISRotated, // 80 B5 (JIS) Rotated 257 x 182 mm
JAPANESE_POSTCARD_ROTATED, // 81 Japanese Postcard Rotated 148 x 100 mm kJapanesePostcardRotated, // 81 Japanese Postcard Rotated 148 x 100 mm
DBL_JAPANESE_POSTCARD_ROTATED, // 82 Double Japanese Postcard Rotated 148 x 200 mm kDBLJapanesePostcardRotated, // 82 Double Japanese Postcard Rotated 148 x 200 mm
A6_ROTATED, // 83 A6 Rotated 148 x 105 mm kA6Rotated, // 83 A6 Rotated 148 x 105 mm
JENV_KAKU2_ROTATED, // 84 Japanese Envelope Kaku #2 Rotated kJEnvKaku2Rotated, // 84 Japanese Envelope Kaku #2 Rotated
JENV_KAKU3_ROTATED, // 85 Japanese Envelope Kaku #3 Rotated kJEnvKaku3Rotated, // 85 Japanese Envelope Kaku #3 Rotated
JENV_CHOU3_ROTATED, // 86 Japanese Envelope Chou #3 Rotated kJEnvChou3Rotated, // 86 Japanese Envelope Chou #3 Rotated
JENV_CHOU4_ROTATED, // 87 Japanese Envelope Chou #4 Rotated kJEnvChou4Rotated, // 87 Japanese Envelope Chou #4 Rotated
B6_JIS, // 88 B6 (JIS) 128 x 182 mm kB6JIS, // 88 B6 (JIS) 128 x 182 mm
B6_JIS_ROTATED, // 89 B6 (JIS) Rotated 182 x 128 mm kB6JISRotated, // 89 B6 (JIS) Rotated 182 x 128 mm
P_12X11, // 90 12 x 11 in k12X11, // 90 12 x 11 in
JENV_YOU4, // 91 Japanese Envelope You #4 kJEnvYou4, // 91 Japanese Envelope You #4
JENV_YOU4_ROTATED, // 92 Japanese Envelope You #4 Rotated kJEnvYou4Rotated, // 92 Japanese Envelope You #4 Rotated
P16K, // 93 PRC 16K 146 x 215 mm kP16K, // 93 PRC 16K 146 x 215 mm
P32K, // 94 PRC 32K 97 x 151 mm kP32K, // 94 PRC 32K 97 x 151 mm
P32KBIG, // 95 PRC 32K(Big) 97 x 151 mm kP32KBig, // 95 PRC 32K(Big) 97 x 151 mm
PENV_1, // 96 PRC Envelope #1 102 x 165 mm kPEnv1, // 96 PRC Envelope #1 102 x 165 mm
PENV_2, // 97 PRC Envelope #2 102 x 176 mm kPEnv2, // 97 PRC Envelope #2 102 x 176 mm
PENV_3, // 98 PRC Envelope #3 125 x 176 mm kPEnv3, // 98 PRC Envelope #3 125 x 176 mm
PENV_4, // 99 PRC Envelope #4 110 x 208 mm kPEnv4, // 99 PRC Envelope #4 110 x 208 mm
PENV_5, // 100 PRC Envelope #5 110 x 220 mm kPEnv5, // 100 PRC Envelope #5 110 x 220 mm
PENV_6, // 101 PRC Envelope #6 120 x 230 mm kPEnv6, // 101 PRC Envelope #6 120 x 230 mm
PENV_7, // 102 PRC Envelope #7 160 x 230 mm kPEnv7, // 102 PRC Envelope #7 160 x 230 mm
PENV_8, // 103 PRC Envelope #8 120 x 309 mm kPEnv8, // 103 PRC Envelope #8 120 x 309 mm
PENV_9, // 104 PRC Envelope #9 229 x 324 mm kPEnv9, // 104 PRC Envelope #9 229 x 324 mm
PENV_10, // 105 PRC Envelope #10 324 x 458 mm kPEnv10, // 105 PRC Envelope #10 324 x 458 mm
P16K_ROTATED, // 106 PRC 16K Rotated kP16KRotated, // 106 PRC 16K Rotated
P32K_ROTATED, // 107 PRC 32K Rotated kP32KRotated, // 107 PRC 32K Rotated
P32KBIG_ROTATED, // 108 PRC 32K(Big) Rotated kP32KBIGRotated, // 108 PRC 32K(Big) Rotated
PENV_1_ROTATED, // 109 PRC Envelope #1 Rotated 165 x 102 mm kPEnv1Rotated, // 109 PRC Envelope #1 Rotated 165 x 102 mm
PENV_2_ROTATED, // 110 PRC Envelope #2 Rotated 176 x 102 mm kPEnv2Rotated, // 110 PRC Envelope #2 Rotated 176 x 102 mm
PENV_3_ROTATED, // 111 PRC Envelope #3 Rotated 176 x 125 mm kPEnv3Rotated, // 111 PRC Envelope #3 Rotated 176 x 125 mm
PENV_4_ROTATED, // 112 PRC Envelope #4 Rotated 208 x 110 mm kPEnv4Rotated, // 112 PRC Envelope #4 Rotated 208 x 110 mm
PENV_5_ROTATED, // 113 PRC Envelope #5 Rotated 220 x 110 mm kPEnv5Rotated, // 113 PRC Envelope #5 Rotated 220 x 110 mm
PENV_6_ROTATED, // 114 PRC Envelope #6 Rotated 230 x 120 mm kPEnv6Rotated, // 114 PRC Envelope #6 Rotated 230 x 120 mm
PENV_7_ROTATED, // 115 PRC Envelope #7 Rotated 230 x 160 mm kPEnv7Rotated, // 115 PRC Envelope #7 Rotated 230 x 160 mm
PENV_8_ROTATED, // 116 PRC Envelope #8 Rotated 309 x 120 mm kPEnv8Rotated, // 116 PRC Envelope #8 Rotated 309 x 120 mm
PENV_9_ROTATED, // 117 PRC Envelope #9 Rotated 324 x 229 mm kPEnv9Rotated, // 117 PRC Envelope #9 Rotated 324 x 229 mm
PENV_10_ROTATED, // 118 PRC Envelope #10 Rotated 458 x 324 mm kPEnv10Rotated, // 118 PRC Envelope #10 Rotated 458 x 324 mm
USER_DEFINED = 256 kUserDefined = 256
}; };
enum PAPERSOURCE { enum PaperSource {
AUTO, // 7 o kAuto, // 7 o
MANUAL, // 4 o kManual, // 4 o
UPPER, // 1 o kUpper, // 1 o
MIDDLE, // 3 o kMiddle, // 3 o
LOWER, // 2 o kLower, // 2 o
// ONLYONE, // 1 x // kOnlyOne, // 1 x
// ENVELOPE, // 5 o // kEnvelope, // 5 o
// ENVMANUAL, // 6 x // kEnvManual, // 6 x
// TRACTOR, // 8 x // kTractor, // 8 x
// SMALLFMT, // 9 x // kSmallFmt, // 9 x
// LARGEFMT, // 10 x // kLargeFmt, // 10 x
// LARGECAPACITY, // 11 x // kLargeCapacity, // 11 x
// CASSETTE, // 14 x // kCassette, // 14 x
// FORMSOURCE, // 15 x // kFormSource, // 15 x
CASSETTE1 = 21, kCassette1 = 21,
CASSETTE2, kCassette2,
CASSETTE3, kCassette3,
CASSETTE4, kCassette4,
CASSETTE5, kCassette5,
CASSETTE6, kCassette6,
CASSETTE7, kCassette7,
CASSETTE8, kCassette8,
CASSETTE9, kCassette9,
USER = 256 // device specific bins start here kUser = 256 // device specific bins start here
}; };
enum PRINTSTYLE { enum PrintStyle {
SIMPLEX, kSimplex,
DUPLEX, kDuplex,
BOOKLET kBooklet
}; };
enum BINDINGLOCATION { enum BindingLocation {
LONG_EDGE_LEFT, kLongEdgeLeft,
LONG_EDGE_RIGHT, kLongEdgeRight,
SHORT_EDGE_TOP, kShortEdgeTop,
SHORT_EDGE_BOTTOM, kShortEdgeBottom,
LONG_EDGE = LONG_EDGE_LEFT, kLongEdge = kLongEdgeLeft,
SHORT_EDGE = SHORT_EDGE_TOP kShortEdge = kShortEdgeTop
}; };
enum PAGEORDER { enum PageOrder {
ACROSS_FROM_LEFT, kAcrossFromLeft,
DOWN_FROM_LEFT, kDownFromLeft,
ACROSS_FROM_RIGHT, kAcrossFromRight,
DOWN_FROM_RIGHT, kDownFromRight,
LEFT_TO_RIGHT = ACROSS_FROM_LEFT, kLeftToRight = kAcrossFromLeft,
RIGHT_TO_LEFT = ACROSS_FROM_RIGHT kRightToLeft = kAcrossFromRight
}; };
/* /*
enum QUALITY { enum Quality {
DRAFT = -1, kDraft = -1,
LOW = -2, kLow = -2,
MEDIUM = -3, kMedium = -3,
HIGH = -4 kHigh = -4
}; };
*/ */
enum COLOR { enum Color {
kMONOCHROME = 1, kMonochrome = 1,
kCOLOR kColor
}; };
private: private:
PAPER __paper; Paper fPaper;
int32 __xres; int32 fXRes;
int32 __yres; int32 fYRes;
ORIENTATION __orientation; Orientation fOrientation;
float __scaling; float fScaling;
BRect __paper_rect; BRect fPaperRect;
BRect __printable_rect; BRect fPrintableRect;
int32 __nup; int32 fNup;
int32 __first_page; int32 fFirstPage;
int32 __last_page; int32 fLastPage;
color_space __surface_type; float fGamma;
float __gamma; PaperSource fPaperSource;
PAPERSOURCE __paper_source; int32 fCopies;
int32 __copies; bool fCollate;
bool __collate; bool fReverse;
bool __reverse; PrintStyle fPrintStyle;
PRINTSTYLE __print_style; BindingLocation fBindingLocation;
BINDINGLOCATION __binding_location; PageOrder fPageOrder;
PAGEORDER __page_order; BMessage *fMsg;
BMessage *__msg; bool fColor;
bool __color;
public: public:
JobData(BMessage *msg, const PrinterCap *cap); JobData(BMessage *msg, const PrinterCap *cap);
@@ -240,65 +239,65 @@ public:
void load(BMessage *msg, const PrinterCap *cap); void load(BMessage *msg, const PrinterCap *cap);
void save(BMessage *msg = NULL); void save(BMessage *msg = NULL);
PAPER getPaper() const { return __paper; } Paper getPaper() const { return fPaper; }
void setPaper(PAPER paper) { __paper = paper; } void setPaper(Paper paper) { fPaper = paper; }
int32 getXres() const { return __xres; } int32 getXres() const { return fXRes; }
void setXres(int32 xres) { __xres = xres; } void setXres(int32 xres) { fXRes = xres; }
int32 getYres() const { return __yres; } int32 getYres() const { return fYRes; }
void setYres(int32 yres) { __yres = yres; }; void setYres(int32 yres) { fYRes = yres; };
ORIENTATION getOrientation() const { return __orientation; } Orientation getOrientation() const { return fOrientation; }
void setOrientation(ORIENTATION orientation) { __orientation = orientation; } void setOrientation(Orientation orientation) { fOrientation = orientation; }
float getScaling() const { return __scaling; } float getScaling() const { return fScaling; }
void setScaling(float scaling) { __scaling = scaling; } void setScaling(float scaling) { fScaling = scaling; }
const BRect &getPaperRect() const { return __paper_rect; } const BRect &getPaperRect() const { return fPaperRect; }
void setPaperRect(const BRect &paper_rect) { __paper_rect = paper_rect; } void setPaperRect(const BRect &paper_rect) { fPaperRect = paper_rect; }
const BRect &getPrintableRect() const { return __printable_rect; } const BRect &getPrintableRect() const { return fPrintableRect; }
void setPrintableRect(const BRect &printable_rect) { __printable_rect = printable_rect; } void setPrintableRect(const BRect &printable_rect) { fPrintableRect = printable_rect; }
int32 getNup() const { return __nup; } int32 getNup() const { return fNup; }
void setNup(int32 nup) { __nup = nup; } void setNup(int32 nup) { fNup = nup; }
bool getReverse() const { return __reverse; } bool getReverse() const { return fReverse; }
void setReverse(bool reverse) { __reverse = reverse; } void setReverse(bool reverse) { fReverse = reverse; }
int32 getFirstPage() const { return __first_page; } int32 getFirstPage() const { return fFirstPage; }
void setFirstPage(int32 first_page) { __first_page = first_page; } void setFirstPage(int32 first_page) { fFirstPage = first_page; }
int32 getLastPage() const { return __last_page; } int32 getLastPage() const { return fLastPage; }
void setLastPage(int32 last_page) { __last_page = last_page; } void setLastPage(int32 last_page) { fLastPage = last_page; }
color_space getSurfaceType() const { return B_RGB32; /* __surface_type;*/ } // libprint supports only B_RGB32
void setSurfaceType(color_space surface_type) { __surface_type = surface_type; } color_space getSurfaceType() const { return B_RGB32; }
float getGamma() const { return __gamma; } float getGamma() const { return fGamma; }
void setGamma(float gamma) { __gamma = gamma; } void setGamma(float gamma) { fGamma = gamma; }
PAPERSOURCE getPaperSource() const { return __paper_source; } PaperSource getPaperSource() const { return fPaperSource; }
void setPaperSource(PAPERSOURCE paper_source) { __paper_source = paper_source; }; void setPaperSource(PaperSource paper_source) { fPaperSource = paper_source; };
int32 getCopies() const { return __copies; } int32 getCopies() const { return fCopies; }
void setCopies(int32 copies) { __copies = copies; } void setCopies(int32 copies) { fCopies = copies; }
bool getCollate() const { return __collate; } bool getCollate() const { return fCollate; }
void setCollate(bool collate) { __collate = collate; } void setCollate(bool collate) { fCollate = collate; }
PRINTSTYLE getPrintStyle() const { return __print_style; } PrintStyle getPrintStyle() const { return fPrintStyle; }
void setPrintStyle(PRINTSTYLE print_style) { __print_style = print_style; } void setPrintStyle(PrintStyle print_style) { fPrintStyle = print_style; }
BINDINGLOCATION getBindingLocation() const { return __binding_location; } BindingLocation getBindingLocation() const { return fBindingLocation; }
void setBindingLocation(BINDINGLOCATION binding_location) { __binding_location = binding_location; } void setBindingLocation(BindingLocation binding_location) { fBindingLocation = binding_location; }
PAGEORDER getPageOrder() const { return __page_order; } PageOrder getPageOrder() const { return fPageOrder; }
void setPageOrder(PAGEORDER page_order) { __page_order = page_order; } void setPageOrder(PageOrder page_order) { fPageOrder = page_order; }
COLOR getColor() const { return __color ? kCOLOR : kMONOCHROME; } Color getColor() const { return fColor ? kColor : kMonochrome; }
void setColor(COLOR color) { __color = color == kCOLOR; } void setColor(Color color) { fColor = color == kColor; }
/* /*
protected: protected:
JobData(const JobData &job_data); JobData(const JobData &job_data);
+14 -14
View File
@@ -30,17 +30,17 @@ public:
BTextControl *to_page; BTextControl *to_page;
private: private:
JobData *__job_data; JobData *fJobData;
PrinterData *__printer_data; PrinterData *fPrinterData;
const PrinterCap *__printer_cap; const PrinterCap *fPrinterCap;
BTextControl *__gamma; BTextControl *fGamma;
BRadioButton *__all; BRadioButton *fAll;
BCheckBox *__collate; BCheckBox *fCollate;
BCheckBox *__reverse; BCheckBox *fReverse;
BPopUpMenu *__color_type; BPopUpMenu *fColorType;
BPopUpMenu *__paper_feed; BPopUpMenu *fPaperFeed;
BCheckBox *__duplex; BCheckBox *fDuplex;
BPopUpMenu *__nup; BPopUpMenu *fNup;
}; };
class JobSetupDlg : public BWindow { class JobSetupDlg : public BWindow {
@@ -52,9 +52,9 @@ public:
int Go(); int Go();
private: private:
int __result; int fResult;
long __semaphore; long fSemaphore;
BMessageFilter *__filter; BMessageFilter *fFilter;
}; };
#endif /* __JOBSETUPDLG_H */ #endif /* __JOBSETUPDLG_H */
@@ -23,12 +23,12 @@ public:
bool UpdateJobData(); bool UpdateJobData();
private: private:
JobData *__job_data; JobData *fJobData;
PrinterData *__printer_data; PrinterData *fPrinterData;
const PrinterCap *__printer_cap; const PrinterCap *fPrinterCap;
BRadioButton *__portrait; BRadioButton *fPortrait;
BPopUpMenu *__paper; BPopUpMenu *fPaper;
BPopUpMenu *__resolution; BPopUpMenu *fResolution;
}; };
class PageSetupDlg : public BWindow { class PageSetupDlg : public BWindow {
@@ -40,9 +40,9 @@ public:
int Go(); int Go();
private: private:
int __result; int fResult;
long __semaphore; long fSemaphore;
BMessageFilter *__filter; BMessageFilter *fFilter;
}; };
#endif /* __PAGESETUPDLG_H */ #endif /* __PAGESETUPDLG_H */
+1 -1
View File
@@ -22,7 +22,7 @@ protected:
PreviewWindow &operator = (const PreviewWindow &); PreviewWindow &operator = (const PreviewWindow &);
private: private:
long __semaphore; long fSemaphore;
}; };
#endif /* __PREVIEW_H */ #endif /* __PREVIEW_H */
@@ -39,12 +39,12 @@ public:
bool enumObject(PictureData **); bool enumObject(PictureData **);
private: private:
BFile *__file; BFile *fFile;
bool __reverse; bool fReverse;
int __picture_count; int fPictureCount;
int __rest; int fRest;
off_t __offset; off_t fOffset;
bool __hollow; bool fHollow;
}; };
typedef list<PageData *> PageDataList; typedef list<PageData *> PageDataList;
@@ -57,8 +57,8 @@ public:
bool enumObject(PageData **); bool enumObject(PageData **);
private: private:
PageDataList __pages; PageDataList fPages;
PageDataList::iterator __it; PageDataList::iterator fIt;
}; };
#endif /* __PRINTPROCESS_H */ #endif /* __PRINTPROCESS_H */
+32 -30
View File
@@ -16,7 +16,9 @@ using namespace std;
#define std #define std
#endif #endif
#define UNKNOWN_PRINTER 0 enum {
kUnknownPrinter = 0
};
struct BaseCap { struct BaseCap {
string label; string label;
@@ -25,16 +27,16 @@ struct BaseCap {
}; };
struct PaperCap : public BaseCap { struct PaperCap : public BaseCap {
JobData::PAPER paper; JobData::Paper paper;
BRect paper_rect; BRect paper_rect;
BRect printable_rect; BRect printable_rect;
PaperCap(const string &n, bool d, JobData::PAPER p, const BRect &r1, const BRect &r2) PaperCap(const string &n, bool d, JobData::Paper p, const BRect &r1, const BRect &r2)
: BaseCap(n, d), paper(p), paper_rect(r1), printable_rect(r2) {} : BaseCap(n, d), paper(p), paper_rect(r1), printable_rect(r2) {}
}; };
struct PaperSourceCap : public BaseCap { struct PaperSourceCap : public BaseCap {
JobData::PAPERSOURCE paper_source; JobData::PaperSource paper_source;
PaperSourceCap(const string &n, bool d, JobData::PAPERSOURCE f) PaperSourceCap(const string &n, bool d, JobData::PaperSource f)
: BaseCap(n, d), paper_source(f) {} : BaseCap(n, d), paper_source(f) {}
}; };
@@ -46,26 +48,26 @@ struct ResolutionCap : public BaseCap {
}; };
struct OrientationCap : public BaseCap { struct OrientationCap : public BaseCap {
JobData::ORIENTATION orientation; JobData::Orientation orientation;
OrientationCap(const string &n, bool d, JobData::ORIENTATION o) OrientationCap(const string &n, bool d, JobData::Orientation o)
: BaseCap(n, d), orientation(o) {} : BaseCap(n, d), orientation(o) {}
}; };
struct PrintStyleCap : public BaseCap { struct PrintStyleCap : public BaseCap {
JobData::PRINTSTYLE print_style; JobData::PrintStyle print_style;
PrintStyleCap(const string &n, bool d, JobData::PRINTSTYLE x) PrintStyleCap(const string &n, bool d, JobData::PrintStyle x)
: BaseCap(n, d), print_style(x) {} : BaseCap(n, d), print_style(x) {}
}; };
struct BindingLocationCap : public BaseCap { struct BindingLocationCap : public BaseCap {
JobData::BINDINGLOCATION binding_location; JobData::BindingLocation binding_location;
BindingLocationCap(const string &n, bool d, JobData::BINDINGLOCATION b) BindingLocationCap(const string &n, bool d, JobData::BindingLocation b)
: BaseCap(n, d), binding_location(b) {} : BaseCap(n, d), binding_location(b) {}
}; };
struct ColorCap : public BaseCap { struct ColorCap : public BaseCap {
JobData::COLOR color; JobData::Color color;
ColorCap(const string &n, bool d, JobData::COLOR c) ColorCap(const string &n, bool d, JobData::Color c)
: BaseCap(n, d), color(c) {} : BaseCap(n, d), color(c) {}
}; };
@@ -79,20 +81,20 @@ public:
PrinterCap(const PrinterCap &printer_cap); PrinterCap(const PrinterCap &printer_cap);
PrinterCap &operator = (const PrinterCap &printer_cap); PrinterCap &operator = (const PrinterCap &printer_cap);
*/ */
enum CAPID { enum CapID {
PAPER, kPaper,
PAPERSOURCE, kPaperSource,
RESOLUTION, kResolution,
ORIENTATION, kOrientation,
PRINTSTYLE, kPrintStyle,
BINDINGLOCATION, kBindingLocation,
COLOR kColor
}; };
virtual int countCap(CAPID) const = 0; virtual int countCap(CapID) const = 0;
virtual bool isSupport(CAPID) const = 0; virtual bool isSupport(CapID) const = 0;
virtual const BaseCap **enumCap(CAPID) const = 0; virtual const BaseCap **enumCap(CapID) const = 0;
const BaseCap *getDefaultCap(CAPID) const; const BaseCap *getDefaultCap(CapID) const;
int getPrinterId() const; int getPrinterId() const;
protected: protected:
@@ -102,23 +104,23 @@ protected:
void setPrinterId(int id); void setPrinterId(int id);
private: private:
const PrinterData *__printer_data; const PrinterData *fPrinterData;
int __printer_id; int fPrinterID;
}; };
inline const PrinterData *PrinterCap::getPrinterData() const inline const PrinterData *PrinterCap::getPrinterData() const
{ {
return __printer_data; return fPrinterData;
} }
inline int PrinterCap::getPrinterId() const inline int PrinterCap::getPrinterId() const
{ {
return __printer_id; return fPrinterID;
} }
inline void PrinterCap::setPrinterId(int id) inline void PrinterCap::setPrinterId(int id)
{ {
__printer_id = id; fPrinterID = id;
} }
#endif /* __PRINTERCAP_H */ #endif /* __PRINTERCAP_H */
+12 -12
View File
@@ -33,7 +33,7 @@ public:
const string &getComments() const; const string &getComments() const;
const string &getTransport() const; const string &getTransport() const;
// void setDriverName(const char *s) { __driver_name = driver_name; } // void setDriverName(const char *s) { fDriverName = driver_name; }
void setPrinterName(const char *printer_name); void setPrinterName(const char *printer_name);
void setComments(const char *comments); void setComments(const char *comments);
@@ -44,41 +44,41 @@ protected:
PrinterData &operator = (const PrinterData &printer_data); PrinterData &operator = (const PrinterData &printer_data);
private: private:
string __driver_name; string fDriverName;
string __printer_name; string fPrinterName;
string __comments; string fComments;
string __transport; string fTransport;
BNode *__node; BNode *fNode;
}; };
inline const string &PrinterData::getDriverName() const inline const string &PrinterData::getDriverName() const
{ {
return __driver_name; return fDriverName;
} }
inline const string &PrinterData::getPrinterName() const inline const string &PrinterData::getPrinterName() const
{ {
return __printer_name; return fPrinterName;
} }
inline const string &PrinterData::getComments() const inline const string &PrinterData::getComments() const
{ {
return __comments; return fComments;
} }
inline const string &PrinterData::getTransport() const inline const string &PrinterData::getTransport() const
{ {
return __transport; return fTransport;
} }
inline void PrinterData::setPrinterName(const char *printer_name) inline void PrinterData::setPrinterName(const char *printer_name)
{ {
__printer_name = printer_name; fPrinterName = printer_name;
} }
inline void PrinterData::setComments(const char *comments) inline void PrinterData::setComments(const char *comments)
{ {
__comments = comments; fComments = comments;
} }
#endif // __PRINTERDATA_H #endif // __PRINTERDATA_H
@@ -12,17 +12,17 @@
class SpoolMetaData { class SpoolMetaData {
private: private:
string __description; string fDescription;
string __mime_type; string fMimeType;
string __creation_time; string fCreationTime;
public: public:
SpoolMetaData(BFile* spool_file); SpoolMetaData(BFile* spool_file);
~SpoolMetaData(); ~SpoolMetaData();
const string& getDescription() const { return __description; } const string& getDescription() const { return fDescription; }
const string& getMimeType() const { return __mime_type; } const string& getMimeType() const { return fMimeType; }
const string& getCreationTime() const { return __creation_time; } const string& getCreationTime() const { return fCreationTime; }
}; };
#endif /* __SpoolMetaData_H */ #endif /* __SpoolMetaData_H */
+9 -9
View File
@@ -25,10 +25,10 @@ extern "C" {
class TransportException { class TransportException {
private: private:
string __str; string fWhat;
public: public:
TransportException(const string &what_arg) : __str(what_arg) {} TransportException(const string &what_arg) : fWhat(what_arg) {}
const char *what() const { return __str.c_str(); } const char *what() const { return fWhat.c_str(); }
}; };
class Transport { class Transport {
@@ -45,12 +45,12 @@ protected:
Transport &operator = (const Transport &); Transport &operator = (const Transport &);
private: private:
image_id __image; image_id fImage;
PFN_init_transport __init_transport; PFN_init_transport fInitTransport;
PFN_exit_transport __exit_transport; PFN_exit_transport fExitTransport;
BDataIO *__data_stream; BDataIO *fDataStream;
bool __abort; bool fAbort;
string __last_error_string; string fLastErrorString;
}; };
#endif // __TRANSPORT_H #endif // __TRANSPORT_H
+3 -3
View File
@@ -26,9 +26,9 @@ protected:
UIDriver &operator = (const UIDriver &); UIDriver &operator = (const UIDriver &);
private: private:
BMessage *__msg; BMessage *fMsg;
PrinterData *__printer_data; PrinterData *fPrinterData;
const PrinterCap *__printer_cap; const PrinterCap *fPrinterCap;
}; };
#endif /* __UIDRIVER_H */ #endif /* __UIDRIVER_H */
+1 -1
View File
@@ -17,7 +17,7 @@ struct RECT {
int bottom; int bottom;
}; };
bool get_valid_rect(BBitmap *bitmap, const rgb_color *palette, RECT *rc); bool get_valid_rect(BBitmap *bitmap, RECT *rc);
int color_space2pixel_depth(color_space cs); int color_space2pixel_depth(color_space cs);
@@ -18,6 +18,11 @@ using namespace std;
#define std #define std
#endif #endif
enum {
kMsgOK = 'AbOK'
};
class AboutBoxView : public BView { class AboutBoxView : public BView {
public: public:
AboutBoxView(BRect frame, const char *driver_name, const char *version, const char *copyright); AboutBoxView(BRect frame, const char *driver_name, const char *version, const char *copyright);
@@ -25,17 +30,17 @@ public:
virtual void AttachedToWindow(); virtual void AttachedToWindow();
private: private:
string __driver_name; string fDriverName;
string __version; string fVersion;
string __copyright; string fCopyright;
}; };
AboutBoxView::AboutBoxView(BRect rect, const char *driver_name, const char *version, const char *copyright) AboutBoxView::AboutBoxView(BRect rect, const char *driver_name, const char *version, const char *copyright)
: BView(rect, "", B_FOLLOW_ALL, B_WILL_DRAW) : BView(rect, "", B_FOLLOW_ALL, B_WILL_DRAW)
{ {
__driver_name = driver_name; fDriverName = driver_name;
__version = version; fVersion = version;
__copyright = copyright; fCopyright = copyright;
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
SetDrawingMode(B_OP_SELECT); SetDrawingMode(B_OP_SELECT);
} }
@@ -43,7 +48,7 @@ AboutBoxView::AboutBoxView(BRect rect, const char *driver_name, const char *vers
void AboutBoxView::Draw(BRect) void AboutBoxView::Draw(BRect)
{ {
SetHighColor(0, 0, 0); SetHighColor(0, 0, 0);
DrawString(__driver_name.c_str(), BPoint(10.0f, 16.0f)); DrawString(fDriverName.c_str(), BPoint(10.0f, 16.0f));
DrawString(" Driver for "); DrawString(" Driver for ");
SetHighColor(0, 0, 0xff); SetHighColor(0, 0, 0xff);
DrawString("B"); DrawString("B");
@@ -51,17 +56,15 @@ void AboutBoxView::Draw(BRect)
DrawString("e"); DrawString("e");
SetHighColor(0, 0, 0); SetHighColor(0, 0, 0);
DrawString("OS Version "); DrawString("OS Version ");
DrawString(__version.c_str()); DrawString(fVersion.c_str());
DrawString(__copyright.c_str(), BPoint(10.0f, 30.0f)); DrawString(fCopyright.c_str(), BPoint(10.0f, 30.0f));
} }
#define M_OK 1
void AboutBoxView::AttachedToWindow() void AboutBoxView::AttachedToWindow()
{ {
BRect rect; BRect rect;
rect.Set(110, 50, 175, 55); rect.Set(110, 50, 175, 55);
BButton *button = new BButton(rect, "", "OK", new BMessage(M_OK)); BButton *button = new BButton(rect, "", "OK", new BMessage(kMsgOK));
AddChild(button); AddChild(button);
button->MakeDefault(true); button->MakeDefault(true);
} }
@@ -85,7 +88,7 @@ AboutBoxWindow::AboutBoxWindow(BRect frame, const char *driver_name, const char
void AboutBoxWindow::MessageReceived(BMessage *msg) void AboutBoxWindow::MessageReceived(BMessage *msg)
{ {
switch (msg->what) { switch (msg->what) {
case M_OK: case kMsgOK:
be_app->PostMessage(B_QUIT_REQUESTED); be_app->PostMessage(B_QUIT_REQUESTED);
break; break;
} }
@@ -34,15 +34,19 @@ using namespace std;
#define std #define std
#endif #endif
enum {
kMaxMemorySize = (4 *1024 *1024)
};
GraphicsDriver::GraphicsDriver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap) GraphicsDriver::GraphicsDriver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap)
: __msg(msg), __printer_data(printer_data), __printer_cap(printer_cap) : fMsg(msg), fPrinterData(printer_data), fPrinterCap(printer_cap)
{ {
__view = NULL; fView = NULL;
__bitmap = NULL; fBitmap = NULL;
__transport = NULL; fTransport = NULL;
__org_job_data = NULL; fOrgJobData = NULL;
__real_job_data = NULL; fRealJobData = NULL;
__spool_meta_data = NULL; fSpoolMetaData = NULL;
} }
GraphicsDriver::~GraphicsDriver() GraphicsDriver::~GraphicsDriver()
@@ -53,96 +57,94 @@ void GraphicsDriver::setupData(BFile *spool_file, long page_count)
{ {
BMessage *msg = new BMessage(); BMessage *msg = new BMessage();
msg->Unflatten(spool_file); msg->Unflatten(spool_file);
__org_job_data = new JobData(msg, __printer_cap); fOrgJobData = new JobData(msg, fPrinterCap);
DUMP_BMESSAGE(msg); DUMP_BMESSAGE(msg);
delete msg; delete msg;
__real_job_data = new JobData(*__org_job_data); fRealJobData = new JobData(*fOrgJobData);
BRect rc; BRect rc;
switch (__org_job_data->getNup()) { switch (fOrgJobData->getNup()) {
case 2: case 2:
case 8: case 8:
case 32: case 32:
case 128: case 128:
rc.left = __org_job_data->getPrintableRect().top; rc.left = fOrgJobData->getPrintableRect().top;
rc.top = __org_job_data->getPrintableRect().left; rc.top = fOrgJobData->getPrintableRect().left;
rc.right = __org_job_data->getPrintableRect().bottom; rc.right = fOrgJobData->getPrintableRect().bottom;
rc.bottom = __org_job_data->getPrintableRect().right; rc.bottom = fOrgJobData->getPrintableRect().right;
__real_job_data->setPrintableRect(rc); fRealJobData->setPrintableRect(rc);
if (JobData::PORTRAIT == __org_job_data->getOrientation()) if (JobData::kPortrait == fOrgJobData->getOrientation())
__real_job_data->setOrientation(JobData::LANDSCAPE); fRealJobData->setOrientation(JobData::kLandscape);
else else
__real_job_data->setOrientation(JobData::PORTRAIT); fRealJobData->setOrientation(JobData::kPortrait);
break; break;
} }
if (__org_job_data->getCollate() && page_count > 1) { if (fOrgJobData->getCollate() && page_count > 1) {
__real_job_data->setCopies(1); fRealJobData->setCopies(1);
__internal_copies = __org_job_data->getCopies(); fInternalCopies = fOrgJobData->getCopies();
} else { } else {
__internal_copies = 1; fInternalCopies = 1;
} }
__spool_meta_data = new SpoolMetaData(spool_file); fSpoolMetaData = new SpoolMetaData(spool_file);
} }
void GraphicsDriver::cleanupData() void GraphicsDriver::cleanupData()
{ {
delete __real_job_data; delete fRealJobData;
delete __org_job_data; delete fOrgJobData;
delete __spool_meta_data; delete fSpoolMetaData;
__real_job_data = NULL; fRealJobData = NULL;
__org_job_data = NULL; fOrgJobData = NULL;
__spool_meta_data = NULL; fSpoolMetaData = NULL;
} }
#define MAX_MEMORY_SIZE (4 *1024 *1024)
void GraphicsDriver::setupBitmap() void GraphicsDriver::setupBitmap()
{ {
__pixel_depth = color_space2pixel_depth(__org_job_data->getSurfaceType()); fPixelDepth = color_space2pixel_depth(fOrgJobData->getSurfaceType());
__page_width = (__real_job_data->getPrintableRect().IntegerWidth() * __org_job_data->getXres() + 71) / 72; fPageWidth = (fRealJobData->getPrintableRect().IntegerWidth() * fOrgJobData->getXres() + 71) / 72;
__page_height = (__real_job_data->getPrintableRect().IntegerHeight() * __org_job_data->getYres() + 71) / 72; fPageHeight = (fRealJobData->getPrintableRect().IntegerHeight() * fOrgJobData->getYres() + 71) / 72;
int widthByte = (__page_width * __pixel_depth + 7) / 8; int widthByte = (fPageWidth * fPixelDepth + 7) / 8;
int size = widthByte * __page_height; int size = widthByte * fPageHeight;
if (size < MAX_MEMORY_SIZE) { if (size < kMaxMemorySize) {
__band_count = 0; fBandCount = 0;
__band_width = __page_width; fBandWidth = fPageWidth;
__band_height = __page_height; fBandHeight = fPageHeight;
} else { } else {
__band_count = (size + MAX_MEMORY_SIZE - 1) / MAX_MEMORY_SIZE; fBandCount = (size + kMaxMemorySize - 1) / kMaxMemorySize;
if ((JobData::LANDSCAPE == __real_job_data->getOrientation()) && (__flags & GDF_ROTATE_BAND_BITMAP)) { if ((JobData::kLandscape == fRealJobData->getOrientation()) && (fFlags & kGDFRotateBandBitmap)) {
__band_width = (__page_width + __band_count - 1) / __band_count; fBandWidth = (fPageWidth + fBandCount - 1) / fBandCount;
__band_height = __page_height; fBandHeight = fPageHeight;
} else { } else {
__band_width = __page_width; fBandWidth = fPageWidth;
__band_height = (__page_height + __band_count - 1) / __band_count; fBandHeight = (fPageHeight + fBandCount - 1) / fBandCount;
} }
} }
DBGMSG(("****************\n")); DBGMSG(("****************\n"));
DBGMSG(("page_width = %d\n", __page_width)); DBGMSG(("page_width = %d\n", fPageWidth));
DBGMSG(("page_height = %d\n", __page_height)); DBGMSG(("page_height = %d\n", fPageHeight));
DBGMSG(("band_count = %d\n", __band_count)); DBGMSG(("band_count = %d\n", fBandCount));
DBGMSG(("band_height = %d\n", __band_height)); DBGMSG(("band_height = %d\n", fBandHeight));
DBGMSG(("****************\n")); DBGMSG(("****************\n"));
BRect rect; BRect rect;
rect.Set(0, 0, __band_width - 1, __band_height - 1); rect.Set(0, 0, fBandWidth - 1, fBandHeight - 1);
__bitmap = new BBitmap(rect, __org_job_data->getSurfaceType(), true); fBitmap = new BBitmap(rect, fOrgJobData->getSurfaceType(), true);
__view = new BView(rect, "", B_FOLLOW_ALL, B_WILL_DRAW); fView = new BView(rect, "", B_FOLLOW_ALL, B_WILL_DRAW);
__bitmap->AddChild(__view); fBitmap->AddChild(fView);
} }
void GraphicsDriver::cleanupBitmap() void GraphicsDriver::cleanupBitmap()
{ {
delete __bitmap; delete fBitmap;
__bitmap = NULL; fBitmap = NULL;
__view = NULL; fView = NULL;
} }
BPoint get_scale(JobData *org_job_data) BPoint get_scale(JobData *org_job_data)
@@ -243,7 +245,7 @@ BPoint get_offset(
break; break;
case 2: case 2:
if (index == 1) { if (index == 1) {
if (JobData::PORTRAIT == org_job_data->getOrientation()) { if (JobData::kPortrait == org_job_data->getOrientation()) {
offset.x = width; offset.x = width;
} else { } else {
offset.y = height; offset.y = height;
@@ -251,7 +253,7 @@ BPoint get_offset(
} }
break; break;
case 8: case 8:
if (JobData::PORTRAIT == org_job_data->getOrientation()) { if (JobData::kPortrait == org_job_data->getOrientation()) {
offset.x = width * (index / 2); offset.x = width * (index / 2);
offset.y = height * (index % 2); offset.y = height * (index % 2);
} else { } else {
@@ -260,7 +262,7 @@ BPoint get_offset(
} }
break; break;
case 32: case 32:
if (JobData::PORTRAIT == org_job_data->getOrientation()) { if (JobData::kPortrait == org_job_data->getOrientation()) {
offset.x = width * (index / 4); offset.x = width * (index / 4);
offset.y = height * (index % 4); offset.y = height * (index % 4);
} else { } else {
@@ -331,27 +333,27 @@ bool GraphicsDriver::printPage(PageDataList *pages)
} }
do { do {
__view->SetScale(1.0); fView->SetScale(1.0);
__view->SetHighColor(255, 255, 255); fView->SetHighColor(255, 255, 255);
__view->ConstrainClippingRegion(NULL); fView->ConstrainClippingRegion(NULL);
__view->FillRect(__view->Bounds()); fView->FillRect(fView->Bounds());
BPoint scale = get_scale(__org_job_data); BPoint scale = get_scale(fOrgJobData);
float real_scale = min(scale.x, scale.y) * __org_job_data->getXres() / 72.0f; float real_scale = min(scale.x, scale.y) * fOrgJobData->getXres() / 72.0f;
__view->SetScale(real_scale); fView->SetScale(real_scale);
float x = offset.x / real_scale; float x = offset.x / real_scale;
float y = offset.y / real_scale; float y = offset.y / real_scale;
int page_index = 0; int page_index = 0;
for (PageDataList::iterator it = pages->begin(); it != pages->end(); it++) { for (PageDataList::iterator it = pages->begin(); it != pages->end(); it++) {
BPoint left_top(get_offset(page_index++, &scale, __org_job_data)); BPoint left_top(get_offset(page_index++, &scale, fOrgJobData));
left_top.x -= x; left_top.x -= x;
left_top.y -= y; left_top.y -= y;
BRect clip(__org_job_data->getPrintableRect()); BRect clip(fOrgJobData->getPrintableRect());
clip.OffsetTo(left_top); clip.OffsetTo(left_top);
BRegion *region = new BRegion(); BRegion *region = new BRegion();
region->Set(clip); region->Set(clip);
__view->ConstrainClippingRegion(region); fView->ConstrainClippingRegion(region);
delete region; delete region;
if ((*it)->startEnum()) { if ((*it)->startEnum()) {
bool more; bool more;
@@ -359,37 +361,37 @@ bool GraphicsDriver::printPage(PageDataList *pages)
PictureData *picture_data; PictureData *picture_data;
more = (*it)->enumObject(&picture_data); more = (*it)->enumObject(&picture_data);
BPoint real_offset = left_top + picture_data->point; BPoint real_offset = left_top + picture_data->point;
__view->DrawPicture(picture_data->picture, real_offset); fView->DrawPicture(picture_data->picture, real_offset);
__view->Sync(); fView->Sync();
delete picture_data; delete picture_data;
} while (more); } while (more);
} }
} }
if (!nextBand(__bitmap, &offset)) { if (!nextBand(fBitmap, &offset)) {
return false; return false;
} }
} while (offset.x >= 0.0f && offset.y >= 0.0f); } while (offset.x >= 0.0f && offset.y >= 0.0f);
return true; return true;
#else // !USE_PREVIEW_FOR_DEBUG #else // !USE_PREVIEW_FOR_DEBUG
__view->SetScale(1.0); fView->SetScale(1.0);
__view->SetHighColor(255, 255, 255); fView->SetHighColor(255, 255, 255);
__view->ConstrainClippingRegion(NULL); fView->ConstrainClippingRegion(NULL);
__view->FillRect(__view->Bounds()); fView->FillRect(fView->Bounds());
BPoint scale = get_scale(__org_job_data); BPoint scale = get_scale(fOrgJobData);
__view->SetScale(min(scale.x, scale.y)); fView->SetScale(min(scale.x, scale.y));
int page_index = 0; int page_index = 0;
PageDataList::iterator it; PageDataList::iterator it;
for (it = pages->begin() ; it != pages->end() ; it++) { for (it = pages->begin() ; it != pages->end() ; it++) {
BPoint left_top(get_offset(page_index, &scale, __org_job_data)); BPoint left_top(get_offset(page_index, &scale, fOrgJobData));
BRect clip(__org_job_data->getPrintableRect()); BRect clip(fOrgJobData->getPrintableRect());
clip.OffsetTo(left_top); clip.OffsetTo(left_top);
BRegion *region = new BRegion(); BRegion *region = new BRegion();
region->Set(clip); region->Set(clip);
__view->ConstrainClippingRegion(region); fView->ConstrainClippingRegion(region);
delete region; delete region;
if ((*it)->startEnum()) { if ((*it)->startEnum()) {
bool more; bool more;
@@ -397,17 +399,17 @@ bool GraphicsDriver::printPage(PageDataList *pages)
PictureData *picture_data; PictureData *picture_data;
more = (*it)->enumObject(&picture_data); more = (*it)->enumObject(&picture_data);
BPoint real_offset = left_top + picture_data->point; BPoint real_offset = left_top + picture_data->point;
__view->DrawPicture(picture_data->picture, real_offset); fView->DrawPicture(picture_data->picture, real_offset);
__view->Sync(); fView->Sync();
delete picture_data; delete picture_data;
} while (more); } while (more);
} }
page_index++; page_index++;
} }
BRect rc(__real_job_data->getPrintableRect()); BRect rc(fRealJobData->getPrintableRect());
rc.OffsetTo(30.0, 30.0); rc.OffsetTo(30.0, 30.0);
PreviewWindow *preview = new PreviewWindow(rc, "Preview", __bitmap); PreviewWindow *preview = new PreviewWindow(rc, "Preview", fBitmap);
preview->Go(); preview->Go();
#endif // USE_PREVIEW_FOR_DEBUG #endif // USE_PREVIEW_FOR_DEBUG
} }
@@ -429,15 +431,15 @@ bool GraphicsDriver::printDocument(SpoolData *spool_data)
DBGMSG(("page index = %d\n", page_index)); DBGMSG(("page index = %d\n", page_index));
if (!(success = startPage(page_index))) if (!(success = startPage(page_index)))
break; break;
nup = __org_job_data->getNup(); nup = fOrgJobData->getNup();
PageDataList pages; PageDataList pages;
do { do {
more = spool_data->enumObject(&page_data); more = spool_data->enumObject(&page_data);
pages.push_back(page_data); pages.push_back(page_data);
} while (more && --nup); } while (more && --nup);
__view->Window()->Lock(); fView->Window()->Lock();
success = printPage(&pages); success = printPage(&pages);
__view->Window()->Unlock(); fView->Window()->Unlock();
if (!success) if (!success)
break; break;
if (!(success = endPage(page_index))) if (!(success = endPage(page_index)))
@@ -448,9 +450,9 @@ bool GraphicsDriver::printDocument(SpoolData *spool_data)
#ifndef USE_PREVIEW_FOR_DEBUG #ifndef USE_PREVIEW_FOR_DEBUG
if (success if (success
&& __printer_cap->isSupport(PrinterCap::PRINTSTYLE) && fPrinterCap->isSupport(PrinterCap::kPrintStyle)
&& (__org_job_data->getPrintStyle() != JobData::SIMPLEX) && (fOrgJobData->getPrintStyle() != JobData::kSimplex)
&& (((page_index + __org_job_data->getNup() - 1) / __org_job_data->getNup()) % 2)) && (((page_index + fOrgJobData->getNup() - 1) / fOrgJobData->getNup()) % 2))
{ {
success = startPage(page_index); success = startPage(page_index);
if (success) { if (success) {
@@ -481,17 +483,17 @@ bool GraphicsDriver::printJob(BFile *spool_file)
return true; return true;
} }
__transport = new Transport(__printer_data); fTransport = new Transport(fPrinterData);
if (__transport->check_abort()) { if (fTransport->check_abort()) {
success = false; success = false;
} else { } else {
setupData(spool_file, pfh.page_count); setupData(spool_file, pfh.page_count);
setupBitmap(); setupBitmap();
SpoolData spool_data(spool_file, pfh.page_count, __org_job_data->getNup(), __org_job_data->getReverse()); SpoolData spool_data(spool_file, pfh.page_count, fOrgJobData->getNup(), fOrgJobData->getReverse());
success = startDoc(); success = startDoc();
if (success) { if (success) {
while (__internal_copies--) { while (fInternalCopies--) {
success = printDocument(&spool_data); success = printDocument(&spool_data);
if (success == false) { if (success == false) {
break; break;
@@ -505,23 +507,23 @@ bool GraphicsDriver::printJob(BFile *spool_file)
if (success == false) { if (success == false) {
BAlert *alert; BAlert *alert;
if (__transport->check_abort()) { if (fTransport->check_abort()) {
alert = new BAlert("", __transport->last_error().c_str(), "OK"); alert = new BAlert("", fTransport->last_error().c_str(), "OK");
} else { } else {
alert = new BAlert("", "Printer not responding.", "OK"); alert = new BAlert("", "Printer not responding.", "OK");
} }
alert->Go(); alert->Go();
} }
delete __transport; delete fTransport;
__transport = NULL; fTransport = NULL;
return success; return success;
} }
BMessage *GraphicsDriver::takeJob(BFile* spool_file, uint32 flags) BMessage *GraphicsDriver::takeJob(BFile* spool_file, uint32 flags)
{ {
__flags = flags; fFlags = flags;
BMessage *msg; BMessage *msg;
if (printJob(spool_file)) { if (printJob(spool_file)) {
msg = new BMessage('okok'); msg = new BMessage('okok');
@@ -558,27 +560,27 @@ bool GraphicsDriver::endDoc(bool)
void GraphicsDriver::writeSpoolData(const void *buffer, size_t size) throw(TransportException) void GraphicsDriver::writeSpoolData(const void *buffer, size_t size) throw(TransportException)
{ {
if (__transport) { if (fTransport) {
__transport->write(buffer, size); fTransport->write(buffer, size);
} }
} }
void GraphicsDriver::writeSpoolString(const char *format, ...) throw(TransportException) void GraphicsDriver::writeSpoolString(const char *format, ...) throw(TransportException)
{ {
if (__transport) { if (fTransport) {
char buffer[256]; char buffer[256];
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);
vsprintf(buffer, format, ap); vsprintf(buffer, format, ap);
__transport->write(buffer, strlen(buffer)); fTransport->write(buffer, strlen(buffer));
va_end(ap); va_end(ap);
} }
} }
void GraphicsDriver::writeSpoolChar(char c) throw(TransportException) void GraphicsDriver::writeSpoolChar(char c) throw(TransportException)
{ {
if (__transport) { if (fTransport) {
__transport->write(&c, 1); fTransport->write(&c, 1);
} }
} }
@@ -9,27 +9,26 @@
#include "PrinterCap.h" #include "PrinterCap.h"
#include "DbgMsg.h" #include "DbgMsg.h"
const char *JD_XRES = "xres"; const char *kJDXRes = "xres";
const char *JD_YRES = "yres"; const char *kJDYRes = "yres";
const char *JD_COPIES = "copies"; const char *kJDCopies = "copies";
const char *JD_ORIENTATION = "orientation"; const char *kJDOrientation = "orientation";
const char *JD_SCALING = "scaling"; const char *kJDScaling = "scaling";
const char *JD_PAPER_RECT = "paper_rect"; const char *kJDPaperRect = "paper_rect";
const char *JD_FIRST_PAGE = "first_page"; const char *kJDFirstPage = "first_page";
const char *JD_LAST_PAGE = "last_page"; const char *kJDLastPage = "last_page";
const char *JD_PRINTABLE_RECT = "printable_rect"; const char *kJDPrintableRect = "printable_rect";
const char *JD_PAPER = "JJJJ_paper"; const char *kJDPaper = "JJJJ_paper";
const char *JD_NUP = "JJJJ_nup"; const char *kJDNup = "JJJJ_nup";
const char *JD_SURFACE_TYPE = "JJJJ_surface_type"; const char *kJDGamma = "JJJJ_gamma";
const char *JD_GAMMA = "JJJJ_gamma"; const char *kJDPaperSource = "JJJJ_paper_source";
const char *JD_PAPER_SOURCE = "JJJJ_paper_source"; const char *kJDCollate = "JJJJ_collate";
const char *JD_COLLATE = "JJJJ_collate"; const char *kJDReverse = "JJJJ_reverse";
const char *JD_REVERSE = "JJJJ_reverse"; const char *kJDPrintStyle = "JJJJ_print_style";
const char *JD_PRINT_STYLE = "JJJJ_print_style"; const char *kJDBindingLocation = "JJJJ_binding_location";
const char *JD_BINDING_LOCATION = "JJJJ_binding_location"; const char *kJDPageOrder = "JJJJ_page_order";
const char *JD_PAGE_ORDER = "JJJJ_page_order"; const char *kJDColor = "JJJJ_color";
const char *JD_COLOR = "JJJJ_color";
JobData::JobData(BMessage *msg, const PrinterCap *cap) JobData::JobData(BMessage *msg, const PrinterCap *cap)
{ {
@@ -42,281 +41,269 @@ JobData::~JobData()
JobData::JobData(const JobData &job_data) JobData::JobData(const JobData &job_data)
{ {
__paper = job_data.__paper; fPaper = job_data.fPaper;
__xres = job_data.__xres; fXRes = job_data.fXRes;
__yres = job_data.__yres; fYRes = job_data.fYRes;
__orientation = job_data.__orientation; fOrientation = job_data.fOrientation;
__scaling = job_data.__scaling; fScaling = job_data.fScaling;
__paper_rect = job_data.__paper_rect; fPaperRect = job_data.fPaperRect;
__printable_rect = job_data.__printable_rect; fPrintableRect = job_data.fPrintableRect;
__nup = job_data.__nup; fNup = job_data.fNup;
__first_page = job_data.__first_page; fFirstPage = job_data.fFirstPage;
__last_page = job_data.__last_page; fLastPage = job_data.fLastPage;
__surface_type = job_data.__surface_type; fGamma = job_data.fGamma;
__gamma = job_data.__gamma; fPaperSource = job_data.fPaperSource;
__paper_source = job_data.__paper_source; fCopies = job_data.fCopies;
__copies = job_data.__copies; fCollate = job_data.fCollate;
__collate = job_data.__collate; fReverse = job_data.fReverse;
__reverse = job_data.__reverse; fPrintStyle = job_data.fPrintStyle;
__print_style = job_data.__print_style; fBindingLocation = job_data.fBindingLocation;
__binding_location = job_data.__binding_location; fPageOrder = job_data.fPageOrder;
__page_order = job_data.__page_order; fMsg = job_data.fMsg;
__msg = job_data.__msg; fColor = job_data.fColor;
__color = job_data.__color;
} }
JobData &JobData::operator = (const JobData &job_data) JobData &JobData::operator = (const JobData &job_data)
{ {
__paper = job_data.__paper; fPaper = job_data.fPaper;
__xres = job_data.__xres; fXRes = job_data.fXRes;
__yres = job_data.__yres; fYRes = job_data.fYRes;
__orientation = job_data.__orientation; fOrientation = job_data.fOrientation;
__scaling = job_data.__scaling; fScaling = job_data.fScaling;
__paper_rect = job_data.__paper_rect; fPaperRect = job_data.fPaperRect;
__printable_rect = job_data.__printable_rect; fPrintableRect = job_data.fPrintableRect;
__nup = job_data.__nup; fNup = job_data.fNup;
__first_page = job_data.__first_page; fFirstPage = job_data.fFirstPage;
__last_page = job_data.__last_page; fLastPage = job_data.fLastPage;
__surface_type = job_data.__surface_type; fGamma = job_data.fGamma;
__gamma = job_data.__gamma; fPaperSource = job_data.fPaperSource;
__paper_source = job_data.__paper_source; fCopies = job_data.fCopies;
__copies = job_data.__copies; fCollate = job_data.fCollate;
__collate = job_data.__collate; fReverse = job_data.fReverse;
__reverse = job_data.__reverse; fPrintStyle = job_data.fPrintStyle;
__print_style = job_data.__print_style; fBindingLocation = job_data.fBindingLocation;
__binding_location = job_data.__binding_location; fPageOrder = job_data.fPageOrder;
__page_order = job_data.__page_order; fMsg = job_data.fMsg;
__msg = job_data.__msg; fColor = job_data.fColor;
__color = job_data.__color;
return *this; return *this;
} }
void JobData::load(BMessage *msg, const PrinterCap *cap) void JobData::load(BMessage *msg, const PrinterCap *cap)
{ {
__msg = msg; fMsg = msg;
if (msg->HasInt32(JD_PAPER)) if (msg->HasInt32(kJDPaper))
__paper = (PAPER)msg->FindInt32(JD_PAPER); fPaper = (Paper)msg->FindInt32(kJDPaper);
else if (cap->isSupport(PrinterCap::PAPER)) else if (cap->isSupport(PrinterCap::kPaper))
__paper = ((const PaperCap *)cap->getDefaultCap(PrinterCap::PAPER))->paper; fPaper = ((const PaperCap *)cap->getDefaultCap(PrinterCap::kPaper))->paper;
else else
__paper = A4; fPaper = kA4;
if (msg->HasInt64(JD_XRES)) { if (msg->HasInt64(kJDXRes)) {
int64 xres64; int64 xres64;
msg->FindInt64(JD_XRES, &xres64); msg->FindInt64(kJDXRes, &xres64);
__xres = xres64; fXRes = xres64;
} else if (cap->isSupport(PrinterCap::RESOLUTION)) { } else if (cap->isSupport(PrinterCap::kResolution)) {
__xres = ((const ResolutionCap *)cap->getDefaultCap(PrinterCap::RESOLUTION))->xres; fXRes = ((const ResolutionCap *)cap->getDefaultCap(PrinterCap::kResolution))->xres;
} else { } else {
__xres = 300; fXRes = 300;
} }
if (msg->HasInt64(JD_YRES)) { if (msg->HasInt64(kJDYRes)) {
int64 yres64; int64 yres64;
msg->FindInt64(JD_YRES, &yres64); msg->FindInt64(kJDYRes, &yres64);
__yres = yres64; fYRes = yres64;
} else if (cap->isSupport(PrinterCap::RESOLUTION)) { } else if (cap->isSupport(PrinterCap::kResolution)) {
__yres = ((const ResolutionCap *)cap->getDefaultCap(PrinterCap::RESOLUTION))->yres; fYRes = ((const ResolutionCap *)cap->getDefaultCap(PrinterCap::kResolution))->yres;
} else { } else {
__yres = 300; fYRes = 300;
} }
if (msg->HasInt32(JD_ORIENTATION)) if (msg->HasInt32(kJDOrientation))
__orientation = (ORIENTATION)msg->FindInt32(JD_ORIENTATION); fOrientation = (Orientation)msg->FindInt32(kJDOrientation);
else if (cap->isSupport(PrinterCap::ORIENTATION)) else if (cap->isSupport(PrinterCap::kOrientation))
__orientation = ((const OrientationCap *)cap->getDefaultCap(PrinterCap::ORIENTATION))->orientation; fOrientation = ((const OrientationCap *)cap->getDefaultCap(PrinterCap::kOrientation))->orientation;
else else
__orientation = PORTRAIT; fOrientation = kPortrait;
if (msg->HasFloat(JD_SCALING)) if (msg->HasFloat(kJDScaling))
__scaling = msg->FindFloat(JD_SCALING); fScaling = msg->FindFloat(kJDScaling);
else else
__scaling = 100.0f; fScaling = 100.0f;
if (msg->HasRect(JD_PAPER_RECT)) { if (msg->HasRect(kJDPaperRect)) {
__paper_rect = msg->FindRect(JD_PAPER_RECT); fPaperRect = msg->FindRect(kJDPaperRect);
} }
if (msg->HasRect(JD_PRINTABLE_RECT)) { if (msg->HasRect(kJDPrintableRect)) {
__printable_rect = msg->FindRect(JD_PRINTABLE_RECT); fPrintableRect = msg->FindRect(kJDPrintableRect);
} }
if (msg->HasInt32(JD_FIRST_PAGE)) if (msg->HasInt32(kJDFirstPage))
__first_page = msg->FindInt32(JD_FIRST_PAGE); fFirstPage = msg->FindInt32(kJDFirstPage);
else else
__first_page = 1; fFirstPage = 1;
if (msg->HasInt32(JD_LAST_PAGE)) if (msg->HasInt32(kJDLastPage))
__last_page = msg->FindInt32(JD_LAST_PAGE); fLastPage = msg->FindInt32(kJDLastPage);
else else
__last_page = -1; fLastPage = -1;
if (msg->HasInt32(JD_NUP)) if (msg->HasInt32(kJDNup))
__nup = msg->FindInt32(JD_NUP); fNup = msg->FindInt32(kJDNup);
else else
__nup = 1; fNup = 1;
if (msg->HasInt32(JD_SURFACE_TYPE)) if (msg->HasFloat(kJDGamma))
__surface_type = (color_space)msg->FindInt32(JD_SURFACE_TYPE); fGamma = fMsg->FindFloat(kJDGamma);
else else
__surface_type = B_CMAP8; fGamma = 1.4f;
if (msg->HasFloat(JD_GAMMA)) if (msg->HasInt32(kJDPaperSource))
__gamma = __msg->FindFloat(JD_GAMMA); fPaperSource = (PaperSource)fMsg->FindInt32(kJDPaperSource);
else if (cap->isSupport(PrinterCap::kPaperSource))
fPaperSource = ((const PaperSourceCap *)cap->getDefaultCap(PrinterCap::kPaperSource))->paper_source;
else else
__gamma = 1.4f; fPaperSource = kAuto;
if (msg->HasInt32(JD_PAPER_SOURCE)) if (msg->HasInt32(kJDCopies))
__paper_source = (PAPERSOURCE)__msg->FindInt32(JD_PAPER_SOURCE); fCopies = msg->FindInt32(kJDCopies);
else if (cap->isSupport(PrinterCap::PAPERSOURCE))
__paper_source = ((const PaperSourceCap *)cap->getDefaultCap(PrinterCap::PAPERSOURCE))->paper_source;
else else
__paper_source = AUTO; fCopies = 1;
if (msg->HasInt32(JD_COPIES)) if (msg->HasBool(kJDCollate))
__copies = msg->FindInt32(JD_COPIES); fCollate = msg->FindBool(kJDCollate);
else else
__copies = 1; fCollate = false;
if (msg->HasBool(JD_COLLATE)) if (msg->HasBool(kJDReverse))
__collate = msg->FindBool(JD_COLLATE); fReverse = msg->FindBool(kJDReverse);
else else
__collate = false; fReverse = false;
if (msg->HasBool(JD_REVERSE)) if (msg->HasInt32(kJDPrintStyle))
__reverse = msg->FindBool(JD_REVERSE); fPrintStyle = (PrintStyle)msg->FindInt32(kJDPrintStyle);
else if (cap->isSupport(PrinterCap::kPrintStyle))
fPrintStyle = ((const PrintStyleCap *)cap->getDefaultCap(PrinterCap::kPrintStyle))->print_style;
else else
__reverse = false; fPrintStyle = kSimplex;
if (msg->HasInt32(JD_PRINT_STYLE)) if (msg->HasInt32(kJDBindingLocation))
__print_style = (PRINTSTYLE)msg->FindInt32(JD_PRINT_STYLE); fBindingLocation = (BindingLocation)msg->FindInt32(kJDBindingLocation);
else if (cap->isSupport(PrinterCap::PRINTSTYLE)) else if (cap->isSupport(PrinterCap::kBindingLocation))
__print_style = ((const PrintStyleCap *)cap->getDefaultCap(PrinterCap::PRINTSTYLE))->print_style; fBindingLocation = ((const BindingLocationCap *)cap->getDefaultCap(PrinterCap::kBindingLocation))->binding_location;
else else
__print_style = SIMPLEX; fBindingLocation = kLongEdgeLeft;
if (msg->HasInt32(JD_BINDING_LOCATION)) if (msg->HasInt32(kJDPageOrder))
__binding_location = (BINDINGLOCATION)msg->FindInt32(JD_BINDING_LOCATION); fPageOrder = (PageOrder)msg->FindInt32(kJDPageOrder);
else if (cap->isSupport(PrinterCap::BINDINGLOCATION))
__binding_location = ((const BindingLocationCap *)cap->getDefaultCap(PrinterCap::BINDINGLOCATION))->binding_location;
else else
__binding_location = LONG_EDGE_LEFT; fPageOrder = kAcrossFromLeft;
if (msg->HasInt32(JD_PAGE_ORDER)) if (msg->HasBool(kJDColor))
__page_order = (PAGEORDER)msg->FindInt32(JD_PAGE_ORDER); fColor = msg->FindBool(kJDColor);
else else
__page_order = ACROSS_FROM_LEFT; fColor = false;
if (msg->HasBool(JD_COLOR))
__color = msg->FindBool(JD_COLOR);
else
__color = false;
} }
void JobData::save(BMessage *msg) void JobData::save(BMessage *msg)
{ {
if (msg == NULL) { if (msg == NULL) {
msg = __msg; msg = fMsg;
} }
if (msg->HasInt32(JD_PAPER)) if (msg->HasInt32(kJDPaper))
msg->ReplaceInt32(JD_PAPER, __paper); msg->ReplaceInt32(kJDPaper, fPaper);
else else
msg->AddInt32(JD_PAPER, __paper); msg->AddInt32(kJDPaper, fPaper);
if (msg->HasInt64(JD_XRES)) if (msg->HasInt64(kJDXRes))
msg->ReplaceInt64(JD_XRES, __xres); msg->ReplaceInt64(kJDXRes, fXRes);
else else
msg->AddInt64(JD_XRES, __xres); msg->AddInt64(kJDXRes, fXRes);
if (msg->HasInt64(JD_YRES)) if (msg->HasInt64(kJDYRes))
msg->ReplaceInt64(JD_YRES, __yres); msg->ReplaceInt64(kJDYRes, fYRes);
else else
msg->AddInt64(JD_YRES, __yres); msg->AddInt64(kJDYRes, fYRes);
if (msg->HasInt32(JD_ORIENTATION)) if (msg->HasInt32(kJDOrientation))
msg->ReplaceInt32(JD_ORIENTATION, __orientation); msg->ReplaceInt32(kJDOrientation, fOrientation);
else else
msg->AddInt32(JD_ORIENTATION, __orientation); msg->AddInt32(kJDOrientation, fOrientation);
if (msg->HasFloat(JD_SCALING)) if (msg->HasFloat(kJDScaling))
msg->ReplaceFloat(JD_SCALING, __scaling); msg->ReplaceFloat(kJDScaling, fScaling);
else else
msg->AddFloat(JD_SCALING, __scaling); msg->AddFloat(kJDScaling, fScaling);
if (msg->HasRect(JD_PAPER_RECT)) if (msg->HasRect(kJDPaperRect))
msg->ReplaceRect(JD_PAPER_RECT, __paper_rect); msg->ReplaceRect(kJDPaperRect, fPaperRect);
else else
msg->AddRect(JD_PAPER_RECT, __paper_rect); msg->AddRect(kJDPaperRect, fPaperRect);
if (msg->HasRect(JD_PRINTABLE_RECT)) if (msg->HasRect(kJDPrintableRect))
msg->ReplaceRect(JD_PRINTABLE_RECT, __printable_rect); msg->ReplaceRect(kJDPrintableRect, fPrintableRect);
else else
msg->AddRect(JD_PRINTABLE_RECT, __printable_rect); msg->AddRect(kJDPrintableRect, fPrintableRect);
if (msg->HasInt32(JD_NUP)) if (msg->HasInt32(kJDNup))
msg->ReplaceInt32(JD_NUP, __nup); msg->ReplaceInt32(kJDNup, fNup);
else else
msg->AddInt32(JD_NUP, __nup); msg->AddInt32(kJDNup, fNup);
if (msg->HasInt32(JD_FIRST_PAGE)) if (msg->HasInt32(kJDFirstPage))
msg->ReplaceInt32(JD_FIRST_PAGE, __first_page); msg->ReplaceInt32(kJDFirstPage, fFirstPage);
else else
msg->AddInt32(JD_FIRST_PAGE, __first_page); msg->AddInt32(kJDFirstPage, fFirstPage);
if (msg->HasInt32(JD_LAST_PAGE)) if (msg->HasInt32(kJDLastPage))
msg->ReplaceInt32(JD_LAST_PAGE, __last_page); msg->ReplaceInt32(kJDLastPage, fLastPage);
else else
msg->AddInt32(JD_LAST_PAGE, __last_page); msg->AddInt32(kJDLastPage, fLastPage);
if (msg->HasInt32(JD_SURFACE_TYPE)) if (msg->HasFloat(kJDGamma))
msg->ReplaceInt32(JD_SURFACE_TYPE, __surface_type); msg->ReplaceFloat(kJDGamma, fGamma);
else else
msg->AddInt32(JD_SURFACE_TYPE, __surface_type); msg->AddFloat(kJDGamma, fGamma);
if (msg->HasFloat(JD_GAMMA)) if (msg->HasInt32(kJDPaperSource))
msg->ReplaceFloat(JD_GAMMA, __gamma); msg->ReplaceInt32(kJDPaperSource, fPaperSource);
else else
msg->AddFloat(JD_GAMMA, __gamma); msg->AddInt32(kJDPaperSource, fPaperSource);
if (msg->HasInt32(JD_PAPER_SOURCE)) if (msg->HasInt32(kJDCopies))
msg->ReplaceInt32(JD_PAPER_SOURCE, __paper_source); msg->ReplaceInt32(kJDCopies, fCopies);
else else
msg->AddInt32(JD_PAPER_SOURCE, __paper_source); msg->AddInt32(kJDCopies, fCopies);
if (msg->HasInt32(JD_COPIES)) if (msg->HasBool(kJDCollate))
msg->ReplaceInt32(JD_COPIES, __copies); msg->ReplaceBool(kJDCollate, fCollate);
else else
msg->AddInt32(JD_COPIES, __copies); msg->AddBool(kJDCollate, fCollate);
if (msg->HasBool(JD_COLLATE)) if (msg->HasBool(kJDReverse))
msg->ReplaceBool(JD_COLLATE, __collate); msg->ReplaceBool(kJDReverse, fReverse);
else else
msg->AddBool(JD_COLLATE, __collate); msg->AddBool(kJDReverse, fReverse);
if (msg->HasBool(JD_REVERSE)) if (msg->HasInt32(kJDPrintStyle))
msg->ReplaceBool(JD_REVERSE, __reverse); msg->ReplaceInt32(kJDPrintStyle, fPrintStyle);
else else
msg->AddBool(JD_REVERSE, __reverse); msg->AddInt32(kJDPrintStyle, fPrintStyle);
if (msg->HasInt32(JD_PRINT_STYLE)) if (msg->HasInt32(kJDBindingLocation))
msg->ReplaceInt32(JD_PRINT_STYLE, __print_style); msg->ReplaceInt32(kJDBindingLocation, fBindingLocation);
else else
msg->AddInt32(JD_PRINT_STYLE, __print_style); msg->AddInt32(kJDBindingLocation, fBindingLocation);
if (msg->HasInt32(JD_BINDING_LOCATION)) if (msg->HasInt32(kJDPageOrder))
msg->ReplaceInt32(JD_BINDING_LOCATION, __binding_location); msg->ReplaceInt32(kJDPageOrder, fPageOrder);
else else
msg->AddInt32(JD_BINDING_LOCATION, __binding_location); msg->AddInt32(kJDPageOrder, fPageOrder);
if (msg->HasInt32(JD_PAGE_ORDER)) if (msg->HasBool(kJDColor))
msg->ReplaceInt32(JD_PAGE_ORDER, __page_order); msg->ReplaceBool(kJDColor, fColor);
else else
msg->AddInt32(JD_PAGE_ORDER, __page_order); msg->AddBool(kJDColor, fColor);
if (msg->HasBool(JD_COLOR))
msg->ReplaceBool(JD_COLOR, __color);
else
msg->AddBool(JD_COLOR, __color);
} }
@@ -235,49 +235,49 @@ struct NupCap : public BaseCap {
NupCap(const string &s, bool d, int n) : BaseCap(s, d), nup(n) {} NupCap(const string &s, bool d, int n) : BaseCap(s, d), nup(n) {}
}; };
const SurfaceCap rgb32("RGB32", false, B_RGB32); static const SurfaceCap gRGB32("RGB32", false, B_RGB32);
const SurfaceCap cmap8("CMAP8", true, B_CMAP8); static const SurfaceCap gCMAP8("CMAP8", true, B_CMAP8);
const SurfaceCap gray8("GRAY8", false, B_GRAY8); static const SurfaceCap gGray8("GRAY8", false, B_GRAY8);
const SurfaceCap gray1("GRAY1", false, B_GRAY1); static const SurfaceCap gGray1("GRAY1", false, B_GRAY1);
const NupCap nup1("Normal", true, 1); static const NupCap gNup1("Normal", true, 1);
const NupCap nup2("2-up", false, 2); static const NupCap gNup2("2-up", false, 2);
const NupCap nup4("4-up", false, 4); static const NupCap gNup4("4-up", false, 4);
const NupCap nup8("8-up", false, 8); static const NupCap gNup8("8-up", false, 8);
const NupCap nup9("9-up", false, 9); static const NupCap gNup9("9-up", false, 9);
const NupCap nup16("16-up", false, 16); static const NupCap gNup16("16-up", false, 16);
const NupCap nup25("25-up", false, 25); static const NupCap gNup25("25-up", false, 25);
const NupCap nup32("32-up", false, 32); static const NupCap gNup32("32-up", false, 32);
const NupCap nup36("36-up", false, 36); static const NupCap gNup36("36-up", false, 36);
const SurfaceCap *surfaces[] = { const SurfaceCap *gSurfaces[] = {
&rgb32, &gRGB32,
&cmap8, &gCMAP8,
&gray8, &gGray8,
&gray1 &gGray1
}; };
const NupCap *nups[] = { const NupCap *gNups[] = {
&nup1, &gNup1,
&nup2, &gNup2,
&nup4, &gNup4,
&nup8, &gNup8,
&nup9, &gNup9,
&nup16, &gNup16,
&nup25, &gNup25,
&nup32, &gNup32,
&nup36 &gNup36
}; };
enum { enum {
M_RANGE_ALL = 1, kMsgRangeAll = 'JSdl',
M_RANGE_SELECTION, kMsgRangeSelection,
M_CANCEL, kMsgCancel,
M_OK kMsgOK
}; };
JobSetupView::JobSetupView(BRect frame, JobData *job_data, PrinterData *printer_data, const PrinterCap *printer_cap) JobSetupView::JobSetupView(BRect frame, JobData *job_data, PrinterData *printer_data, const PrinterCap *printer_cap)
: BView(frame, "", B_FOLLOW_ALL, B_WILL_DRAW), __job_data(job_data), __printer_data(printer_data), __printer_cap(printer_cap) : BView(frame, "", B_FOLLOW_ALL, B_WILL_DRAW), fJobData(job_data), fPrinterData(printer_data), fPrinterCap(printer_cap)
{ {
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
} }
@@ -300,24 +300,24 @@ void JobSetupView::AttachedToWindow()
/* /*
// always B_RGB32 // always B_RGB32
__surface_type = new BPopUpMenu(""); fSurfaceType = new BPopUpMenu("");
__surface_type->SetRadioMode(true); fSurfaceType->SetRadioMode(true);
count = sizeof(surfaces) / sizeof(surfaces[0]); count = sizeof(gSurfaces) / sizeof(gSurfaces[0]);
const SurfaceCap **surface_cap = surfaces; const SurfaceCap **surface_cap = gSurfaces;
uint32 support_flags; uint32 support_flags;
while (count--) { while (count--) {
if (bitmaps_support_space((*surface_cap)->surface_type, &support_flags)) { if (bitmaps_support_space((*surface_cap)->surface_type, &support_flags)) {
item = new BMenuItem((*surface_cap)->label.c_str(), NULL); item = new BMenuItem((*surface_cap)->label.c_str(), NULL);
__surface_type->AddItem(item); fSurfaceType->AddItem(item);
if ((*surface_cap)->surface_type == __job_data->getSurfaceType()) { if ((*surface_cap)->surface_type == fJobData->getSurfaceType()) {
item->SetMarked(true); item->SetMarked(true);
marked = true; marked = true;
} }
} }
surface_cap++; surface_cap++;
} }
menufield = new BMenuField(bpp_rect, "", "Surface Type", __surface_type); menufield = new BMenuField(bpp_rect, "", "Surface Type", fSurfaceType);
box->AddChild(menufield); box->AddChild(menufield);
width = StringWidth("Color") + 10; width = StringWidth("Color") + 10;
menufield->SetDivider(width); menufield->SetDivider(width);
@@ -325,15 +325,15 @@ void JobSetupView::AttachedToWindow()
/* color */ /* color */
marked = false; marked = false;
__color_type = new BPopUpMenu(""); fColorType = new BPopUpMenu("");
__color_type->SetRadioMode(true); fColorType->SetRadioMode(true);
count = __printer_cap->countCap(PrinterCap::COLOR); count = fPrinterCap->countCap(PrinterCap::kColor);
const ColorCap **color_cap = (const ColorCap **)__printer_cap->enumCap(PrinterCap::COLOR); const ColorCap **color_cap = (const ColorCap **)fPrinterCap->enumCap(PrinterCap::kColor);
while (count--) { while (count--) {
item = new BMenuItem((*color_cap)->label.c_str(), NULL); item = new BMenuItem((*color_cap)->label.c_str(), NULL);
__color_type->AddItem(item); fColorType->AddItem(item);
if ((*color_cap)->color == __job_data->getColor()) { if ((*color_cap)->color == fJobData->getColor()) {
item->SetMarked(true); item->SetMarked(true);
marked = true; marked = true;
} }
@@ -341,18 +341,18 @@ void JobSetupView::AttachedToWindow()
} }
if (!marked && item) if (!marked && item)
item->SetMarked(true); item->SetMarked(true);
menufield = new BMenuField(bpp_rect, "", "Color", __color_type); menufield = new BMenuField(bpp_rect, "", "Color", fColorType);
box->AddChild(menufield); box->AddChild(menufield);
width = StringWidth("Color") + 10; width = StringWidth("Color") + 10;
menufield->SetDivider(width); menufield->SetDivider(width);
__gamma = new BTextControl(gamma_rect, "", "Gamma", "", NULL); fGamma = new BTextControl(gamma_rect, "", "Gamma", "", NULL);
box->AddChild(__gamma); box->AddChild(fGamma);
__gamma->SetDivider(width); fGamma->SetDivider(width);
ostringstream oss3; ostringstream oss3;
oss3 << __job_data->getGamma(); oss3 << fJobData->getGamma();
__gamma->SetText(oss3.str().c_str()); fGamma->SetText(oss3.str().c_str());
/* page range */ /* page range */
@@ -360,10 +360,10 @@ void JobSetupView::AttachedToWindow()
AddChild(box); AddChild(box);
box->SetLabel("Page Range"); box->SetLabel("Page Range");
__all = new BRadioButton(all_button_rect, "", "All", new BMessage(M_RANGE_ALL)); fAll = new BRadioButton(all_button_rect, "", "All", new BMessage(kMsgRangeAll));
box->AddChild(__all); box->AddChild(fAll);
BRadioButton *from = new BRadioButton(selection_rect, "", "", new BMessage(M_RANGE_SELECTION)); BRadioButton *from = new BRadioButton(selection_rect, "", "", new BMessage(kMsgRangeSelection));
box->AddChild(from); box->AddChild(from);
from_page = new BTextControl(from_rect, "", "From", "", NULL); from_page = new BTextControl(from_rect, "", "From", "", NULL);
@@ -376,11 +376,11 @@ void JobSetupView::AttachedToWindow()
to_page->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); to_page->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
to_page->SetDivider(StringWidth("To") + 7); to_page->SetDivider(StringWidth("To") + 7);
int first_page = __job_data->getFirstPage(); int first_page = fJobData->getFirstPage();
int last_page = __job_data->getLastPage(); int last_page = fJobData->getLastPage();
if (first_page <= 1 && last_page <= 0) { if (first_page <= 1 && last_page <= 0) {
__all->SetValue(B_CONTROL_ON); fAll->SetValue(B_CONTROL_ON);
from_page->SetEnabled(false); from_page->SetEnabled(false);
to_page->SetEnabled(false); to_page->SetEnabled(false);
} else { } else {
@@ -399,20 +399,20 @@ void JobSetupView::AttachedToWindow()
to_page->SetText(oss2.str().c_str()); to_page->SetText(oss2.str().c_str());
} }
__all->SetTarget(this); fAll->SetTarget(this);
from->SetTarget(this); from->SetTarget(this);
/* paper source */ /* paper source */
marked = false; marked = false;
__paper_feed = new BPopUpMenu(""); fPaperFeed = new BPopUpMenu("");
__paper_feed->SetRadioMode(true); fPaperFeed->SetRadioMode(true);
count = __printer_cap->countCap(PrinterCap::PAPERSOURCE); count = fPrinterCap->countCap(PrinterCap::kPaperSource);
const PaperSourceCap **paper_source_cap = (const PaperSourceCap **)__printer_cap->enumCap(PrinterCap::PAPERSOURCE); const PaperSourceCap **paper_source_cap = (const PaperSourceCap **)fPrinterCap->enumCap(PrinterCap::kPaperSource);
while (count--) { while (count--) {
item = new BMenuItem((*paper_source_cap)->label.c_str(), NULL); item = new BMenuItem((*paper_source_cap)->label.c_str(), NULL);
__paper_feed->AddItem(item); fPaperFeed->AddItem(item);
if ((*paper_source_cap)->paper_source == __job_data->getPaperSource()) { if ((*paper_source_cap)->paper_source == fJobData->getPaperSource()) {
item->SetMarked(true); item->SetMarked(true);
marked = true; marked = true;
} }
@@ -420,7 +420,7 @@ void JobSetupView::AttachedToWindow()
} }
if (!marked) if (!marked)
item->SetMarked(true); item->SetMarked(true);
menufield = new BMenuField(paperfeed_rect, "", "Paper Source", __paper_feed); menufield = new BMenuField(paperfeed_rect, "", "Paper Source", fPaperFeed);
AddChild(menufield); AddChild(menufield);
width = StringWidth("Number of Copies") + 7; width = StringWidth("Number of Copies") + 7;
menufield->SetDivider(width); menufield->SetDivider(width);
@@ -428,14 +428,14 @@ void JobSetupView::AttachedToWindow()
/* Page Per Sheet */ /* Page Per Sheet */
marked = false; marked = false;
__nup = new BPopUpMenu(""); fNup = new BPopUpMenu("");
__nup->SetRadioMode(true); fNup->SetRadioMode(true);
count = sizeof(nups) / sizeof(nups[0]); count = sizeof(gNups) / sizeof(gNups[0]);
const NupCap **nup_cap = nups; const NupCap **nup_cap = gNups;
while (count--) { while (count--) {
item = new BMenuItem((*nup_cap)->label.c_str(), NULL); item = new BMenuItem((*nup_cap)->label.c_str(), NULL);
__nup->AddItem(item); fNup->AddItem(item);
if ((*nup_cap)->nup == __job_data->getNup()) { if ((*nup_cap)->nup == fJobData->getNup()) {
item->SetMarked(true); item->SetMarked(true);
marked = true; marked = true;
} }
@@ -443,17 +443,17 @@ void JobSetupView::AttachedToWindow()
} }
if (!marked) if (!marked)
item->SetMarked(true); item->SetMarked(true);
menufield = new BMenuField(nup_rect, "", "Page Per Sheet", __nup); menufield = new BMenuField(nup_rect, "", "Page Per Sheet", fNup);
menufield->SetDivider(width); menufield->SetDivider(width);
AddChild(menufield); AddChild(menufield);
/* duplex */ /* duplex */
if (__printer_cap->isSupport(PrinterCap::PRINTSTYLE)) { if (fPrinterCap->isSupport(PrinterCap::kPrintStyle)) {
__duplex = new BCheckBox(duplex_rect, "Duplex", "Duplex", NULL); fDuplex = new BCheckBox(duplex_rect, "Duplex", "Duplex", NULL);
AddChild(__duplex); AddChild(fDuplex);
if (__job_data->getPrintStyle() != JobData::SIMPLEX) { if (fJobData->getPrintStyle() != JobData::kSimplex) {
__duplex->SetValue(B_CONTROL_ON); fDuplex->SetValue(B_CONTROL_ON);
} }
} }
@@ -464,33 +464,33 @@ void JobSetupView::AttachedToWindow()
copies->SetDivider(width); copies->SetDivider(width);
ostringstream oss4; ostringstream oss4;
oss4 << __job_data->getCopies(); oss4 << fJobData->getCopies();
copies->SetText(oss4.str().c_str()); copies->SetText(oss4.str().c_str());
/* collate */ /* collate */
__collate = new BCheckBox(collate_rect, "Collate", "Collate", NULL); fCollate = new BCheckBox(collate_rect, "Collate", "Collate", NULL);
AddChild(__collate); AddChild(fCollate);
if (__job_data->getCollate()) { if (fJobData->getCollate()) {
__collate->SetValue(B_CONTROL_ON); fCollate->SetValue(B_CONTROL_ON);
} }
/* reverse */ /* reverse */
__reverse = new BCheckBox(reverse_rect, "Reverse", "Reverse", NULL); fReverse = new BCheckBox(reverse_rect, "Reverse", "Reverse", NULL);
AddChild(__reverse); AddChild(fReverse);
if (__job_data->getReverse()) { if (fJobData->getReverse()) {
__reverse->SetValue(B_CONTROL_ON); fReverse->SetValue(B_CONTROL_ON);
} }
/* cancel */ /* cancel */
button = new BButton(cancel_rect, "", "Cancel", new BMessage(M_CANCEL)); button = new BButton(cancel_rect, "", "Cancel", new BMessage(kMsgCancel));
AddChild(button); AddChild(button);
/* ok */ /* ok */
button = new BButton(ok_rect, "", "OK", new BMessage(M_OK)); button = new BButton(ok_rect, "", "OK", new BMessage(kMsgOK));
AddChild(button); AddChild(button);
button->MakeDefault(true); button->MakeDefault(true);
} }
@@ -498,14 +498,14 @@ void JobSetupView::AttachedToWindow()
void JobSetupView::MessageReceived(BMessage *msg) void JobSetupView::MessageReceived(BMessage *msg)
{ {
switch (msg->what) { switch (msg->what) {
case M_RANGE_ALL: case kMsgRangeAll:
Window()->Lock(); Window()->Lock();
from_page->SetEnabled(false); from_page->SetEnabled(false);
to_page->SetEnabled(false); to_page->SetEnabled(false);
Window()->Unlock(); Window()->Unlock();
break; break;
case M_RANGE_SELECTION: case kMsgRangeSelection:
Window()->Lock(); Window()->Lock();
from_page->SetEnabled(true); from_page->SetEnabled(true);
to_page->SetEnabled(true); to_page->SetEnabled(true);
@@ -519,34 +519,34 @@ bool JobSetupView::UpdateJobData()
int count; int count;
/* /*
count = sizeof(surfaces) / sizeof(surfaces[0]); count = sizeof(gSurfaces) / sizeof(gSurfaces[0]);
const SurfaceCap **surface_cap = surfaces; const SurfaceCap **surface_cap = gSurfaces;
const char *surface_label = __surface_type->FindMarked()->Label(); const char *surface_label = fSurfaceType->FindMarked()->Label();
while (count--) { while (count--) {
if (!strcmp((*surface_cap)->label.c_str(), surface_label)) { if (!strcmp((*surface_cap)->label.c_str(), surface_label)) {
__job_data->setSurfaceType((*surface_cap)->surface_type); fJobData->setSurfaceType((*surface_cap)->surface_type);
break; break;
} }
surface_cap++; surface_cap++;
} }
*/ */
count = __printer_cap->countCap(PrinterCap::COLOR); count = fPrinterCap->countCap(PrinterCap::kColor);
const ColorCap **color_cap = (const ColorCap**)__printer_cap->enumCap(PrinterCap::COLOR); const ColorCap **color_cap = (const ColorCap**)fPrinterCap->enumCap(PrinterCap::kColor);
const char *color_label = __color_type->FindMarked()->Label(); const char *color_label = fColorType->FindMarked()->Label();
while (count--) { while (count--) {
if (!strcmp((*color_cap)->label.c_str(), color_label)) { if (!strcmp((*color_cap)->label.c_str(), color_label)) {
__job_data->setColor((*color_cap)->color); fJobData->setColor((*color_cap)->color);
break; break;
} }
color_cap++; color_cap++;
} }
__job_data->setGamma(atof(__gamma->Text())); fJobData->setGamma(atof(fGamma->Text()));
int first_page; int first_page;
int last_page; int last_page;
if (B_CONTROL_ON == __all->Value()) { if (B_CONTROL_ON == fAll->Value()) {
first_page = 1; first_page = 1;
last_page = -1; last_page = -1;
} else { } else {
@@ -554,41 +554,41 @@ bool JobSetupView::UpdateJobData()
last_page = atoi(to_page->Text()); last_page = atoi(to_page->Text());
} }
__job_data->setFirstPage(first_page); fJobData->setFirstPage(first_page);
__job_data->setLastPage(last_page); fJobData->setLastPage(last_page);
count = __printer_cap->countCap(PrinterCap::PAPERSOURCE); count = fPrinterCap->countCap(PrinterCap::kPaperSource);
const PaperSourceCap **paper_source_cap = (const PaperSourceCap **)__printer_cap->enumCap(PrinterCap::PAPERSOURCE); const PaperSourceCap **paper_source_cap = (const PaperSourceCap **)fPrinterCap->enumCap(PrinterCap::kPaperSource);
const char *paper_source_label = __paper_feed->FindMarked()->Label(); const char *paper_source_label = fPaperFeed->FindMarked()->Label();
while (count--) { while (count--) {
if (!strcmp((*paper_source_cap)->label.c_str(), paper_source_label)) { if (!strcmp((*paper_source_cap)->label.c_str(), paper_source_label)) {
__job_data->setPaperSource((*paper_source_cap)->paper_source); fJobData->setPaperSource((*paper_source_cap)->paper_source);
break; break;
} }
paper_source_cap++; paper_source_cap++;
} }
count = sizeof(nups) / sizeof(nups[0]); count = sizeof(gNups) / sizeof(gNups[0]);
const NupCap **nup_cap = nups; const NupCap **nup_cap = gNups;
const char *nup_label = __nup->FindMarked()->Label(); const char *nup_label = fNup->FindMarked()->Label();
while (count--) { while (count--) {
if (!strcmp((*nup_cap)->label.c_str(), nup_label)) { if (!strcmp((*nup_cap)->label.c_str(), nup_label)) {
__job_data->setNup((*nup_cap)->nup); fJobData->setNup((*nup_cap)->nup);
break; break;
} }
nup_cap++; nup_cap++;
} }
if (__printer_cap->isSupport(PrinterCap::PRINTSTYLE)) { if (fPrinterCap->isSupport(PrinterCap::kPrintStyle)) {
__job_data->setPrintStyle((B_CONTROL_ON == __duplex->Value()) ? JobData::DUPLEX : JobData::SIMPLEX); fJobData->setPrintStyle((B_CONTROL_ON == fDuplex->Value()) ? JobData::kDuplex : JobData::kSimplex);
} }
__job_data->setCopies(atoi(copies->Text())); fJobData->setCopies(atoi(copies->Text()));
__job_data->setCollate((B_CONTROL_ON == __collate->Value()) ? true : false); fJobData->setCollate((B_CONTROL_ON == fCollate->Value()) ? true : false);
__job_data->setReverse((B_CONTROL_ON == __reverse->Value()) ? true : false); fJobData->setReverse((B_CONTROL_ON == fReverse->Value()) ? true : false);
__job_data->save(); fJobData->save();
return true; return true;
} }
@@ -634,7 +634,7 @@ JobSetupDlg::JobSetupDlg(JobData *job_data, PrinterData *printer_data, const Pri
"PrintJob Setup", B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, "PrintJob Setup", B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL,
B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE) B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE)
{ {
__result = 0; fResult = 0;
/* /*
ostringstream oss; ostringstream oss;
oss << printer_data->get_printer_name() << " Print"; oss << printer_data->get_printer_name() << " Print";
@@ -643,42 +643,42 @@ JobSetupDlg::JobSetupDlg(JobData *job_data, PrinterData *printer_data, const Pri
Lock(); Lock();
JobSetupView *view = new JobSetupView(Bounds(), job_data, printer_data, printer_cap); JobSetupView *view = new JobSetupView(Bounds(), job_data, printer_data, printer_cap);
AddChild(view); AddChild(view);
__filter = new BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, B_KEY_DOWN, &PrintKeyFilter); fFilter = new BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, B_KEY_DOWN, &PrintKeyFilter);
AddCommonFilter(__filter); AddCommonFilter(fFilter);
Unlock(); Unlock();
__semaphore = create_sem(0, "JobSetupSem"); fSemaphore = create_sem(0, "JobSetupSem");
} }
JobSetupDlg::~JobSetupDlg() JobSetupDlg::~JobSetupDlg()
{ {
Lock(); Lock();
RemoveCommonFilter(__filter); RemoveCommonFilter(fFilter);
Unlock(); Unlock();
delete __filter; delete fFilter;
} }
bool JobSetupDlg::QuitRequested() bool JobSetupDlg::QuitRequested()
{ {
__result = B_ERROR; fResult = B_ERROR;
release_sem(__semaphore); release_sem(fSemaphore);
return true; return true;
} }
void JobSetupDlg::MessageReceived(BMessage *msg) void JobSetupDlg::MessageReceived(BMessage *msg)
{ {
switch (msg->what) { switch (msg->what) {
case M_OK: case kMsgOK:
Lock(); Lock();
((JobSetupView *)ChildAt(0))->UpdateJobData(); ((JobSetupView *)ChildAt(0))->UpdateJobData();
Unlock(); Unlock();
__result = B_NO_ERROR; fResult = B_NO_ERROR;
release_sem(__semaphore); release_sem(fSemaphore);
break; break;
case M_CANCEL: case kMsgCancel:
__result = B_ERROR; fResult = B_ERROR;
release_sem(__semaphore); release_sem(fSemaphore);
break; break;
default: default:
@@ -690,9 +690,9 @@ void JobSetupDlg::MessageReceived(BMessage *msg)
int JobSetupDlg::Go() int JobSetupDlg::Go()
{ {
Show(); Show();
acquire_sem(__semaphore); acquire_sem(fSemaphore);
delete_sem(__semaphore); delete_sem(fSemaphore);
int value = __result; int value = fResult;
Lock(); Lock();
Quit(); Quit();
return value; return value;
@@ -109,12 +109,12 @@ const BRect CANCEL_RECT(
CANCEL_V + BUTTON_HEIGHT); CANCEL_V + BUTTON_HEIGHT);
enum MSGS { enum MSGS {
M_CANCEL = 1, kMsgCancel = 1,
M_OK kMsgOK
}; };
PageSetupView::PageSetupView(BRect frame, JobData *job_data, PrinterData *printer_data, const PrinterCap *printer_cap) PageSetupView::PageSetupView(BRect frame, JobData *job_data, PrinterData *printer_data, const PrinterCap *printer_cap)
: BView(frame, "", B_FOLLOW_ALL, B_WILL_DRAW), __job_data(job_data), __printer_data(printer_data), __printer_cap(printer_cap) : BView(frame, "", B_FOLLOW_ALL, B_WILL_DRAW), fJobData(job_data), fPrinterData(printer_data), fPrinterCap(printer_cap)
{ {
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
} }
@@ -137,29 +137,29 @@ void PageSetupView::AttachedToWindow()
AddChild(box); AddChild(box);
box->SetLabel("Orientation"); box->SetLabel("Orientation");
__portrait = new BRadioButton(PORT_RECT, "", PORT_TEXT, NULL); fPortrait = new BRadioButton(PORT_RECT, "", PORT_TEXT, NULL);
box->AddChild(__portrait); box->AddChild(fPortrait);
BRadioButton *landscape = new BRadioButton(LAND_RECT, "", RAND_TEXT, NULL); BRadioButton *landscape = new BRadioButton(LAND_RECT, "", RAND_TEXT, NULL);
box->AddChild(landscape); box->AddChild(landscape);
if (JobData::PORTRAIT == __job_data->getOrientation()) if (JobData::kPortrait == fJobData->getOrientation())
__portrait->SetValue(B_CONTROL_ON); fPortrait->SetValue(B_CONTROL_ON);
else else
landscape->SetValue(B_CONTROL_ON); landscape->SetValue(B_CONTROL_ON);
/* paper selection */ /* paper selection */
marked = false; marked = false;
__paper = new BPopUpMenu(""); fPaper = new BPopUpMenu("");
__paper->SetRadioMode(true); fPaper->SetRadioMode(true);
count = __printer_cap->countCap(PrinterCap::PAPER); count = fPrinterCap->countCap(PrinterCap::kPaper);
PaperCap **paper_cap = (PaperCap **)__printer_cap->enumCap(PrinterCap::PAPER); PaperCap **paper_cap = (PaperCap **)fPrinterCap->enumCap(PrinterCap::kPaper);
while (count--) { while (count--) {
item = new BMenuItem((*paper_cap)->label.c_str(), NULL); item = new BMenuItem((*paper_cap)->label.c_str(), NULL);
__paper->AddItem(item); fPaper->AddItem(item);
item->SetTarget(this); item->SetTarget(this);
if ((*paper_cap)->paper == __job_data->getPaper()) { if ((*paper_cap)->paper == fJobData->getPaper()) {
item->SetMarked(true); item->SetMarked(true);
marked = true; marked = true;
} }
@@ -167,7 +167,7 @@ void PageSetupView::AttachedToWindow()
} }
if (!marked) if (!marked)
item->SetMarked(true); item->SetMarked(true);
menufield = new BMenuField(PAPER_RECT, "", PAPER_TEXT, __paper); menufield = new BMenuField(PAPER_RECT, "", PAPER_TEXT, fPaper);
AddChild(menufield); AddChild(menufield);
float width = StringWidth(PAPER_TEXT) + 7; float width = StringWidth(PAPER_TEXT) + 7;
menufield->SetDivider(width); menufield->SetDivider(width);
@@ -175,15 +175,15 @@ void PageSetupView::AttachedToWindow()
/* resolution */ /* resolution */
marked = false; marked = false;
__resolution = new BPopUpMenu(""); fResolution = new BPopUpMenu("");
__resolution->SetRadioMode(true); fResolution->SetRadioMode(true);
count = __printer_cap->countCap(PrinterCap::RESOLUTION); count = fPrinterCap->countCap(PrinterCap::kResolution);
ResolutionCap **resolution_cap = (ResolutionCap **)__printer_cap->enumCap(PrinterCap::RESOLUTION); ResolutionCap **resolution_cap = (ResolutionCap **)fPrinterCap->enumCap(PrinterCap::kResolution);
while (count--) { while (count--) {
item = new BMenuItem((*resolution_cap)->label.c_str(), NULL); item = new BMenuItem((*resolution_cap)->label.c_str(), NULL);
__resolution->AddItem(item); fResolution->AddItem(item);
item->SetTarget(this); item->SetTarget(this);
if (((*resolution_cap)->xres == __job_data->getXres()) && ((*resolution_cap)->yres == __job_data->getYres())) { if (((*resolution_cap)->xres == fJobData->getXres()) && ((*resolution_cap)->yres == fJobData->getYres())) {
item->SetMarked(true); item->SetMarked(true);
marked = true; marked = true;
} }
@@ -191,18 +191,18 @@ void PageSetupView::AttachedToWindow()
} }
if (!marked) if (!marked)
item->SetMarked(true); item->SetMarked(true);
menufield = new BMenuField(RESOLUTION_RECT, "", RES_TEXT, __resolution); menufield = new BMenuField(RESOLUTION_RECT, "", RES_TEXT, fResolution);
AddChild(menufield); AddChild(menufield);
menufield->SetDivider(width); menufield->SetDivider(width);
/* cancel */ /* cancel */
button = new BButton(CANCEL_RECT, "", CANCEL_TEXT, new BMessage(M_CANCEL)); button = new BButton(CANCEL_RECT, "", CANCEL_TEXT, new BMessage(kMsgCancel));
AddChild(button); AddChild(button);
/* ok */ /* ok */
button = new BButton(OK_RECT, "", OK_TEXT, new BMessage(M_OK)); button = new BButton(OK_RECT, "", OK_TEXT, new BMessage(kMsgOK));
AddChild(button); AddChild(button);
button->MakeDefault(true); button->MakeDefault(true);
} }
@@ -216,10 +216,10 @@ inline void swap(float *e1, float *e2)
bool PageSetupView::UpdateJobData() bool PageSetupView::UpdateJobData()
{ {
if (B_CONTROL_ON == __portrait->Value()) { if (B_CONTROL_ON == fPortrait->Value()) {
__job_data->setOrientation(JobData::PORTRAIT); fJobData->setOrientation(JobData::kPortrait);
} else { } else {
__job_data->setOrientation(JobData::LANDSCAPE); fJobData->setOrientation(JobData::kLandscape);
} }
BRect paper_rect; BRect paper_rect;
@@ -227,12 +227,12 @@ bool PageSetupView::UpdateJobData()
int count; int count;
count = __printer_cap->countCap(PrinterCap::PAPER); count = fPrinterCap->countCap(PrinterCap::kPaper);
PaperCap **paper_cap = (PaperCap **)__printer_cap->enumCap(PrinterCap::PAPER); PaperCap **paper_cap = (PaperCap **)fPrinterCap->enumCap(PrinterCap::kPaper);
const char *paper_label = __paper->FindMarked()->Label(); const char *paper_label = fPaper->FindMarked()->Label();
while (count--) { while (count--) {
if (!strcmp((*paper_cap)->label.c_str(), paper_label)) { if (!strcmp((*paper_cap)->label.c_str(), paper_label)) {
__job_data->setPaper((*paper_cap)->paper); fJobData->setPaper((*paper_cap)->paper);
paper_rect = (*paper_cap)->paper_rect; paper_rect = (*paper_cap)->paper_rect;
printable_rect = (*paper_cap)->printable_rect; printable_rect = (*paper_cap)->printable_rect;
break; break;
@@ -240,30 +240,30 @@ bool PageSetupView::UpdateJobData()
paper_cap++; paper_cap++;
} }
count = __printer_cap->countCap(PrinterCap::RESOLUTION); count = fPrinterCap->countCap(PrinterCap::kResolution);
ResolutionCap **resolution_cap = (ResolutionCap **)__printer_cap->enumCap(PrinterCap::RESOLUTION); ResolutionCap **resolution_cap = (ResolutionCap **)fPrinterCap->enumCap(PrinterCap::kResolution);
const char *resolution_label = __resolution->FindMarked()->Label(); const char *resolution_label = fResolution->FindMarked()->Label();
while (count--) { while (count--) {
if (!strcmp((*resolution_cap)->label.c_str(), resolution_label)) { if (!strcmp((*resolution_cap)->label.c_str(), resolution_label)) {
__job_data->setXres((*resolution_cap)->xres); fJobData->setXres((*resolution_cap)->xres);
__job_data->setYres((*resolution_cap)->yres); fJobData->setYres((*resolution_cap)->yres);
break; break;
} }
resolution_cap++; resolution_cap++;
} }
if (JobData::LANDSCAPE == __job_data->getOrientation()) { if (JobData::kLandscape == fJobData->getOrientation()) {
swap(&paper_rect.left, &paper_rect.top); swap(&paper_rect.left, &paper_rect.top);
swap(&paper_rect.right, &paper_rect.bottom); swap(&paper_rect.right, &paper_rect.bottom);
swap(&printable_rect.left, &printable_rect.top); swap(&printable_rect.left, &printable_rect.top);
swap(&printable_rect.right, &printable_rect.bottom); swap(&printable_rect.right, &printable_rect.bottom);
} }
__job_data->setScaling(100.0); fJobData->setScaling(100.0);
__job_data->setPaperRect(paper_rect); fJobData->setPaperRect(paper_rect);
__job_data->setPrintableRect(printable_rect); fJobData->setPrintableRect(printable_rect);
__job_data->save(); fJobData->save();
return true; return true;
} }
@@ -274,7 +274,7 @@ PageSetupDlg::PageSetupDlg(JobData *job_data, PrinterData *printer_data, const P
"Page Setup", B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, "Page Setup", B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL,
B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE) B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE)
{ {
__result = 0; fResult = 0;
/* /*
ostringstream oss; ostringstream oss;
oss << printer_data->get_printer_name() << " Setup"; oss << printer_data->get_printer_name() << " Setup";
@@ -286,7 +286,7 @@ PageSetupDlg::PageSetupDlg(JobData *job_data, PrinterData *printer_data, const P
AddChild(view); AddChild(view);
Unlock(); Unlock();
__semaphore = create_sem(0, "PageSetupSem"); fSemaphore = create_sem(0, "PageSetupSem");
} }
PageSetupDlg::~PageSetupDlg() PageSetupDlg::~PageSetupDlg()
@@ -295,25 +295,25 @@ PageSetupDlg::~PageSetupDlg()
bool PageSetupDlg::QuitRequested() bool PageSetupDlg::QuitRequested()
{ {
__result = B_ERROR; fResult = B_ERROR;
release_sem(__semaphore); release_sem(fSemaphore);
return true; return true;
} }
void PageSetupDlg::MessageReceived(BMessage *msg) void PageSetupDlg::MessageReceived(BMessage *msg)
{ {
switch (msg->what) { switch (msg->what) {
case M_OK: case kMsgOK:
Lock(); Lock();
((PageSetupView *)ChildAt(0))->UpdateJobData(); ((PageSetupView *)ChildAt(0))->UpdateJobData();
Unlock(); Unlock();
__result = B_NO_ERROR; fResult = B_NO_ERROR;
release_sem(__semaphore); release_sem(fSemaphore);
break; break;
case M_CANCEL: case kMsgCancel:
__result = B_ERROR; fResult = B_ERROR;
release_sem(__semaphore); release_sem(fSemaphore);
break; break;
default: default:
@@ -325,9 +325,9 @@ void PageSetupDlg::MessageReceived(BMessage *msg)
int PageSetupDlg::Go() int PageSetupDlg::Go()
{ {
Show(); Show();
acquire_sem(__semaphore); acquire_sem(fSemaphore);
delete_sem(__semaphore); delete_sem(fSemaphore);
int value = __result; int value = fResult;
Lock(); Lock();
Quit(); Quit();
return value; return value;
@@ -13,38 +13,38 @@ public:
PreviewView(BRect, BBitmap *); PreviewView(BRect, BBitmap *);
void Draw(BRect); void Draw(BRect);
private: private:
BBitmap *__bitmap; BBitmap *fBitmap;
}; };
PreviewView::PreviewView(BRect frame, BBitmap *bitmap) PreviewView::PreviewView(BRect frame, BBitmap *bitmap)
: BView(frame, "preview", B_FOLLOW_ALL, B_WILL_DRAW) : BView(frame, "preview", B_FOLLOW_ALL, B_WILL_DRAW)
{ {
__bitmap = bitmap; fBitmap = bitmap;
} }
void PreviewView::Draw(BRect) void PreviewView::Draw(BRect)
{ {
DrawBitmap(__bitmap); DrawBitmap(fBitmap);
} }
PreviewWindow::PreviewWindow(BRect frame, const char *title, BBitmap *bitmap) PreviewWindow::PreviewWindow(BRect frame, const char *title, BBitmap *bitmap)
: BWindow(frame, title, B_TITLED_WINDOW, 0) : BWindow(frame, title, B_TITLED_WINDOW, 0)
{ {
AddChild(new PreviewView(Bounds(), bitmap)); AddChild(new PreviewView(Bounds(), bitmap));
__semaphore = create_sem(0, "PreviewSem"); fSemaphore = create_sem(0, "PreviewSem");
} }
bool PreviewWindow::QuitRequested() bool PreviewWindow::QuitRequested()
{ {
release_sem(__semaphore); release_sem(fSemaphore);
return true; return true;
} }
int PreviewWindow::Go() int PreviewWindow::Go()
{ {
Show(); Show();
acquire_sem(__semaphore); acquire_sem(fSemaphore);
delete_sem(__semaphore); delete_sem(fSemaphore);
Lock(); Lock();
Quit(); Quit();
return 0; return 0;
@@ -39,26 +39,26 @@ PictureData::~PictureData()
PageData::PageData() PageData::PageData()
{ {
__hollow = true; fHollow = true;
} }
PageData::PageData(BFile *file, bool reverse) PageData::PageData(BFile *file, bool reverse)
{ {
__file = file; fFile = file;
__reverse = reverse; fReverse = reverse;
__picture_count = 0; fPictureCount = 0;
__rest = 0; fRest = 0;
__offset = 0; fOffset = 0;
__hollow = false; fHollow = false;
if (reverse) { if (reverse) {
file->Read(&__picture_count, sizeof(long)); file->Read(&fPictureCount, sizeof(long));
DBGMSG(("picture_count = %d\n", (int)__picture_count)); DBGMSG(("picture_count = %d\n", (int)fPictureCount));
__offset = __file->Position(); fOffset = fFile->Position();
off_t o = __offset; off_t o = fOffset;
// seek to start of next page // seek to start of next page
__file->Read(&o, sizeof(o)); fFile->Read(&o, sizeof(o));
__file->Seek(o, SEEK_SET); fFile->Seek(o, SEEK_SET);
} }
} }
@@ -67,30 +67,30 @@ bool PageData::startEnum()
off_t offset; off_t offset;
uchar dummy[40]; uchar dummy[40];
if (__hollow) if (fHollow)
return false; return false;
if (__offset == 0) { if (fOffset == 0) {
__file->Read(&__picture_count, sizeof(long)); fFile->Read(&fPictureCount, sizeof(long));
DBGMSG(("picture_count = %d\n", (int)__picture_count)); DBGMSG(("picture_count = %d\n", (int)fPictureCount));
__offset = __file->Position(); fOffset = fFile->Position();
} else { } else {
__file->Seek(__offset, SEEK_SET); fFile->Seek(fOffset, SEEK_SET);
} }
// skip page header // skip page header
__file->Seek(sizeof(offset) + sizeof(dummy), SEEK_CUR); fFile->Seek(sizeof(offset) + sizeof(dummy), SEEK_CUR);
__rest = __picture_count; fRest = fPictureCount;
return __picture_count > 0; return fPictureCount > 0;
} }
bool PageData::enumObject(PictureData **picture_data) bool PageData::enumObject(PictureData **picture_data)
{ {
if (__hollow || __picture_count <= 0) { if (fHollow || fPictureCount <= 0) {
*picture_data = NULL; *picture_data = NULL;
} else { } else {
*picture_data = new PictureData(__file); *picture_data = new PictureData(fFile);
if (--__rest > 0) { if (--fRest > 0) {
return true; return true;
} }
} }
@@ -113,48 +113,48 @@ SpoolData::SpoolData(
if (nup > 1) { if (nup > 1) {
for (int page_index = 0; page_index < page_count; page_index++) { for (int page_index = 0; page_index < page_count; page_index++) {
if (page_index % nup == 0) { if (page_index % nup == 0) {
__pages.push_front(new PageData(file, reverse)); fPages.push_front(new PageData(file, reverse));
__it = __pages.begin(); fIt = fPages.begin();
__it++; fIt++;
} else { } else {
__pages.insert(__it, new PageData(file, reverse)); fPages.insert(fIt, new PageData(file, reverse));
} }
} }
page_count = nup - page_count % nup; page_count = nup - page_count % nup;
if (page_count < nup) { if (page_count < nup) {
while (page_count--) { while (page_count--) {
__pages.insert(__it, new PageData); fPages.insert(fIt, new PageData);
} }
} }
} else { } else {
while (page_count--) { while (page_count--) {
__pages.push_front(new PageData(file, reverse)); fPages.push_front(new PageData(file, reverse));
} }
} }
} else { } else {
while (page_count--) { while (page_count--) {
__pages.push_back(new PageData(file, reverse)); fPages.push_back(new PageData(file, reverse));
} }
} }
} }
SpoolData::~SpoolData() SpoolData::~SpoolData()
{ {
for (__it = __pages.begin(); __it != __pages.end(); __it++) { for (fIt = fPages.begin(); fIt != fPages.end(); fIt++) {
delete (*__it); delete (*fIt);
} }
} }
bool SpoolData::startEnum() bool SpoolData::startEnum()
{ {
__it = __pages.begin(); fIt = fPages.begin();
return true; return true;
} }
bool SpoolData::enumObject(PageData **page_data) bool SpoolData::enumObject(PageData **page_data)
{ {
*page_data = *__it++; *page_data = *fIt++;
if (__it == __pages.end()) { if (fIt == fPages.end()) {
return false; return false;
} }
return true; return true;
@@ -6,7 +6,7 @@
#include "PrinterCap.h" #include "PrinterCap.h"
PrinterCap::PrinterCap(const PrinterData *printer_data) PrinterCap::PrinterCap(const PrinterData *printer_data)
: __printer_data(printer_data), __printer_id(UNKNOWN_PRINTER) : fPrinterData(printer_data), fPrinterID(kUnknownPrinter)
{ {
} }
@@ -17,19 +17,19 @@ PrinterCap::~PrinterCap()
/* /*
PrinterCap::PrinterCap(const PrinterCap &printer_cap) PrinterCap::PrinterCap(const PrinterCap &printer_cap)
{ {
__printer_data = printer_cap.__printer_data; fPrinterData = printer_cap.fPrinterData;
__printer_id = printer_cap.__printer_id; fPrinterID = printer_cap.fPrinterID;
} }
PrinterCap::PrinterCap &operator = (const PrinterCap &printer_cap) PrinterCap::PrinterCap &operator = (const PrinterCap &printer_cap)
{ {
__printer_data = printer_cap.__printer_data; fPrinterData = printer_cap.fPrinterData;
__printer_id = printer_cap.__printer_id; fPrinterID = printer_cap.fPrinterID;
return *this; return *this;
} }
*/ */
const BaseCap *PrinterCap::getDefaultCap(CAPID id) const const BaseCap *PrinterCap::getDefaultCap(CapID id) const
{ {
int count = countCap(id); int count = countCap(id);
if (count > 0) { if (count > 0) {
@@ -29,20 +29,20 @@ PrinterData::~PrinterData()
/* /*
PrinterData::PrinterData(const PrinterData &printer_data) PrinterData::PrinterData(const PrinterData &printer_data)
{ {
__driver_name = printer_data.__driver_name; fDriverName = printer_data.fDriverName;
__printer_name = printer_data.__printer_name; fPrinterName = printer_data.fPrinterName;
__comments = printer_data.__comments; fComments = printer_data.fComments;
__transport = printer_data.__transport; fTransport = printer_data.fTransport;
__node = printer_data.__node; fNode = printer_data.fNode;
} }
PrinterData &PrinterData::operator = (const PrinterData &printer_data) PrinterData &PrinterData::operator = (const PrinterData &printer_data)
{ {
__driver_name = printer_data.__driver_name; fDriverName = printer_data.fDriverName;
__printer_name = printer_data.__printer_name; fPrinterName = printer_data.fPrinterName;
__comments = printer_data.__comments; fComments = printer_data.fComments;
__transport = printer_data.__transport; fTransport = printer_data.fTransport;
__node = printer_data.__node; fNode = printer_data.fNode;
return *this; return *this;
} }
*/ */
@@ -51,16 +51,16 @@ void PrinterData::load(BNode *node)
{ {
char buffer[512]; char buffer[512];
__node = node; fNode = node;
__node->ReadAttr(PD_DRIVER_NAME, B_STRING_TYPE, 0, buffer, sizeof(buffer)); fNode->ReadAttr(PD_DRIVER_NAME, B_STRING_TYPE, 0, buffer, sizeof(buffer));
__driver_name = buffer; fDriverName = buffer;
__node->ReadAttr(PD_PRINTER_NAME, B_STRING_TYPE, 0, buffer, sizeof(buffer)); fNode->ReadAttr(PD_PRINTER_NAME, B_STRING_TYPE, 0, buffer, sizeof(buffer));
__printer_name = buffer; fPrinterName = buffer;
__node->ReadAttr(PD_COMMENTS, B_STRING_TYPE, 0, buffer, sizeof(buffer)); fNode->ReadAttr(PD_COMMENTS, B_STRING_TYPE, 0, buffer, sizeof(buffer));
__comments = buffer; fComments = buffer;
__node->ReadAttr(PD_TRANSPORT, B_STRING_TYPE, 0, buffer, sizeof(buffer)); fNode->ReadAttr(PD_TRANSPORT, B_STRING_TYPE, 0, buffer, sizeof(buffer));
__transport = buffer; fTransport = buffer;
} }
/* /*
@@ -70,7 +70,7 @@ void PrinterData::save(BNode *node)
if (node == NULL) { if (node == NULL) {
BPath path; BPath path;
::find_directory(B_USER_PRINTERS_DIRECTORY, &path, false); ::find_directory(B_USER_PRINTERS_DIRECTORY, &path, false);
path.Append(__printer_name.c_str()); path.Append(fPrinterName.c_str());
BDirectory base_dir; BDirectory base_dir;
base_dir.CreateDirectory(path.Path(), &dir); base_dir.CreateDirectory(path.Path(), &dir);
node = &dir; node = &dir;
@@ -83,9 +83,9 @@ void PrinterData::save(BNode *node)
bool PrinterData::getPath(char *buf) const bool PrinterData::getPath(char *buf) const
{ {
if (__node) { if (fNode) {
node_ref nref; node_ref nref;
__node->GetNodeRef(&nref); fNode->GetNodeRef(&nref);
BDirectory dir; BDirectory dir;
dir.SetTo(&nref); dir.SetTo(&nref);
BPath path(&dir, NULL); BPath path(&dir, NULL);
@@ -6,21 +6,21 @@
#include "SpoolMetaData.h" #include "SpoolMetaData.h"
#include <String.h> #include <String.h>
const char *SD_DESCRIPTION = "_spool/Description"; const char *kSDDescription = "_spool/Description";
const char* SD_MIME_TYPE = "_spool/MimeType"; const char* kSDMimeType = "_spool/MimeType";
SpoolMetaData::SpoolMetaData(BFile* spool_file) SpoolMetaData::SpoolMetaData(BFile* spool_file)
{ {
BString string; BString string;
time_t time; time_t time;
if (spool_file->ReadAttrString(SD_DESCRIPTION, &string) == B_OK) { if (spool_file->ReadAttrString(kSDDescription, &string) == B_OK) {
__description = string.String(); fDescription = string.String();
} }
if (spool_file->ReadAttrString(SD_MIME_TYPE, &string) == B_OK) { if (spool_file->ReadAttrString(kSDMimeType, &string) == B_OK) {
__mime_type = string.String(); fMimeType = string.String();
} }
if (spool_file->GetCreationTime(&time) == B_OK) { if (spool_file->GetCreationTime(&time) == B_OK) {
__creation_time = ctime(&time); fCreationTime = ctime(&time);
} }
} }
@@ -21,7 +21,7 @@ using namespace std;
#endif #endif
Transport::Transport(const PrinterData *printer_data) Transport::Transport(const PrinterData *printer_data)
: __image(-1), __init_transport(0), __exit_transport(0), __data_stream(0), __abort(false) : fImage(-1), fInitTransport(0), fExitTransport(0), fDataStream(0), fAbort(false)
{ {
BPath path; BPath path;
@@ -29,45 +29,45 @@ Transport::Transport(const PrinterData *printer_data)
path.Append("Print/transport"); path.Append("Print/transport");
path.Append(printer_data->getTransport().c_str()); path.Append(printer_data->getTransport().c_str());
DBGMSG(("load_add_on: %s\n", path.Path())); DBGMSG(("load_add_on: %s\n", path.Path()));
__image = load_add_on(path.Path()); fImage = load_add_on(path.Path());
} }
if (__image < 0) { if (fImage < 0) {
if (B_OK == find_directory(B_BEOS_ADDONS_DIRECTORY, &path)) { if (B_OK == find_directory(B_BEOS_ADDONS_DIRECTORY, &path)) {
path.Append("Print/transport"); path.Append("Print/transport");
path.Append(printer_data->getTransport().c_str()); path.Append(printer_data->getTransport().c_str());
DBGMSG(("load_add_on: %s\n", path.Path())); DBGMSG(("load_add_on: %s\n", path.Path()));
__image = load_add_on(path.Path()); fImage = load_add_on(path.Path());
} }
} }
if (__image < 0) { if (fImage < 0) {
set_last_error("cannot load a transport add-on"); set_last_error("cannot load a transport add-on");
return; return;
} }
DBGMSG(("image id = %d\n", (int)__image)); DBGMSG(("image id = %d\n", (int)fImage));
get_image_symbol(__image, "init_transport", B_SYMBOL_TYPE_TEXT, (void **)&__init_transport); get_image_symbol(fImage, "init_transport", B_SYMBOL_TYPE_TEXT, (void **)&fInitTransport);
get_image_symbol(__image, "exit_transport", B_SYMBOL_TYPE_TEXT, (void **)&__exit_transport); get_image_symbol(fImage, "exit_transport", B_SYMBOL_TYPE_TEXT, (void **)&fExitTransport);
if (__init_transport == NULL) { if (fInitTransport == NULL) {
set_last_error("get_image_symbol failed."); set_last_error("get_image_symbol failed.");
DBGMSG(("init_transport is NULL\n")); DBGMSG(("init_transport is NULL\n"));
} }
if (__exit_transport == NULL) { if (fExitTransport == NULL) {
set_last_error("get_image_symbol failed."); set_last_error("get_image_symbol failed.");
DBGMSG(("exit_transport is NULL\n")); DBGMSG(("exit_transport is NULL\n"));
} }
if (__init_transport) { if (fInitTransport) {
char spool_path[256]; char spool_path[256];
printer_data->getPath(spool_path); printer_data->getPath(spool_path);
BMessage *msg = new BMessage('TRIN'); BMessage *msg = new BMessage('TRIN');
msg->AddString("printer_file", spool_path); msg->AddString("printer_file", spool_path);
__data_stream = (*__init_transport)(msg); fDataStream = (*fInitTransport)(msg);
delete msg; delete msg;
if (__data_stream == 0) { if (fDataStream == 0) {
set_last_error("init_transport failed."); set_last_error("init_transport failed.");
} }
} }
@@ -75,34 +75,34 @@ Transport::Transport(const PrinterData *printer_data)
Transport::~Transport() Transport::~Transport()
{ {
if (__exit_transport) { if (fExitTransport) {
(*__exit_transport)(); (*fExitTransport)();
} }
if (__image >= 0) { if (fImage >= 0) {
unload_add_on(__image); unload_add_on(fImage);
} }
} }
bool Transport::check_abort() const bool Transport::check_abort() const
{ {
return __data_stream == 0; return fDataStream == 0;
} }
const string &Transport::last_error() const const string &Transport::last_error() const
{ {
return __last_error_string; return fLastErrorString;
} }
void Transport::set_last_error(const char *e) void Transport::set_last_error(const char *e)
{ {
__last_error_string = e; fLastErrorString = e;
__abort = true; fAbort = true;
} }
void Transport::write(const void *buffer, size_t size) throw(TransportException) void Transport::write(const void *buffer, size_t size) throw(TransportException)
{ {
if (__data_stream) { if (fDataStream) {
if (size == (size_t)__data_stream->Write(buffer, size)) { if (size == (size_t)fDataStream->Write(buffer, size)) {
return; return;
} }
set_last_error("BDataIO::Write failed."); set_last_error("BDataIO::Write failed.");
@@ -13,7 +13,7 @@
#include "DbgMsg.h" #include "DbgMsg.h"
UIDriver::UIDriver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap) UIDriver::UIDriver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap)
: __msg(msg), __printer_data(printer_data), __printer_cap(printer_cap) : fMsg(msg), fPrinterData(printer_data), fPrinterCap(printer_cap)
{ {
} }
@@ -23,10 +23,10 @@ UIDriver::~UIDriver()
BMessage *UIDriver::configPage() BMessage *UIDriver::configPage()
{ {
BMessage *clone_msg = new BMessage(*__msg); BMessage *clone_msg = new BMessage(*fMsg);
JobData *job_data = new JobData(clone_msg, __printer_cap); JobData *job_data = new JobData(clone_msg, fPrinterCap);
if (doPageSetup(job_data,__printer_data, __printer_cap) < 0) { if (doPageSetup(job_data,fPrinterData, fPrinterCap) < 0) {
delete clone_msg; delete clone_msg;
clone_msg = NULL; clone_msg = NULL;
} else { } else {
@@ -39,10 +39,10 @@ BMessage *UIDriver::configPage()
BMessage *UIDriver::configJob() BMessage *UIDriver::configJob()
{ {
BMessage *clone_msg = new BMessage(*__msg); BMessage *clone_msg = new BMessage(*fMsg);
JobData *job_data = new JobData(clone_msg, __printer_cap); JobData *job_data = new JobData(clone_msg, fPrinterCap);
if (doJobSetup(job_data, __printer_data, __printer_cap) < 0) { if (doJobSetup(job_data, fPrinterData, fPrinterCap) < 0) {
delete clone_msg; delete clone_msg;
clone_msg = NULL; clone_msg = NULL;
} else { } else {
@@ -8,7 +8,6 @@
bool get_valid_line_RGB32( bool get_valid_line_RGB32(
const uchar *bits, const uchar *bits,
const rgb_color *,
int width, int width,
int *left, int *left,
int *right) int *right)
@@ -44,117 +43,9 @@ bool get_valid_line_RGB32(
return true; return true;
} }
bool get_valid_line_CMAP8( typedef bool (*PFN_GET_VALID_LINE)(const uchar *, int, int *, int *);
const uchar *bits,
const rgb_color *palette,
int width,
int *left,
int *right)
{
int i = 0;
rgb_color c;
const uchar *ptr = bits;
while (i < *left) { bool get_valid_rect(BBitmap *a_bitmap, RECT *rc)
c = palette[*ptr++];
if (c.red != 0xff || c.green != 0xff || c.blue != 0xff) {
*left = i;
break;
}
i++;
}
if (i == width) {
return false;
}
i = width - 1;
ptr = bits + width - 1;
while (i > *right) {
c = palette[*ptr--];
if (c.red != 0xff || c.green != 0xff || c.blue != 0xff) {
*right = i;
break;
}
i--;
}
return true;
}
bool get_valid_line_GRAY8(
const uchar *bits,
const rgb_color *,
int width,
int *left,
int *right)
{
int i = 0;
const uchar *ptr = bits;
while (i < *left) {
if (*ptr++) {
*left = i;
break;
}
i++;
}
if (i == width) {
return false;
}
i = width - 1;
ptr = bits + width - 1;
while (i > *right) {
if (*ptr--) {
*right = i;
break;
}
i--;
}
return true;
}
bool get_valid_line_GRAY1(
const uchar *bits,
const rgb_color *,
int width,
int *left,
int *right)
{
int i = 0;
const uchar *ptr = bits;
while (i < *left) {
if (*ptr++) {
*left = i;
break;
}
i += 8;
}
if (i == width) {
return false;
}
i = width - 1;
ptr = bits + ((width - 1) + 7) / 8;
while (i > *right) {
if (*ptr--) {
*right = i;
break;
}
i -= 8;
}
return true;
}
typedef bool (*PFN_GET_VALID_LINE)(const uchar *, const rgb_color *, int, int *, int *);
bool get_valid_rect(BBitmap *a_bitmap, const rgb_color *palette, RECT *rc)
{ {
int width = rc->right - rc->left + 1; int width = rc->right - rc->left + 1;
int height = rc->bottom - rc->top + 1; int height = rc->bottom - rc->top + 1;
@@ -172,17 +63,8 @@ bool get_valid_rect(BBitmap *a_bitmap, const rgb_color *palette, RECT *rc)
case B_RGB32_BIG: case B_RGB32_BIG:
get_valid_line = get_valid_line_RGB32; get_valid_line = get_valid_line_RGB32;
break; break;
case B_CMAP8:
get_valid_line = get_valid_line_CMAP8;
break;
case B_GRAY8:
get_valid_line = get_valid_line_GRAY8;
break;
case B_GRAY1:
get_valid_line = get_valid_line_GRAY1;
break;
default: default:
get_valid_line = get_valid_line_GRAY1; return false;
break; break;
}; };
@@ -190,7 +72,7 @@ bool get_valid_rect(BBitmap *a_bitmap, const rgb_color *palette, RECT *rc)
uchar *ptr = (uchar *)a_bitmap->Bits(); uchar *ptr = (uchar *)a_bitmap->Bits();
while (i < height) { while (i < height) {
if (get_valid_line(ptr, palette, width, &left, &right)) { if (get_valid_line(ptr, width, &left, &right)) {
top = i; top = i;
break; break;
} }
@@ -207,7 +89,7 @@ bool get_valid_rect(BBitmap *a_bitmap, const rgb_color *palette, RECT *rc)
bool found_boundary = false; bool found_boundary = false;
while (j >= i) { while (j >= i) {
if (get_valid_line(ptr, palette, width, &left, &right)) { if (get_valid_line(ptr, width, &left, &right)) {
if (!found_boundary) { if (!found_boundary) {
bottom = j; bottom = j;
found_boundary = true; found_boundary = true;