diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-01 21:17:46 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-01 21:17:46 +0000 |
commit | 21a1d3cffb820b001b0901f8e82d4c8bfc5e1683 (patch) | |
tree | ad9d08bc725d963acafab219a33699ae2d6e723c /client/crystalbutton.cpp | |
parent | 424422475d6f30da2b84041dcb2b13b425126f04 (diff) | |
download | twin-style-crystal-21a1d3cffb820b001b0901f8e82d4c8bfc5e1683.tar.gz twin-style-crystal-21a1d3cffb820b001b0901f8e82d4c8bfc5e1683.zip |
TQt4 port kwin-style-crystal
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kwin-style-crystal@1239032 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'client/crystalbutton.cpp')
-rw-r--r-- | client/crystalbutton.cpp | 126 |
1 files changed, 63 insertions, 63 deletions
diff --git a/client/crystalbutton.cpp b/client/crystalbutton.cpp index 8566e41..d38cbee 100644 --- a/client/crystalbutton.cpp +++ b/client/crystalbutton.cpp @@ -19,9 +19,9 @@ ***************************************************************************/ -#include <qimage.h> -#include <qtooltip.h> -#include <qpainter.h> +#include <tqimage.h> +#include <tqtooltip.h> +#include <tqpainter.h> #include "crystalclient.h" #include "crystalbutton.h" @@ -29,10 +29,10 @@ #include "imageholder.h" -CrystalButton::CrystalButton(CrystalClient *parent, const char *name, - const QString& tip, ButtonType type, +CrystalButton::CrystalButton(CrystalClient *tqparent, const char *name, + const TQString& tip, ButtonType type, ButtonImage *vimage) -: QButton(parent->widget(), name), client_(parent), type_(type), image(vimage), lastmouse_(0) +: TQButton(tqparent->widget(), name), client_(tqparent), type_(type), image(vimage), lastmouse_(0) { setBackgroundMode(NoBackground); resetSize(false); @@ -40,8 +40,8 @@ CrystalButton::CrystalButton(CrystalClient *parent, const char *name, hover=first=last=false; animation=0.0; - QToolTip::add(this, tip); - connect ( &animation_timer,SIGNAL(timeout()),this,SLOT(animate())); + TQToolTip::add(this, tip); + connect ( &animation_timer,TQT_SIGNAL(timeout()),this,TQT_SLOT(animate())); } CrystalButton::~CrystalButton() @@ -59,12 +59,12 @@ void CrystalButton::resetSize(bool FullSize) void CrystalButton::setBitmap(ButtonImage *newimage) { image=newimage; - repaint(false); + tqrepaint(false); } -QSize CrystalButton::sizeHint() const +TQSize CrystalButton::tqsizeHint() const { - return QSize(buttonSizeH(),buttonSizeV()); + return TQSize(buttonSizeH(),buttonSizeV()); } int CrystalButton::buttonSizeH() const @@ -85,105 +85,105 @@ int CrystalButton::buttonSizeV() const return (factory->titlesize-1-vS>h)?h:factory->titlesize-1-vS; } -void CrystalButton::enterEvent(QEvent *e) +void CrystalButton::enterEvent(TQEvent *e) { hover=true; - if (factory->hovereffect)repaint(false); + if (factory->hovereffect)tqrepaint(false); if (factory->animateHover)animation_timer.start(60); - QButton::enterEvent(e); + TQButton::enterEvent(e); } -void CrystalButton::leaveEvent(QEvent *e) +void CrystalButton::leaveEvent(TQEvent *e) { hover=false; - if (factory->hovereffect)repaint(false); + if (factory->hovereffect)tqrepaint(false); if (factory->animateHover)animation_timer.start(80); - QButton::leaveEvent(e); + TQButton::leaveEvent(e); } -void CrystalButton::mousePressEvent(QMouseEvent* e) +void CrystalButton::mousePressEvent(TQMouseEvent* e) { lastmouse_ = e->button(); int button; switch(e->button()) { - case LeftButton: - button=LeftButton; + case Qt::LeftButton: + button=Qt::LeftButton; break; - case RightButton: + case Qt::RightButton: if ((type_ == ButtonMax) || (type_ == ButtonMin) || (type_ == ButtonMenu) || (type_ == ButtonClose)) - button=LeftButton; else button=NoButton; + button=Qt::LeftButton; else button=Qt::NoButton; break; - case MidButton: + case Qt::MidButton: if ((type_ == ButtonMax) || (type_ == ButtonMin)) - button=LeftButton; else button=NoButton; + button=Qt::LeftButton; else button=Qt::NoButton; break; - default:button=NoButton; + default:button=Qt::NoButton; break; } - QMouseEvent me(e->type(), e->pos(), e->globalPos(),button, e->state()); - QButton::mousePressEvent(&me); + TQMouseEvent me(e->type(), e->pos(), e->globalPos(),button, e->state()); + TQButton::mousePressEvent(&me); } -void CrystalButton::mouseReleaseEvent(QMouseEvent* e) +void CrystalButton::mouseReleaseEvent(TQMouseEvent* e) { lastmouse_ = e->button(); int button; switch(e->button()) { - case LeftButton: - button=LeftButton; + case Qt::LeftButton: + button=Qt::LeftButton; break; - case RightButton: + case Qt::RightButton: if ((type_ == ButtonMax) || (type_ == ButtonMin) || (type_ == ButtonMenu) || (type_==ButtonClose)) - button=LeftButton; else button=NoButton; + button=Qt::LeftButton; else button=Qt::NoButton; break; - case MidButton: + case Qt::MidButton: if ((type_ == ButtonMax) || (type_ == ButtonMin)) - button=LeftButton; else button=NoButton; + button=Qt::LeftButton; else button=Qt::NoButton; break; - default:button=NoButton; + default:button=Qt::NoButton; break; } - QMouseEvent me(e->type(), e->pos(), e->globalPos(), button, e->state()); - QButton::mouseReleaseEvent(&me); + TQMouseEvent me(e->type(), e->pos(), e->globalPos(), button, e->state()); + TQButton::mouseReleaseEvent(&me); } -void CrystalButton::drawButton(QPainter *painter) +void CrystalButton::drawButton(TQPainter *painter) { if (!CrystalFactory::initialized()) return; - QColorGroup group; + TQColorGroup group; float dx, dy; int dm=0; - QPixmap pufferPixmap; + TQPixmap pufferPixmap; pufferPixmap.resize(width(), height()); - QPainter pufferPainter(&pufferPixmap); + TQPainter pufferPainter(&pufferPixmap); CrystalFactory *f=((CrystalFactory*)client_->factory()); - QPixmap *background; + TQPixmap *background; if (f->transparency)background=f->image_holder->image(client_->isActive()); else background=NULL; WND_CONFIG *wndcfg=client_->isActive()?&f->active:&f->inactive; if (background && !background->isNull()) { - QRect r=rect(); - QPoint p=mapToGlobal(QPoint(0,0)); + TQRect r=rect(); + TQPoint p=mapToGlobal(TQPoint(0,0)); r.moveBy(p.x(),p.y()); - pufferPainter.drawPixmap(QPoint(0,0),*background,r); + pufferPainter.drawPixmap(TQPoint(0,0),*background,r); }else{ - group = client_->options()->colorGroup(KDecoration::ColorTitleBar, client_->isActive()); + group = client_->options()->tqcolorGroup(KDecoration::ColorTitleBar, client_->isActive()); pufferPainter.fillRect(rect(), group.background()); } if (!wndcfg->overlay.isNull()) { - pufferPainter.drawTiledPixmap(rect(),wndcfg->overlay,QPoint(x(),y())); + pufferPainter.drawTiledPixmap(rect(),wndcfg->overlay,TQPoint(x(),y())); } dm=0; @@ -228,21 +228,21 @@ void CrystalButton::drawButton(QPainter *painter) if (dx<1 || dy<=1) { int m=(rect().width()-2<rect().height())?rect().width()-2:rect().height(); - QRect r((rect().width()-m)/2,(rect().height()-m)/2,m,m); + TQRect r((rect().width()-m)/2,(rect().height()-m)/2,m,m); // if (isDown()) { r.moveBy(1,1); } - pufferPainter.drawPixmap(r, client_->icon().pixmap(QIconSet::Small, - QIconSet::Normal)); + pufferPainter.drawPixmap(r, client_->icon().pixmap(TQIconSet::Small, + TQIconSet::Normal)); }else{ // if (isDown()) { dx++; dy++; } - pufferPainter.drawPixmap((int)dx, (int)dy, client_->icon().pixmap(QIconSet::Small, - QIconSet::Normal)); + pufferPainter.drawPixmap((int)dx, (int)dy, client_->icon().pixmap(TQIconSet::Small, + TQIconSet::Normal)); } } else if (image && image->initialized()) { // otherwise we paint the deco dx = float(width() - image->image_width) / 2.0; dy = float(height() - image->image_height) / 2.0; - QImage *img=image->normal; + TQImage *img=image->normal; if (::factory->hovereffect) { @@ -274,17 +274,17 @@ void CrystalButton::drawButton(QPainter *painter) w=(int)((float)h*(float)image->image_width/(float)image->image_height); } - QRect r((rect().width()-w)/2,(rect().height()-h)/2,w,h); + TQRect r((rect().width()-w)/2,(rect().height()-h)/2,w,h); pufferPainter.drawImage(r,*img); if (type_ == ButtonMenu) drawMenuImage(&pufferPainter, r); }else{ // Otherwise we just paint it if (image->drawMode==1)dy=0; - pufferPainter.drawImage(QPoint((int)dx,(int)dy),*img); + pufferPainter.drawImage(TQPoint((int)dx,(int)dy),*img); if (type_ == ButtonMenu) drawMenuImage(&pufferPainter, - QRect((int)dx,(int)dy,image->image_width,image->image_height)); + TQRect((int)dx,(int)dy,image->image_width,image->image_height)); } } @@ -292,7 +292,7 @@ void CrystalButton::drawButton(QPainter *painter) painter->drawPixmap(0,0, pufferPixmap); } -void CrystalButton::drawMenuImage(QPainter* painter, QRect r) +void CrystalButton::drawMenuImage(TQPainter* painter, TQRect r) { if (type_ != ButtonMenu) return; // we paint the mini icon (which is 16 pixels high) @@ -304,12 +304,12 @@ void CrystalButton::drawMenuImage(QPainter* painter, QRect r) if (dx<1 || dy<=1) { int m=(r.width()-2<r.height())?r.width()-2:r.height(); - QRect r2(r.left()+(r.width()-m)/2,r.top()+(r.height()-m)/2,m,m); - painter->drawPixmap(r2, client_->icon().pixmap(QIconSet::Small, - QIconSet::Normal)); + TQRect r2(r.left()+(r.width()-m)/2,r.top()+(r.height()-m)/2,m,m); + painter->drawPixmap(r2, client_->icon().pixmap(TQIconSet::Small, + TQIconSet::Normal)); }else{ - painter->drawPixmap(r.left()+(int)dx, r.top()+(int)dy, client_->icon().pixmap(QIconSet::Small, - QIconSet::Normal)); + painter->drawPixmap(r.left()+(int)dx, r.top()+(int)dy, client_->icon().pixmap(TQIconSet::Small, + TQIconSet::Normal)); } } @@ -331,7 +331,7 @@ void CrystalButton::animate() animation_timer.stop(); } } - repaint(false); + tqrepaint(false); } #include "crystalbutton.moc" |