Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef QTXCOLORBUTTON_H
00024 #define QTXCOLORBUTTON_H
00025
00026 #include "Qtx.h"
00027
00028 #include <QMap>
00029 #include <QColor>
00030 #include <QPixmap>
00031 #include <QToolButton>
00032
00033 class QPaintDevice;
00034
00035 class QTX_EXPORT QtxColorButton : public QToolButton
00036 {
00037 Q_OBJECT
00038
00039 public:
00040 QtxColorButton( QWidget* = 0 );
00041 virtual ~QtxColorButton();
00042
00043 QColor color() const;
00044 void setColor( const QColor& );
00045
00046 bool eventFilter( QObject*, QEvent* );
00047
00048 bool isAutoEnabled() const;
00049 void setAutoEnabled( bool );
00050
00051 QString autoText() const;
00052 void setAutoText( const QString& );
00053
00054 signals:
00055 void clicked( QColor );
00056 void changed( QColor );
00057
00058 private slots:
00059 void onClicked( bool );
00060 void onToggled( bool );
00061
00062 void onAboutToShow();
00063 void onAutoClicked( bool );
00064 void onDialogClicked( bool );
00065
00066 protected:
00067 virtual void paintEvent( QPaintEvent* );
00068
00069 private:
00070 QList<QColor> colorsList() const;
00071
00072 void updateState();
00073 void updateButton( QToolButton* );
00074 QPixmap buttonIcon( const QColor& ) const;
00075 void drawColor( QPaintDevice*, const QColor&, const int = 1 ) const;
00076
00077 private:
00078 typedef QMap<const QToolButton*, QColor> ColorMap;
00079
00080 private:
00081 ColorMap myColors;
00082 QToolButton* myAutoButton;
00083 };
00084
00085 #endif