Style cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37364 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Wim van der Meer
2010-07-03 06:29:52 +00:00
parent affec393bc
commit 24874466dc
7 changed files with 228 additions and 161 deletions
@@ -3,6 +3,7 @@
* Copyright 1999-2000 Y.Takagi. All Rights Reserved. * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/ */
// #define DBG_CON_STREAM // #define DBG_CON_STREAM
#ifdef DBG_CON_STREAM #ifdef DBG_CON_STREAM
@@ -14,7 +15,9 @@ using namespace std;
#define PACK_TYPE 2 #define PACK_TYPE 2
int compress3(unsigned char *pOut, unsigned char *pIn, int n)
int
compress3(unsigned char* pOut, unsigned char* pIn, int n)
{ {
int count; int count;
int count_byte; int count_byte;
@@ -56,25 +59,25 @@ int compress3(unsigned char *pOut, unsigned char *pIn, int n)
*pOut++ = keep; *pOut++ = keep;
*pOut++ = count - PACK_TYPE; *pOut++ = count - PACK_TYPE;
count_byte += 2; count_byte += 2;
} else { } else
count_byte = n; count_byte = n;
} }
}
return count_byte; return count_byte;
} }
#ifdef DBG_CON_STREAM #ifdef DBG_CON_STREAM
int main(int argc, char **argv)
int
main(int argc, char **argv)
{ {
if (argc < 2) { if (argc < 2)
return -1; return -1;
}
ifstream ifs(*++argv, ios::binary | ios::nocreate); ifstream ifs(*++argv, ios::binary | ios::nocreate);
if (!ifs) { if (!ifs)
return -1; return -1;
}
ifs.seekg(0, ios::end); ifs.seekg(0, ios::end);
long size = ifs.tellg(); long size = ifs.tellg();
@@ -94,4 +97,5 @@ int main(int argc, char **argv)
delete [] pOut; delete [] pOut;
} }
#endif #endif
@@ -2,10 +2,11 @@
* Compress3.h * Compress3.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved. * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/ */
#ifndef __COMPRESS3_H #ifndef __COMPRESS3_H
#define __COMPRESS3_H #define __COMPRESS3_H
int compress3(unsigned char* out, unsigned char* in, int bytes); int compress3(unsigned char* out, unsigned char* in, int bytes);
#endif /* __COMPRESS3_H */ #endif /* __COMPRESS3_H */
@@ -3,19 +3,24 @@
* Copyright 1999-2000 Y.Takagi. All Rights Reserved. * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/ */
#include "Lips3.h"
#include <memory>
#include <Alert.h> #include <Alert.h>
#include <Bitmap.h> #include <Bitmap.h>
#include <File.h> #include <File.h>
#include <memory>
#include "Lips3.h"
#include "UIDriver.h"
#include "Compress3.h" #include "Compress3.h"
#include "JobData.h"
#include "PrinterData.h"
#include "Lips3Cap.h"
#include "Halftone.h"
#include "ValidRect.h"
#include "DbgMsg.h" #include "DbgMsg.h"
#include "Halftone.h"
#include "JobData.h"
#include "Lips3Cap.h"
#include "PrinterData.h"
#include "UIDriver.h"
#include "ValidRect.h"
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE)) #if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
using namespace std; using namespace std;
@@ -23,13 +28,18 @@ using namespace std;
#define std #define std
#endif #endif
LIPS3Driver::LIPS3Driver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap)
: GraphicsDriver(msg, printer_data, printer_cap) LIPS3Driver::LIPS3Driver(BMessage *msg, PrinterData *printer_data,
const PrinterCap *printer_cap)
:
GraphicsDriver(msg, printer_data, printer_cap)
{ {
fHalftone = NULL; fHalftone = NULL;
} }
bool LIPS3Driver::startDoc()
bool
LIPS3Driver::startDoc()
{ {
try { try {
beginTextMode(); beginTextMode();
@@ -41,7 +51,9 @@ bool LIPS3Driver::startDoc()
paperFeedMode(); paperFeedMode();
disableAutoFF(); disableAutoFF();
setNumberOfCopies(); setNumberOfCopies();
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) {
@@ -49,7 +61,9 @@ bool LIPS3Driver::startDoc()
} }
} }
bool LIPS3Driver::startPage(int)
bool
LIPS3Driver::startPage(int)
{ {
try { try {
fCurrentX = 0; fCurrentX = 0;
@@ -62,7 +76,9 @@ bool LIPS3Driver::startPage(int)
} }
} }
bool LIPS3Driver::endPage(int)
bool
LIPS3Driver::endPage(int)
{ {
try { try {
formFeed(); formFeed();
@@ -73,7 +89,9 @@ bool LIPS3Driver::endPage(int)
} }
} }
bool LIPS3Driver::endDoc(bool)
bool
LIPS3Driver::endDoc(bool)
{ {
try { try {
if (fHalftone) { if (fHalftone) {
@@ -87,7 +105,9 @@ bool LIPS3Driver::endDoc(bool)
} }
} }
bool LIPS3Driver::nextBand(BBitmap *bitmap, BPoint *offset)
bool
LIPS3Driver::nextBand(BBitmap* bitmap, BPoint* offset)
{ {
DBGMSG(("> nextBand\n")); DBGMSG(("> nextBand\n"));
@@ -107,9 +127,8 @@ bool LIPS3Driver::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;
@@ -126,7 +145,8 @@ bool LIPS3Driver::nextBand(BBitmap *bitmap, BPoint *offset)
y += rc.top; y += rc.top;
int width = rc.right - rc.left + 1; int width = rc.right - rc.left + 1;
int widthByte = (width + 7) / 8; /* byte boundary */ int widthByte = (width + 7) / 8;
// byte boundary
int height = rc.bottom - rc.top + 1; int height = rc.bottom - rc.top + 1;
int in_size = widthByte * height; int in_size = widthByte * height;
int out_size = (in_size * 6 + 4) / 5; int out_size = (in_size * 6 + 4) / 5;
@@ -138,9 +158,10 @@ bool LIPS3Driver::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(("renderobj->get_pixel_depth() = %d\n", fHalftone->getPixelDepth())); DBGMSG(("renderobj->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;
@@ -154,7 +175,7 @@ bool LIPS3Driver::nextBand(BBitmap *bitmap, BPoint *offset)
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"));
@@ -170,10 +191,12 @@ bool LIPS3Driver::nextBand(BBitmap *bitmap, BPoint *offset)
compressed_size = compress3(out_buffer, in_buffer, in_size); compressed_size = compress3(out_buffer, in_buffer, in_size);
if (compressed_size < in_size) { if (compressed_size < in_size) {
compression_method = 9; /* compress3 */ compression_method = 9;
// compress3
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 {
@@ -194,16 +217,14 @@ bool LIPS3Driver::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;
@@ -215,32 +236,44 @@ bool LIPS3Driver::nextBand(BBitmap *bitmap, BPoint *offset)
} }
} }
void LIPS3Driver::beginTextMode()
void
LIPS3Driver::beginTextMode()
{ {
writeSpoolString("\033%%@"); writeSpoolString("\033%%@");
} }
void LIPS3Driver::jobStart()
void
LIPS3Driver::jobStart()
{ {
writeSpoolString("\033P31;300;1J\033\\"); writeSpoolString("\033P31;300;1J\033\\");
} }
void LIPS3Driver::softReset()
void
LIPS3Driver::softReset()
{ {
writeSpoolString("\033<"); writeSpoolString("\033<");
} }
void LIPS3Driver::sizeUnitMode()
void
LIPS3Driver::sizeUnitMode()
{ {
writeSpoolString("\033[11h"); writeSpoolString("\033[11h");
} }
void LIPS3Driver::selectSizeUnit()
void
LIPS3Driver::selectSizeUnit()
{ {
writeSpoolString("\033[7 I"); writeSpoolString("\033[7 I");
} }
void LIPS3Driver::selectPageFormat()
void
LIPS3Driver::selectPageFormat()
{ {
int i; int i;
int width = 0; int width = 0;
@@ -301,14 +334,15 @@ void LIPS3Driver::selectPageFormat()
if (JobData::kLandscape == getJobData()->getOrientation()) if (JobData::kLandscape == getJobData()->getOrientation())
i++; i++;
if (i < 80) { if (i < 80)
writeSpoolString("\033[%d;;p", i); writeSpoolString("\033[%d;;p", i);
} else { else
writeSpoolString("\033[%d;%d;%dp", i, height, width); writeSpoolString("\033[%d;%d;%dp", i, height, width);
} }
}
void LIPS3Driver::paperFeedMode()
void
LIPS3Driver::paperFeedMode()
{ {
// 0 auto // 0 auto
// -------------- // --------------
@@ -346,74 +380,85 @@ void LIPS3Driver::paperFeedMode()
writeSpoolString("\033[%dq", i); writeSpoolString("\033[%dq", i);
} }
void LIPS3Driver::disableAutoFF()
void
LIPS3Driver::disableAutoFF()
{ {
writeSpoolString("\033[?2h"); writeSpoolString("\033[?2h");
} }
void LIPS3Driver::setNumberOfCopies()
void
LIPS3Driver::setNumberOfCopies()
{ {
writeSpoolString("\033[%ldv", getJobData()->getCopies()); writeSpoolString("\033[%ldv", getJobData()->getCopies());
} }
void LIPS3Driver::memorizedPosition()
void
LIPS3Driver::memorizedPosition()
{ {
writeSpoolString("\033[0;1;0x"); writeSpoolString("\033[0;1;0x");
} }
void LIPS3Driver::moveAbsoluteHorizontal(int x)
void
LIPS3Driver::moveAbsoluteHorizontal(int x)
{ {
writeSpoolString("\033[%d`", x); writeSpoolString("\033[%d`", x);
} }
void LIPS3Driver::carriageReturn()
void
LIPS3Driver::carriageReturn()
{ {
writeSpoolChar('\x0d'); writeSpoolChar('\x0d');
} }
void LIPS3Driver::moveDown(int dy)
void
LIPS3Driver::moveDown(int dy)
{ {
writeSpoolString("\033[%de", dy); writeSpoolString("\033[%de", dy);
} }
void LIPS3Driver::rasterGraphics(
int compression_size, void
int widthbyte, LIPS3Driver::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
// 9 compress-3 // 9 compress-3
writeSpoolString( writeSpoolString("\033[%d;%d;%d;%d;%d.r", compression_size, widthbyte,
"\033[%d;%d;%d;%d;%d.r", getJobData()->getXres(), compression_method, height);
compression_size,
widthbyte,
getJobData()->getXres(),
compression_method,
height);
writeSpoolData(buffer, compression_size); writeSpoolData(buffer, compression_size);
} }
void LIPS3Driver::formFeed()
void
LIPS3Driver::formFeed()
{ {
writeSpoolChar('\014'); writeSpoolChar('\014');
} }
void LIPS3Driver::jobEnd()
void
LIPS3Driver::jobEnd()
{ {
writeSpoolString("\033P0J\033\\"); writeSpoolString("\033P0J\033\\");
} }
void LIPS3Driver::move(int x, int y)
void
LIPS3Driver::move(int x, int y)
{ {
if (fCurrentX != x) { if (fCurrentX != x) {
if (x) { if (x)
moveAbsoluteHorizontal(x); moveAbsoluteHorizontal(x);
} else { else
carriageReturn(); carriageReturn();
}
fCurrentX = x; fCurrentX = x;
} }
if (fCurrentY != y) { if (fCurrentY != y) {
@@ -2,17 +2,20 @@
* Lips3.h * Lips3.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved. * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/ */
#ifndef __LIPS3_H #ifndef __LIPS3_H
#define __LIPS3_H #define __LIPS3_H
#include "GraphicsDriver.h" #include "GraphicsDriver.h"
class Halftone; class Halftone;
class LIPS3Driver : public GraphicsDriver { class LIPS3Driver : public GraphicsDriver {
public: public:
LIPS3Driver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap); LIPS3Driver(BMessage* msg, PrinterData* printer_data,
const PrinterCap* printer_cap);
protected: protected:
virtual bool startDoc(); virtual bool startDoc();
@@ -50,4 +53,4 @@ private:
Halftone* fHalftone; Halftone* fHalftone;
}; };
#endif /* __LIPS3_H */ #endif // __LIPS3_H
@@ -3,11 +3,13 @@
* Copyright 1999-2000 Y.Takagi. All Rights Reserved. * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/ */
#include "PrinterData.h"
#include "Lips3Cap.h" #include "Lips3Cap.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,
@@ -100,12 +102,16 @@ const ColorCap *colors[] = {
&monochrome &monochrome
}; };
Lips3Cap::Lips3Cap(const PrinterData* printer_data) Lips3Cap::Lips3Cap(const PrinterData* printer_data)
: PrinterCap(printer_data) :
PrinterCap(printer_data)
{ {
} }
int Lips3Cap::countCap(CapID capid) const
int
Lips3Cap::countCap(CapID capid) const
{ {
switch (capid) { switch (capid) {
case kPaper: case kPaper:
@@ -121,7 +127,9 @@ int Lips3Cap::countCap(CapID capid) const
} }
} }
const BaseCap **Lips3Cap::enumCap(CapID capid) const
const
BaseCap **Lips3Cap::enumCap(CapID capid) const
{ {
switch (capid) { switch (capid) {
case kPaper: case kPaper:
@@ -137,7 +145,9 @@ const BaseCap **Lips3Cap::enumCap(CapID capid) const
} }
} }
bool Lips3Cap::isSupport(CapID capid) const
bool
Lips3Cap::isSupport(CapID capid) const
{ {
switch (capid) { switch (capid) {
case kPaper: case kPaper:
@@ -2,12 +2,13 @@
* Lips3Cap.h * Lips3Cap.h
* Copyright 1999-2000 Y.Takagi. All Rights Reserved. * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/ */
#ifndef __LIPS3CAP_H #ifndef __LIPS3CAP_H
#define __LIPS3CAP_H #define __LIPS3CAP_H
#include "PrinterCap.h" #include "PrinterCap.h"
class Lips3Cap : public PrinterCap { class Lips3Cap : public PrinterCap {
public: public:
Lips3Cap(const PrinterData* printer_data); Lips3Cap(const PrinterData* printer_data);
@@ -16,4 +17,4 @@ public:
virtual const BaseCap **enumCap(CapID) const; virtual const BaseCap **enumCap(CapID) const;
}; };
#endif /* __LIPS3CAP_H */ #endif // __LIPS3CAP_H
@@ -3,10 +3,12 @@
* Copyright 1999-2000 Y.Takagi. All Rights Reserved. * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
*/ */
#include "Lips3.h" #include "Lips3.h"
#include "Lips3Cap.h" #include "Lips3Cap.h"
#include "PrinterDriver.h" #include "PrinterDriver.h"
class Lips3PrinterDriver : public PrinterDriver class Lips3PrinterDriver : public PrinterDriver
{ {
public: public:
@@ -37,14 +39,15 @@ public:
return new Lips3Cap(printerData); return new Lips3Cap(printerData);
} }
GraphicsDriver* InstantiateGraphicsDriver(BMessage* settings, PrinterData* printerData, PrinterCap* printerCap) GraphicsDriver* InstantiateGraphicsDriver(BMessage* settings,
PrinterData* printerData, PrinterCap* printerCap)
{ {
return new LIPS3Driver(settings, printerData, printerCap); return new LIPS3Driver(settings, printerData, printerCap);
} }
}; };
PrinterDriver* instantiate_printer_driver(BNode* printerFolder) PrinterDriver* instantiate_printer_driver(BNode* printerFolder)
{ {
return new Lips3PrinterDriver(printerFolder); return new Lips3PrinterDriver(printerFolder);
} }