00001 /*************************************************************************** 00002 colorbutton.h - description 00003 ------------------- 00004 begin : Tue Apr 1 2003 00005 copyright : (C) 2003-2006 by Ben Swerts 00006 email : bswerts@users.sourceforge.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 00020 00021 #ifndef COLORBUTTON_H 00022 #define COLORBUTTON_H 00023 00025 00026 // Qt forward class declarations 00027 class QColor; 00028 00029 // Base class header file 00030 #include <qpushbutton.h> 00031 00033 class ColorButton : public QPushButton 00034 { 00035 Q_OBJECT 00036 00037 public: 00038 ColorButton(QWidget* parent = 0, const char* name = 0); // constructor 00039 ColorButton(const QColor& color, QWidget* parent = 0, const char* name = 0);// constructor (overloaded) 00040 ~ColorButton(); // destructor 00041 00042 QColor color() const; // returns the color of the button 00043 void setColor(const QColor color); // sets a new color for the button 00044 00045 signals: 00046 void resized(); // emitted when the button has been resized 00047 void newColor(QColor* color); // emitted when the color has been changed 00048 00049 protected: 00050 virtual void resizeEvent(QResizeEvent* e); // occurs when the button is resized 00051 00052 private slots: 00053 void selectColor(); // selects a new color for the button 00054 void updatePixmap(); // updates the pixmap of the button with a new size and color 00055 00056 private: 00057 QColor fillColor; 00058 QPixmap* pixmap; 00059 00060 }; 00061 00062 #endif 00063