Back to index

kdeartwork  4.3.2
Public Member Functions | Protected Slots | Protected Member Functions | Private Types | Private Attributes
Glow::GlowButton Class Reference

#include <glowbutton.h>

List of all members.

Public Member Functions

 GlowButton (QWidget *parent, const char *name, const QString &tip, const int realizeBtns)
 ~GlowButton ()
void setTipText (const QString &tip)
QString getPixmapName () const
ButtonState lastButton () const
void setPixmapName (const QString &pixmapName)
 Sets the name of the pixmap in the pixmap cache.

Protected Slots

void slotTimeout ()

Protected Member Functions

virtual void paintEvent (QPaintEvent *)
virtual void enterEvent (QEvent *)
virtual void leaveEvent (QEvent *)
virtual void mousePressEvent (QMouseEvent *)
virtual void mouseReleaseEvent (QMouseEvent *)

Private Types

enum  TimerStatus { Run, Stop }

Private Attributes

int m_updateTime
int _steps
QString m_pixmapName
QTimer * m_timer
int m_pos
TimerStatus m_timerStatus
int m_realizeButtons
ButtonState _last_button

Detailed Description

Definition at line 52 of file glowbutton.h.


Member Enumeration Documentation

Enumerator:
Run 
Stop 

Definition at line 80 of file glowbutton.h.

{ Run, Stop };

Constructor & Destructor Documentation

Glow::GlowButton::GlowButton ( QWidget *  parent,
const char *  name,
const QString &  tip,
const int  realizeBtns 
)

Definition at line 86 of file glowbutton.cpp.

       : Q3Button(parent, name)
{
       m_realizeButtons = realizeBtns;

       _steps = 0;
       m_updateTime = 50;
       m_pixmapName = QString();

       m_timer = new QTimer(this);
       connect(m_timer, SIGNAL(timeout()), this, SLOT(slotTimeout()));
       m_pos = 0;
       m_timerStatus = Stop;

       setTipText (tip);
       setCursor(arrowCursor);
}

Here is the call graph for this function:

Definition at line 105 of file glowbutton.cpp.

{
}

Member Function Documentation

void Glow::GlowButton::enterEvent ( QEvent *  e) [protected, virtual]

Definition at line 163 of file glowbutton.cpp.

{
       if( m_pos<0 )
              m_pos=-m_pos;
       m_timerStatus = Run;
       if( ! m_timer->isActive() )
              m_timer->start(m_updateTime);
       Q3Button::enterEvent(e);
}

Definition at line 118 of file glowbutton.cpp.

{
       return m_pixmapName;
}
Qt::ButtonState Glow::GlowButton::lastButton ( ) const

Definition at line 123 of file glowbutton.cpp.

{
       return _last_button;
}

Here is the caller graph for this function:

void Glow::GlowButton::leaveEvent ( QEvent *  e) [protected, virtual]

Definition at line 173 of file glowbutton.cpp.

{
       m_timerStatus = Stop;
       if( ! m_timer->isActive() )
              m_timer->start(m_updateTime);
       Q3Button::leaveEvent(e);
}
void Glow::GlowButton::mousePressEvent ( QMouseEvent *  e) [protected, virtual]

Definition at line 181 of file glowbutton.cpp.

{
       _last_button = e->button();
       if( m_timer->isActive() )
              m_timer->stop();
       m_pos = _steps;
       repaint(false);
       // without pretending Qt::LeftButton, clicking on the button with Qt::MidButton
       // or Qt::RightButton would cause unwanted titlebar action
       QMouseEvent me (e->type(), e->pos(), e->globalPos(),
                     (e->button()&m_realizeButtons)?Qt::LeftButton:Qt::NoButton, e->state());
       Q3Button::mousePressEvent(&me);
}
void Glow::GlowButton::mouseReleaseEvent ( QMouseEvent *  e) [protected, virtual]

Definition at line 195 of file glowbutton.cpp.

{
       _last_button = e->button();
       QPoint p = mapToParent(mapFromGlobal(e->globalPos()));
       if( ! m_timer->isActive() ) {
              m_timer->start(m_updateTime);
       }
       if( ! geometry().contains(p) ) {
              m_timerStatus = Stop;
       }
       QMouseEvent me (e->type(), e->pos(), e->globalPos(),
                     (e->button()&m_realizeButtons)?Qt::LeftButton:Qt::NoButton, e->state());
       Q3Button::mouseReleaseEvent(&me);
}
void Glow::GlowButton::paintEvent ( QPaintEvent *  e) [protected, virtual]

Definition at line 142 of file glowbutton.cpp.

{
       QWidget::paintEvent(e);
       const QPixmap *pixmap = PixmapCache::find(m_pixmapName);
       if( pixmap != 0 )
       {
              int pos = m_pos>=0?m_pos:-m_pos;
              QPainter p;
              QPixmap pm (pixmap->size());
              p.begin(&pm);
              const QPixmap * bg_pixmap = PixmapCache::find(
                            QString::number(parentWidget()->winId()));
              p.drawPixmap (0, 0, *bg_pixmap, x(), y(), width(), height());
              p.drawPixmap (0, 0, *pixmap, 0, pos*height(), width(), height());
              p.end();
              p.begin(this);
              p.drawPixmap (0, 0, pm);
              p.end();
       }
}

Here is the call graph for this function:

void Glow::GlowButton::setPixmapName ( const QString &  pixmapName)

Sets the name of the pixmap in the pixmap cache.

If no background pixmap is wanted use QString() as name.

Definition at line 128 of file glowbutton.cpp.

{
       m_pixmapName = pixmapName;

       const QPixmap *pixmap = PixmapCache::find(pixmapName);
       if( ! pixmap )
              return;

       // set steps
       _steps = pixmap->height()/pixmap->width() - 1;

       repaint(false);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Glow::GlowButton::setTipText ( const QString &  tip)

Definition at line 109 of file glowbutton.cpp.

{
       if (KDecoration::options()->showTooltips())
       {
           QToolTip::remove( this );
           this->setToolTip( tip );
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Glow::GlowButton::slotTimeout ( ) [protected, slot]

Definition at line 210 of file glowbutton.cpp.

{
       repaint(false);

       if( m_pos>=_steps-1 ) {
              m_pos = -m_pos;
       }
       if( m_timerStatus==Stop ) {
              if( m_pos==0 ) {
                     m_timer->stop();
                     return;
              } else if( m_pos>0 ) {
                     m_pos = -m_pos;
              }
       }

       m_pos++;
}

Here is the caller graph for this function:


Member Data Documentation

ButtonState Glow::GlowButton::_last_button [private]

Definition at line 91 of file glowbutton.h.

int Glow::GlowButton::_steps [private]

Definition at line 83 of file glowbutton.h.

QString Glow::GlowButton::m_pixmapName [private]

Definition at line 84 of file glowbutton.h.

int Glow::GlowButton::m_pos [private]

Definition at line 87 of file glowbutton.h.

Definition at line 90 of file glowbutton.h.

QTimer* Glow::GlowButton::m_timer [private]

Definition at line 86 of file glowbutton.h.

Definition at line 88 of file glowbutton.h.

Definition at line 82 of file glowbutton.h.


The documentation for this class was generated from the following files: