tdeui
kdualcolorbutton.h
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 TQBitmap;
00022 #include <tqbrush.h>
00023 #include <tqwidget.h>
00024
00025 #include <tdelibs_export.h>
00026
00048 class TDEUI_EXPORT KDualColorButton : public TQWidget
00049 {
00050 Q_OBJECT
00051 TQ_ENUMS( DualColor )
00052 TQ_PROPERTY( TQColor foreground READ foreground WRITE setForeground )
00053 TQ_PROPERTY( TQColor background READ background WRITE setBackground )
00054 TQ_PROPERTY( TQColor currentColor READ currentColor WRITE setCurrentColor STORED false DESIGNABLE false )
00055 TQ_PROPERTY( DualColor current READ current WRITE setCurrent )
00056
00057 public:
00058
00059 enum DualColor { Foreground, Background };
00067 KDualColorButton(TQWidget *parent=0, const char *name=0, TQWidget* dialogParent=0);
00068
00073 KDualColorButton(const TQColor &fgColor, const TQColor &bgColor,
00074 TQWidget *parent=0, const char *name=0, TQWidget* dialogParent=0);
00075
00076 ~KDualColorButton();
00080 TQColor foreground() const;
00084 TQColor background() const;
00088 DualColor current() const;
00092 TQColor currentColor() const;
00097 virtual TQSize sizeHint() const;
00098 public slots:
00102 void setForeground(const TQColor &c);
00106 void setBackground(const TQColor &c);
00110 void setCurrent(DualColor s);
00114 void setCurrentColor(const TQColor &c);
00115 signals:
00119 void fgChanged(const TQColor &c);
00123 void bgChanged(const TQColor &c);
00127 void currentChanged(KDualColorButton::DualColor s);
00128 protected:
00136 virtual void metrics(TQRect &fgRect, TQRect &bgRect);
00137 virtual void paintEvent(TQPaintEvent *ev);
00138 virtual void mousePressEvent(TQMouseEvent *ev);
00139 virtual void mouseMoveEvent(TQMouseEvent *ev);
00140 virtual void mouseReleaseEvent(TQMouseEvent *ev);
00141
00142 virtual void dragEnterEvent(TQDragEnterEvent *ev);
00143 virtual void dropEvent(TQDropEvent *ev);
00144 private:
00145 TQBitmap *arrowBitmap;
00146 TQPixmap *resetPixmap;
00147 TQBrush fg, bg;
00148 TQPoint 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