summaryrefslogtreecommitdiffstats
path: root/kbarcode/pixmapbarcode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kbarcode/pixmapbarcode.cpp')
-rw-r--r--kbarcode/pixmapbarcode.cpp120
1 files changed, 60 insertions, 60 deletions
diff --git a/kbarcode/pixmapbarcode.cpp b/kbarcode/pixmapbarcode.cpp
index 56a597e..ce07836 100644
--- a/kbarcode/pixmapbarcode.cpp
+++ b/kbarcode/pixmapbarcode.cpp
@@ -25,14 +25,14 @@
#include <kprocess.h>
#include <ktempfile.h>
-#include <qbuffer.h>
-#include <qdom.h>
-#include <qfile.h>
-#include <qfileinfo.h>
-#include <qpainter.h>
-#include <qpaintdevicemetrics.h>
-#include <qpixmap.h>
-#include <qtextstream.h>
+#include <tqbuffer.h>
+#include <tqdom.h>
+#include <tqfile.h>
+#include <tqfileinfo.h>
+#include <tqpainter.h>
+#include <tqpaintdevicemetrics.h>
+#include <tqpixmap.h>
+#include <tqtextstream.h>
/* Margin added by GNU Barcode to the barcodes */
#define BARCODE_MARGIN 10
@@ -63,14 +63,14 @@ void PDF417Options::defaults()
m_err = 5;
}
-void PDF417Options::load( const QDomElement* tag )
+void PDF417Options::load( const TQDomElement* tag )
{
m_row = tag->attribute( "pdf417.row", "24" ).toInt();
m_col = tag->attribute( "pdf417.col", "8" ).toInt();
m_err = tag->attribute( "pdf417.err", "5" ).toInt();
}
-void PDF417Options::save( QDomElement* tag )
+void PDF417Options::save( TQDomElement* tag )
{
tag->setAttribute( "pdf417.row", m_row );
tag->setAttribute( "pdf417.col", m_col );
@@ -100,21 +100,21 @@ const PixmapBarcode & PixmapBarcode::operator=( const BarkodeEngine & rhs )
return *this;
}
-const QSize PixmapBarcode::size() const
+const TQSize PixmapBarcode::size() const
{
- return ( p.size().isNull() ? QSize( 100, 80 ) : p.size() );
+ return ( p.size().isNull() ? TQSize( 100, 80 ) : p.size() );
}
-void PixmapBarcode::update( const QPaintDevice* device )
+void PixmapBarcode::update( const TQPaintDevice* device )
{
p.resize( 0, 0 );
createBarcode( &p, device );
}
-void PixmapBarcode::drawBarcode( QPainter & painter, int x, int y )
+void PixmapBarcode::drawBarcode( TQPainter & painter, int x, int y )
{
if( p.isNull() )
- createBarcode( &p, painter.device() );
+ createBarcode( &p, TQT_TQPAINTDEVICE(painter.device()) );
if( p.isNull() ) // still no barcode....
{
@@ -125,18 +125,18 @@ void PixmapBarcode::drawBarcode( QPainter & painter, int x, int y )
painter.drawPixmap( x, y, p );
}
-bool PixmapBarcode::createPixmap( QPixmap* target, int resx, int resy )
+bool PixmapBarcode::createPixmap( TQPixmap* target, int resx, int resy )
{
char* postscript = NULL;
long postscript_size = 0;
- QString cmd;
+ TQString cmd;
bool bMonocrome;
- bMonocrome = ( barkode->foreground() == Qt::black &&
- barkode->background() == Qt::white &&
- barkode->textColor() == Qt::black );
+ bMonocrome = ( barkode->foreground() == TQt::black &&
+ barkode->background() == TQt::white &&
+ barkode->textColor() == TQt::black );
- KTempFile* input = new KTempFile( QString::null, bMonocrome ? ".pbm" : ".ppm" );
+ KTempFile* input = new KTempFile( TQString(), bMonocrome ? ".pbm" : ".ppm" );
input->file()->close();
if( Barkode::engineForType( barkode->type() ) == PDF417 ) {
@@ -162,7 +162,7 @@ bool PixmapBarcode::createPixmap( QPixmap* target, int resx, int resy )
return false;
}
- QRect size = bbox( postscript, postscript_size );
+ TQRect size = bbox( postscript, postscript_size );
double sw = (double)(size.x() + size.width())/72 * resx;
double sh = (double)(size.y() + size.height())/72 * resy;
@@ -172,9 +172,9 @@ bool PixmapBarcode::createPixmap( QPixmap* target, int resx, int resy )
sh = (double)(size.y() + size.height());
}
- cmd = QString("gs -g%1x%2").arg(int(sw*(double)barkode->scaling())).arg(int(sh*(double)barkode->scaling()));
- cmd += " -r" + QString::number( resx*(double)barkode->scaling()) + "x" + QString::number( resy*(double)barkode->scaling() );
- cmd += QString(" -sDEVICE=%1 -sOutputFile=").arg( bMonocrome ? "pbmraw" : "ppm" );
+ cmd = TQString("gs -g%1x%2").tqarg(int(sw*(double)barkode->scaling())).tqarg(int(sh*(double)barkode->scaling()));
+ cmd += " -r" + TQString::number( resx*(double)barkode->scaling()) + "x" + TQString::number( resy*(double)barkode->scaling() );
+ cmd += TQString(" -sDEVICE=%1 -sOutputFile=").tqarg( bMonocrome ? "pbmraw" : "ppm" );
cmd += input->name();
cmd += " -sNOPAUSE -q - -c showpage quit";
@@ -204,7 +204,7 @@ bool PixmapBarcode::createPixmap( QPixmap* target, int resx, int resy )
bool PixmapBarcode::createPostscript( char** postscript, long* postscript_size )
{
- QString cmd;
+ TQString cmd;
/*
if( Barkode::engineForType( barkode->type() ) == TBARCODE )
@@ -226,30 +226,30 @@ bool PixmapBarcode::createPostscript( char** postscript, long* postscript_size )
return true;
}
-QRect PixmapBarcode::bbox( const char* data, long size )
+TQRect PixmapBarcode::bbox( const char* data, long size )
{
int x = 0, y = 0, w = 0, h = 0;
const char* bbox = "%%BoundingBox:";
int len = strlen( bbox );
- QRect s(0,0,0,0);
- QByteArray array;
+ TQRect s(0,0,0,0);
+ TQByteArray array;
array.setRawData( data, size );
- QBuffer b( array );
+ TQBuffer b( array );
if( !b.open( IO_ReadOnly ) )
return s;
- QTextStream t( &b );
+ TQTextStream t( &b );
- QString text = t.readLine();
+ TQString text = t.readLine();
while( !text.isNull() )
{
if( text.startsWith( bbox ) )
{
text = text.right( text.length() - len );
sscanf( (const char*)text, "%d %d %d %d", &x, &y, &w, &h );
- s = QRect( x, y, w, h );
+ s = TQRect( x, y, w, h );
break;
}
@@ -304,13 +304,13 @@ bool PixmapBarcode::readFromPipe( const char* command, char** buffer, long* buff
return true;
}
-void PixmapBarcode::createBarcode( QPixmap* target, const QPaintDevice* device )
+void PixmapBarcode::createBarcode( TQPixmap* target, const TQPaintDevice* device )
{
- QPaintDeviceMetrics pdm( device );
+ TQPaintDeviceMetrics pdm( device );
int resx = pdm.logicalDpiX();
int resy = pdm.logicalDpiY();
- QPixmap* cached = 0;//BarcodeCache::instance()->read( barcode, resx, resy, value );
+ TQPixmap* cached = 0;//BarcodeCache::instance()->read( barcode, resx, resy, value );
// no matching barcode found in cache
if( !cached ) {
@@ -325,11 +325,11 @@ void PixmapBarcode::createBarcode( QPixmap* target, const QPaintDevice* device )
// we have to scale to the correct resolution.
// we scale already here and not at the end,
// so that the addMargin function does not get a scaled margin.
- QPaintDeviceMetrics pdm( KApplication::desktop() );
+ TQPaintDeviceMetrics pdm( KApplication::desktop() );
int screenresx = pdm.logicalDpiX();
int screenresy = pdm.logicalDpiY();
- QWMatrix m;
+ TQWMatrix m;
double scalex = (resx/screenresx)*barkode->scaling();
double scaley = (resy/screenresy)*barkode->scaling();
m.scale( scalex, scaley );
@@ -339,7 +339,7 @@ void PixmapBarcode::createBarcode( QPixmap* target, const QPaintDevice* device )
*target = addMargin( target );
// Rotate
- QWMatrix m;
+ TQWMatrix m;
m.rotate( (double)barkode->rotation() );
*target = target->xForm( m );
@@ -356,8 +356,8 @@ bool PixmapBarcode::createPdf417( KTempFile* output )
return false;
}
- KTempFile text( QString::null, ".txt" );
- QTextStream t( text.file() );
+ KTempFile text( TQString(), ".txt" );
+ TQTextStream t( text.file() );
t << barkode->parsedValue();
text.file()->close();
@@ -383,42 +383,42 @@ bool PixmapBarcode::createPdf417( KTempFile* output )
}
#if 0
-QString PixmapBarcode::createTBarcodeCmd()
+TQString PixmapBarcode::createTBarcodeCmd()
{
- QString cmd;
+ TQString cmd;
// print text
- QString flag = barkode->textVisible() ? " Ton" : " n Toff"; // we pass the old parameter Ton and the new one: n
+ TQString flag = barkode->textVisible() ? " Ton" : " n Toff"; // we pass the old parameter Ton and the new one: n
// escape text
flag.append( barkode->tbarcodeOptions()->escape() ? " son" : " soff" );
// autocorrection
flag.append( barkode->tbarcodeOptions()->autocorrect() ? " Aon" : " Aoff" );
// barcode height
- flag.append( QString( " h%1" ).arg( barkode->tbarcodeOptions()->height() ) );
+ flag.append( TQString( " h%1" ).tqarg( barkode->tbarcodeOptions()->height() ) );
// text above
if( barkode->tbarcodeOptions()->above() )
flag.append( " a" );
cmd = "tbarcodeclient ";
if( !Barkode::hasFeature( barkode->type(), BARCODE2D ) )
- cmd += QString( " m%1" ).arg( barkode->tbarcodeOptions()->moduleWidth() * 1000 );
+ cmd += TQString( " m%1" ).tqarg( barkode->tbarcodeOptions()->moduleWidth() * 1000 );
if( Barkode::hasFeature( barkode->type(), DATAMATRIX ) )
- cmd += QString( " Ds%1" ).arg( barkode->datamatrixSize() );
+ cmd += TQString( " Ds%1" ).tqarg( barkode->datamatrixSize() );
if( Barkode::hasFeature( barkode->type(), PDF417BARCODE ) )
- cmd += QString( " Pr%1 Pc%2 Pe%3" ).arg( barkode->pdf417Options()->row() )
- .arg( barkode->pdf417Options()->col() )
- .arg( barkode->pdf417Options()->err() );
+ cmd += TQString( " Pr%1 Pc%2 Pe%3" ).tqarg( barkode->pdf417Options()->row() )
+ .tqarg( barkode->pdf417Options()->col() )
+ .tqarg( barkode->pdf417Options()->err() );
- cmd += " " + barkode->type() + QString(" tPS c%1").arg( barkode->tbarcodeOptions()->checksum() );
+ cmd += " " + barkode->type() + TQString(" tPS c%1").tqarg( barkode->tbarcodeOptions()->checksum() );
cmd += flag + " d" + KShellProcess::quote( barkode->parsedValue() );
return cmd;
}
#endif // 0
-void PixmapBarcode::cleanUp( KTempFile* file, QPixmap* target )
+void PixmapBarcode::cleanUp( KTempFile* file, TQPixmap* target )
{
target->resize( 0, 0 );
@@ -426,15 +426,15 @@ void PixmapBarcode::cleanUp( KTempFile* file, QPixmap* target )
delete file;
}
-QPixmap PixmapBarcode::cut( QPixmap* pic, double cut)
+TQPixmap PixmapBarcode::cut( TQPixmap* pic, double cut)
{
if( cut == 1.0 )
return (*pic);
- QPixmap pcut( pic->width(), int((double)pic->height() * cut) );
- pcut.fill( Qt::white ); // barcode.bg
+ TQPixmap pcut( pic->width(), int((double)pic->height() * cut) );
+ pcut.fill( TQt::white ); // barcode.bg
- QWMatrix m;
+ TQWMatrix m;
/*
* if text is above the barcode cut from
* below the barcode.
@@ -447,15 +447,15 @@ QPixmap PixmapBarcode::cut( QPixmap* pic, double cut)
} else
m.rotate( 180 );
- QPainter painter( &pcut );
+ TQPainter painter( &pcut );
painter.drawPixmap( 0, 0, pic->xForm( m ) );
return pcut.xForm( m );
}
-QPixmap PixmapBarcode::addMargin( QPixmap* pic )
+TQPixmap PixmapBarcode::addMargin( TQPixmap* pic )
{
- QPixmap p;
+ TQPixmap p;
/* We have to handle UPC special because of the checksum character
* which is printed on the right margin.
@@ -484,7 +484,7 @@ QPixmap PixmapBarcode::addMargin( QPixmap* pic )
p.resize( pic->width() + margin, pic->height() + margin );
p.fill( barkode->background() );
- QPainter painter( &p );
+ TQPainter painter( &p );
painter.drawPixmap( barkode->quietZone(), barkode->quietZone(), *pic, (int)sx, (int)sy, (int)sw, (int)sh );
painter.end();