- you can now set in GlowButtonFactory (with 'setSteps') how many pixmaps are

used to create the glow effect

svn path=/trunk/kdebase/kwin/; revision=114494
This commit is contained in:
Henning Burchardt 2001-09-17 00:06:34 +00:00
parent b5c7e843fe
commit 5b3e00c28a
2 changed files with 38 additions and 18 deletions

View file

@ -31,7 +31,7 @@ GlowButton::GlowButton(QWidget *parent, const char *name,
const QString& tip, QPixmap *pixmap)
: KWinWidgetButton(parent, name, 0, tip), m_pixmap(pixmap)
{
m_steps = 20;
m_steps = 0;
m_updateTime = 50;
m_timer = new QTimer();
@ -52,10 +52,16 @@ QPixmap *GlowButton::getPixmap()
void GlowButton::setPixmap(QPixmap *pixmap)
{
m_pixmap = pixmap;
// set mask
QBitmap mask(width(), height());
mask.fill(Qt::color0);
bitBlt(&mask, 0, 0, pixmap->mask(), 0, 0, width(), height());
setMask(mask);
// set steps
m_steps = pixmap->height()/pixmap->width() - 1;
repaint(false);
}
@ -139,9 +145,16 @@ void GlowButton::slotTimeout()
GlowButtonFactory::GlowButtonFactory()
{
m_steps = 20;
// cerr << "GlowButtonFactory " << "GlowButtonFactory " << m_steps << endl;
m_glowFactor = 1.0;
m_updateTime = 50;
}
int GlowButtonFactory::getSteps()
{
return m_steps;
}
void GlowButtonFactory::setSteps(int steps)
{
m_steps = steps;
}
QPixmap* GlowButtonFactory::createGlowButtonPixmap(
@ -227,8 +240,6 @@ GlowButton* GlowButtonFactory::createGlowButton(
{
GlowButton *glowButton = new GlowButton(
parent, name, tip, pixmap);
glowButton->m_steps = m_steps;
glowButton->m_updateTime = m_updateTime;
return glowButton;
}
@ -330,4 +341,5 @@ QBitmap DrawUtils::drawSimpleRoundButtonMask( const QSize& size )
return mask;
}
#include "glowbutton.moc"
#include "glowbutton.moc"

View file

@ -18,6 +18,7 @@
#ifndef GLOW_BUTTON_H
#define GLOW_BUTTON_H
#include <vector>
#include <kwin/kwinbutton.h>
class QPixmap;
@ -27,24 +28,27 @@ class QTimer;
namespace KWinInternal
{
class GlowButtonFactory;
class GlowButton : public KWinWidgetButton
{
Q_OBJECT
friend class GlowButtonFactory;
public:
GlowButton(QWidget *parent, const char* name,
const QString& tip, QPixmap *bgPixmap=0);
~GlowButton();
QPixmap *getPixmap();
/**
* Sets the background pixmap of the button.
* The pixmap should consist of sub pixmaps of the size of the button which
* are placed one below the other. Each sub pixmap is copied on the button
* in succession to create the glow effect. The last sub pixmap is used
* when the button is pressed.
*/
void setPixmap(QPixmap* pixmap);
protected:
GlowButton(QWidget *parent, const char* name,
const QString& tip, QPixmap *bgPixmap=0);
virtual void paintEvent( QPaintEvent * );
virtual void enterEvent( QEvent * );
virtual void leaveEvent( QEvent * );
@ -66,8 +70,6 @@ private:
TimerStatus m_timerStatus;
signals:
// void pressed();
// void released();
void clicked();
void clicked(int button);
};
@ -79,6 +81,14 @@ class GlowButtonFactory
public:
GlowButtonFactory();
int getSteps();
/**
* Sets the number of pixmaps used to create the glow effect of the
* glow buttons.
*/
void setSteps(int steps);
QPixmap* createGlowButtonPixmap(
const QSize& size, const QColor& glowColor,
const QColorGroup& colorGroup, const QPixmap& fgPixmap );
@ -91,8 +101,6 @@ public:
private:
int m_steps;
float m_glowFactor;
int m_updateTime;
};
//-----------------------------------------------------------------------------
@ -110,4 +118,4 @@ public:
}; // namespace
#endif
#endif