00001 #ifndef QCOLORSELECT_H 00002 #define QCOLORSELECT_H 00003 00004 /**************************************************************************\ 00005 * REQUIRED HEADERS * 00006 \**************************************************************************/ 00007 00008 //QT 00009 #include <QGraphicsView> 00010 #include <QGraphicsScene> 00011 #include <QImage> 00012 #include <QList> 00013 #include <QMutex> 00014 #include <QLinearGradient> 00015 //OWN 00016 #include "Definitions.h" 00017 00018 00019 /**************************************************************************\ 00020 * DEFINITIONS * 00021 \**************************************************************************/ 00022 00023 enum eColorSelectType{ 00024 SELECT_COLOR, SELECT_ALPHA 00025 }; 00026 00027 class CTransferWdt; 00028 class QLinearGradient; 00029 00030 /**************************************************************************\ 00031 * CLASS * 00032 \**************************************************************************/ 00033 class QColorSelect : public QGraphicsView 00034 { 00035 Q_OBJECT 00036 00037 /**************************************************************************\ 00038 * PUBLIC CLASS FUNCTIONS * 00039 \**************************************************************************/ 00040 public: 00041 00042 QColorSelect(eColorSelectType eType, QWidget * parent); 00043 ~QColorSelect(); 00044 00045 //ColorStops 00046 void SetColorStop(float pos,QColor & color); 00047 QGradientStops GetColorStops(); 00048 void ClearColorStops(); 00049 00050 void UpdateGradient(){Changed(QList<QRectF>());} 00051 void GetGradient(QImage & img); 00052 00053 /**************************************************************************\ 00054 * PUBLIC SIGNALS * 00055 \**************************************************************************/ 00056 signals: 00057 00058 void GradientChanged(); 00059 00060 /**************************************************************************\ 00061 * PROTECTED CLASS FUNCTIONS * 00062 \**************************************************************************/ 00063 protected: 00064 00065 void resizeEvent(QResizeEvent *); 00066 void mouseDoubleClickEvent(QMouseEvent *); 00067 void mousePressEvent(QMouseEvent *); 00068 void showEvent(QShowEvent *){Changed(QList<QRectF>());} 00069 00070 /**************************************************************************\ 00071 * PRIVATE CLASS FUNCTIONS * 00072 \**************************************************************************/ 00073 private slots: 00074 00075 void Changed(const QList<QRectF> &); 00076 void Transform(float,float); 00077 00078 /**************************************************************************\ 00079 * PRIVATE CLASS MEMBERS * 00080 \**************************************************************************/ 00081 private: 00082 QGraphicsScene scene; 00083 QRectF rSceneRect; 00084 eColorSelectType type; 00085 //DEBUG 00086 QMutex locker; 00087 QLinearGradient gradient; 00088 00089 QRect transformRect; 00090 00091 }; 00092 00093 #endif // QCOLORSELECT_H