Go to the documentation of this file.00001
00022 #ifndef COLOR_WHEEL_HPP
00023 #define COLOR_WHEEL_HPP
00024
00025 #include <QWidget>
00026
00027 namespace color_widgets {
00028
00035 class ColorWheel : public QWidget
00036 {
00037 Q_OBJECT
00038
00039 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged DESIGNABLE true STORED false )
00040 Q_PROPERTY(qreal hue READ hue WRITE setHue DESIGNABLE false )
00041 Q_PROPERTY(qreal saturation READ saturation WRITE setSaturation DESIGNABLE false )
00042 Q_PROPERTY(qreal value READ value WRITE setValue DESIGNABLE false )
00043 Q_PROPERTY(unsigned wheelWidth READ wheelWidth WRITE setWheelWidth DESIGNABLE true )
00044 Q_PROPERTY(DisplayFlags displayFlags READ displayFlags WRITE setDisplayFlags NOTIFY displayFlagsChanged DESIGNABLE true )
00045
00046 public:
00047 enum DisplayEnum
00048 {
00049 SHAPE_DEFAULT = 0x000,
00050 SHAPE_TRIANGLE = 0x001,
00051 SHAPE_SQUARE = 0x002,
00052 SHAPE_FLAGS = 0x00f,
00053
00054 ANGLE_DEFAULT = 0x000,
00055 ANGLE_FIXED = 0x010,
00056 ANGLE_ROTATING = 0x020,
00057 ANGLE_FLAGS = 0x0f0,
00058
00059 COLOR_DEFAULT = 0x000,
00060 COLOR_HSV = 0x100,
00061 COLOR_HSL = 0x200,
00062 COLOR_LCH = 0x400,
00063 COLOR_FLAGS = 0xf00,
00064
00065 FLAGS_DEFAULT = 0x000,
00066 FLAGS_ALL = 0xfff
00067 };
00068 Q_DECLARE_FLAGS(DisplayFlags, DisplayEnum)
00069 Q_FLAGS(DisplayFlags)
00070
00071 explicit ColorWheel(QWidget *parent = 0);
00072 ~ColorWheel();
00073
00075 QColor color() const;
00076
00077 QSize sizeHint() const Q_DECL_OVERRIDE;
00078
00080 qreal hue() const;
00081
00083 qreal saturation() const;
00084
00086 qreal value() const;
00087
00089 unsigned int wheelWidth() const;
00090
00092 void setWheelWidth(unsigned int w);
00093
00095 DisplayFlags displayFlags(DisplayFlags mask = FLAGS_ALL) const;
00096
00098 static void setDefaultDisplayFlags(DisplayFlags flags);
00099
00101 static DisplayFlags defaultDisplayFlags(DisplayFlags mask = FLAGS_ALL);
00102
00108 void setDisplayFlag(DisplayFlags flag, DisplayFlags mask);
00109
00110 public slots:
00111
00113 void setColor(QColor c);
00114
00118 void setHue(qreal h);
00119
00123 void setSaturation(qreal s);
00124
00128 void setValue(qreal v);
00129
00134 void setDisplayFlags(ColorWheel::DisplayFlags flags);
00135
00136 signals:
00140 void colorChanged(QColor);
00141
00145 void colorSelected(QColor);
00146
00147 void displayFlagsChanged(ColorWheel::DisplayFlags flags);
00148
00149 protected:
00150 void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
00151 void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
00152 void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
00153 void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;
00154 void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
00155 void dragEnterEvent(QDragEnterEvent* event) Q_DECL_OVERRIDE;
00156 void dropEvent(QDropEvent* event) Q_DECL_OVERRIDE;
00157
00158 private:
00159 class Private;
00160 Private * const p;
00161 };
00162
00163 Q_DECLARE_OPERATORS_FOR_FLAGS(ColorWheel::DisplayFlags)
00164
00165 }
00166
00167 #endif // COLOR_WHEEL_HPP