summaryrefslogtreecommitdiffstats
path: root/kbarcode/labelutils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kbarcode/labelutils.cpp')
-rw-r--r--kbarcode/labelutils.cpp96
1 files changed, 42 insertions, 54 deletions
diff --git a/kbarcode/labelutils.cpp b/kbarcode/labelutils.cpp
index b83cb9e..73f5a3b 100644
--- a/kbarcode/labelutils.cpp
+++ b/kbarcode/labelutils.cpp
@@ -16,7 +16,6 @@
***************************************************************************/
#include "labelutils.h"
-#include "dsrichtext.h"
// TQt includes
#include <tqbitmap.h>
@@ -108,81 +107,70 @@ TQSize LabelUtils::stringSize( const TQString & t )
return s;
}
-void LabelUtils::renderString( TQPainter* painter, const TQString & t, const TQRect & rect, double scalex, double scaley )
+TQPixmap* LabelUtils::drawString(const TQString & t, int w, int h, double rot)
{
- // DSRichText cannot calculate the width on its own
- TQSimpleRichText srt( t, TDEApplication::font() );
- int width = (rect.width() > 0) ? rect.width() : srt.widthUsed();
- int height = (rect.height() > 0) ? rect.height() : srt.height();
-
- DSRichText r( t );
- r.setX( rect.x() );
- r.setY( rect.y() );
- r.setWidth( width );
- r.setHeight( height );
- r.setScale( scalex, scaley );
- r.draw( painter );
-}
-
-TQPixmap* LabelUtils::drawString( const TQString & t, int w, int h, double rot )
-{
- TQSimpleRichText srt( t, TDEApplication::font() );
+ TQSimpleRichText srt(t, TDEApplication::font());
int width = (w > 0) ? w : srt.widthUsed();
int height = (h > 0) ? h : srt.height();
srt.setWidth( width );
-
+
TQPixmap* pix;
TQPainter painter;
- if( rot == 0.0 ) {
- TQBitmap bm( width, height );
- bm.fill( TQt::color0 ); //transparent
- painter.begin( &bm );
-
- painter.save();
- painter.setPen( TQt::color1 );
- TQColorGroup cg;
- cg.setColor( TQColorGroup::Foreground, TQt::color1 );
- cg.setColor( TQColorGroup::Text, TQt::color1 );
- cg.setColor( TQColorGroup::Base, TQt::color0 );
-
- srt.draw( &painter, 0, 0, bm.rect(), cg );
- painter.restore();
+
+ if (rot == 0.0)
+ {
+ TQBitmap bm(width, height);
+ bm.fill(TQt::color0); //transtqparent
+ painter.begin(&bm);
+
+ painter.save();
+ painter.setPen(TQt::color1);
+ TQColorGroup cg;
+ cg.setColor(TQColorGroup::Foreground, TQt::color1);
+ cg.setColor(TQColorGroup::Text, TQt::color1);
+ cg.setColor(TQColorGroup::Base, TQt::color0);
+
+ srt.draw(&painter, 0, 0, bm.rect(), cg);
+ painter.restore();
painter.end();
-
- pix = new TQPixmap( width, height );
- pix->fill( TQt::white );
- pix->setMask( bm );
-
- if( !pix->isNull() ) {
- painter.begin( pix );
- painter.setPen( TQt::black );
+
+ pix = new TQPixmap(width, height);
+ pix->fill(TQt::white);
+ pix->setMask(bm);
+
+ if (!pix->isNull())
+ {
+ painter.begin(pix);
+ painter.setPen(TQt::black);
TQColorGroup cg;
- srt.draw( &painter, 0, 0, pix->rect(), cg );
+ srt.draw(&painter, 0, 0, pix->rect(), cg);
painter.end();
- }
- } else {
+ }
+ }
+ else
+ {
int w2 = (w > 0) ? w : srt.widthUsed();
int h2 = (h > 0) ? h : srt.height();
TQWMatrix wm;
- wm.rotate( rot );
+ wm.rotate(rot);
- TQSize s = LabelUtils::stringSize( t );
- TQPixmap* tmp = LabelUtils::drawString( t, s.width(), s.height() );
+ TQSize s = LabelUtils::stringSize(t);
+ TQPixmap* tmp = LabelUtils::drawString(t, s.width(), s.height());
- TQPixmap* p = new TQPixmap( w2, h2 );
- p->fill( TQt::white );
- painter.begin( p );
- painter.drawPixmap( 0, 0, tmp->xForm( wm ) );
+ TQPixmap* p = new TQPixmap(w2, h2);
+ p->fill(TQt::white);
+ painter.begin(p);
+ painter.drawPixmap(0, 0, tmp->xForm(wm));
painter.end();
- p->setMask( p->createHeuristicMask() );
+ p->setMask(p->createHeuristicMask());
pix = p;
delete tmp;
}
-
+
return pix;
}