kdualcolorbutton.h
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 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 // Dnd 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