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

View File

@ -17,7 +17,9 @@ class BMessage;
class PrinterData;
class PrinterCap;
#define GDF_ROTATE_BAND_BITMAP 0x01
enum {
kGDFRotateBandBitmap = 1
};
class GraphicsDriver {
public:
@ -67,64 +69,64 @@ private:
static void rgb32_to_gray(void* src, void* dst, int width);
static void cmap8_to_gray(void* src, void* dst, int width);
uint32 __flags;
BMessage *__msg;
BView *__view;
BBitmap *__bitmap;
Transport *__transport;
JobData *__org_job_data;
JobData *__real_job_data;
PrinterData *__printer_data;
const PrinterCap *__printer_cap;
SpoolMetaData *__spool_meta_data;
uint32 fFlags;
BMessage *fMsg;
BView *fView;
BBitmap *fBitmap;
Transport *fTransport;
JobData *fOrgJobData;
JobData *fRealJobData;
PrinterData *fPrinterData;
const PrinterCap *fPrinterCap;
SpoolMetaData *fSpoolMetaData;
int __page_width;
int __page_height;
int __band_width;
int __band_height;
int __pixel_depth;
int __band_count;
int __internal_copies;
int fPageWidth;
int fPageHeight;
int fBandWidth;
int fBandHeight;
int fPixelDepth;
int fBandCount;
int fInternalCopies;
};
inline const JobData *GraphicsDriver::getJobData() const
{
return __real_job_data;
return fRealJobData;
}
inline const PrinterData *GraphicsDriver::getPrinterData() const
{
return __printer_data;
return fPrinterData;
}
inline const PrinterCap *GraphicsDriver::getPrinterCap() const
{
return __printer_cap;
return fPrinterCap;
}
inline const SpoolMetaData *GraphicsDriver::getSpoolMetaData() const
{
return __spool_meta_data;
return fSpoolMetaData;
}
inline int GraphicsDriver::getPageWidth() const
{
return __page_width;
return fPageWidth;
}
inline int GraphicsDriver::getPageHeight() const
{
return __page_height;
return fPageHeight;
}
inline int GraphicsDriver::getBandWidth() const
{
return __band_width;
return fBandWidth;
}
inline int GraphicsDriver::getBandHeight() const
{
return __band_height;
return fBandHeight;
}
#endif /* __GRAPHICSDRIVER_H */

View File

@ -15,220 +15,219 @@ class PrinterCap;
class JobData {
public:
enum ORIENTATION {
PORTRAIT,
LANDSCAPE
enum Orientation {
kPortrait,
kLandscape
};
enum PAPER {
LETTER = 1, // 1 Letter 8 1/2 x 11 in
LETTERSMALL, // 2 Letter Small 8 1/2 x 11 in
TABLOID, // 3 Tabloid 11 x 17 in
LEDGER, // 4 Ledger 17 x 11 in
LEGAL, // 5 Legal 8 1/2 x 14 in
STATEMENT, // 6 Statement 5 1/2 x 8 1/2 in
EXECUTIVE, // 7 Executive 7 1/4 x 10 1/2 in
A3, // 8 A3 297 x 420 mm
A4, // 9 A4 210 x 297 mm
A4SMALL, // 10 A4 Small 210 x 297 mm
A5, // 11 A5 148 x 210 mm
B4, // 12 B4 (JIS) 250 x 354
B5, // 13 B5 (JIS) 182 x 257 mm
FOLIO, // 14 Folio 8 1/2 x 13 in
QUARTO, // 15 Quarto 215 x 275 mm
P_10X14, // 16 10x14 in
P_11X17, // 17 11x17 in
NOTE, // 18 Note 8 1/2 x 11 in
ENV_9, // 19 Envelope #9 3 7/8 x 8 7/8
ENV_10, // 20 Envelope #10 4 1/8 x 9 1/2
ENV_11, // 21 Envelope #11 4 1/2 x 10 3/8
ENV_12, // 22 Envelope #12 4 \276 x 11
ENV_14, // 23 Envelope #14 5 x 11 1/2
CSHEET, // 24 C size sheet
DSHEET, // 25 D size sheet
ESHEET, // 26 E size sheet
ENV_DL, // 27 Envelope DL 110 x 220mm
ENV_C5, // 28 Envelope C5 162 x 229 mm
ENV_C3, // 29 Envelope C3 324 x 458 mm
ENV_C4, // 30 Envelope C4 229 x 324 mm
ENV_C6, // 31 Envelope C6 114 x 162 mm
ENV_C65, // 32 Envelope C65 114 x 229 mm
ENV_B4, // 33 Envelope B4 250 x 353 mm
ENV_B5, // 34 Envelope B5 176 x 250 mm
ENV_B6, // 35 Envelope B6 176 x 125 mm
ENV_ITALY, // 36 Envelope 110 x 230 mm
ENV_MONARCH, // 37 Envelope Monarch 3.875 x 7.5 in
ENV_PERSONAL, // 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
FANFOLD_STD_GERMAN, // 40 German Std Fanfold 8 1/2 x 12 in
FANFOLD_LGL_GERMAN, // 41 German Legal Fanfold 8 1/2 x 13 in
ISO_B4, // 42 B4 (ISO) 250 x 353 mm
JAPANESE_POSTCARD, // 43 Japanese Postcard 100 x 148 mm
P_9X11, // 44 9 x 11 in
P_10X11, // 45 10 x 11 in
P_15X11, // 46 15 x 11 in
ENV_INVITE, // 47 Envelope Invite 220 x 220 mm
RESERVED_48, // 48 RESERVED--DO NOT USE
RESERVED_49, // 49 RESERVED--DO NOT USE
LETTER_EXTRA, // 50 Letter Extra 9 \275 x 12 in
LEGAL_EXTRA, // 51 Legal Extra 9 \275 x 15 in
TABLOID_EXTRA, // 52 Tabloid Extra 11.69 x 18 in
A4_EXTRA, // 53 A4 Extra 9.27 x 12.69 in
LETTER_TRANSVERSE, // 54 Letter Transverse 8 \275 x 11 in
A4_TRANSVERSE, // 55 A4 Transverse 210 x 297 mm
LETTER_EXTRA_TRANSVERSE,// 56 Letter Extra Transverse 9\275 x 12 in
A_PLUS, // 57 SuperA/SuperA/A4 227 x 356 mm
B_PLUS, // 58 SuperB/SuperB/A3 305 x 487 mm
LETTER_PLUS, // 59 Letter Plus 8.5 x 12.69 in
A4_PLUS, // 60 A4 Plus 210 x 330 mm
A5_TRANSVERSE, // 61 A5 Transverse 148 x 210 mm
B5_TRANSVERSE, // 62 B5 (JIS) Transverse 182 x 257 mm
A3_EXTRA, // 63 A3 Extra 322 x 445 mm
A5_EXTRA, // 64 A5 Extra 174 x 235 mm
B5_EXTRA, // 65 B5 (ISO) Extra 201 x 276 mm
A2, // 66 A2 420 x 594 mm
A3_TRANSVERSE, // 67 A3 Transverse 297 x 420 mm
A3_EXTRA_TRANSVERSE, // 68 A3 Extra Transverse 322 x 445 mm
DBL_JAPANESE_POSTCARD, // 69 Japanese Double Postcard 200 x 148 mm
A6, // 70 A6 105 x 148 mm
JENV_KAKU2, // 71 Japanese Envelope Kaku #2
JENV_KAKU3, // 72 Japanese Envelope Kaku #3
JENV_CHOU3, // 73 Japanese Envelope Chou #3
JENV_CHOU4, // 74 Japanese Envelope Chou #4
LETTER_ROTATED, // 75 Letter Rotated 11 x 8 1/2 11 in
A3_ROTATED, // 76 A3 Rotated 420 x 297 mm
A4_ROTATED, // 77 A4 Rotated 297 x 210 mm
A5_ROTATED, // 78 A5 Rotated 210 x 148 mm
B4_JIS_ROTATED, // 79 B4 (JIS) Rotated 364 x 257 mm
B5_JIS_ROTATED, // 80 B5 (JIS) Rotated 257 x 182 mm
JAPANESE_POSTCARD_ROTATED, // 81 Japanese Postcard Rotated 148 x 100 mm
DBL_JAPANESE_POSTCARD_ROTATED, // 82 Double Japanese Postcard Rotated 148 x 200 mm
A6_ROTATED, // 83 A6 Rotated 148 x 105 mm
JENV_KAKU2_ROTATED, // 84 Japanese Envelope Kaku #2 Rotated
JENV_KAKU3_ROTATED, // 85 Japanese Envelope Kaku #3 Rotated
JENV_CHOU3_ROTATED, // 86 Japanese Envelope Chou #3 Rotated
JENV_CHOU4_ROTATED, // 87 Japanese Envelope Chou #4 Rotated
B6_JIS, // 88 B6 (JIS) 128 x 182 mm
B6_JIS_ROTATED, // 89 B6 (JIS) Rotated 182 x 128 mm
P_12X11, // 90 12 x 11 in
JENV_YOU4, // 91 Japanese Envelope You #4
JENV_YOU4_ROTATED, // 92 Japanese Envelope You #4 Rotated
P16K, // 93 PRC 16K 146 x 215 mm
P32K, // 94 PRC 32K 97 x 151 mm
P32KBIG, // 95 PRC 32K(Big) 97 x 151 mm
PENV_1, // 96 PRC Envelope #1 102 x 165 mm
PENV_2, // 97 PRC Envelope #2 102 x 176 mm
PENV_3, // 98 PRC Envelope #3 125 x 176 mm
PENV_4, // 99 PRC Envelope #4 110 x 208 mm
PENV_5, // 100 PRC Envelope #5 110 x 220 mm
PENV_6, // 101 PRC Envelope #6 120 x 230 mm
PENV_7, // 102 PRC Envelope #7 160 x 230 mm
PENV_8, // 103 PRC Envelope #8 120 x 309 mm
PENV_9, // 104 PRC Envelope #9 229 x 324 mm
PENV_10, // 105 PRC Envelope #10 324 x 458 mm
P16K_ROTATED, // 106 PRC 16K Rotated
P32K_ROTATED, // 107 PRC 32K Rotated
P32KBIG_ROTATED, // 108 PRC 32K(Big) Rotated
PENV_1_ROTATED, // 109 PRC Envelope #1 Rotated 165 x 102 mm
PENV_2_ROTATED, // 110 PRC Envelope #2 Rotated 176 x 102 mm
PENV_3_ROTATED, // 111 PRC Envelope #3 Rotated 176 x 125 mm
PENV_4_ROTATED, // 112 PRC Envelope #4 Rotated 208 x 110 mm
PENV_5_ROTATED, // 113 PRC Envelope #5 Rotated 220 x 110 mm
PENV_6_ROTATED, // 114 PRC Envelope #6 Rotated 230 x 120 mm
PENV_7_ROTATED, // 115 PRC Envelope #7 Rotated 230 x 160 mm
PENV_8_ROTATED, // 116 PRC Envelope #8 Rotated 309 x 120 mm
PENV_9_ROTATED, // 117 PRC Envelope #9 Rotated 324 x 229 mm
PENV_10_ROTATED, // 118 PRC Envelope #10 Rotated 458 x 324 mm
USER_DEFINED = 256
enum Paper {
kLetter = 1, // 1 Letter 8 1/2 x 11 in
kLetterSmall, // 2 Letter Small 8 1/2 x 11 in
kTabloid, // 3 Tabloid 11 x 17 in
kLedger, // 4 Ledger 17 x 11 in
kLegal, // 5 Legal 8 1/2 x 14 in
kStatement, // 6 Statement 5 1/2 x 8 1/2 in
kExecutive, // 7 Executive 7 1/4 x 10 1/2 in
kA3, // 8 A3 297 x 420 mm
kA4, // 9 A4 210 x 297 mm
kA4Small, // 10 A4 Small 210 x 297 mm
kA5, // 11 A5 148 x 210 mm
kB4, // 12 B4 (JIS) 250 x 354
kB5, // 13 B5 (JIS) 182 x 257 mm
kFolio, // 14 Folio 8 1/2 x 13 in
kQuarto, // 15 Quarto 215 x 275 mm
k10X14, // 16 10x14 in
k11X17, // 17 11x17 in
kNote, // 18 Note 8 1/2 x 11 in
kEnv9, // 19 Envelope #9 3 7/8 x 8 7/8
kEnv10, // 20 Envelope #10 4 1/8 x 9 1/2
kEnv11, // 21 Envelope #11 4 1/2 x 10 3/8
kEnv12, // 22 Envelope #12 4 \276 x 11
kEnv14, // 23 Envelope #14 5 x 11 1/2
kCSheet, // 24 C size sheet
kDSheet, // 25 D size sheet
kESheet, // 26 E size sheet
kEnvDL, // 27 Envelope DL 110 x 220mm
kEnvC5, // 28 Envelope C5 162 x 229 mm
kEnvC3, // 29 Envelope C3 324 x 458 mm
kEnvC4, // 30 Envelope C4 229 x 324 mm
kEnvC6, // 31 Envelope C6 114 x 162 mm
kEnvC65, // 32 Envelope C65 114 x 229 mm
kEnvB4, // 33 Envelope B4 250 x 353 mm
kEnvB5, // 34 Envelope B5 176 x 250 mm
kEnvB6, // 35 Envelope B6 176 x 125 mm
kEnvItaly, // 36 Envelope 110 x 230 mm
kEnvMonarch, // 37 Envelope Monarch 3.875 x 7.5 in
kEnvPersonal, // 38 6 3/4 Envelope 3 5/8 x 6 1/2 in
kFanFoldUS, // 39 US Std Fanfold 14 7/8 x 11 in
kFanFoldStdGerman, // 40 German Std Fanfold 8 1/2 x 12 in
kFanFoldLglGerman, // 41 German Legal Fanfold 8 1/2 x 13 in
kIsoB4, // 42 B4 (ISO) 250 x 353 mm
kJapanesePostcard, // 43 Japanese Postcard 100 x 148 mm
k9X11, // 44 9 x 11 in
k10X11, // 45 10 x 11 in
k15X11, // 46 15 x 11 in
kEnvInvite, // 47 Envelope Invite 220 x 220 mm
kReserved48, // 48 RESERVED--DO NOT USE
kReserved49, // 49 RESERVED--DO NOT USE
kLetterExtra, // 50 Letter Extra 9 \275 x 12 in
kLegalExtra, // 51 Legal Extra 9 \275 x 15 in
kTabloidExtra, // 52 Tabloid Extra 11.69 x 18 in
kA4Extra, // 53 A4 Extra 9.27 x 12.69 in
kLetterTransverse, // 54 Letter Transverse 8 \275 x 11 in
kA4Transverse, // 55 A4 Transverse 210 x 297 mm
kLetterExtraTransverse, // 56 Letter Extra Transverse 9\275 x 12 in
kAPlus, // 57 SuperA/SuperA/A4 227 x 356 mm
kBPlus, // 58 SuperB/SuperB/A3 305 x 487 mm
kLetterPlus, // 59 Letter Plus 8.5 x 12.69 in
kA4Plus, // 60 A4 Plus 210 x 330 mm
kA5Transverse, // 61 A5 Transverse 148 x 210 mm
kB5Transverse, // 62 B5 (JIS) Transverse 182 x 257 mm
kA3Extra, // 63 A3 Extra 322 x 445 mm
kA5Extra, // 64 A5 Extra 174 x 235 mm
kB5Extra, // 65 B5 (ISO) Extra 201 x 276 mm
kA2, // 66 A2 420 x 594 mm
kA3Transverse, // 67 A3 Transverse 297 x 420 mm
kA3ExtraTransverse, // 68 A3 Extra Transverse 322 x 445 mm
kDBLJapanesePostcard, // 69 Japanese Double Postcard 200 x 148 mm
kA6, // 70 A6 105 x 148 mm
kJEnvKaku2, // 71 Japanese Envelope Kaku #2
kJEnvKaku3, // 72 Japanese Envelope Kaku #3
kJEnvChou3, // 73 Japanese Envelope Chou #3
kJEnvChou4, // 74 Japanese Envelope Chou #4
kLetterRotated, // 75 Letter Rotated 11 x 8 1/2 11 in
kA3Rotated, // 76 A3 Rotated 420 x 297 mm
kA4Rotated, // 77 A4 Rotated 297 x 210 mm
kA5Rotated, // 78 A5 Rotated 210 x 148 mm
kB4JISRotated, // 79 B4 (JIS) Rotated 364 x 257 mm
kB5JISRotated, // 80 B5 (JIS) Rotated 257 x 182 mm
kJapanesePostcardRotated, // 81 Japanese Postcard Rotated 148 x 100 mm
kDBLJapanesePostcardRotated, // 82 Double Japanese Postcard Rotated 148 x 200 mm
kA6Rotated, // 83 A6 Rotated 148 x 105 mm
kJEnvKaku2Rotated, // 84 Japanese Envelope Kaku #2 Rotated
kJEnvKaku3Rotated, // 85 Japanese Envelope Kaku #3 Rotated
kJEnvChou3Rotated, // 86 Japanese Envelope Chou #3 Rotated
kJEnvChou4Rotated, // 87 Japanese Envelope Chou #4 Rotated
kB6JIS, // 88 B6 (JIS) 128 x 182 mm
kB6JISRotated, // 89 B6 (JIS) Rotated 182 x 128 mm
k12X11, // 90 12 x 11 in
kJEnvYou4, // 91 Japanese Envelope You #4
kJEnvYou4Rotated, // 92 Japanese Envelope You #4 Rotated
kP16K, // 93 PRC 16K 146 x 215 mm
kP32K, // 94 PRC 32K 97 x 151 mm
kP32KBig, // 95 PRC 32K(Big) 97 x 151 mm
kPEnv1, // 96 PRC Envelope #1 102 x 165 mm
kPEnv2, // 97 PRC Envelope #2 102 x 176 mm
kPEnv3, // 98 PRC Envelope #3 125 x 176 mm
kPEnv4, // 99 PRC Envelope #4 110 x 208 mm
kPEnv5, // 100 PRC Envelope #5 110 x 220 mm
kPEnv6, // 101 PRC Envelope #6 120 x 230 mm
kPEnv7, // 102 PRC Envelope #7 160 x 230 mm
kPEnv8, // 103 PRC Envelope #8 120 x 309 mm
kPEnv9, // 104 PRC Envelope #9 229 x 324 mm
kPEnv10, // 105 PRC Envelope #10 324 x 458 mm
kP16KRotated, // 106 PRC 16K Rotated
kP32KRotated, // 107 PRC 32K Rotated
kP32KBIGRotated, // 108 PRC 32K(Big) Rotated
kPEnv1Rotated, // 109 PRC Envelope #1 Rotated 165 x 102 mm
kPEnv2Rotated, // 110 PRC Envelope #2 Rotated 176 x 102 mm
kPEnv3Rotated, // 111 PRC Envelope #3 Rotated 176 x 125 mm
kPEnv4Rotated, // 112 PRC Envelope #4 Rotated 208 x 110 mm
kPEnv5Rotated, // 113 PRC Envelope #5 Rotated 220 x 110 mm
kPEnv6Rotated, // 114 PRC Envelope #6 Rotated 230 x 120 mm
kPEnv7Rotated, // 115 PRC Envelope #7 Rotated 230 x 160 mm
kPEnv8Rotated, // 116 PRC Envelope #8 Rotated 309 x 120 mm
kPEnv9Rotated, // 117 PRC Envelope #9 Rotated 324 x 229 mm
kPEnv10Rotated, // 118 PRC Envelope #10 Rotated 458 x 324 mm
kUserDefined = 256
};
enum PAPERSOURCE {
AUTO, // 7 o
MANUAL, // 4 o
UPPER, // 1 o
MIDDLE, // 3 o
LOWER, // 2 o
// ONLYONE, // 1 x
// ENVELOPE, // 5 o
// ENVMANUAL, // 6 x
// TRACTOR, // 8 x
// SMALLFMT, // 9 x
// LARGEFMT, // 10 x
// LARGECAPACITY, // 11 x
// CASSETTE, // 14 x
// FORMSOURCE, // 15 x
CASSETTE1 = 21,
CASSETTE2,
CASSETTE3,
CASSETTE4,
CASSETTE5,
CASSETTE6,
CASSETTE7,
CASSETTE8,
CASSETTE9,
USER = 256 // device specific bins start here
enum PaperSource {
kAuto, // 7 o
kManual, // 4 o
kUpper, // 1 o
kMiddle, // 3 o
kLower, // 2 o
// kOnlyOne, // 1 x
// kEnvelope, // 5 o
// kEnvManual, // 6 x
// kTractor, // 8 x
// kSmallFmt, // 9 x
// kLargeFmt, // 10 x
// kLargeCapacity, // 11 x
// kCassette, // 14 x
// kFormSource, // 15 x
kCassette1 = 21,
kCassette2,
kCassette3,
kCassette4,
kCassette5,
kCassette6,
kCassette7,
kCassette8,
kCassette9,
kUser = 256 // device specific bins start here
};
enum PRINTSTYLE {
SIMPLEX,
DUPLEX,
BOOKLET
enum PrintStyle {
kSimplex,
kDuplex,
kBooklet
};
enum BINDINGLOCATION {
LONG_EDGE_LEFT,
LONG_EDGE_RIGHT,
SHORT_EDGE_TOP,
SHORT_EDGE_BOTTOM,
LONG_EDGE = LONG_EDGE_LEFT,
SHORT_EDGE = SHORT_EDGE_TOP
enum BindingLocation {
kLongEdgeLeft,
kLongEdgeRight,
kShortEdgeTop,
kShortEdgeBottom,
kLongEdge = kLongEdgeLeft,
kShortEdge = kShortEdgeTop
};
enum PAGEORDER {
ACROSS_FROM_LEFT,
DOWN_FROM_LEFT,
ACROSS_FROM_RIGHT,
DOWN_FROM_RIGHT,
LEFT_TO_RIGHT = ACROSS_FROM_LEFT,
RIGHT_TO_LEFT = ACROSS_FROM_RIGHT
enum PageOrder {
kAcrossFromLeft,
kDownFromLeft,
kAcrossFromRight,
kDownFromRight,
kLeftToRight = kAcrossFromLeft,
kRightToLeft = kAcrossFromRight
};
/*
enum QUALITY {
DRAFT = -1,
LOW = -2,
MEDIUM = -3,
HIGH = -4
enum Quality {
kDraft = -1,
kLow = -2,
kMedium = -3,
kHigh = -4
};
*/
enum COLOR {
kMONOCHROME = 1,
kCOLOR
enum Color {
kMonochrome = 1,
kColor
};
private:
PAPER __paper;
int32 __xres;
int32 __yres;
ORIENTATION __orientation;
float __scaling;
BRect __paper_rect;
BRect __printable_rect;
int32 __nup;
int32 __first_page;
int32 __last_page;
color_space __surface_type;
float __gamma;
PAPERSOURCE __paper_source;
int32 __copies;
bool __collate;
bool __reverse;
PRINTSTYLE __print_style;
BINDINGLOCATION __binding_location;
PAGEORDER __page_order;
BMessage *__msg;
bool __color;
Paper fPaper;
int32 fXRes;
int32 fYRes;
Orientation fOrientation;
float fScaling;
BRect fPaperRect;
BRect fPrintableRect;
int32 fNup;
int32 fFirstPage;
int32 fLastPage;
float fGamma;
PaperSource fPaperSource;
int32 fCopies;
bool fCollate;
bool fReverse;
PrintStyle fPrintStyle;
BindingLocation fBindingLocation;
PageOrder fPageOrder;
BMessage *fMsg;
bool fColor;
public:
JobData(BMessage *msg, const PrinterCap *cap);
@ -240,65 +239,65 @@ public:
void load(BMessage *msg, const PrinterCap *cap);
void save(BMessage *msg = NULL);
PAPER getPaper() const { return __paper; }
void setPaper(PAPER paper) { __paper = paper; }
Paper getPaper() const { return fPaper; }
void setPaper(Paper paper) { fPaper = paper; }
int32 getXres() const { return __xres; }
void setXres(int32 xres) { __xres = xres; }
int32 getXres() const { return fXRes; }
void setXres(int32 xres) { fXRes = xres; }
int32 getYres() const { return __yres; }
void setYres(int32 yres) { __yres = yres; };
int32 getYres() const { return fYRes; }
void setYres(int32 yres) { fYRes = yres; };
ORIENTATION getOrientation() const { return __orientation; }
void setOrientation(ORIENTATION orientation) { __orientation = orientation; }
Orientation getOrientation() const { return fOrientation; }
void setOrientation(Orientation orientation) { fOrientation = orientation; }
float getScaling() const { return __scaling; }
void setScaling(float scaling) { __scaling = scaling; }
float getScaling() const { return fScaling; }
void setScaling(float scaling) { fScaling = scaling; }
const BRect &getPaperRect() const { return __paper_rect; }
void setPaperRect(const BRect &paper_rect) { __paper_rect = paper_rect; }
const BRect &getPaperRect() const { return fPaperRect; }
void setPaperRect(const BRect &paper_rect) { fPaperRect = paper_rect; }
const BRect &getPrintableRect() const { return __printable_rect; }
void setPrintableRect(const BRect &printable_rect) { __printable_rect = printable_rect; }
const BRect &getPrintableRect() const { return fPrintableRect; }
void setPrintableRect(const BRect &printable_rect) { fPrintableRect = printable_rect; }
int32 getNup() const { return __nup; }
void setNup(int32 nup) { __nup = nup; }
int32 getNup() const { return fNup; }
void setNup(int32 nup) { fNup = nup; }
bool getReverse() const { return __reverse; }
void setReverse(bool reverse) { __reverse = reverse; }
bool getReverse() const { return fReverse; }
void setReverse(bool reverse) { fReverse = reverse; }
int32 getFirstPage() const { return __first_page; }
void setFirstPage(int32 first_page) { __first_page = first_page; }
int32 getFirstPage() const { return fFirstPage; }
void setFirstPage(int32 first_page) { fFirstPage = first_page; }
int32 getLastPage() const { return __last_page; }
void setLastPage(int32 last_page) { __last_page = last_page; }
int32 getLastPage() const { return fLastPage; }
void setLastPage(int32 last_page) { fLastPage = last_page; }
color_space getSurfaceType() const { return B_RGB32; /* __surface_type;*/ }
void setSurfaceType(color_space surface_type) { __surface_type = surface_type; }
// libprint supports only B_RGB32
color_space getSurfaceType() const { return B_RGB32; }
float getGamma() const { return __gamma; }
void setGamma(float gamma) { __gamma = gamma; }
float getGamma() const { return fGamma; }
void setGamma(float gamma) { fGamma = gamma; }
PAPERSOURCE getPaperSource() const { return __paper_source; }
void setPaperSource(PAPERSOURCE paper_source) { __paper_source = paper_source; };
PaperSource getPaperSource() const { return fPaperSource; }
void setPaperSource(PaperSource paper_source) { fPaperSource = paper_source; };
int32 getCopies() const { return __copies; }
void setCopies(int32 copies) { __copies = copies; }
int32 getCopies() const { return fCopies; }
void setCopies(int32 copies) { fCopies = copies; }
bool getCollate() const { return __collate; }
void setCollate(bool collate) { __collate = collate; }
bool getCollate() const { return fCollate; }
void setCollate(bool collate) { fCollate = collate; }
PRINTSTYLE getPrintStyle() const { return __print_style; }
void setPrintStyle(PRINTSTYLE print_style) { __print_style = print_style; }
PrintStyle getPrintStyle() const { return fPrintStyle; }
void setPrintStyle(PrintStyle print_style) { fPrintStyle = print_style; }
BINDINGLOCATION getBindingLocation() const { return __binding_location; }
void setBindingLocation(BINDINGLOCATION binding_location) { __binding_location = binding_location; }
BindingLocation getBindingLocation() const { return fBindingLocation; }
void setBindingLocation(BindingLocation binding_location) { fBindingLocation = binding_location; }
PAGEORDER getPageOrder() const { return __page_order; }
void setPageOrder(PAGEORDER page_order) { __page_order = page_order; }
PageOrder getPageOrder() const { return fPageOrder; }
void setPageOrder(PageOrder page_order) { fPageOrder = page_order; }
COLOR getColor() const { return __color ? kCOLOR : kMONOCHROME; }
void setColor(COLOR color) { __color = color == kCOLOR; }
Color getColor() const { return fColor ? kColor : kMonochrome; }
void setColor(Color color) { fColor = color == kColor; }
/*
protected:
JobData(const JobData &job_data);

View File

@ -30,17 +30,17 @@ public:
BTextControl *to_page;
private:
JobData *__job_data;
PrinterData *__printer_data;
const PrinterCap *__printer_cap;
BTextControl *__gamma;
BRadioButton *__all;
BCheckBox *__collate;
BCheckBox *__reverse;
BPopUpMenu *__color_type;
BPopUpMenu *__paper_feed;
BCheckBox *__duplex;
BPopUpMenu *__nup;
JobData *fJobData;
PrinterData *fPrinterData;
const PrinterCap *fPrinterCap;
BTextControl *fGamma;
BRadioButton *fAll;
BCheckBox *fCollate;
BCheckBox *fReverse;
BPopUpMenu *fColorType;
BPopUpMenu *fPaperFeed;
BCheckBox *fDuplex;
BPopUpMenu *fNup;
};
class JobSetupDlg : public BWindow {
@ -52,9 +52,9 @@ public:
int Go();
private:
int __result;
long __semaphore;
BMessageFilter *__filter;
int fResult;
long fSemaphore;
BMessageFilter *fFilter;
};
#endif /* __JOBSETUPDLG_H */

View File

@ -23,12 +23,12 @@ public:
bool UpdateJobData();
private:
JobData *__job_data;
PrinterData *__printer_data;
const PrinterCap *__printer_cap;
BRadioButton *__portrait;
BPopUpMenu *__paper;
BPopUpMenu *__resolution;
JobData *fJobData;
PrinterData *fPrinterData;
const PrinterCap *fPrinterCap;
BRadioButton *fPortrait;
BPopUpMenu *fPaper;
BPopUpMenu *fResolution;
};
class PageSetupDlg : public BWindow {
@ -40,9 +40,9 @@ public:
int Go();
private:
int __result;
long __semaphore;
BMessageFilter *__filter;
int fResult;
long fSemaphore;
BMessageFilter *fFilter;
};
#endif /* __PAGESETUPDLG_H */

View File

@ -22,7 +22,7 @@ protected:
PreviewWindow &operator = (const PreviewWindow &);
private:
long __semaphore;
long fSemaphore;
};
#endif /* __PREVIEW_H */

View File

@ -39,12 +39,12 @@ public:
bool enumObject(PictureData **);
private:
BFile *__file;
bool __reverse;
int __picture_count;
int __rest;
off_t __offset;
bool __hollow;
BFile *fFile;
bool fReverse;
int fPictureCount;
int fRest;
off_t fOffset;
bool fHollow;
};
typedef list<PageData *> PageDataList;
@ -57,8 +57,8 @@ public:
bool enumObject(PageData **);
private:
PageDataList __pages;
PageDataList::iterator __it;
PageDataList fPages;
PageDataList::iterator fIt;
};
#endif /* __PRINTPROCESS_H */

View File

@ -16,7 +16,9 @@ using namespace std;
#define std
#endif
#define UNKNOWN_PRINTER 0
enum {
kUnknownPrinter = 0
};
struct BaseCap {
string label;
@ -25,16 +27,16 @@ struct BaseCap {
};
struct PaperCap : public BaseCap {
JobData::PAPER paper;
JobData::Paper paper;
BRect paper_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) {}
};
struct PaperSourceCap : public BaseCap {
JobData::PAPERSOURCE paper_source;
PaperSourceCap(const string &n, bool d, JobData::PAPERSOURCE f)
JobData::PaperSource paper_source;
PaperSourceCap(const string &n, bool d, JobData::PaperSource f)
: BaseCap(n, d), paper_source(f) {}
};
@ -46,26 +48,26 @@ struct ResolutionCap : public BaseCap {
};
struct OrientationCap : public BaseCap {
JobData::ORIENTATION orientation;
OrientationCap(const string &n, bool d, JobData::ORIENTATION o)
JobData::Orientation orientation;
OrientationCap(const string &n, bool d, JobData::Orientation o)
: BaseCap(n, d), orientation(o) {}
};
struct PrintStyleCap : public BaseCap {
JobData::PRINTSTYLE print_style;
PrintStyleCap(const string &n, bool d, JobData::PRINTSTYLE x)
JobData::PrintStyle print_style;
PrintStyleCap(const string &n, bool d, JobData::PrintStyle x)
: BaseCap(n, d), print_style(x) {}
};
struct BindingLocationCap : public BaseCap {
JobData::BINDINGLOCATION binding_location;
BindingLocationCap(const string &n, bool d, JobData::BINDINGLOCATION b)
JobData::BindingLocation binding_location;
BindingLocationCap(const string &n, bool d, JobData::BindingLocation b)
: BaseCap(n, d), binding_location(b) {}
};
struct ColorCap : public BaseCap {
JobData::COLOR color;
ColorCap(const string &n, bool d, JobData::COLOR c)
JobData::Color color;
ColorCap(const string &n, bool d, JobData::Color c)
: BaseCap(n, d), color(c) {}
};
@ -79,20 +81,20 @@ public:
PrinterCap(const PrinterCap &printer_cap);
PrinterCap &operator = (const PrinterCap &printer_cap);
*/
enum CAPID {
PAPER,
PAPERSOURCE,
RESOLUTION,
ORIENTATION,
PRINTSTYLE,
BINDINGLOCATION,
COLOR
enum CapID {
kPaper,
kPaperSource,
kResolution,
kOrientation,
kPrintStyle,
kBindingLocation,
kColor
};
virtual int countCap(CAPID) const = 0;
virtual bool isSupport(CAPID) const = 0;
virtual const BaseCap **enumCap(CAPID) const = 0;
const BaseCap *getDefaultCap(CAPID) const;
virtual int countCap(CapID) const = 0;
virtual bool isSupport(CapID) const = 0;
virtual const BaseCap **enumCap(CapID) const = 0;
const BaseCap *getDefaultCap(CapID) const;
int getPrinterId() const;
protected:
@ -102,23 +104,23 @@ protected:
void setPrinterId(int id);
private:
const PrinterData *__printer_data;
int __printer_id;
const PrinterData *fPrinterData;
int fPrinterID;
};
inline const PrinterData *PrinterCap::getPrinterData() const
{
return __printer_data;
return fPrinterData;
}
inline int PrinterCap::getPrinterId() const
{
return __printer_id;
return fPrinterID;
}
inline void PrinterCap::setPrinterId(int id)
{
__printer_id = id;
fPrinterID = id;
}
#endif /* __PRINTERCAP_H */

View File

@ -33,7 +33,7 @@ public:
const string &getComments() 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 setComments(const char *comments);
@ -44,41 +44,41 @@ protected:
PrinterData &operator = (const PrinterData &printer_data);
private:
string __driver_name;
string __printer_name;
string __comments;
string __transport;
BNode *__node;
string fDriverName;
string fPrinterName;
string fComments;
string fTransport;
BNode *fNode;
};
inline const string &PrinterData::getDriverName() const
{
return __driver_name;
return fDriverName;
}
inline const string &PrinterData::getPrinterName() const
{
return __printer_name;
return fPrinterName;
}
inline const string &PrinterData::getComments() const
{
return __comments;
return fComments;
}
inline const string &PrinterData::getTransport() const
{
return __transport;
return fTransport;
}
inline void PrinterData::setPrinterName(const char *printer_name)
{
__printer_name = printer_name;
fPrinterName = printer_name;
}
inline void PrinterData::setComments(const char *comments)
{
__comments = comments;
fComments = comments;
}
#endif // __PRINTERDATA_H

View File

@ -12,17 +12,17 @@
class SpoolMetaData {
private:
string __description;
string __mime_type;
string __creation_time;
string fDescription;
string fMimeType;
string fCreationTime;
public:
SpoolMetaData(BFile* spool_file);
~SpoolMetaData();
const string& getDescription() const { return __description; }
const string& getMimeType() const { return __mime_type; }
const string& getCreationTime() const { return __creation_time; }
const string& getDescription() const { return fDescription; }
const string& getMimeType() const { return fMimeType; }
const string& getCreationTime() const { return fCreationTime; }
};
#endif /* __SpoolMetaData_H */

View File

@ -25,10 +25,10 @@ extern "C" {
class TransportException {
private:
string __str;
string fWhat;
public:
TransportException(const string &what_arg) : __str(what_arg) {}
const char *what() const { return __str.c_str(); }
TransportException(const string &what_arg) : fWhat(what_arg) {}
const char *what() const { return fWhat.c_str(); }
};
class Transport {
@ -45,12 +45,12 @@ protected:
Transport &operator = (const Transport &);
private:
image_id __image;
PFN_init_transport __init_transport;
PFN_exit_transport __exit_transport;
BDataIO *__data_stream;
bool __abort;
string __last_error_string;
image_id fImage;
PFN_init_transport fInitTransport;
PFN_exit_transport fExitTransport;
BDataIO *fDataStream;
bool fAbort;
string fLastErrorString;
};
#endif // __TRANSPORT_H

View File

@ -26,9 +26,9 @@ protected:
UIDriver &operator = (const UIDriver &);
private:
BMessage *__msg;
PrinterData *__printer_data;
const PrinterCap *__printer_cap;
BMessage *fMsg;
PrinterData *fPrinterData;
const PrinterCap *fPrinterCap;
};
#endif /* __UIDRIVER_H */

View File

@ -17,7 +17,7 @@ struct RECT {
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);

View File

@ -18,6 +18,11 @@ using namespace std;
#define std
#endif
enum {
kMsgOK = 'AbOK'
};
class AboutBoxView : public BView {
public:
AboutBoxView(BRect frame, const char *driver_name, const char *version, const char *copyright);
@ -25,17 +30,17 @@ public:
virtual void AttachedToWindow();
private:
string __driver_name;
string __version;
string __copyright;
string fDriverName;
string fVersion;
string fCopyright;
};
AboutBoxView::AboutBoxView(BRect rect, const char *driver_name, const char *version, const char *copyright)
: BView(rect, "", B_FOLLOW_ALL, B_WILL_DRAW)
{
__driver_name = driver_name;
__version = version;
__copyright = copyright;
fDriverName = driver_name;
fVersion = version;
fCopyright = copyright;
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
SetDrawingMode(B_OP_SELECT);
}
@ -43,7 +48,7 @@ AboutBoxView::AboutBoxView(BRect rect, const char *driver_name, const char *vers
void AboutBoxView::Draw(BRect)
{
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 ");
SetHighColor(0, 0, 0xff);
DrawString("B");
@ -51,17 +56,15 @@ void AboutBoxView::Draw(BRect)
DrawString("e");
SetHighColor(0, 0, 0);
DrawString("OS Version ");
DrawString(__version.c_str());
DrawString(__copyright.c_str(), BPoint(10.0f, 30.0f));
DrawString(fVersion.c_str());
DrawString(fCopyright.c_str(), BPoint(10.0f, 30.0f));
}
#define M_OK 1
void AboutBoxView::AttachedToWindow()
{
BRect rect;
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);
button->MakeDefault(true);
}
@ -85,7 +88,7 @@ AboutBoxWindow::AboutBoxWindow(BRect frame, const char *driver_name, const char
void AboutBoxWindow::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case M_OK:
case kMsgOK:
be_app->PostMessage(B_QUIT_REQUESTED);
break;
}

View File

@ -34,15 +34,19 @@ using namespace std;
#define std
#endif
enum {
kMaxMemorySize = (4 *1024 *1024)
};
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;
__bitmap = NULL;
__transport = NULL;
__org_job_data = NULL;
__real_job_data = NULL;
__spool_meta_data = NULL;
fView = NULL;
fBitmap = NULL;
fTransport = NULL;
fOrgJobData = NULL;
fRealJobData = NULL;
fSpoolMetaData = NULL;
}
GraphicsDriver::~GraphicsDriver()
@ -53,96 +57,94 @@ void GraphicsDriver::setupData(BFile *spool_file, long page_count)
{
BMessage *msg = new BMessage();
msg->Unflatten(spool_file);
__org_job_data = new JobData(msg, __printer_cap);
fOrgJobData = new JobData(msg, fPrinterCap);
DUMP_BMESSAGE(msg);
delete msg;
__real_job_data = new JobData(*__org_job_data);
fRealJobData = new JobData(*fOrgJobData);
BRect rc;
switch (__org_job_data->getNup()) {
switch (fOrgJobData->getNup()) {
case 2:
case 8:
case 32:
case 128:
rc.left = __org_job_data->getPrintableRect().top;
rc.top = __org_job_data->getPrintableRect().left;
rc.right = __org_job_data->getPrintableRect().bottom;
rc.bottom = __org_job_data->getPrintableRect().right;
__real_job_data->setPrintableRect(rc);
if (JobData::PORTRAIT == __org_job_data->getOrientation())
__real_job_data->setOrientation(JobData::LANDSCAPE);
rc.left = fOrgJobData->getPrintableRect().top;
rc.top = fOrgJobData->getPrintableRect().left;
rc.right = fOrgJobData->getPrintableRect().bottom;
rc.bottom = fOrgJobData->getPrintableRect().right;
fRealJobData->setPrintableRect(rc);
if (JobData::kPortrait == fOrgJobData->getOrientation())
fRealJobData->setOrientation(JobData::kLandscape);
else
__real_job_data->setOrientation(JobData::PORTRAIT);
fRealJobData->setOrientation(JobData::kPortrait);
break;
}
if (__org_job_data->getCollate() && page_count > 1) {
__real_job_data->setCopies(1);
__internal_copies = __org_job_data->getCopies();
if (fOrgJobData->getCollate() && page_count > 1) {
fRealJobData->setCopies(1);
fInternalCopies = fOrgJobData->getCopies();
} else {
__internal_copies = 1;
fInternalCopies = 1;
}
__spool_meta_data = new SpoolMetaData(spool_file);
fSpoolMetaData = new SpoolMetaData(spool_file);
}
void GraphicsDriver::cleanupData()
{
delete __real_job_data;
delete __org_job_data;
delete __spool_meta_data;
__real_job_data = NULL;
__org_job_data = NULL;
__spool_meta_data = NULL;
delete fRealJobData;
delete fOrgJobData;
delete fSpoolMetaData;
fRealJobData = NULL;
fOrgJobData = NULL;
fSpoolMetaData = NULL;
}
#define MAX_MEMORY_SIZE (4 *1024 *1024)
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;
__page_height = (__real_job_data->getPrintableRect().IntegerHeight() * __org_job_data->getYres() + 71) / 72;
fPageWidth = (fRealJobData->getPrintableRect().IntegerWidth() * fOrgJobData->getXres() + 71) / 72;
fPageHeight = (fRealJobData->getPrintableRect().IntegerHeight() * fOrgJobData->getYres() + 71) / 72;
int widthByte = (__page_width * __pixel_depth + 7) / 8;
int size = widthByte * __page_height;
int widthByte = (fPageWidth * fPixelDepth + 7) / 8;
int size = widthByte * fPageHeight;
if (size < MAX_MEMORY_SIZE) {
__band_count = 0;
__band_width = __page_width;
__band_height = __page_height;
if (size < kMaxMemorySize) {
fBandCount = 0;
fBandWidth = fPageWidth;
fBandHeight = fPageHeight;
} else {
__band_count = (size + MAX_MEMORY_SIZE - 1) / MAX_MEMORY_SIZE;
if ((JobData::LANDSCAPE == __real_job_data->getOrientation()) && (__flags & GDF_ROTATE_BAND_BITMAP)) {
__band_width = (__page_width + __band_count - 1) / __band_count;
__band_height = __page_height;
fBandCount = (size + kMaxMemorySize - 1) / kMaxMemorySize;
if ((JobData::kLandscape == fRealJobData->getOrientation()) && (fFlags & kGDFRotateBandBitmap)) {
fBandWidth = (fPageWidth + fBandCount - 1) / fBandCount;
fBandHeight = fPageHeight;
} else {
__band_width = __page_width;
__band_height = (__page_height + __band_count - 1) / __band_count;
fBandWidth = fPageWidth;
fBandHeight = (fPageHeight + fBandCount - 1) / fBandCount;
}
}
DBGMSG(("****************\n"));
DBGMSG(("page_width = %d\n", __page_width));
DBGMSG(("page_height = %d\n", __page_height));
DBGMSG(("band_count = %d\n", __band_count));
DBGMSG(("band_height = %d\n", __band_height));
DBGMSG(("page_width = %d\n", fPageWidth));
DBGMSG(("page_height = %d\n", fPageHeight));
DBGMSG(("band_count = %d\n", fBandCount));
DBGMSG(("band_height = %d\n", fBandHeight));
DBGMSG(("****************\n"));
BRect rect;
rect.Set(0, 0, __band_width - 1, __band_height - 1);
__bitmap = new BBitmap(rect, __org_job_data->getSurfaceType(), true);
__view = new BView(rect, "", B_FOLLOW_ALL, B_WILL_DRAW);
__bitmap->AddChild(__view);
rect.Set(0, 0, fBandWidth - 1, fBandHeight - 1);
fBitmap = new BBitmap(rect, fOrgJobData->getSurfaceType(), true);
fView = new BView(rect, "", B_FOLLOW_ALL, B_WILL_DRAW);
fBitmap->AddChild(fView);
}
void GraphicsDriver::cleanupBitmap()
{
delete __bitmap;
__bitmap = NULL;
__view = NULL;
delete fBitmap;
fBitmap = NULL;
fView = NULL;
}
BPoint get_scale(JobData *org_job_data)
@ -243,7 +245,7 @@ BPoint get_offset(
break;
case 2:
if (index == 1) {
if (JobData::PORTRAIT == org_job_data->getOrientation()) {
if (JobData::kPortrait == org_job_data->getOrientation()) {
offset.x = width;
} else {
offset.y = height;
@ -251,7 +253,7 @@ BPoint get_offset(
}
break;
case 8:
if (JobData::PORTRAIT == org_job_data->getOrientation()) {
if (JobData::kPortrait == org_job_data->getOrientation()) {
offset.x = width * (index / 2);
offset.y = height * (index % 2);
} else {
@ -260,7 +262,7 @@ BPoint get_offset(
}
break;
case 32:
if (JobData::PORTRAIT == org_job_data->getOrientation()) {
if (JobData::kPortrait == org_job_data->getOrientation()) {
offset.x = width * (index / 4);
offset.y = height * (index % 4);
} else {
@ -331,27 +333,27 @@ bool GraphicsDriver::printPage(PageDataList *pages)
}
do {
__view->SetScale(1.0);
__view->SetHighColor(255, 255, 255);
__view->ConstrainClippingRegion(NULL);
__view->FillRect(__view->Bounds());
fView->SetScale(1.0);
fView->SetHighColor(255, 255, 255);
fView->ConstrainClippingRegion(NULL);
fView->FillRect(fView->Bounds());
BPoint scale = get_scale(__org_job_data);
float real_scale = min(scale.x, scale.y) * __org_job_data->getXres() / 72.0f;
__view->SetScale(real_scale);
BPoint scale = get_scale(fOrgJobData);
float real_scale = min(scale.x, scale.y) * fOrgJobData->getXres() / 72.0f;
fView->SetScale(real_scale);
float x = offset.x / real_scale;
float y = offset.y / real_scale;
int page_index = 0;
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.y -= y;
BRect clip(__org_job_data->getPrintableRect());
BRect clip(fOrgJobData->getPrintableRect());
clip.OffsetTo(left_top);
BRegion *region = new BRegion();
region->Set(clip);
__view->ConstrainClippingRegion(region);
fView->ConstrainClippingRegion(region);
delete region;
if ((*it)->startEnum()) {
bool more;
@ -359,37 +361,37 @@ bool GraphicsDriver::printPage(PageDataList *pages)
PictureData *picture_data;
more = (*it)->enumObject(&picture_data);
BPoint real_offset = left_top + picture_data->point;
__view->DrawPicture(picture_data->picture, real_offset);
__view->Sync();
fView->DrawPicture(picture_data->picture, real_offset);
fView->Sync();
delete picture_data;
} while (more);
}
}
if (!nextBand(__bitmap, &offset)) {
if (!nextBand(fBitmap, &offset)) {
return false;
}
} while (offset.x >= 0.0f && offset.y >= 0.0f);
return true;
#else // !USE_PREVIEW_FOR_DEBUG
__view->SetScale(1.0);
__view->SetHighColor(255, 255, 255);
__view->ConstrainClippingRegion(NULL);
__view->FillRect(__view->Bounds());
fView->SetScale(1.0);
fView->SetHighColor(255, 255, 255);
fView->ConstrainClippingRegion(NULL);
fView->FillRect(fView->Bounds());
BPoint scale = get_scale(__org_job_data);
__view->SetScale(min(scale.x, scale.y));
BPoint scale = get_scale(fOrgJobData);
fView->SetScale(min(scale.x, scale.y));
int page_index = 0;
PageDataList::iterator it;
for (it = pages->begin() ; it != pages->end() ; it++) {
BPoint left_top(get_offset(page_index, &scale, __org_job_data));
BRect clip(__org_job_data->getPrintableRect());
BPoint left_top(get_offset(page_index, &scale, fOrgJobData));
BRect clip(fOrgJobData->getPrintableRect());
clip.OffsetTo(left_top);
BRegion *region = new BRegion();
region->Set(clip);
__view->ConstrainClippingRegion(region);
fView->ConstrainClippingRegion(region);
delete region;
if ((*it)->startEnum()) {
bool more;
@ -397,17 +399,17 @@ bool GraphicsDriver::printPage(PageDataList *pages)
PictureData *picture_data;
more = (*it)->enumObject(&picture_data);
BPoint real_offset = left_top + picture_data->point;
__view->DrawPicture(picture_data->picture, real_offset);
__view->Sync();
fView->DrawPicture(picture_data->picture, real_offset);
fView->Sync();
delete picture_data;
} while (more);
}
page_index++;
}
BRect rc(__real_job_data->getPrintableRect());
BRect rc(fRealJobData->getPrintableRect());
rc.OffsetTo(30.0, 30.0);
PreviewWindow *preview = new PreviewWindow(rc, "Preview", __bitmap);
PreviewWindow *preview = new PreviewWindow(rc, "Preview", fBitmap);
preview->Go();
#endif // USE_PREVIEW_FOR_DEBUG
}
@ -429,15 +431,15 @@ bool GraphicsDriver::printDocument(SpoolData *spool_data)
DBGMSG(("page index = %d\n", page_index));
if (!(success = startPage(page_index)))
break;
nup = __org_job_data->getNup();
nup = fOrgJobData->getNup();
PageDataList pages;
do {
more = spool_data->enumObject(&page_data);
pages.push_back(page_data);
} while (more && --nup);
__view->Window()->Lock();
fView->Window()->Lock();
success = printPage(&pages);
__view->Window()->Unlock();
fView->Window()->Unlock();
if (!success)
break;
if (!(success = endPage(page_index)))
@ -448,9 +450,9 @@ bool GraphicsDriver::printDocument(SpoolData *spool_data)
#ifndef USE_PREVIEW_FOR_DEBUG
if (success
&& __printer_cap->isSupport(PrinterCap::PRINTSTYLE)
&& (__org_job_data->getPrintStyle() != JobData::SIMPLEX)
&& (((page_index + __org_job_data->getNup() - 1) / __org_job_data->getNup()) % 2))
&& fPrinterCap->isSupport(PrinterCap::kPrintStyle)
&& (fOrgJobData->getPrintStyle() != JobData::kSimplex)
&& (((page_index + fOrgJobData->getNup() - 1) / fOrgJobData->getNup()) % 2))
{
success = startPage(page_index);
if (success) {
@ -481,17 +483,17 @@ bool GraphicsDriver::printJob(BFile *spool_file)
return true;
}
__transport = new Transport(__printer_data);
fTransport = new Transport(fPrinterData);
if (__transport->check_abort()) {
if (fTransport->check_abort()) {
success = false;
} else {
setupData(spool_file, pfh.page_count);
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();
if (success) {
while (__internal_copies--) {
while (fInternalCopies--) {
success = printDocument(&spool_data);
if (success == false) {
break;
@ -505,23 +507,23 @@ bool GraphicsDriver::printJob(BFile *spool_file)
if (success == false) {
BAlert *alert;
if (__transport->check_abort()) {
alert = new BAlert("", __transport->last_error().c_str(), "OK");
if (fTransport->check_abort()) {
alert = new BAlert("", fTransport->last_error().c_str(), "OK");
} else {
alert = new BAlert("", "Printer not responding.", "OK");
}
alert->Go();
}
delete __transport;
__transport = NULL;
delete fTransport;
fTransport = NULL;
return success;
}
BMessage *GraphicsDriver::takeJob(BFile* spool_file, uint32 flags)
{
__flags = flags;
fFlags = flags;
BMessage *msg;
if (printJob(spool_file)) {
msg = new BMessage('okok');
@ -558,27 +560,27 @@ bool GraphicsDriver::endDoc(bool)
void GraphicsDriver::writeSpoolData(const void *buffer, size_t size) throw(TransportException)
{
if (__transport) {
__transport->write(buffer, size);
if (fTransport) {
fTransport->write(buffer, size);
}
}
void GraphicsDriver::writeSpoolString(const char *format, ...) throw(TransportException)
{
if (__transport) {
if (fTransport) {
char buffer[256];
va_list ap;
va_start(ap, format);
vsprintf(buffer, format, ap);
__transport->write(buffer, strlen(buffer));
fTransport->write(buffer, strlen(buffer));
va_end(ap);
}
}
void GraphicsDriver::writeSpoolChar(char c) throw(TransportException)
{
if (__transport) {
__transport->write(&c, 1);
if (fTransport) {
fTransport->write(&c, 1);
}
}

View File

@ -9,27 +9,26 @@
#include "PrinterCap.h"
#include "DbgMsg.h"
const char *JD_XRES = "xres";
const char *JD_YRES = "yres";
const char *JD_COPIES = "copies";
const char *JD_ORIENTATION = "orientation";
const char *JD_SCALING = "scaling";
const char *JD_PAPER_RECT = "paper_rect";
const char *JD_FIRST_PAGE = "first_page";
const char *JD_LAST_PAGE = "last_page";
const char *JD_PRINTABLE_RECT = "printable_rect";
const char *kJDXRes = "xres";
const char *kJDYRes = "yres";
const char *kJDCopies = "copies";
const char *kJDOrientation = "orientation";
const char *kJDScaling = "scaling";
const char *kJDPaperRect = "paper_rect";
const char *kJDFirstPage = "first_page";
const char *kJDLastPage = "last_page";
const char *kJDPrintableRect = "printable_rect";
const char *JD_PAPER = "JJJJ_paper";
const char *JD_NUP = "JJJJ_nup";
const char *JD_SURFACE_TYPE = "JJJJ_surface_type";
const char *JD_GAMMA = "JJJJ_gamma";
const char *JD_PAPER_SOURCE = "JJJJ_paper_source";
const char *JD_COLLATE = "JJJJ_collate";
const char *JD_REVERSE = "JJJJ_reverse";
const char *JD_PRINT_STYLE = "JJJJ_print_style";
const char *JD_BINDING_LOCATION = "JJJJ_binding_location";
const char *JD_PAGE_ORDER = "JJJJ_page_order";
const char *JD_COLOR = "JJJJ_color";
const char *kJDPaper = "JJJJ_paper";
const char *kJDNup = "JJJJ_nup";
const char *kJDGamma = "JJJJ_gamma";
const char *kJDPaperSource = "JJJJ_paper_source";
const char *kJDCollate = "JJJJ_collate";
const char *kJDReverse = "JJJJ_reverse";
const char *kJDPrintStyle = "JJJJ_print_style";
const char *kJDBindingLocation = "JJJJ_binding_location";
const char *kJDPageOrder = "JJJJ_page_order";
const char *kJDColor = "JJJJ_color";
JobData::JobData(BMessage *msg, const PrinterCap *cap)
{
@ -42,281 +41,269 @@ JobData::~JobData()
JobData::JobData(const JobData &job_data)
{
__paper = job_data.__paper;
__xres = job_data.__xres;
__yres = job_data.__yres;
__orientation = job_data.__orientation;
__scaling = job_data.__scaling;
__paper_rect = job_data.__paper_rect;
__printable_rect = job_data.__printable_rect;
__nup = job_data.__nup;
__first_page = job_data.__first_page;
__last_page = job_data.__last_page;
__surface_type = job_data.__surface_type;
__gamma = job_data.__gamma;
__paper_source = job_data.__paper_source;
__copies = job_data.__copies;
__collate = job_data.__collate;
__reverse = job_data.__reverse;
__print_style = job_data.__print_style;
__binding_location = job_data.__binding_location;
__page_order = job_data.__page_order;
__msg = job_data.__msg;
__color = job_data.__color;
fPaper = job_data.fPaper;
fXRes = job_data.fXRes;
fYRes = job_data.fYRes;
fOrientation = job_data.fOrientation;
fScaling = job_data.fScaling;
fPaperRect = job_data.fPaperRect;
fPrintableRect = job_data.fPrintableRect;
fNup = job_data.fNup;
fFirstPage = job_data.fFirstPage;
fLastPage = job_data.fLastPage;
fGamma = job_data.fGamma;
fPaperSource = job_data.fPaperSource;
fCopies = job_data.fCopies;
fCollate = job_data.fCollate;
fReverse = job_data.fReverse;
fPrintStyle = job_data.fPrintStyle;
fBindingLocation = job_data.fBindingLocation;
fPageOrder = job_data.fPageOrder;
fMsg = job_data.fMsg;
fColor = job_data.fColor;
}
JobData &JobData::operator = (const JobData &job_data)
{
__paper = job_data.__paper;
__xres = job_data.__xres;
__yres = job_data.__yres;
__orientation = job_data.__orientation;
__scaling = job_data.__scaling;
__paper_rect = job_data.__paper_rect;
__printable_rect = job_data.__printable_rect;
__nup = job_data.__nup;
__first_page = job_data.__first_page;
__last_page = job_data.__last_page;
__surface_type = job_data.__surface_type;
__gamma = job_data.__gamma;
__paper_source = job_data.__paper_source;
__copies = job_data.__copies;
__collate = job_data.__collate;
__reverse = job_data.__reverse;
__print_style = job_data.__print_style;
__binding_location = job_data.__binding_location;
__page_order = job_data.__page_order;
__msg = job_data.__msg;
__color = job_data.__color;
fPaper = job_data.fPaper;
fXRes = job_data.fXRes;
fYRes = job_data.fYRes;
fOrientation = job_data.fOrientation;
fScaling = job_data.fScaling;
fPaperRect = job_data.fPaperRect;
fPrintableRect = job_data.fPrintableRect;
fNup = job_data.fNup;
fFirstPage = job_data.fFirstPage;
fLastPage = job_data.fLastPage;
fGamma = job_data.fGamma;
fPaperSource = job_data.fPaperSource;
fCopies = job_data.fCopies;
fCollate = job_data.fCollate;
fReverse = job_data.fReverse;
fPrintStyle = job_data.fPrintStyle;
fBindingLocation = job_data.fBindingLocation;
fPageOrder = job_data.fPageOrder;
fMsg = job_data.fMsg;
fColor = job_data.fColor;
return *this;
}
void JobData::load(BMessage *msg, const PrinterCap *cap)
{
__msg = msg;
fMsg = msg;
if (msg->HasInt32(JD_PAPER))
__paper = (PAPER)msg->FindInt32(JD_PAPER);
else if (cap->isSupport(PrinterCap::PAPER))
__paper = ((const PaperCap *)cap->getDefaultCap(PrinterCap::PAPER))->paper;
if (msg->HasInt32(kJDPaper))
fPaper = (Paper)msg->FindInt32(kJDPaper);
else if (cap->isSupport(PrinterCap::kPaper))
fPaper = ((const PaperCap *)cap->getDefaultCap(PrinterCap::kPaper))->paper;
else
__paper = A4;
fPaper = kA4;
if (msg->HasInt64(JD_XRES)) {
if (msg->HasInt64(kJDXRes)) {
int64 xres64;
msg->FindInt64(JD_XRES, &xres64);
__xres = xres64;
} else if (cap->isSupport(PrinterCap::RESOLUTION)) {
__xres = ((const ResolutionCap *)cap->getDefaultCap(PrinterCap::RESOLUTION))->xres;
msg->FindInt64(kJDXRes, &xres64);
fXRes = xres64;
} else if (cap->isSupport(PrinterCap::kResolution)) {
fXRes = ((const ResolutionCap *)cap->getDefaultCap(PrinterCap::kResolution))->xres;
} else {
__xres = 300;
fXRes = 300;
}
if (msg->HasInt64(JD_YRES)) {
if (msg->HasInt64(kJDYRes)) {
int64 yres64;
msg->FindInt64(JD_YRES, &yres64);
__yres = yres64;
} else if (cap->isSupport(PrinterCap::RESOLUTION)) {
__yres = ((const ResolutionCap *)cap->getDefaultCap(PrinterCap::RESOLUTION))->yres;
msg->FindInt64(kJDYRes, &yres64);
fYRes = yres64;
} else if (cap->isSupport(PrinterCap::kResolution)) {
fYRes = ((const ResolutionCap *)cap->getDefaultCap(PrinterCap::kResolution))->yres;
} else {
__yres = 300;
fYRes = 300;
}
if (msg->HasInt32(JD_ORIENTATION))
__orientation = (ORIENTATION)msg->FindInt32(JD_ORIENTATION);
else if (cap->isSupport(PrinterCap::ORIENTATION))
__orientation = ((const OrientationCap *)cap->getDefaultCap(PrinterCap::ORIENTATION))->orientation;
if (msg->HasInt32(kJDOrientation))
fOrientation = (Orientation)msg->FindInt32(kJDOrientation);
else if (cap->isSupport(PrinterCap::kOrientation))
fOrientation = ((const OrientationCap *)cap->getDefaultCap(PrinterCap::kOrientation))->orientation;
else
__orientation = PORTRAIT;
fOrientation = kPortrait;
if (msg->HasFloat(JD_SCALING))
__scaling = msg->FindFloat(JD_SCALING);
if (msg->HasFloat(kJDScaling))
fScaling = msg->FindFloat(kJDScaling);
else
__scaling = 100.0f;
fScaling = 100.0f;
if (msg->HasRect(JD_PAPER_RECT)) {
__paper_rect = msg->FindRect(JD_PAPER_RECT);
if (msg->HasRect(kJDPaperRect)) {
fPaperRect = msg->FindRect(kJDPaperRect);
}
if (msg->HasRect(JD_PRINTABLE_RECT)) {
__printable_rect = msg->FindRect(JD_PRINTABLE_RECT);
if (msg->HasRect(kJDPrintableRect)) {
fPrintableRect = msg->FindRect(kJDPrintableRect);
}
if (msg->HasInt32(JD_FIRST_PAGE))
__first_page = msg->FindInt32(JD_FIRST_PAGE);
if (msg->HasInt32(kJDFirstPage))
fFirstPage = msg->FindInt32(kJDFirstPage);
else
__first_page = 1;
fFirstPage = 1;
if (msg->HasInt32(JD_LAST_PAGE))
__last_page = msg->FindInt32(JD_LAST_PAGE);
if (msg->HasInt32(kJDLastPage))
fLastPage = msg->FindInt32(kJDLastPage);
else
__last_page = -1;
fLastPage = -1;
if (msg->HasInt32(JD_NUP))
__nup = msg->FindInt32(JD_NUP);
if (msg->HasInt32(kJDNup))
fNup = msg->FindInt32(kJDNup);
else
__nup = 1;
fNup = 1;
if (msg->HasInt32(JD_SURFACE_TYPE))
__surface_type = (color_space)msg->FindInt32(JD_SURFACE_TYPE);
if (msg->HasFloat(kJDGamma))
fGamma = fMsg->FindFloat(kJDGamma);
else
__surface_type = B_CMAP8;
fGamma = 1.4f;
if (msg->HasFloat(JD_GAMMA))
__gamma = __msg->FindFloat(JD_GAMMA);
if (msg->HasInt32(kJDPaperSource))
fPaperSource = (PaperSource)fMsg->FindInt32(kJDPaperSource);
else if (cap->isSupport(PrinterCap::kPaperSource))
fPaperSource = ((const PaperSourceCap *)cap->getDefaultCap(PrinterCap::kPaperSource))->paper_source;
else
__gamma = 1.4f;
fPaperSource = kAuto;
if (msg->HasInt32(JD_PAPER_SOURCE))
__paper_source = (PAPERSOURCE)__msg->FindInt32(JD_PAPER_SOURCE);
else if (cap->isSupport(PrinterCap::PAPERSOURCE))
__paper_source = ((const PaperSourceCap *)cap->getDefaultCap(PrinterCap::PAPERSOURCE))->paper_source;
if (msg->HasInt32(kJDCopies))
fCopies = msg->FindInt32(kJDCopies);
else
__paper_source = AUTO;
fCopies = 1;
if (msg->HasInt32(JD_COPIES))
__copies = msg->FindInt32(JD_COPIES);
if (msg->HasBool(kJDCollate))
fCollate = msg->FindBool(kJDCollate);
else
__copies = 1;
fCollate = false;
if (msg->HasBool(JD_COLLATE))
__collate = msg->FindBool(JD_COLLATE);
if (msg->HasBool(kJDReverse))
fReverse = msg->FindBool(kJDReverse);
else
__collate = false;
fReverse = false;
if (msg->HasBool(JD_REVERSE))
__reverse = msg->FindBool(JD_REVERSE);
if (msg->HasInt32(kJDPrintStyle))
fPrintStyle = (PrintStyle)msg->FindInt32(kJDPrintStyle);
else if (cap->isSupport(PrinterCap::kPrintStyle))
fPrintStyle = ((const PrintStyleCap *)cap->getDefaultCap(PrinterCap::kPrintStyle))->print_style;
else
__reverse = false;
fPrintStyle = kSimplex;
if (msg->HasInt32(JD_PRINT_STYLE))
__print_style = (PRINTSTYLE)msg->FindInt32(JD_PRINT_STYLE);
else if (cap->isSupport(PrinterCap::PRINTSTYLE))
__print_style = ((const PrintStyleCap *)cap->getDefaultCap(PrinterCap::PRINTSTYLE))->print_style;
if (msg->HasInt32(kJDBindingLocation))
fBindingLocation = (BindingLocation)msg->FindInt32(kJDBindingLocation);
else if (cap->isSupport(PrinterCap::kBindingLocation))
fBindingLocation = ((const BindingLocationCap *)cap->getDefaultCap(PrinterCap::kBindingLocation))->binding_location;
else
__print_style = SIMPLEX;
fBindingLocation = kLongEdgeLeft;
if (msg->HasInt32(JD_BINDING_LOCATION))
__binding_location = (BINDINGLOCATION)msg->FindInt32(JD_BINDING_LOCATION);
else if (cap->isSupport(PrinterCap::BINDINGLOCATION))
__binding_location = ((const BindingLocationCap *)cap->getDefaultCap(PrinterCap::BINDINGLOCATION))->binding_location;
if (msg->HasInt32(kJDPageOrder))
fPageOrder = (PageOrder)msg->FindInt32(kJDPageOrder);
else
__binding_location = LONG_EDGE_LEFT;
fPageOrder = kAcrossFromLeft;
if (msg->HasInt32(JD_PAGE_ORDER))
__page_order = (PAGEORDER)msg->FindInt32(JD_PAGE_ORDER);
if (msg->HasBool(kJDColor))
fColor = msg->FindBool(kJDColor);
else
__page_order = ACROSS_FROM_LEFT;
if (msg->HasBool(JD_COLOR))
__color = msg->FindBool(JD_COLOR);
else
__color = false;
fColor = false;
}
void JobData::save(BMessage *msg)
{
if (msg == NULL) {
msg = __msg;
msg = fMsg;
}
if (msg->HasInt32(JD_PAPER))
msg->ReplaceInt32(JD_PAPER, __paper);
if (msg->HasInt32(kJDPaper))
msg->ReplaceInt32(kJDPaper, fPaper);
else
msg->AddInt32(JD_PAPER, __paper);
msg->AddInt32(kJDPaper, fPaper);
if (msg->HasInt64(JD_XRES))
msg->ReplaceInt64(JD_XRES, __xres);
if (msg->HasInt64(kJDXRes))
msg->ReplaceInt64(kJDXRes, fXRes);
else
msg->AddInt64(JD_XRES, __xres);
msg->AddInt64(kJDXRes, fXRes);
if (msg->HasInt64(JD_YRES))
msg->ReplaceInt64(JD_YRES, __yres);
if (msg->HasInt64(kJDYRes))
msg->ReplaceInt64(kJDYRes, fYRes);
else
msg->AddInt64(JD_YRES, __yres);
msg->AddInt64(kJDYRes, fYRes);
if (msg->HasInt32(JD_ORIENTATION))
msg->ReplaceInt32(JD_ORIENTATION, __orientation);
if (msg->HasInt32(kJDOrientation))
msg->ReplaceInt32(kJDOrientation, fOrientation);
else
msg->AddInt32(JD_ORIENTATION, __orientation);
msg->AddInt32(kJDOrientation, fOrientation);
if (msg->HasFloat(JD_SCALING))
msg->ReplaceFloat(JD_SCALING, __scaling);
if (msg->HasFloat(kJDScaling))
msg->ReplaceFloat(kJDScaling, fScaling);
else
msg->AddFloat(JD_SCALING, __scaling);
msg->AddFloat(kJDScaling, fScaling);
if (msg->HasRect(JD_PAPER_RECT))
msg->ReplaceRect(JD_PAPER_RECT, __paper_rect);
if (msg->HasRect(kJDPaperRect))
msg->ReplaceRect(kJDPaperRect, fPaperRect);
else
msg->AddRect(JD_PAPER_RECT, __paper_rect);
msg->AddRect(kJDPaperRect, fPaperRect);
if (msg->HasRect(JD_PRINTABLE_RECT))
msg->ReplaceRect(JD_PRINTABLE_RECT, __printable_rect);
if (msg->HasRect(kJDPrintableRect))
msg->ReplaceRect(kJDPrintableRect, fPrintableRect);
else
msg->AddRect(JD_PRINTABLE_RECT, __printable_rect);
msg->AddRect(kJDPrintableRect, fPrintableRect);
if (msg->HasInt32(JD_NUP))
msg->ReplaceInt32(JD_NUP, __nup);
if (msg->HasInt32(kJDNup))
msg->ReplaceInt32(kJDNup, fNup);
else
msg->AddInt32(JD_NUP, __nup);
msg->AddInt32(kJDNup, fNup);
if (msg->HasInt32(JD_FIRST_PAGE))
msg->ReplaceInt32(JD_FIRST_PAGE, __first_page);
if (msg->HasInt32(kJDFirstPage))
msg->ReplaceInt32(kJDFirstPage, fFirstPage);
else
msg->AddInt32(JD_FIRST_PAGE, __first_page);
msg->AddInt32(kJDFirstPage, fFirstPage);
if (msg->HasInt32(JD_LAST_PAGE))
msg->ReplaceInt32(JD_LAST_PAGE, __last_page);
if (msg->HasInt32(kJDLastPage))
msg->ReplaceInt32(kJDLastPage, fLastPage);
else
msg->AddInt32(JD_LAST_PAGE, __last_page);
msg->AddInt32(kJDLastPage, fLastPage);
if (msg->HasInt32(JD_SURFACE_TYPE))
msg->ReplaceInt32(JD_SURFACE_TYPE, __surface_type);
if (msg->HasFloat(kJDGamma))
msg->ReplaceFloat(kJDGamma, fGamma);
else
msg->AddInt32(JD_SURFACE_TYPE, __surface_type);
msg->AddFloat(kJDGamma, fGamma);
if (msg->HasFloat(JD_GAMMA))
msg->ReplaceFloat(JD_GAMMA, __gamma);
if (msg->HasInt32(kJDPaperSource))
msg->ReplaceInt32(kJDPaperSource, fPaperSource);
else
msg->AddFloat(JD_GAMMA, __gamma);
msg->AddInt32(kJDPaperSource, fPaperSource);
if (msg->HasInt32(JD_PAPER_SOURCE))
msg->ReplaceInt32(JD_PAPER_SOURCE, __paper_source);
if (msg->HasInt32(kJDCopies))
msg->ReplaceInt32(kJDCopies, fCopies);
else
msg->AddInt32(JD_PAPER_SOURCE, __paper_source);
msg->AddInt32(kJDCopies, fCopies);
if (msg->HasInt32(JD_COPIES))
msg->ReplaceInt32(JD_COPIES, __copies);
if (msg->HasBool(kJDCollate))
msg->ReplaceBool(kJDCollate, fCollate);
else
msg->AddInt32(JD_COPIES, __copies);
msg->AddBool(kJDCollate, fCollate);
if (msg->HasBool(JD_COLLATE))
msg->ReplaceBool(JD_COLLATE, __collate);
if (msg->HasBool(kJDReverse))
msg->ReplaceBool(kJDReverse, fReverse);
else
msg->AddBool(JD_COLLATE, __collate);
msg->AddBool(kJDReverse, fReverse);
if (msg->HasBool(JD_REVERSE))
msg->ReplaceBool(JD_REVERSE, __reverse);
if (msg->HasInt32(kJDPrintStyle))
msg->ReplaceInt32(kJDPrintStyle, fPrintStyle);
else
msg->AddBool(JD_REVERSE, __reverse);
msg->AddInt32(kJDPrintStyle, fPrintStyle);
if (msg->HasInt32(JD_PRINT_STYLE))
msg->ReplaceInt32(JD_PRINT_STYLE, __print_style);
if (msg->HasInt32(kJDBindingLocation))
msg->ReplaceInt32(kJDBindingLocation, fBindingLocation);
else
msg->AddInt32(JD_PRINT_STYLE, __print_style);
msg->AddInt32(kJDBindingLocation, fBindingLocation);
if (msg->HasInt32(JD_BINDING_LOCATION))
msg->ReplaceInt32(JD_BINDING_LOCATION, __binding_location);
if (msg->HasInt32(kJDPageOrder))
msg->ReplaceInt32(kJDPageOrder, fPageOrder);
else
msg->AddInt32(JD_BINDING_LOCATION, __binding_location);
msg->AddInt32(kJDPageOrder, fPageOrder);
if (msg->HasInt32(JD_PAGE_ORDER))
msg->ReplaceInt32(JD_PAGE_ORDER, __page_order);
if (msg->HasBool(kJDColor))
msg->ReplaceBool(kJDColor, fColor);
else
msg->AddInt32(JD_PAGE_ORDER, __page_order);
if (msg->HasBool(JD_COLOR))
msg->ReplaceBool(JD_COLOR, __color);
else
msg->AddBool(JD_COLOR, __color);
msg->AddBool(kJDColor, fColor);
}

View File

@ -235,49 +235,49 @@ struct NupCap : public BaseCap {
NupCap(const string &s, bool d, int n) : BaseCap(s, d), nup(n) {}
};
const SurfaceCap rgb32("RGB32", false, B_RGB32);
const SurfaceCap cmap8("CMAP8", true, B_CMAP8);
const SurfaceCap gray8("GRAY8", false, B_GRAY8);
const SurfaceCap gray1("GRAY1", false, B_GRAY1);
static const SurfaceCap gRGB32("RGB32", false, B_RGB32);
static const SurfaceCap gCMAP8("CMAP8", true, B_CMAP8);
static const SurfaceCap gGray8("GRAY8", false, B_GRAY8);
static const SurfaceCap gGray1("GRAY1", false, B_GRAY1);
const NupCap nup1("Normal", true, 1);
const NupCap nup2("2-up", false, 2);
const NupCap nup4("4-up", false, 4);
const NupCap nup8("8-up", false, 8);
const NupCap nup9("9-up", false, 9);
const NupCap nup16("16-up", false, 16);
const NupCap nup25("25-up", false, 25);
const NupCap nup32("32-up", false, 32);
const NupCap nup36("36-up", false, 36);
static const NupCap gNup1("Normal", true, 1);
static const NupCap gNup2("2-up", false, 2);
static const NupCap gNup4("4-up", false, 4);
static const NupCap gNup8("8-up", false, 8);
static const NupCap gNup9("9-up", false, 9);
static const NupCap gNup16("16-up", false, 16);
static const NupCap gNup25("25-up", false, 25);
static const NupCap gNup32("32-up", false, 32);
static const NupCap gNup36("36-up", false, 36);
const SurfaceCap *surfaces[] = {
&rgb32,
&cmap8,
&gray8,
&gray1
const SurfaceCap *gSurfaces[] = {
&gRGB32,
&gCMAP8,
&gGray8,
&gGray1
};
const NupCap *nups[] = {
&nup1,
&nup2,
&nup4,
&nup8,
&nup9,
&nup16,
&nup25,
&nup32,
&nup36
const NupCap *gNups[] = {
&gNup1,
&gNup2,
&gNup4,
&gNup8,
&gNup9,
&gNup16,
&gNup25,
&gNup32,
&gNup36
};
enum {
M_RANGE_ALL = 1,
M_RANGE_SELECTION,
M_CANCEL,
M_OK
kMsgRangeAll = 'JSdl',
kMsgRangeSelection,
kMsgCancel,
kMsgOK
};
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));
}
@ -300,24 +300,24 @@ void JobSetupView::AttachedToWindow()
/*
// always B_RGB32
__surface_type = new BPopUpMenu("");
__surface_type->SetRadioMode(true);
fSurfaceType = new BPopUpMenu("");
fSurfaceType->SetRadioMode(true);
count = sizeof(surfaces) / sizeof(surfaces[0]);
const SurfaceCap **surface_cap = surfaces;
count = sizeof(gSurfaces) / sizeof(gSurfaces[0]);
const SurfaceCap **surface_cap = gSurfaces;
uint32 support_flags;
while (count--) {
if (bitmaps_support_space((*surface_cap)->surface_type, &support_flags)) {
item = new BMenuItem((*surface_cap)->label.c_str(), NULL);
__surface_type->AddItem(item);
if ((*surface_cap)->surface_type == __job_data->getSurfaceType()) {
fSurfaceType->AddItem(item);
if ((*surface_cap)->surface_type == fJobData->getSurfaceType()) {
item->SetMarked(true);
marked = true;
}
}
surface_cap++;
}
menufield = new BMenuField(bpp_rect, "", "Surface Type", __surface_type);
menufield = new BMenuField(bpp_rect, "", "Surface Type", fSurfaceType);
box->AddChild(menufield);
width = StringWidth("Color") + 10;
menufield->SetDivider(width);
@ -325,15 +325,15 @@ void JobSetupView::AttachedToWindow()
/* color */
marked = false;
__color_type = new BPopUpMenu("");
__color_type->SetRadioMode(true);
fColorType = new BPopUpMenu("");
fColorType->SetRadioMode(true);
count = __printer_cap->countCap(PrinterCap::COLOR);
const ColorCap **color_cap = (const ColorCap **)__printer_cap->enumCap(PrinterCap::COLOR);
count = fPrinterCap->countCap(PrinterCap::kColor);
const ColorCap **color_cap = (const ColorCap **)fPrinterCap->enumCap(PrinterCap::kColor);
while (count--) {
item = new BMenuItem((*color_cap)->label.c_str(), NULL);
__color_type->AddItem(item);
if ((*color_cap)->color == __job_data->getColor()) {
fColorType->AddItem(item);
if ((*color_cap)->color == fJobData->getColor()) {
item->SetMarked(true);
marked = true;
}
@ -341,18 +341,18 @@ void JobSetupView::AttachedToWindow()
}
if (!marked && item)
item->SetMarked(true);
menufield = new BMenuField(bpp_rect, "", "Color", __color_type);
menufield = new BMenuField(bpp_rect, "", "Color", fColorType);
box->AddChild(menufield);
width = StringWidth("Color") + 10;
menufield->SetDivider(width);
__gamma = new BTextControl(gamma_rect, "", "Gamma", "", NULL);
box->AddChild(__gamma);
__gamma->SetDivider(width);
fGamma = new BTextControl(gamma_rect, "", "Gamma", "", NULL);
box->AddChild(fGamma);
fGamma->SetDivider(width);
ostringstream oss3;
oss3 << __job_data->getGamma();
__gamma->SetText(oss3.str().c_str());
oss3 << fJobData->getGamma();
fGamma->SetText(oss3.str().c_str());
/* page range */
@ -360,10 +360,10 @@ void JobSetupView::AttachedToWindow()
AddChild(box);
box->SetLabel("Page Range");
__all = new BRadioButton(all_button_rect, "", "All", new BMessage(M_RANGE_ALL));
box->AddChild(__all);
fAll = new BRadioButton(all_button_rect, "", "All", new BMessage(kMsgRangeAll));
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);
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->SetDivider(StringWidth("To") + 7);
int first_page = __job_data->getFirstPage();
int last_page = __job_data->getLastPage();
int first_page = fJobData->getFirstPage();
int last_page = fJobData->getLastPage();
if (first_page <= 1 && last_page <= 0) {
__all->SetValue(B_CONTROL_ON);
fAll->SetValue(B_CONTROL_ON);
from_page->SetEnabled(false);
to_page->SetEnabled(false);
} else {
@ -399,20 +399,20 @@ void JobSetupView::AttachedToWindow()
to_page->SetText(oss2.str().c_str());
}
__all->SetTarget(this);
fAll->SetTarget(this);
from->SetTarget(this);
/* paper source */
marked = false;
__paper_feed = new BPopUpMenu("");
__paper_feed->SetRadioMode(true);
count = __printer_cap->countCap(PrinterCap::PAPERSOURCE);
const PaperSourceCap **paper_source_cap = (const PaperSourceCap **)__printer_cap->enumCap(PrinterCap::PAPERSOURCE);
fPaperFeed = new BPopUpMenu("");
fPaperFeed->SetRadioMode(true);
count = fPrinterCap->countCap(PrinterCap::kPaperSource);
const PaperSourceCap **paper_source_cap = (const PaperSourceCap **)fPrinterCap->enumCap(PrinterCap::kPaperSource);
while (count--) {
item = new BMenuItem((*paper_source_cap)->label.c_str(), NULL);
__paper_feed->AddItem(item);
if ((*paper_source_cap)->paper_source == __job_data->getPaperSource()) {
fPaperFeed->AddItem(item);
if ((*paper_source_cap)->paper_source == fJobData->getPaperSource()) {
item->SetMarked(true);
marked = true;
}
@ -420,7 +420,7 @@ void JobSetupView::AttachedToWindow()
}
if (!marked)
item->SetMarked(true);
menufield = new BMenuField(paperfeed_rect, "", "Paper Source", __paper_feed);
menufield = new BMenuField(paperfeed_rect, "", "Paper Source", fPaperFeed);
AddChild(menufield);
width = StringWidth("Number of Copies") + 7;
menufield->SetDivider(width);
@ -428,14 +428,14 @@ void JobSetupView::AttachedToWindow()
/* Page Per Sheet */
marked = false;
__nup = new BPopUpMenu("");
__nup->SetRadioMode(true);
count = sizeof(nups) / sizeof(nups[0]);
const NupCap **nup_cap = nups;
fNup = new BPopUpMenu("");
fNup->SetRadioMode(true);
count = sizeof(gNups) / sizeof(gNups[0]);
const NupCap **nup_cap = gNups;
while (count--) {
item = new BMenuItem((*nup_cap)->label.c_str(), NULL);
__nup->AddItem(item);
if ((*nup_cap)->nup == __job_data->getNup()) {
fNup->AddItem(item);
if ((*nup_cap)->nup == fJobData->getNup()) {
item->SetMarked(true);
marked = true;
}
@ -443,17 +443,17 @@ void JobSetupView::AttachedToWindow()
}
if (!marked)
item->SetMarked(true);
menufield = new BMenuField(nup_rect, "", "Page Per Sheet", __nup);
menufield = new BMenuField(nup_rect, "", "Page Per Sheet", fNup);
menufield->SetDivider(width);
AddChild(menufield);
/* duplex */
if (__printer_cap->isSupport(PrinterCap::PRINTSTYLE)) {
__duplex = new BCheckBox(duplex_rect, "Duplex", "Duplex", NULL);
AddChild(__duplex);
if (__job_data->getPrintStyle() != JobData::SIMPLEX) {
__duplex->SetValue(B_CONTROL_ON);
if (fPrinterCap->isSupport(PrinterCap::kPrintStyle)) {
fDuplex = new BCheckBox(duplex_rect, "Duplex", "Duplex", NULL);
AddChild(fDuplex);
if (fJobData->getPrintStyle() != JobData::kSimplex) {
fDuplex->SetValue(B_CONTROL_ON);
}
}
@ -464,33 +464,33 @@ void JobSetupView::AttachedToWindow()
copies->SetDivider(width);
ostringstream oss4;
oss4 << __job_data->getCopies();
oss4 << fJobData->getCopies();
copies->SetText(oss4.str().c_str());
/* collate */
__collate = new BCheckBox(collate_rect, "Collate", "Collate", NULL);
AddChild(__collate);
if (__job_data->getCollate()) {
__collate->SetValue(B_CONTROL_ON);
fCollate = new BCheckBox(collate_rect, "Collate", "Collate", NULL);
AddChild(fCollate);
if (fJobData->getCollate()) {
fCollate->SetValue(B_CONTROL_ON);
}
/* reverse */
__reverse = new BCheckBox(reverse_rect, "Reverse", "Reverse", NULL);
AddChild(__reverse);
if (__job_data->getReverse()) {
__reverse->SetValue(B_CONTROL_ON);
fReverse = new BCheckBox(reverse_rect, "Reverse", "Reverse", NULL);
AddChild(fReverse);
if (fJobData->getReverse()) {
fReverse->SetValue(B_CONTROL_ON);
}
/* cancel */
button = new BButton(cancel_rect, "", "Cancel", new BMessage(M_CANCEL));
button = new BButton(cancel_rect, "", "Cancel", new BMessage(kMsgCancel));
AddChild(button);
/* ok */
button = new BButton(ok_rect, "", "OK", new BMessage(M_OK));
button = new BButton(ok_rect, "", "OK", new BMessage(kMsgOK));
AddChild(button);
button->MakeDefault(true);
}
@ -498,14 +498,14 @@ void JobSetupView::AttachedToWindow()
void JobSetupView::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case M_RANGE_ALL:
case kMsgRangeAll:
Window()->Lock();
from_page->SetEnabled(false);
to_page->SetEnabled(false);
Window()->Unlock();
break;
case M_RANGE_SELECTION:
case kMsgRangeSelection:
Window()->Lock();
from_page->SetEnabled(true);
to_page->SetEnabled(true);
@ -519,34 +519,34 @@ bool JobSetupView::UpdateJobData()
int count;
/*
count = sizeof(surfaces) / sizeof(surfaces[0]);
const SurfaceCap **surface_cap = surfaces;
const char *surface_label = __surface_type->FindMarked()->Label();
count = sizeof(gSurfaces) / sizeof(gSurfaces[0]);
const SurfaceCap **surface_cap = gSurfaces;
const char *surface_label = fSurfaceType->FindMarked()->Label();
while (count--) {
if (!strcmp((*surface_cap)->label.c_str(), surface_label)) {
__job_data->setSurfaceType((*surface_cap)->surface_type);
fJobData->setSurfaceType((*surface_cap)->surface_type);
break;
}
surface_cap++;
}
*/
count = __printer_cap->countCap(PrinterCap::COLOR);
const ColorCap **color_cap = (const ColorCap**)__printer_cap->enumCap(PrinterCap::COLOR);
const char *color_label = __color_type->FindMarked()->Label();
count = fPrinterCap->countCap(PrinterCap::kColor);
const ColorCap **color_cap = (const ColorCap**)fPrinterCap->enumCap(PrinterCap::kColor);
const char *color_label = fColorType->FindMarked()->Label();
while (count--) {
if (!strcmp((*color_cap)->label.c_str(), color_label)) {
__job_data->setColor((*color_cap)->color);
fJobData->setColor((*color_cap)->color);
break;
}
color_cap++;
}
__job_data->setGamma(atof(__gamma->Text()));
fJobData->setGamma(atof(fGamma->Text()));
int first_page;
int last_page;
if (B_CONTROL_ON == __all->Value()) {
if (B_CONTROL_ON == fAll->Value()) {
first_page = 1;
last_page = -1;
} else {
@ -554,41 +554,41 @@ bool JobSetupView::UpdateJobData()
last_page = atoi(to_page->Text());
}
__job_data->setFirstPage(first_page);
__job_data->setLastPage(last_page);
fJobData->setFirstPage(first_page);
fJobData->setLastPage(last_page);
count = __printer_cap->countCap(PrinterCap::PAPERSOURCE);
const PaperSourceCap **paper_source_cap = (const PaperSourceCap **)__printer_cap->enumCap(PrinterCap::PAPERSOURCE);
const char *paper_source_label = __paper_feed->FindMarked()->Label();
count = fPrinterCap->countCap(PrinterCap::kPaperSource);
const PaperSourceCap **paper_source_cap = (const PaperSourceCap **)fPrinterCap->enumCap(PrinterCap::kPaperSource);
const char *paper_source_label = fPaperFeed->FindMarked()->Label();
while (count--) {
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;
}
paper_source_cap++;
}
count = sizeof(nups) / sizeof(nups[0]);
const NupCap **nup_cap = nups;
const char *nup_label = __nup->FindMarked()->Label();
count = sizeof(gNups) / sizeof(gNups[0]);
const NupCap **nup_cap = gNups;
const char *nup_label = fNup->FindMarked()->Label();
while (count--) {
if (!strcmp((*nup_cap)->label.c_str(), nup_label)) {
__job_data->setNup((*nup_cap)->nup);
fJobData->setNup((*nup_cap)->nup);
break;
}
nup_cap++;
}
if (__printer_cap->isSupport(PrinterCap::PRINTSTYLE)) {
__job_data->setPrintStyle((B_CONTROL_ON == __duplex->Value()) ? JobData::DUPLEX : JobData::SIMPLEX);
if (fPrinterCap->isSupport(PrinterCap::kPrintStyle)) {
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);
__job_data->setReverse((B_CONTROL_ON == __reverse->Value()) ? true : false);
fJobData->setCollate((B_CONTROL_ON == fCollate->Value()) ? true : false);
fJobData->setReverse((B_CONTROL_ON == fReverse->Value()) ? true : false);
__job_data->save();
fJobData->save();
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,
B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE)
{
__result = 0;
fResult = 0;
/*
ostringstream oss;
oss << printer_data->get_printer_name() << " Print";
@ -643,42 +643,42 @@ JobSetupDlg::JobSetupDlg(JobData *job_data, PrinterData *printer_data, const Pri
Lock();
JobSetupView *view = new JobSetupView(Bounds(), job_data, printer_data, printer_cap);
AddChild(view);
__filter = new BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, B_KEY_DOWN, &PrintKeyFilter);
AddCommonFilter(__filter);
fFilter = new BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, B_KEY_DOWN, &PrintKeyFilter);
AddCommonFilter(fFilter);
Unlock();
__semaphore = create_sem(0, "JobSetupSem");
fSemaphore = create_sem(0, "JobSetupSem");
}
JobSetupDlg::~JobSetupDlg()
{
Lock();
RemoveCommonFilter(__filter);
RemoveCommonFilter(fFilter);
Unlock();
delete __filter;
delete fFilter;
}
bool JobSetupDlg::QuitRequested()
{
__result = B_ERROR;
release_sem(__semaphore);
fResult = B_ERROR;
release_sem(fSemaphore);
return true;
}
void JobSetupDlg::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case M_OK:
case kMsgOK:
Lock();
((JobSetupView *)ChildAt(0))->UpdateJobData();
Unlock();
__result = B_NO_ERROR;
release_sem(__semaphore);
fResult = B_NO_ERROR;
release_sem(fSemaphore);
break;
case M_CANCEL:
__result = B_ERROR;
release_sem(__semaphore);
case kMsgCancel:
fResult = B_ERROR;
release_sem(fSemaphore);
break;
default:
@ -690,9 +690,9 @@ void JobSetupDlg::MessageReceived(BMessage *msg)
int JobSetupDlg::Go()
{
Show();
acquire_sem(__semaphore);
delete_sem(__semaphore);
int value = __result;
acquire_sem(fSemaphore);
delete_sem(fSemaphore);
int value = fResult;
Lock();
Quit();
return value;

View File

@ -109,12 +109,12 @@ const BRect CANCEL_RECT(
CANCEL_V + BUTTON_HEIGHT);
enum MSGS {
M_CANCEL = 1,
M_OK
kMsgCancel = 1,
kMsgOK
};
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));
}
@ -137,29 +137,29 @@ void PageSetupView::AttachedToWindow()
AddChild(box);
box->SetLabel("Orientation");
__portrait = new BRadioButton(PORT_RECT, "", PORT_TEXT, NULL);
box->AddChild(__portrait);
fPortrait = new BRadioButton(PORT_RECT, "", PORT_TEXT, NULL);
box->AddChild(fPortrait);
BRadioButton *landscape = new BRadioButton(LAND_RECT, "", RAND_TEXT, NULL);
box->AddChild(landscape);
if (JobData::PORTRAIT == __job_data->getOrientation())
__portrait->SetValue(B_CONTROL_ON);
if (JobData::kPortrait == fJobData->getOrientation())
fPortrait->SetValue(B_CONTROL_ON);
else
landscape->SetValue(B_CONTROL_ON);
/* paper selection */
marked = false;
__paper = new BPopUpMenu("");
__paper->SetRadioMode(true);
count = __printer_cap->countCap(PrinterCap::PAPER);
PaperCap **paper_cap = (PaperCap **)__printer_cap->enumCap(PrinterCap::PAPER);
fPaper = new BPopUpMenu("");
fPaper->SetRadioMode(true);
count = fPrinterCap->countCap(PrinterCap::kPaper);
PaperCap **paper_cap = (PaperCap **)fPrinterCap->enumCap(PrinterCap::kPaper);
while (count--) {
item = new BMenuItem((*paper_cap)->label.c_str(), NULL);
__paper->AddItem(item);
fPaper->AddItem(item);
item->SetTarget(this);
if ((*paper_cap)->paper == __job_data->getPaper()) {
if ((*paper_cap)->paper == fJobData->getPaper()) {
item->SetMarked(true);
marked = true;
}
@ -167,7 +167,7 @@ void PageSetupView::AttachedToWindow()
}
if (!marked)
item->SetMarked(true);
menufield = new BMenuField(PAPER_RECT, "", PAPER_TEXT, __paper);
menufield = new BMenuField(PAPER_RECT, "", PAPER_TEXT, fPaper);
AddChild(menufield);
float width = StringWidth(PAPER_TEXT) + 7;
menufield->SetDivider(width);
@ -175,15 +175,15 @@ void PageSetupView::AttachedToWindow()
/* resolution */
marked = false;
__resolution = new BPopUpMenu("");
__resolution->SetRadioMode(true);
count = __printer_cap->countCap(PrinterCap::RESOLUTION);
ResolutionCap **resolution_cap = (ResolutionCap **)__printer_cap->enumCap(PrinterCap::RESOLUTION);
fResolution = new BPopUpMenu("");
fResolution->SetRadioMode(true);
count = fPrinterCap->countCap(PrinterCap::kResolution);
ResolutionCap **resolution_cap = (ResolutionCap **)fPrinterCap->enumCap(PrinterCap::kResolution);
while (count--) {
item = new BMenuItem((*resolution_cap)->label.c_str(), NULL);
__resolution->AddItem(item);
fResolution->AddItem(item);
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);
marked = true;
}
@ -191,18 +191,18 @@ void PageSetupView::AttachedToWindow()
}
if (!marked)
item->SetMarked(true);
menufield = new BMenuField(RESOLUTION_RECT, "", RES_TEXT, __resolution);
menufield = new BMenuField(RESOLUTION_RECT, "", RES_TEXT, fResolution);
AddChild(menufield);
menufield->SetDivider(width);
/* cancel */
button = new BButton(CANCEL_RECT, "", CANCEL_TEXT, new BMessage(M_CANCEL));
button = new BButton(CANCEL_RECT, "", CANCEL_TEXT, new BMessage(kMsgCancel));
AddChild(button);
/* ok */
button = new BButton(OK_RECT, "", OK_TEXT, new BMessage(M_OK));
button = new BButton(OK_RECT, "", OK_TEXT, new BMessage(kMsgOK));
AddChild(button);
button->MakeDefault(true);
}
@ -216,10 +216,10 @@ inline void swap(float *e1, float *e2)
bool PageSetupView::UpdateJobData()
{
if (B_CONTROL_ON == __portrait->Value()) {
__job_data->setOrientation(JobData::PORTRAIT);
if (B_CONTROL_ON == fPortrait->Value()) {
fJobData->setOrientation(JobData::kPortrait);
} else {
__job_data->setOrientation(JobData::LANDSCAPE);
fJobData->setOrientation(JobData::kLandscape);
}
BRect paper_rect;
@ -227,12 +227,12 @@ bool PageSetupView::UpdateJobData()
int count;
count = __printer_cap->countCap(PrinterCap::PAPER);
PaperCap **paper_cap = (PaperCap **)__printer_cap->enumCap(PrinterCap::PAPER);
const char *paper_label = __paper->FindMarked()->Label();
count = fPrinterCap->countCap(PrinterCap::kPaper);
PaperCap **paper_cap = (PaperCap **)fPrinterCap->enumCap(PrinterCap::kPaper);
const char *paper_label = fPaper->FindMarked()->Label();
while (count--) {
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;
printable_rect = (*paper_cap)->printable_rect;
break;
@ -240,30 +240,30 @@ bool PageSetupView::UpdateJobData()
paper_cap++;
}
count = __printer_cap->countCap(PrinterCap::RESOLUTION);
ResolutionCap **resolution_cap = (ResolutionCap **)__printer_cap->enumCap(PrinterCap::RESOLUTION);
const char *resolution_label = __resolution->FindMarked()->Label();
count = fPrinterCap->countCap(PrinterCap::kResolution);
ResolutionCap **resolution_cap = (ResolutionCap **)fPrinterCap->enumCap(PrinterCap::kResolution);
const char *resolution_label = fResolution->FindMarked()->Label();
while (count--) {
if (!strcmp((*resolution_cap)->label.c_str(), resolution_label)) {
__job_data->setXres((*resolution_cap)->xres);
__job_data->setYres((*resolution_cap)->yres);
fJobData->setXres((*resolution_cap)->xres);
fJobData->setYres((*resolution_cap)->yres);
break;
}
resolution_cap++;
}
if (JobData::LANDSCAPE == __job_data->getOrientation()) {
if (JobData::kLandscape == fJobData->getOrientation()) {
swap(&paper_rect.left, &paper_rect.top);
swap(&paper_rect.right, &paper_rect.bottom);
swap(&printable_rect.left, &printable_rect.top);
swap(&printable_rect.right, &printable_rect.bottom);
}
__job_data->setScaling(100.0);
__job_data->setPaperRect(paper_rect);
__job_data->setPrintableRect(printable_rect);
fJobData->setScaling(100.0);
fJobData->setPaperRect(paper_rect);
fJobData->setPrintableRect(printable_rect);
__job_data->save();
fJobData->save();
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,
B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE)
{
__result = 0;
fResult = 0;
/*
ostringstream oss;
oss << printer_data->get_printer_name() << " Setup";
@ -286,7 +286,7 @@ PageSetupDlg::PageSetupDlg(JobData *job_data, PrinterData *printer_data, const P
AddChild(view);
Unlock();
__semaphore = create_sem(0, "PageSetupSem");
fSemaphore = create_sem(0, "PageSetupSem");
}
PageSetupDlg::~PageSetupDlg()
@ -295,25 +295,25 @@ PageSetupDlg::~PageSetupDlg()
bool PageSetupDlg::QuitRequested()
{
__result = B_ERROR;
release_sem(__semaphore);
fResult = B_ERROR;
release_sem(fSemaphore);
return true;
}
void PageSetupDlg::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case M_OK:
case kMsgOK:
Lock();
((PageSetupView *)ChildAt(0))->UpdateJobData();
Unlock();
__result = B_NO_ERROR;
release_sem(__semaphore);
fResult = B_NO_ERROR;
release_sem(fSemaphore);
break;
case M_CANCEL:
__result = B_ERROR;
release_sem(__semaphore);
case kMsgCancel:
fResult = B_ERROR;
release_sem(fSemaphore);
break;
default:
@ -325,9 +325,9 @@ void PageSetupDlg::MessageReceived(BMessage *msg)
int PageSetupDlg::Go()
{
Show();
acquire_sem(__semaphore);
delete_sem(__semaphore);
int value = __result;
acquire_sem(fSemaphore);
delete_sem(fSemaphore);
int value = fResult;
Lock();
Quit();
return value;

View File

@ -13,38 +13,38 @@ public:
PreviewView(BRect, BBitmap *);
void Draw(BRect);
private:
BBitmap *__bitmap;
BBitmap *fBitmap;
};
PreviewView::PreviewView(BRect frame, BBitmap *bitmap)
: BView(frame, "preview", B_FOLLOW_ALL, B_WILL_DRAW)
{
__bitmap = bitmap;
fBitmap = bitmap;
}
void PreviewView::Draw(BRect)
{
DrawBitmap(__bitmap);
DrawBitmap(fBitmap);
}
PreviewWindow::PreviewWindow(BRect frame, const char *title, BBitmap *bitmap)
: BWindow(frame, title, B_TITLED_WINDOW, 0)
{
AddChild(new PreviewView(Bounds(), bitmap));
__semaphore = create_sem(0, "PreviewSem");
fSemaphore = create_sem(0, "PreviewSem");
}
bool PreviewWindow::QuitRequested()
{
release_sem(__semaphore);
release_sem(fSemaphore);
return true;
}
int PreviewWindow::Go()
{
Show();
acquire_sem(__semaphore);
delete_sem(__semaphore);
acquire_sem(fSemaphore);
delete_sem(fSemaphore);
Lock();
Quit();
return 0;

View File

@ -39,26 +39,26 @@ PictureData::~PictureData()
PageData::PageData()
{
__hollow = true;
fHollow = true;
}
PageData::PageData(BFile *file, bool reverse)
{
__file = file;
__reverse = reverse;
__picture_count = 0;
__rest = 0;
__offset = 0;
__hollow = false;
fFile = file;
fReverse = reverse;
fPictureCount = 0;
fRest = 0;
fOffset = 0;
fHollow = false;
if (reverse) {
file->Read(&__picture_count, sizeof(long));
DBGMSG(("picture_count = %d\n", (int)__picture_count));
__offset = __file->Position();
off_t o = __offset;
file->Read(&fPictureCount, sizeof(long));
DBGMSG(("picture_count = %d\n", (int)fPictureCount));
fOffset = fFile->Position();
off_t o = fOffset;
// seek to start of next page
__file->Read(&o, sizeof(o));
__file->Seek(o, SEEK_SET);
fFile->Read(&o, sizeof(o));
fFile->Seek(o, SEEK_SET);
}
}
@ -67,30 +67,30 @@ bool PageData::startEnum()
off_t offset;
uchar dummy[40];
if (__hollow)
if (fHollow)
return false;
if (__offset == 0) {
__file->Read(&__picture_count, sizeof(long));
DBGMSG(("picture_count = %d\n", (int)__picture_count));
__offset = __file->Position();
if (fOffset == 0) {
fFile->Read(&fPictureCount, sizeof(long));
DBGMSG(("picture_count = %d\n", (int)fPictureCount));
fOffset = fFile->Position();
} else {
__file->Seek(__offset, SEEK_SET);
fFile->Seek(fOffset, SEEK_SET);
}
// skip page header
__file->Seek(sizeof(offset) + sizeof(dummy), SEEK_CUR);
fFile->Seek(sizeof(offset) + sizeof(dummy), SEEK_CUR);
__rest = __picture_count;
return __picture_count > 0;
fRest = fPictureCount;
return fPictureCount > 0;
}
bool PageData::enumObject(PictureData **picture_data)
{
if (__hollow || __picture_count <= 0) {
if (fHollow || fPictureCount <= 0) {
*picture_data = NULL;
} else {
*picture_data = new PictureData(__file);
if (--__rest > 0) {
*picture_data = new PictureData(fFile);
if (--fRest > 0) {
return true;
}
}
@ -113,48 +113,48 @@ SpoolData::SpoolData(
if (nup > 1) {
for (int page_index = 0; page_index < page_count; page_index++) {
if (page_index % nup == 0) {
__pages.push_front(new PageData(file, reverse));
__it = __pages.begin();
__it++;
fPages.push_front(new PageData(file, reverse));
fIt = fPages.begin();
fIt++;
} else {
__pages.insert(__it, new PageData(file, reverse));
fPages.insert(fIt, new PageData(file, reverse));
}
}
page_count = nup - page_count % nup;
if (page_count < nup) {
while (page_count--) {
__pages.insert(__it, new PageData);
fPages.insert(fIt, new PageData);
}
}
} else {
while (page_count--) {
__pages.push_front(new PageData(file, reverse));
fPages.push_front(new PageData(file, reverse));
}
}
} else {
while (page_count--) {
__pages.push_back(new PageData(file, reverse));
fPages.push_back(new PageData(file, reverse));
}
}
}
SpoolData::~SpoolData()
{
for (__it = __pages.begin(); __it != __pages.end(); __it++) {
delete (*__it);
for (fIt = fPages.begin(); fIt != fPages.end(); fIt++) {
delete (*fIt);
}
}
bool SpoolData::startEnum()
{
__it = __pages.begin();
fIt = fPages.begin();
return true;
}
bool SpoolData::enumObject(PageData **page_data)
{
*page_data = *__it++;
if (__it == __pages.end()) {
*page_data = *fIt++;
if (fIt == fPages.end()) {
return false;
}
return true;

View File

@ -6,7 +6,7 @@
#include "PrinterCap.h"
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)
{
__printer_data = printer_cap.__printer_data;
__printer_id = printer_cap.__printer_id;
fPrinterData = printer_cap.fPrinterData;
fPrinterID = printer_cap.fPrinterID;
}
PrinterCap::PrinterCap &operator = (const PrinterCap &printer_cap)
{
__printer_data = printer_cap.__printer_data;
__printer_id = printer_cap.__printer_id;
fPrinterData = printer_cap.fPrinterData;
fPrinterID = printer_cap.fPrinterID;
return *this;
}
*/
const BaseCap *PrinterCap::getDefaultCap(CAPID id) const
const BaseCap *PrinterCap::getDefaultCap(CapID id) const
{
int count = countCap(id);
if (count > 0) {

View File

@ -29,20 +29,20 @@ PrinterData::~PrinterData()
/*
PrinterData::PrinterData(const PrinterData &printer_data)
{
__driver_name = printer_data.__driver_name;
__printer_name = printer_data.__printer_name;
__comments = printer_data.__comments;
__transport = printer_data.__transport;
__node = printer_data.__node;
fDriverName = printer_data.fDriverName;
fPrinterName = printer_data.fPrinterName;
fComments = printer_data.fComments;
fTransport = printer_data.fTransport;
fNode = printer_data.fNode;
}
PrinterData &PrinterData::operator = (const PrinterData &printer_data)
{
__driver_name = printer_data.__driver_name;
__printer_name = printer_data.__printer_name;
__comments = printer_data.__comments;
__transport = printer_data.__transport;
__node = printer_data.__node;
fDriverName = printer_data.fDriverName;
fPrinterName = printer_data.fPrinterName;
fComments = printer_data.fComments;
fTransport = printer_data.fTransport;
fNode = printer_data.fNode;
return *this;
}
*/
@ -51,16 +51,16 @@ void PrinterData::load(BNode *node)
{
char buffer[512];
__node = node;
fNode = node;
__node->ReadAttr(PD_DRIVER_NAME, B_STRING_TYPE, 0, buffer, sizeof(buffer));
__driver_name = buffer;
__node->ReadAttr(PD_PRINTER_NAME, B_STRING_TYPE, 0, buffer, sizeof(buffer));
__printer_name = buffer;
__node->ReadAttr(PD_COMMENTS, B_STRING_TYPE, 0, buffer, sizeof(buffer));
__comments = buffer;
__node->ReadAttr(PD_TRANSPORT, B_STRING_TYPE, 0, buffer, sizeof(buffer));
__transport = buffer;
fNode->ReadAttr(PD_DRIVER_NAME, B_STRING_TYPE, 0, buffer, sizeof(buffer));
fDriverName = buffer;
fNode->ReadAttr(PD_PRINTER_NAME, B_STRING_TYPE, 0, buffer, sizeof(buffer));
fPrinterName = buffer;
fNode->ReadAttr(PD_COMMENTS, B_STRING_TYPE, 0, buffer, sizeof(buffer));
fComments = buffer;
fNode->ReadAttr(PD_TRANSPORT, B_STRING_TYPE, 0, buffer, sizeof(buffer));
fTransport = buffer;
}
/*
@ -70,7 +70,7 @@ void PrinterData::save(BNode *node)
if (node == NULL) {
BPath path;
::find_directory(B_USER_PRINTERS_DIRECTORY, &path, false);
path.Append(__printer_name.c_str());
path.Append(fPrinterName.c_str());
BDirectory base_dir;
base_dir.CreateDirectory(path.Path(), &dir);
node = &dir;
@ -83,9 +83,9 @@ void PrinterData::save(BNode *node)
bool PrinterData::getPath(char *buf) const
{
if (__node) {
if (fNode) {
node_ref nref;
__node->GetNodeRef(&nref);
fNode->GetNodeRef(&nref);
BDirectory dir;
dir.SetTo(&nref);
BPath path(&dir, NULL);

View File

@ -6,21 +6,21 @@
#include "SpoolMetaData.h"
#include <String.h>
const char *SD_DESCRIPTION = "_spool/Description";
const char* SD_MIME_TYPE = "_spool/MimeType";
const char *kSDDescription = "_spool/Description";
const char* kSDMimeType = "_spool/MimeType";
SpoolMetaData::SpoolMetaData(BFile* spool_file)
{
BString string;
time_t time;
if (spool_file->ReadAttrString(SD_DESCRIPTION, &string) == B_OK) {
__description = string.String();
if (spool_file->ReadAttrString(kSDDescription, &string) == B_OK) {
fDescription = string.String();
}
if (spool_file->ReadAttrString(SD_MIME_TYPE, &string) == B_OK) {
__mime_type = string.String();
if (spool_file->ReadAttrString(kSDMimeType, &string) == B_OK) {
fMimeType = string.String();
}
if (spool_file->GetCreationTime(&time) == B_OK) {
__creation_time = ctime(&time);
fCreationTime = ctime(&time);
}
}

View File

@ -21,7 +21,7 @@ using namespace std;
#endif
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;
@ -29,45 +29,45 @@ Transport::Transport(const PrinterData *printer_data)
path.Append("Print/transport");
path.Append(printer_data->getTransport().c_str());
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)) {
path.Append("Print/transport");
path.Append(printer_data->getTransport().c_str());
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");
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(__image, "exit_transport", B_SYMBOL_TYPE_TEXT, (void **)&__exit_transport);
get_image_symbol(fImage, "init_transport", B_SYMBOL_TYPE_TEXT, (void **)&fInitTransport);
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.");
DBGMSG(("init_transport is NULL\n"));
}
if (__exit_transport == NULL) {
if (fExitTransport == NULL) {
set_last_error("get_image_symbol failed.");
DBGMSG(("exit_transport is NULL\n"));
}
if (__init_transport) {
if (fInitTransport) {
char spool_path[256];
printer_data->getPath(spool_path);
BMessage *msg = new BMessage('TRIN');
msg->AddString("printer_file", spool_path);
__data_stream = (*__init_transport)(msg);
fDataStream = (*fInitTransport)(msg);
delete msg;
if (__data_stream == 0) {
if (fDataStream == 0) {
set_last_error("init_transport failed.");
}
}
@ -75,34 +75,34 @@ Transport::Transport(const PrinterData *printer_data)
Transport::~Transport()
{
if (__exit_transport) {
(*__exit_transport)();
if (fExitTransport) {
(*fExitTransport)();
}
if (__image >= 0) {
unload_add_on(__image);
if (fImage >= 0) {
unload_add_on(fImage);
}
}
bool Transport::check_abort() const
{
return __data_stream == 0;
return fDataStream == 0;
}
const string &Transport::last_error() const
{
return __last_error_string;
return fLastErrorString;
}
void Transport::set_last_error(const char *e)
{
__last_error_string = e;
__abort = true;
fLastErrorString = e;
fAbort = true;
}
void Transport::write(const void *buffer, size_t size) throw(TransportException)
{
if (__data_stream) {
if (size == (size_t)__data_stream->Write(buffer, size)) {
if (fDataStream) {
if (size == (size_t)fDataStream->Write(buffer, size)) {
return;
}
set_last_error("BDataIO::Write failed.");

View File

@ -13,7 +13,7 @@
#include "DbgMsg.h"
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 *clone_msg = new BMessage(*__msg);
JobData *job_data = new JobData(clone_msg, __printer_cap);
BMessage *clone_msg = new BMessage(*fMsg);
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;
clone_msg = NULL;
} else {
@ -39,10 +39,10 @@ BMessage *UIDriver::configPage()
BMessage *UIDriver::configJob()
{
BMessage *clone_msg = new BMessage(*__msg);
JobData *job_data = new JobData(clone_msg, __printer_cap);
BMessage *clone_msg = new BMessage(*fMsg);
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;
clone_msg = NULL;
} else {

View File

@ -8,7 +8,6 @@
bool get_valid_line_RGB32(
const uchar *bits,
const rgb_color *,
int width,
int *left,
int *right)
@ -44,117 +43,9 @@ bool get_valid_line_RGB32(
return true;
}
bool get_valid_line_CMAP8(
const uchar *bits,
const rgb_color *palette,
int width,
int *left,
int *right)
{
int i = 0;
rgb_color c;
const uchar *ptr = bits;
typedef bool (*PFN_GET_VALID_LINE)(const uchar *, int, int *, int *);
while (i < *left) {
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)
bool get_valid_rect(BBitmap *a_bitmap, RECT *rc)
{
int width = rc->right - rc->left + 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:
get_valid_line = get_valid_line_RGB32;
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:
get_valid_line = get_valid_line_GRAY1;
return false;
break;
};
@ -190,7 +72,7 @@ bool get_valid_rect(BBitmap *a_bitmap, const rgb_color *palette, RECT *rc)
uchar *ptr = (uchar *)a_bitmap->Bits();
while (i < height) {
if (get_valid_line(ptr, palette, width, &left, &right)) {
if (get_valid_line(ptr, width, &left, &right)) {
top = i;
break;
}
@ -207,7 +89,7 @@ bool get_valid_rect(BBitmap *a_bitmap, const rgb_color *palette, RECT *rc)
bool found_boundary = false;
while (j >= i) {
if (get_valid_line(ptr, palette, width, &left, &right)) {
if (get_valid_line(ptr, width, &left, &right)) {
if (!found_boundary) {
bottom = j;
found_boundary = true;