diff options
Diffstat (limited to 'kexi/plugins/forms/widgets/kexidblabel.cpp')
-rw-r--r-- | kexi/plugins/forms/widgets/kexidblabel.cpp | 220 |
1 files changed, 110 insertions, 110 deletions
diff --git a/kexi/plugins/forms/widgets/kexidblabel.cpp b/kexi/plugins/forms/widgets/kexidblabel.cpp index e30cc19e5..db946141d 100644 --- a/kexi/plugins/forms/widgets/kexidblabel.cpp +++ b/kexi/plugins/forms/widgets/kexidblabel.cpp @@ -20,11 +20,11 @@ #include "kexidblabel.h" -#include <qbitmap.h> -#include <qpainter.h> -#include <qdrawutil.h> -#include <qapplication.h> -#include <qtimer.h> +#include <tqbitmap.h> +#include <tqpainter.h> +#include <tqdrawutil.h> +#include <tqapplication.h> +#include <tqtimer.h> #include <kdebug.h> #include <kimageeffect.h> @@ -41,7 +41,7 @@ #define SHADOW_THICKNESS 1 //! @internal -class KexiDBInternalLabel : public QLabel { +class KexiDBInternalLabel : public TQLabel { friend class KexiDBLabel; public: KexiDBInternalLabel( KexiDBLabel* ); @@ -50,23 +50,23 @@ class KexiDBInternalLabel : public QLabel { protected: void updateFrame(); - QImage makeShadow( const QImage& textImage, const QColor &bgColor, const QRect& boundingRect ); - QRect getBounding( const QImage &image, const QRect& startRect ); -// double defaultDecay( QImage& source, int i, int j ); + TQImage makeShadow( const TQImage& textImage, const TQColor &bgColor, const TQRect& boundingRect ); + TQRect getBounding( const TQImage &image, const TQRect& startRect ); +// double defaultDecay( TQImage& source, int i, int j ); KPixmap getShadowPixmap(); - QRect m_shadowRect; + TQRect m_shadowRect; KexiDBLabel *m_parentLabel; }; -KexiDBInternalLabel::KexiDBInternalLabel( KexiDBLabel* parent ) - : QLabel( parent ) - , m_parentLabel(parent) +KexiDBInternalLabel::KexiDBInternalLabel( KexiDBLabel* tqparent ) + : TQLabel( tqparent ) + , m_parentLabel(tqparent) { - int a = alignment() | Qt::WordBreak; - a &= (0xffffff ^ Qt::AlignVertical_Mask); - a |= Qt::AlignTop; - setAlignment( a ); + int a = tqalignment() | TQt::WordBreak; + a &= (0xffffff ^ TQt::AlignVertical_Mask); + a |= TQt::AlignTop; + tqsetAlignment( a ); updateFrame(); } @@ -93,11 +93,11 @@ KexiDBInternalLabel::~KexiDBInternalLabel() * -- * Christian Nitschkowski */ -QImage KexiDBInternalLabel::makeShadow( const QImage& textImage, - const QColor &bgColor, const QRect& boundingRect ) +TQImage KexiDBInternalLabel::makeShadow( const TQImage& textImage, + const TQColor &bgColor, const TQRect& boundingRect ) { - QImage result; - QString origText( text() ); + TQImage result; + TQString origText( text() ); // create a new image for for the shaddow const int w = textImage.width(); @@ -119,7 +119,7 @@ QImage KexiDBInternalLabel::makeShadow( const QImage& textImage, /* * This is the source pixmap */ - QImage img = textImage.convertDepth( 32 ); + TQImage img = textImage.convertDepth( 32 ); /* * Resize the image if necessary @@ -129,10 +129,10 @@ QImage KexiDBInternalLabel::makeShadow( const QImage& textImage, } // result.fill( 0 ); // all black - double realOpacity = SHADOW_OPACITY + QMIN(50.0/double(256.0-qGray(bgColor.rgb())), 50.0); + double realOpacity = SHADOW_OPACITY + TQMIN(50.0/double(256.0-tqGray(bgColor.rgb())), 50.0); //int _h, _s, _v; //.getHsv( &_h, &_s, &_v ); - if (colorGroup().background()==Qt::red)//_s>=250 && _v>=250) //for colors like cyan or red, make the result more white + if (tqcolorGroup().background()==TQt::red)//_s>=250 && _v>=250) //for colors like cyan or red, make the result more white realOpacity += 50.0; result.fill( (int)realOpacity ); result.setAlphaBuffer( true ); @@ -148,26 +148,26 @@ QImage KexiDBInternalLabel::makeShadow( const QImage& textImage, if ( ( i < 1 ) || ( j < 1 ) || ( i > img.width() - 2 ) || ( j > img.height() - 2 ) ) continue; else - alphaShadow = ( qGray( img.pixel( i - 1, j - 1 ) ) * SHADOW_DIAGONAL_FACTOR + - qGray( img.pixel( i - 1, j ) ) * SHADOW_AXIS_FACTOR + - qGray( img.pixel( i - 1, j + 1 ) ) * SHADOW_DIAGONAL_FACTOR + - qGray( img.pixel( i , j - 1 ) ) * SHADOW_AXIS_FACTOR + + alphaShadow = ( tqGray( img.pixel( i - 1, j - 1 ) ) * SHADOW_DIAGONAL_FACTOR + + tqGray( img.pixel( i - 1, j ) ) * SHADOW_AXIS_FACTOR + + tqGray( img.pixel( i - 1, j + 1 ) ) * SHADOW_DIAGONAL_FACTOR + + tqGray( img.pixel( i , j - 1 ) ) * SHADOW_AXIS_FACTOR + 0 + - qGray( img.pixel( i , j + 1 ) ) * SHADOW_AXIS_FACTOR + - qGray( img.pixel( i + 1, j - 1 ) ) * SHADOW_DIAGONAL_FACTOR + - qGray( img.pixel( i + 1, j ) ) * SHADOW_AXIS_FACTOR + - qGray( img.pixel( i + 1, j + 1 ) ) * SHADOW_DIAGONAL_FACTOR ) / SHADOW_FACTOR; + tqGray( img.pixel( i , j + 1 ) ) * SHADOW_AXIS_FACTOR + + tqGray( img.pixel( i + 1, j - 1 ) ) * SHADOW_DIAGONAL_FACTOR + + tqGray( img.pixel( i + 1, j ) ) * SHADOW_AXIS_FACTOR + + tqGray( img.pixel( i + 1, j + 1 ) ) * SHADOW_DIAGONAL_FACTOR ) / SHADOW_FACTOR; // update the shadow's i,j pixel. if (alphaShadow > 0) - result.setPixel( i, j, qRgba( bgRed, bgGreen , bgBlue, + result.setPixel( i, j, tqRgba( bgRed, bgGreen , bgBlue, ( int ) (( alphaShadow > realOpacity ) ? realOpacity : alphaShadow) ) ); } /*caused too much redraw problems if (period && i % period) { - qApp->processEvents(); + tqApp->processEvents(); if (text() != origText) //text has been changed in the meantime: abort - return QImage(); + return TQImage(); }*/ } return result; @@ -177,25 +177,25 @@ KPixmap KexiDBInternalLabel::getShadowPixmap() { /*! * Backup the default color used to draw text. */ - const QColor textColor = colorGroup().foreground(); + const TQColor textColor = tqcolorGroup().foreground(); /*! * Temporary storage for the generated shadow */ KPixmap finalPixmap, tempPixmap; - QImage shadowImage, tempImage; - QPainter painter; + TQImage shadowImage, tempImage; + TQPainter painter; - m_shadowRect = QRect(); + m_shadowRect = TQRect(); tempPixmap.resize( size() ); - tempPixmap.fill( Qt::black ); + tempPixmap.fill( TQt::black ); tempPixmap.setMask( tempPixmap.createHeuristicMask( true ) ); /*! * The textcolor has to be white for creating shadows! */ - setPaletteForegroundColor( Qt::white ); + setPaletteForegroundColor( TQt::white ); /*! Draw the label "as usual" in a pixmap @@ -211,7 +211,7 @@ KPixmap KexiDBInternalLabel::getShadowPixmap() { * This will fit around the unmodified text. */ shadowImage = tempPixmap; - tempPixmap.setMask( QBitmap() ); + tempPixmap.setMask( TQBitmap() ); /*! Get the first bounding rect. @@ -225,14 +225,14 @@ KPixmap KexiDBInternalLabel::getShadowPixmap() { * The new rect has to fit in the pixmap. * I have to admit this isn't really nice code... */ - m_shadowRect.setX( QMAX( m_shadowRect.x() - ( m_shadowRect.width() / 4 ), 0 ) ); - m_shadowRect.setY( QMAX( m_shadowRect.y() - ( m_shadowRect.height() / 4 ), 0 ) ); - m_shadowRect.setBottomRight( QPoint( - QMIN( m_shadowRect.x() + ( m_shadowRect.width() * 3 / 2 ), shadowImage.width() ), - QMIN( m_shadowRect.y() + ( m_shadowRect.height() * 3 / 2 ), shadowImage.height() ) ) ); + m_shadowRect.setX( TQMAX( m_shadowRect.x() - ( m_shadowRect.width() / 4 ), 0 ) ); + m_shadowRect.setY( TQMAX( m_shadowRect.y() - ( m_shadowRect.height() / 4 ), 0 ) ); + m_shadowRect.setBottomRight( TQPoint( + TQMIN( m_shadowRect.x() + ( m_shadowRect.width() * 3 / 2 ), shadowImage.width() ), + TQMIN( m_shadowRect.y() + ( m_shadowRect.height() * 3 / 2 ), shadowImage.height() ) ) ); shadowImage = makeShadow( shadowImage, - qGray( colorGroup().background().rgb() ) < 127 ? Qt::white : Qt::black, + tqGray( tqcolorGroup().background().rgb() ) < 127 ? TQt::white : TQt::black, m_shadowRect ); if (shadowImage.isNull()) return KPixmap(); @@ -249,8 +249,8 @@ KPixmap KexiDBInternalLabel::getShadowPixmap() { painter.begin( &finalPixmap ); painter.fillRect( 0, 0, finalPixmap.width(), finalPixmap.height(), palette().brush( - isEnabled() ? QPalette::Active : QPalette::Disabled, - QColorGroup::Background ) ); + isEnabled() ? TQPalette::Active : TQPalette::Disabled, + TQColorGroup::Background ) ); painter.end(); /*! @@ -276,7 +276,7 @@ KPixmap KexiDBInternalLabel::getShadowPixmap() { to a new image. I tried to copy this to a pixmap directly, but it didn't work correctly. - Maybe a Qt bug? + Maybe a TQt bug? */ tempImage = shadowImage.copy( m_shadowRect ); tempPixmap.convertFromImage( tempImage ); @@ -296,30 +296,30 @@ KPixmap KexiDBInternalLabel::getShadowPixmap() { return finalPixmap; } -QRect KexiDBInternalLabel::getBounding( const QImage &image, const QRect& startRect ) { - QPoint topLeft; - QPoint bottomRight; +TQRect KexiDBInternalLabel::getBounding( const TQImage &image, const TQRect& startRect ) { + TQPoint topLeft; + TQPoint bottomRight; const int startX = startRect.x(); const int startY = startRect.y(); /*! * Ugly beast to get the correct width and height */ - const int width = QMIN( ( startRect.bottomRight().x() > 0 - ? startRect.bottomRight().x() : QCOORD_MAX ), + const int width = TQMIN( ( startRect.bottomRight().x() > 0 + ? startRect.bottomRight().x() : TQCOORD_MAX ), image.width() ); - const int height = QMIN( ( startRect.bottomRight().y() > 0 - ? startRect.bottomRight().y() : QCOORD_MAX ), + const int height = TQMIN( ( startRect.bottomRight().y() > 0 + ? startRect.bottomRight().y() : TQCOORD_MAX ), image.height() ); /*! Assume the first pixel has the color of the background that has to be cut away. - Qt uses the four corner pixels to guess the + TQt uses the four corner pixels to guess the correct color, but in this case the topleft pixel should be enough. */ - QRgb trans = image.pixel( 0, 0 ); + TQRgb trans = image.pixel( 0, 0 ); for ( int y = startY; y < height; y++ ) { for ( int x = startX; x < width; x++ ) { @@ -361,7 +361,7 @@ QRect KexiDBInternalLabel::getBounding( const QImage &image, const QRect& startR } } - return QRect( + return TQRect( topLeft.x(), topLeft.y(), bottomRight.x() - topLeft.x(), @@ -384,10 +384,10 @@ class KexiDBLabel::Private } ~Private() {} KPixmap shadowPixmap; - QPoint shadowPosition; + TQPoint shadowPosition; KexiDBInternalLabel* internalLabel; - QTimer* timer; - QColor frameColor; + TQTimer* timer; + TQColor frameColor; bool pixmapDirty : 1; bool shadowEnabled : 1; bool resizeEvent : 1; @@ -395,8 +395,8 @@ class KexiDBLabel::Private //========================================================= -KexiDBLabel::KexiDBLabel( QWidget *parent, const char *name, WFlags f ) - : QLabel( parent, name, f ) +KexiDBLabel::KexiDBLabel( TQWidget *tqparent, const char *name, WFlags f ) + : TQLabel( tqparent, name, f ) , KexiDBTextWidgetInterface() , KexiFormDataItemInterface() , d( new Private() ) @@ -404,8 +404,8 @@ KexiDBLabel::KexiDBLabel( QWidget *parent, const char *name, WFlags f ) init(); } -KexiDBLabel::KexiDBLabel( const QString& text, QWidget *parent, const char *name, WFlags f ) - : QLabel( parent, name, f ) +KexiDBLabel::KexiDBLabel( const TQString& text, TQWidget *tqparent, const char *name, WFlags f ) + : TQLabel( tqparent, name, f ) , KexiDBTextWidgetInterface() , KexiFormDataItemInterface() , d( new Private() ) @@ -424,16 +424,16 @@ void KexiDBLabel::init() m_hasFocusableWidget = false; d->internalLabel = new KexiDBInternalLabel( this ); d->internalLabel->hide(); - d->frameColor = palette().active().foreground(); + d->frameColor = tqpalette().active().foreground(); - setAlignment( d->internalLabel->alignment() ); + tqsetAlignment( d->internalLabel->tqalignment() ); } void KexiDBLabel::updatePixmapLater() { if (d->resizeEvent) { if (!d->timer) { - d->timer = new QTimer(this, "KexiDBLabelTimer"); - connect(d->timer, SIGNAL(timeout()), this, SLOT(updatePixmap())); + d->timer = new TQTimer(this, "KexiDBLabelTimer"); + connect(d->timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(updatePixmap())); } d->timer->start(100, true); d->resizeEvent = false; @@ -453,20 +453,20 @@ void KexiDBLabel::updatePixmap() { d->internalLabel->setText( text() ); d->internalLabel->setFixedSize( size() ); d->internalLabel->setPalette( palette() ); - d->internalLabel->setAlignment( alignment() ); -// d->shadowPixmap = KPixmap(); //parallel repaints won't hurt us cause incomplete pixmap + d->internalLabel->tqsetAlignment( tqalignment() ); +// d->shadowPixmap = KPixmap(); //parallel tqrepaints won't hurt us cause incomplete pixmap KPixmap shadowPixmap = d->internalLabel->getShadowPixmap(); if (shadowPixmap.isNull()) return; d->shadowPixmap = shadowPixmap; d->shadowPosition = d->internalLabel->m_shadowRect.topLeft(); d->pixmapDirty = false; - repaint(); + tqrepaint(); } -void KexiDBLabel::paintEvent( QPaintEvent* e ) +void KexiDBLabel::paintEvent( TQPaintEvent* e ) { - QPainter p( this ); + TQPainter p( this ); if ( d->shadowEnabled ) { /*! If required, update the pixmap-cache. @@ -482,31 +482,31 @@ void KexiDBLabel::paintEvent( QPaintEvent* e ) the shadow has to be drawn using an offset relative to the widgets border. */ - if ( !d->pixmapDirty && e->rect().contains( d->shadowPosition ) && !d->shadowPixmap.isNull()) { - QRect clipRect = QRect( - QMAX( e->rect().x() - d->shadowPosition.x(), 0 ), - QMAX( e->rect().y() - d->shadowPosition.y(), 0 ), - QMIN( e->rect().width() + d->shadowPosition.x(), d->shadowPixmap.width() ), - QMIN( e->rect().height() + d->shadowPosition.y(), d->shadowPixmap.height() ) ); + if ( !d->pixmapDirty && e->rect().tqcontains( d->shadowPosition ) && !d->shadowPixmap.isNull()) { + TQRect clipRect = TQRect( + TQMAX( e->rect().x() - d->shadowPosition.x(), 0 ), + TQMAX( e->rect().y() - d->shadowPosition.y(), 0 ), + TQMIN( e->rect().width() + d->shadowPosition.x(), d->shadowPixmap.width() ), + TQMIN( e->rect().height() + d->shadowPosition.y(), d->shadowPixmap.height() ) ); p.drawPixmap( d->internalLabel->m_shadowRect.topLeft(), d->shadowPixmap, clipRect ); } } - KexiDBTextWidgetInterface::paint( this, &p, text().isEmpty(), alignment(), false ); - QLabel::paintEvent( e ); + KexiDBTextWidgetInterface::paint( this, &p, text().isEmpty(), tqalignment(), false ); + TQLabel::paintEvent( e ); } -void KexiDBLabel::setValueInternal( const QVariant& add, bool removeOld ) { +void KexiDBLabel::setValueInternal( const TQVariant& add, bool removeOld ) { if (removeOld) setText(add.toString()); else setText( m_origValue.toString() + add.toString() ); } -QVariant KexiDBLabel::value() { +TQVariant KexiDBLabel::value() { return text(); } -void KexiDBLabel::setInvalidState( const QString& displayText ) +void KexiDBLabel::setInvalidState( const TQString& displayText ) { setText( displayText ); } @@ -531,7 +531,7 @@ void KexiDBLabel::setReadOnly( bool readOnly ) Q_UNUSED(readOnly); } -QWidget* KexiDBLabel::widget() +TQWidget* KexiDBLabel::widget() { return this; } @@ -548,12 +548,12 @@ bool KexiDBLabel::cursorAtEnd() void KexiDBLabel::clear() { - setText(QString::null); + setText(TQString()); } -bool KexiDBLabel::setProperty( const char * name, const QVariant & value ) +bool KexiDBLabel::setProperty( const char * name, const TQVariant & value ) { - const bool ret = QLabel::setProperty(name, value); + const bool ret = TQLabel::setProperty(name, value); if (d->shadowEnabled) { if (0==qstrcmp("indent", name) || 0==qstrcmp("font", name) || 0==qstrcmp("margin", name) || 0==qstrcmp("frameShadow", name) || 0==qstrcmp("frameShape", name) @@ -577,45 +577,45 @@ void KexiDBLabel::setShadowEnabled( bool state ) { d->pixmapDirty = true; if (state) d->internalLabel->updateFrame(); - repaint(); + tqrepaint(); } -void KexiDBLabel::resizeEvent( QResizeEvent* e ) { +void KexiDBLabel::resizeEvent( TQResizeEvent* e ) { if (isVisible()) d->resizeEvent = true; d->pixmapDirty = true; - QLabel::resizeEvent( e ); + TQLabel::resizeEvent( e ); } -void KexiDBLabel::fontChange( const QFont& font ) { +void KexiDBLabel::fontChange( const TQFont& font ) { d->pixmapDirty = true; d->internalLabel->setFont( font ); - QLabel::fontChange( font ); + TQLabel::fontChange( font ); } -void KexiDBLabel::styleChange( QStyle& style ) { +void KexiDBLabel::styleChange( TQStyle& style ) { d->pixmapDirty = true; - QLabel::styleChange( style ); + TQLabel::styleChange( style ); } void KexiDBLabel::enabledChange( bool enabled ) { d->pixmapDirty = true; d->internalLabel->setEnabled( enabled ); - QLabel::enabledChange( enabled ); + TQLabel::enabledChange( enabled ); } -void KexiDBLabel::paletteChange( const QPalette& oldPal ) { +void KexiDBLabel::paletteChange( const TQPalette& oldPal ) { Q_UNUSED(oldPal); d->pixmapDirty = true; d->internalLabel->setPalette( palette() ); } -/*const QColor & KexiDBLabel::paletteForegroundColor () const +/*const TQColor & KexiDBLabel::paletteForegroundColor () const { return d->foregroundColor; } -void KexiDBLabel::setPaletteForegroundColor ( const QColor& color ) +void KexiDBLabel::setPaletteForegroundColor ( const TQColor& color ) { d->foregroundColor = color; }*/ @@ -623,20 +623,20 @@ void KexiDBLabel::setPaletteForegroundColor ( const QColor& color ) void KexiDBLabel::frameChanged() { d->pixmapDirty = true; d->internalLabel->updateFrame(); - QFrame::frameChanged(); + TQFrame::frameChanged(); } -void KexiDBLabel::showEvent( QShowEvent* e ) { +void KexiDBLabel::showEvent( TQShowEvent* e ) { d->pixmapDirty = true; - QLabel::showEvent( e ); + TQLabel::showEvent( e ); } -void KexiDBLabel::setText( const QString& text ) { +void KexiDBLabel::setText( const TQString& text ) { d->pixmapDirty = true; - QLabel::setText( text ); + TQLabel::setText( text ); //This is necessary for KexiFormDataItemInterface valueChanged(); - repaint(); + tqrepaint(); } bool KexiDBLabel::shadowEnabled() const @@ -645,6 +645,6 @@ bool KexiDBLabel::shadowEnabled() const } #define ClassName KexiDBLabel -#define SuperClassName QLabel +#define SuperClassName TQLabel #include "kexiframeutils_p.cpp" #include "kexidblabel.moc" |