- 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) const QString& tip, QPixmap *pixmap)
: KWinWidgetButton(parent, name, 0, tip), m_pixmap(pixmap) : KWinWidgetButton(parent, name, 0, tip), m_pixmap(pixmap)
{ {
m_steps = 20; m_steps = 0;
m_updateTime = 50; m_updateTime = 50;
m_timer = new QTimer(); m_timer = new QTimer();
@ -52,10 +52,16 @@ QPixmap *GlowButton::getPixmap()
void GlowButton::setPixmap(QPixmap *pixmap) void GlowButton::setPixmap(QPixmap *pixmap)
{ {
m_pixmap = pixmap; m_pixmap = pixmap;
// set mask
QBitmap mask(width(), height()); QBitmap mask(width(), height());
mask.fill(Qt::color0); mask.fill(Qt::color0);
bitBlt(&mask, 0, 0, pixmap->mask(), 0, 0, width(), height()); bitBlt(&mask, 0, 0, pixmap->mask(), 0, 0, width(), height());
setMask(mask); setMask(mask);
// set steps
m_steps = pixmap->height()/pixmap->width() - 1;
repaint(false); repaint(false);
} }
@ -139,9 +145,16 @@ void GlowButton::slotTimeout()
GlowButtonFactory::GlowButtonFactory() GlowButtonFactory::GlowButtonFactory()
{ {
m_steps = 20; 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( QPixmap* GlowButtonFactory::createGlowButtonPixmap(
@ -227,8 +240,6 @@ GlowButton* GlowButtonFactory::createGlowButton(
{ {
GlowButton *glowButton = new GlowButton( GlowButton *glowButton = new GlowButton(
parent, name, tip, pixmap); parent, name, tip, pixmap);
glowButton->m_steps = m_steps;
glowButton->m_updateTime = m_updateTime;
return glowButton; return glowButton;
} }
@ -331,3 +342,4 @@ QBitmap DrawUtils::drawSimpleRoundButtonMask( const QSize& size )
} }
#include "glowbutton.moc" #include "glowbutton.moc"

View file

@ -18,6 +18,7 @@
#ifndef GLOW_BUTTON_H #ifndef GLOW_BUTTON_H
#define GLOW_BUTTON_H #define GLOW_BUTTON_H
#include <vector>
#include <kwin/kwinbutton.h> #include <kwin/kwinbutton.h>
class QPixmap; class QPixmap;
@ -27,24 +28,27 @@ class QTimer;
namespace KWinInternal namespace KWinInternal
{ {
class GlowButtonFactory;
class GlowButton : public KWinWidgetButton class GlowButton : public KWinWidgetButton
{ {
Q_OBJECT Q_OBJECT
friend class GlowButtonFactory;
public: public:
GlowButton(QWidget *parent, const char* name,
const QString& tip, QPixmap *bgPixmap=0);
~GlowButton(); ~GlowButton();
QPixmap *getPixmap(); 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); void setPixmap(QPixmap* pixmap);
protected: protected:
GlowButton(QWidget *parent, const char* name,
const QString& tip, QPixmap *bgPixmap=0);
virtual void paintEvent( QPaintEvent * ); virtual void paintEvent( QPaintEvent * );
virtual void enterEvent( QEvent * ); virtual void enterEvent( QEvent * );
virtual void leaveEvent( QEvent * ); virtual void leaveEvent( QEvent * );
@ -66,8 +70,6 @@ private:
TimerStatus m_timerStatus; TimerStatus m_timerStatus;
signals: signals:
// void pressed();
// void released();
void clicked(); void clicked();
void clicked(int button); void clicked(int button);
}; };
@ -79,6 +81,14 @@ class GlowButtonFactory
public: public:
GlowButtonFactory(); GlowButtonFactory();
int getSteps();
/**
* Sets the number of pixmaps used to create the glow effect of the
* glow buttons.
*/
void setSteps(int steps);
QPixmap* createGlowButtonPixmap( QPixmap* createGlowButtonPixmap(
const QSize& size, const QColor& glowColor, const QSize& size, const QColor& glowColor,
const QColorGroup& colorGroup, const QPixmap& fgPixmap ); const QColorGroup& colorGroup, const QPixmap& fgPixmap );
@ -91,8 +101,6 @@ public:
private: private:
int m_steps; int m_steps;
float m_glowFactor;
int m_updateTime;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------