Style cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37365 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Wim van der Meer
2010-07-03 07:49:30 +00:00
parent 24874466dc
commit a6cd1edfaa
7 changed files with 318 additions and 254 deletions
@@ -39,12 +39,8 @@ private:
void moveAbsoluteHorizontal(int x); void moveAbsoluteHorizontal(int x);
void carriageReturn(); void carriageReturn();
void moveDown(int dy); void moveDown(int dy);
void rasterGraphics( void rasterGraphics(int size, int widthbyte, int height,
int size, int compression_method, const uchar* buffer);
int widthbyte,
int height,
int compression_method,
const uchar* buffer);
void formFeed(); void formFeed();
void jobEnd(); void jobEnd();
@@ -3,13 +3,13 @@
* Copyright 1999-2000 Y.Takagi. All Rights Reserved. * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/ */
#include "Lips3Cap.h" #include "Lips3Cap.h"
#include "PrinterData.h" #include "PrinterData.h"
#define TO72DPI(a) (a * 72.0f / 600.0f) #define TO72DPI(a) (a * 72.0f / 600.0f)
const PaperCap a3( const PaperCap a3(
"A3", "A3",
false, false,
@@ -3,18 +3,22 @@
* Copyright 1999-2000 Y.Takagi. All Rights Reserved. * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/ */
#include "Lips4Cap.h"
#include <memory>
#include <Alert.h> #include <Alert.h>
#include <Bitmap.h> #include <Bitmap.h>
#include <File.h> #include <File.h>
#include <memory>
#include "DbgMsg.h"
#include "Halftone.h"
#include "JobData.h"
#include "Lips4.h" #include "Lips4.h"
#include "PackBits.h" #include "PackBits.h"
#include "JobData.h"
#include "PrinterData.h" #include "PrinterData.h"
#include "Lips4Cap.h"
#include "Halftone.h"
#include "ValidRect.h" #include "ValidRect.h"
#include "DbgMsg.h"
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE)) #if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std; using namespace std;
@@ -22,13 +26,18 @@ using namespace std;
#define std #define std
#endif #endif
LIPS4Driver::LIPS4Driver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap)
: GraphicsDriver(msg, printer_data, printer_cap) LIPS4Driver::LIPS4Driver(BMessage* msg, PrinterData* printer_data,
const PrinterCap *printer_cap)
:
GraphicsDriver(msg, printer_data, printer_cap)
{ {
fHalftone = NULL; fHalftone = NULL;
} }
bool LIPS4Driver::startDoc()
bool
LIPS4Driver::startDoc()
{ {
try { try {
beginTextMode(); beginTextMode();
@@ -43,15 +52,19 @@ bool LIPS4Driver::startDoc()
setNumberOfCopies(); setNumberOfCopies();
sidePrintingControl(); sidePrintingControl();
setBindingMargin(); setBindingMargin();
fHalftone = new Halftone(getJobData()->getSurfaceType(), getJobData()->getGamma(), getJobData()->getInkDensity(), getJobData()->getDitherType()); fHalftone = new Halftone(getJobData()->getSurfaceType(),
getJobData()->getGamma(), getJobData()->getInkDensity(),
getJobData()->getDitherType());
return true; return true;
} }
catch (TransportException &err) { catch (TransportException& err) {
return false; return false;
} }
} }
bool LIPS4Driver::startPage(int)
bool
LIPS4Driver::startPage(int)
{ {
try { try {
fCurrentX = 0; fCurrentX = 0;
@@ -59,37 +72,43 @@ bool LIPS4Driver::startPage(int)
memorizedPosition(); memorizedPosition();
return true; return true;
} }
catch (TransportException &err) { catch (TransportException& err) {
return false; return false;
} }
} }
bool LIPS4Driver::endPage(int)
bool
LIPS4Driver::endPage(int)
{ {
try { try {
formFeed(); formFeed();
return true; return true;
} }
catch (TransportException &err) { catch (TransportException& err) {
return false; return false;
} }
} }
bool LIPS4Driver::endDoc(bool)
bool
LIPS4Driver::endDoc(bool)
{ {
try { try {
if (fHalftone) { if (fHalftone)
delete fHalftone; delete fHalftone;
}
jobEnd(); jobEnd();
return true; return true;
} }
catch (TransportException &err) { catch (TransportException& err) {
return false; return false;
} }
} }
bool LIPS4Driver::nextBand(BBitmap *bitmap, BPoint *offset)
bool
LIPS4Driver::nextBand(BBitmap* bitmap, BPoint* offset)
{ {
DBGMSG(("> nextBand\n")); DBGMSG(("> nextBand\n"));
@@ -118,9 +137,8 @@ bool LIPS4Driver::nextBand(BBitmap *bitmap, BPoint *offset)
int page_height = getPageHeight(); int page_height = getPageHeight();
if (y + height > page_height) { if (y + height > page_height)
height = page_height - y; height = page_height - y;
}
rc.bottom = height - 1; rc.bottom = height - 1;
@@ -149,23 +167,24 @@ bool LIPS4Driver::nextBand(BBitmap *bitmap, BPoint *offset)
DBGMSG(("in_size = %d\n", in_size)); DBGMSG(("in_size = %d\n", in_size));
DBGMSG(("out_size = %d\n", out_size)); DBGMSG(("out_size = %d\n", out_size));
DBGMSG(("delta = %d\n", delta)); DBGMSG(("delta = %d\n", delta));
DBGMSG(("fHalftone_engine->get_pixel_depth() = %d\n", fHalftone->getPixelDepth())); DBGMSG(("fHalftone_engine->get_pixel_depth() = %d\n",
fHalftone->getPixelDepth()));
uchar *ptr = (uchar *)bitmap->Bits() uchar* ptr = static_cast<uchar*>(bitmap->Bits())
+ rc.top * delta + rc.top * delta
+ (rc.left * fHalftone->getPixelDepth()) / 8; + (rc.left * fHalftone->getPixelDepth()) / 8;
int compression_method; int compression_method;
int compressed_size; int compressed_size;
const uchar *buffer; const uchar* buffer;
uchar *in_buffer = new uchar[in_size]; uchar* in_buffer = new uchar[in_size];
uchar *out_buffer = new uchar[out_size]; uchar* out_buffer = new uchar[out_size];
auto_ptr<uchar> _in_buffer (in_buffer); auto_ptr<uchar> _in_buffer (in_buffer);
auto_ptr<uchar> _out_buffer(out_buffer); auto_ptr<uchar> _out_buffer(out_buffer);
uchar *ptr2 = (uchar *)in_buffer; uchar* ptr2 = static_cast<uchar *>(in_buffer);
DBGMSG(("move\n")); DBGMSG(("move\n"));
@@ -186,7 +205,7 @@ bool LIPS4Driver::nextBand(BBitmap *bitmap, BPoint *offset)
compression_method = 11; compression_method = 11;
buffer = out_buffer; buffer = out_buffer;
} else if (compressed_size > out_size) { } else if (compressed_size > out_size) {
BAlert *alert = new BAlert("memory overrun!!!", "warning", "OK"); BAlert* alert = new BAlert("memory overrun!!!", "warning", "OK");
alert->Go(); alert->Go();
return false; return false;
} else { } else {
@@ -207,38 +226,42 @@ bool LIPS4Driver::nextBand(BBitmap *bitmap, BPoint *offset)
compression_method, compression_method,
buffer); buffer);
} else { } else
DBGMSG(("band bitmap is clean.\n")); DBGMSG(("band bitmap is clean.\n"));
}
if (y >= page_height) { if (y >= page_height) {
offset->x = -1.0; offset->x = -1.0;
offset->y = -1.0; offset->y = -1.0;
} else { } else
offset->y += height; offset->y += height;
}
DBGMSG(("< nextBand\n")); DBGMSG(("< nextBand\n"));
return true; return true;
} }
catch (TransportException &err) { catch (TransportException& err) {
BAlert *alert = new BAlert("", err.what(), "OK"); BAlert* alert = new BAlert("", err.what(), "OK");
alert->Go(); alert->Go();
return false; return false;
} }
} }
void LIPS4Driver::beginTextMode()
void
LIPS4Driver::beginTextMode()
{ {
writeSpoolString("\033%%@"); writeSpoolString("\033%%@");
} }
void LIPS4Driver::jobStart()
void
LIPS4Driver::jobStart()
{ {
writeSpoolString("\033P41;%d;1J\033\\", getJobData()->getXres()); writeSpoolString("\033P41;%d;1J\033\\", getJobData()->getXres());
} }
void LIPS4Driver::colorModeDeclaration()
void
LIPS4Driver::colorModeDeclaration()
{ {
// if (color) // if (color)
// writeSpoolString("\033[1\"p"); // writeSpoolString("\033[1\"p");
@@ -246,22 +269,30 @@ void LIPS4Driver::colorModeDeclaration()
writeSpoolString("\033[0\"p"); writeSpoolString("\033[0\"p");
} }
void LIPS4Driver::softReset()
void
LIPS4Driver::softReset()
{ {
writeSpoolString("\033<"); writeSpoolString("\033<");
} }
void LIPS4Driver::sizeUnitMode()
void
LIPS4Driver::sizeUnitMode()
{ {
writeSpoolString("\033[11h"); writeSpoolString("\033[11h");
} }
void LIPS4Driver::selectSizeUnit()
void
LIPS4Driver::selectSizeUnit()
{ {
writeSpoolString("\033[?7;%d I", getJobData()->getXres()); writeSpoolString("\033[?7;%d I", getJobData()->getXres());
} }
void LIPS4Driver::paperFeedMode()
void
LIPS4Driver::paperFeedMode()
{ {
// 0 auto // 0 auto
// -------------- // --------------
@@ -302,7 +333,9 @@ void LIPS4Driver::paperFeedMode()
writeSpoolString("\033[%dq", i); writeSpoolString("\033[%dq", i);
} }
void LIPS4Driver::selectPageFormat()
void
LIPS4Driver::selectPageFormat()
{ {
int i; int i;
@@ -362,17 +395,23 @@ void LIPS4Driver::selectPageFormat()
writeSpoolString("\033[%d;;p", i); writeSpoolString("\033[%d;;p", i);
} }
void LIPS4Driver::disableAutoFF()
void
LIPS4Driver::disableAutoFF()
{ {
writeSpoolString("\033[?2h"); writeSpoolString("\033[?2h");
} }
void LIPS4Driver::setNumberOfCopies()
void
LIPS4Driver::setNumberOfCopies()
{ {
writeSpoolString("\033[%ldv", getJobData()->getCopies()); writeSpoolString("\033[%ldv", getJobData()->getCopies());
} }
void LIPS4Driver::sidePrintingControl()
void
LIPS4Driver::sidePrintingControl()
{ {
if (getJobData()->getPrintStyle() == JobData::kSimplex) if (getJobData()->getPrintStyle() == JobData::kSimplex)
writeSpoolString("\033[0#x"); writeSpoolString("\033[0#x");
@@ -380,7 +419,9 @@ void LIPS4Driver::sidePrintingControl()
writeSpoolString("\033[2;0#x"); writeSpoolString("\033[2;0#x");
} }
void LIPS4Driver::setBindingMargin()
void
LIPS4Driver::setBindingMargin()
{ {
if (getJobData()->getPrintStyle() == JobData::kDuplex) { if (getJobData()->getPrintStyle() == JobData::kDuplex) {
int i; int i;
@@ -402,32 +443,38 @@ void LIPS4Driver::setBindingMargin()
} }
} }
void LIPS4Driver::memorizedPosition()
void
LIPS4Driver::memorizedPosition()
{ {
writeSpoolString("\033[0;1;0x"); writeSpoolString("\033[0;1;0x");
} }
void LIPS4Driver::moveAbsoluteHorizontal(int x)
void
LIPS4Driver::moveAbsoluteHorizontal(int x)
{ {
writeSpoolString("\033[%ld`", x); writeSpoolString("\033[%ld`", x);
} }
void LIPS4Driver::carriageReturn()
void
LIPS4Driver::carriageReturn()
{ {
writeSpoolChar('\x0d'); writeSpoolChar('\x0d');
} }
void LIPS4Driver::moveDown(int dy)
void
LIPS4Driver::moveDown(int dy)
{ {
writeSpoolString("\033[%lde", dy); writeSpoolString("\033[%lde", dy);
} }
void LIPS4Driver::rasterGraphics(
int compression_size, void
int widthbyte, LIPS4Driver::rasterGraphics(int compression_size, int widthbyte, int height,
int height, int compression_method, const uchar* buffer)
int compression_method,
const uchar *buffer)
{ {
// 0 RAW // 0 RAW
// 10 RLE // 10 RLE
@@ -444,17 +491,23 @@ void LIPS4Driver::rasterGraphics(
writeSpoolData(buffer, compression_size); writeSpoolData(buffer, compression_size);
} }
void LIPS4Driver::formFeed()
void
LIPS4Driver::formFeed()
{ {
writeSpoolChar('\014'); writeSpoolChar('\014');
} }
void LIPS4Driver::jobEnd()
void
LIPS4Driver::jobEnd()
{ {
writeSpoolString("\033P0J\033\\"); writeSpoolString("\033P0J\033\\");
} }
void LIPS4Driver::move(int x, int y)
void
LIPS4Driver::move(int x, int y)
{ {
if (fCurrentX != x) { if (fCurrentX != x) {
if (x) { if (x) {
@@ -2,14 +2,16 @@
* Lips4.h * Lips4.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved. * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/ */
#ifndef __LIPS4_H #ifndef __LIPS4_H
#define __LIPS4_H #define __LIPS4_H
#include "GraphicsDriver.h" #include "GraphicsDriver.h"
class Halftone; class Halftone;
class LIPS4Driver : public GraphicsDriver { class LIPS4Driver : public GraphicsDriver {
public: public:
LIPS4Driver(BMessage *msg, PrinterData *printer_data, const PrinterCap *cap); LIPS4Driver(BMessage *msg, PrinterData *printer_data, const PrinterCap *cap);
@@ -39,18 +41,14 @@ private:
void moveAbsoluteHorizontal(int x); void moveAbsoluteHorizontal(int x);
void carriageReturn(); void carriageReturn();
void moveDown(int dy); void moveDown(int dy);
void rasterGraphics( void rasterGraphics(int size, int widthbyte, int height,
int size, int compression_method, const uchar* buffer);
int widthbyte,
int height,
int compression_method,
const uchar *buffer);
void formFeed(); void formFeed();
void jobEnd(); void jobEnd();
int fCurrentX; int fCurrentX;
int fCurrentY; int fCurrentY;
Halftone *fHalftone; Halftone* fHalftone;
}; };
#endif /* __LIPS4_H */ #endif // __LIPS4_H
@@ -3,6 +3,7 @@
* Copyright 1999-2000 Y.Takagi. All Rights Reserved. * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/ */
#include "Lips4Cap.h" #include "Lips4Cap.h"
#define TO72DPI(a) (a * 72.0f / 600.0f) #define TO72DPI(a) (a * 72.0f / 600.0f)
@@ -105,12 +106,16 @@ const PrintStyleCap simplex("Simplex", true, JobData::kSimplex);
const PrintStyleCap duplex("Duplex", false, JobData::kDuplex); const PrintStyleCap duplex("Duplex", false, JobData::kDuplex);
const PrintStyleCap booklet("Booklet", false, JobData::kBooklet); const PrintStyleCap booklet("Booklet", false, JobData::kBooklet);
const BindingLocationCap longedge1("Long Edge (left)", true, JobData::kLongEdgeLeft); const BindingLocationCap longedge1("Long Edge (left)", true,
const BindingLocationCap longedge2("Long Edge (right)", false, JobData::kLongEdgeRight); JobData::kLongEdgeLeft);
const BindingLocationCap shortedge1("Short Edge (top)", false, JobData::kShortEdgeTop); const BindingLocationCap longedge2("Long Edge (right)", false,
const BindingLocationCap shortedge2("Short Edge (bottom)", false, JobData::kShortEdgeBottom); JobData::kLongEdgeRight);
const BindingLocationCap shortedge1("Short Edge (top)", false,
JobData::kShortEdgeTop);
const BindingLocationCap shortedge2("Short Edge (bottom)", false,
JobData::kShortEdgeBottom);
const PaperCap *papers[] = { const PaperCap* papers[] = {
&a4, &a4,
&a3, &a3,
&a5, &a5,
@@ -124,7 +129,7 @@ const PaperCap *papers[] = {
&japanese_envelope_you4 &japanese_envelope_you4
}; };
const PaperSourceCap *papersources[] = { const PaperSourceCap* papersources[] = {
&autobin, &autobin,
&manual, &manual,
&upper, &upper,
@@ -132,13 +137,13 @@ const PaperSourceCap *papersources[] = {
&lower &lower
}; };
const ResolutionCap *resolutions[] = { const ResolutionCap* resolutions[] = {
&dpi1200, &dpi1200,
&dpi600, &dpi600,
&dpi300 &dpi300
}; };
const PrintStyleCap *printstyles[] = { const PrintStyleCap* printstyles[] = {
&simplex, &simplex,
&duplex, &duplex,
&booklet &booklet
@@ -154,13 +159,14 @@ const BindingLocationCap *bindinglocations[] = {
const ColorCap color("Color", false, JobData::kColor); const ColorCap color("Color", false, JobData::kColor);
const ColorCap monochrome("Shades of Gray", true, JobData::kMonochrome); const ColorCap monochrome("Shades of Gray", true, JobData::kMonochrome);
const ColorCap *colors[] = { const ColorCap* colors[] = {
&color, &color,
&monochrome &monochrome
}; };
int Lips4Cap::countCap(CapID capid) const int
Lips4Cap::countCap(CapID capid) const
{ {
switch (capid) { switch (capid) {
case kPaper: case kPaper:
@@ -180,7 +186,9 @@ int Lips4Cap::countCap(CapID capid) const
} }
} }
const BaseCap **Lips4Cap::enumCap(CapID capid) const
const BaseCap**
Lips4Cap::enumCap(CapID capid) const
{ {
switch (capid) { switch (capid) {
case kPaper: case kPaper:
@@ -200,7 +208,9 @@ const BaseCap **Lips4Cap::enumCap(CapID capid) const
} }
} }
bool Lips4Cap::isSupport(CapID capid) const
bool
Lips4Cap::isSupport(CapID capid) const
{ {
switch (capid) { switch (capid) {
case kPaper: case kPaper:
@@ -2,18 +2,20 @@
* Lips4Cap.h * Lips4Cap.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved. * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/ */
#ifndef __LIPS4CAP_H #ifndef __LIPS4CAP_H
#define __LIPS4CAP_H #define __LIPS4CAP_H
#include "PrinterCap.h" #include "PrinterCap.h"
class Lips4Cap : public PrinterCap { class Lips4Cap : public PrinterCap {
public: public:
Lips4Cap(const PrinterData *printer_data) : PrinterCap(printer_data) {} Lips4Cap(const PrinterData* printer_data)
: PrinterCap(printer_data) {}
virtual int countCap(CapID) const; virtual int countCap(CapID) const;
virtual bool isSupport(CapID) const; virtual bool isSupport(CapID) const;
virtual const BaseCap **enumCap(CapID) const; virtual const BaseCap** enumCap(CapID) const;
}; };
#endif /* __LIPS4CAP_H */ #endif // __LIPS4CAP_H
@@ -3,10 +3,12 @@
* Copyright 1999-2000 Y.Takagi. All Rights Reserved. * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/ */
#include "Lips4.h" #include "Lips4.h"
#include "Lips4Cap.h" #include "Lips4Cap.h"
#include "PrinterDriver.h" #include "PrinterDriver.h"
class Lips4PrinterDriver : public PrinterDriver class Lips4PrinterDriver : public PrinterDriver
{ {
public: public:
@@ -37,13 +39,16 @@ public:
return new Lips4Cap(printerData); return new Lips4Cap(printerData);
} }
GraphicsDriver* InstantiateGraphicsDriver(BMessage* settings, PrinterData* printerData, PrinterCap* printerCap) GraphicsDriver* InstantiateGraphicsDriver(BMessage* settings,
PrinterData* printerData, PrinterCap* printerCap)
{ {
return new LIPS4Driver(settings, printerData, printerCap); return new LIPS4Driver(settings, printerData, printerCap);
} }
}; };
PrinterDriver* instantiate_printer_driver(BNode* printerFolder)
PrinterDriver*
instantiate_printer_driver(BNode* printerFolder)
{ {
return new Lips4PrinterDriver(printerFolder); return new Lips4PrinterDriver(printerFolder);
} }