Back to index

kdeartwork  4.3.2
glowbutton.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                           glowbutton.h  -  description
00003                              -------------------
00004     begin                : Thu Sep 14 2001
00005     copyright            : (C) 2001 by Henning Burchardt
00006     email                : h_burchardt@gmx.net
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef GLOW_BUTTON_H
00019 #define GLOW_BUTTON_H
00020 
00021 #include <vector>
00022 #include <qmap.h>
00023 #include <q3button.h>
00024 //Added by qt3to4:
00025 #include <QPixmap>
00026 #include <QMouseEvent>
00027 #include <QEvent>
00028 #include <QPaintEvent>
00029 
00030 class QPixmap;
00031 class QBitmap;
00032 class QTimer;
00033 class QString;
00034 
00035 namespace Glow
00036 {
00037 
00038 class PixmapCache
00039 {
00040 public:
00041        static const QPixmap* find(const QString& key);
00042        static void insert(const QString& key, const QPixmap *pixmap);
00043        static void erase(const QString& key);
00044        static void clear();
00045 private:
00046        static QMap<QString, const QPixmap*> m_pixmapMap;
00047 };
00048 
00049 
00050 //-----------------------------------------------------------------------------
00051 
00052 class GlowButton : public Q3Button
00053 {
00054        Q_OBJECT
00055 
00056 public:
00057        GlowButton(QWidget *parent, const char* name, const QString& tip, const int realizeBtns);
00058        ~GlowButton();
00059 
00060        void setTipText( const QString& tip );
00061 
00062        QString getPixmapName() const;
00063        ButtonState lastButton() const;
00064 
00067        void setPixmapName(const QString& pixmapName);
00068 
00069 protected:
00070        virtual void paintEvent( QPaintEvent * );
00071        virtual void enterEvent( QEvent * );
00072        virtual void leaveEvent( QEvent * );
00073        virtual void mousePressEvent( QMouseEvent * );
00074        virtual void mouseReleaseEvent( QMouseEvent * );
00075 
00076 protected slots:
00077        void slotTimeout();
00078 
00079 private:
00080        enum TimerStatus { Run, Stop };
00081 
00082        int m_updateTime;
00083        int _steps;
00084        QString m_pixmapName;
00085 
00086        QTimer *m_timer;
00087        int m_pos;
00088        TimerStatus m_timerStatus;
00089 
00090        int m_realizeButtons;
00091        ButtonState _last_button;
00092 };
00093 
00094 //-----------------------------------------------------------------------------
00095 
00096 class GlowButtonFactory
00097 {
00098 public:
00099        GlowButtonFactory();
00100 
00101        int getSteps();
00102 
00107        void setSteps(int steps);
00108 
00116        QPixmap * createGlowButtonPixmap(
00117                             const QImage & bg_image,
00118 //                          const QImage & bg_alpha_image,
00119                             const QImage & fg_image,
00120                             const QImage & glow_image,
00121                             const QColor & color,
00122                             const QColor & glow_color);
00123 
00124        GlowButton* createGlowButton(
00125               QWidget *parent, const char* name, const QString& tip, const int realizeBtns = Qt::LeftButton);
00126 
00127 private:
00128        int _steps;
00129 };
00130 
00131 } // namespace
00132 
00133 #endif