kdeui
kdualcolorbutton.h
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 #ifndef __KDUALCOLORBTN_H
00019 #define __KDUALCOLORBTN_H
00020
00021 class QBitmap;
00022 #include <qbrush.h>
00023 #include <qwidget.h>
00024
00025 #include <kdelibs_export.h>
00026
00048 class KDEUI_EXPORT KDualColorButton : public QWidget
00049 {
00050 Q_OBJECT
00051 Q_ENUMS( DualColor )
00052 Q_PROPERTY( QColor foreground READ foreground WRITE setForeground )
00053 Q_PROPERTY( QColor background READ background WRITE setBackground )
00054 Q_PROPERTY( QColor currentColor READ currentColor WRITE setCurrentColor STORED false DESIGNABLE false )
00055 Q_PROPERTY( DualColor current READ current WRITE setCurrent )
00056
00057 public:
00058
00059 enum DualColor { Foreground, Background };
00067 KDualColorButton(QWidget *parent=0, const char *name=0, QWidget* dialogParent=0);
00068
00073 KDualColorButton(const QColor &fgColor, const QColor &bgColor,
00074 QWidget *parent=0, const char *name=0, QWidget* dialogParent=0);
00075
00076 ~KDualColorButton();
00080 QColor foreground() const;
00084 QColor background() const;
00088 DualColor current() const;
00092 QColor currentColor() const;
00097 virtual QSize sizeHint() const;
00098 public slots:
00102 void setForeground(const QColor &c);
00106 void setBackground(const QColor &c);
00110 void setCurrent(DualColor s);
00114 void setCurrentColor(const QColor &c);
00115 signals:
00119 void fgChanged(const QColor &c);
00123 void bgChanged(const QColor &c);
00127 void currentChanged(KDualColorButton::DualColor s);
00128 protected:
00136 virtual void metrics(QRect &fgRect, QRect &bgRect);
00137 virtual void paintEvent(QPaintEvent *ev);
00138 virtual void mousePressEvent(QMouseEvent *ev);
00139 virtual void mouseMoveEvent(QMouseEvent *ev);
00140 virtual void mouseReleaseEvent(QMouseEvent *ev);
00141
00142 virtual void dragEnterEvent(QDragEnterEvent *ev);
00143 virtual void dropEvent(QDropEvent *ev);
00144 private:
00145 QBitmap *arrowBitmap;
00146 QPixmap *resetPixmap;
00147 QBrush fg, bg;
00148 QPoint mPos;
00149 bool dragFlag, miniCtlFlag;
00150 DualColor curColor, tmpColor;
00151
00152 protected:
00153 virtual void virtual_hook( int id, void* data );
00154 private:
00155 class KDualColorPrivate;
00156 KDualColorPrivate *d;
00157 };
00158
00159 #endif