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
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #ifndef QTCOLORPICKER_H
00048 #define QTCOLORPICKER_H
00049 #include <QtGui/QPushButton>
00050 #include <QtCore/QString>
00051 #include <QtGui/QColor>
00052
00053 #include <QtGui/QLabel>
00054 #include <QtCore/QEvent>
00055 #include <QtGui/QFocusEvent>
00056
00057 #if defined(Q_WS_WIN)
00058 # if !defined(QT_QTCOLORPICKER_EXPORT) && !defined(QT_QTCOLORPICKER_IMPORT)
00059 # define QT_QTCOLORPICKER_EXPORT
00060 # elif defined(QT_QTCOLORPICKER_IMPORT)
00061 # if defined(QT_QTCOLORPICKER_EXPORT)
00062 # undef QT_QTCOLORPICKER_EXPORT
00063 # endif
00064 # define QT_QTCOLORPICKER_EXPORT __declspec(dllimport)
00065 # elif defined(QT_QTCOLORPICKER_EXPORT)
00066 # undef QT_QTCOLORPICKER_EXPORT
00067 # define QT_QTCOLORPICKER_EXPORT __declspec(dllexport)
00068 # endif
00069 #else
00070 # define QT_QTCOLORPICKER_EXPORT
00071 #endif
00072
00073 class ColorPickerPopup;
00074
00075 class QT_QTCOLORPICKER_EXPORT QtColorPicker : public QPushButton
00076 {
00077 Q_OBJECT
00078
00079 Q_PROPERTY(bool colorDialog READ colorDialogEnabled WRITE setColorDialogEnabled)
00080
00081 public:
00082 QtColorPicker(QWidget *parent = 0,
00083 int columns = -1, bool enableColorDialog = true);
00084
00085 ~QtColorPicker();
00086
00087 void insertColor(const QColor &color, const QString &text = QString::null, int index = -1);
00088
00089 QColor currentColor() const;
00090
00091 QColor color(int index) const;
00092
00093 void setColorDialogEnabled(bool enabled);
00094 bool colorDialogEnabled() const;
00095
00096 void setStandardColors();
00097
00098 static QColor getColor(const QPoint &pos, bool allowCustomColors = true);
00099
00100 public Q_SLOTS:
00101 void setCurrentColor(const QColor &col);
00102
00103 Q_SIGNALS:
00104 void colorChanged(const QColor &);
00105
00106 protected:
00107 void paintEvent(QPaintEvent *e);
00108
00109 private Q_SLOTS:
00110 void buttonPressed(bool toggled);
00111 void popupClosed();
00112
00113 private:
00114 ColorPickerPopup *popup;
00115 QColor col;
00116 bool withColorDialog;
00117 bool dirty;
00118 bool firstInserted;
00119 };
00120
00121 #endif