kdeui Library API Documentation

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., 59 Temple Place - Suite 330,
00016    Boston, MA 02111-1307, USA.
00017 */
00018 #ifndef __KDUALCOLORBTN_H
00019 #define __KDUALCOLORBTN_H
00020 
00021 class QBitmap;
00022 #include <qbrush.h>
00023 #include <qwidget.h>
00024 
00043 class KDualColorButton : public QWidget
00044 {
00045     Q_OBJECT
00046     Q_ENUMS( DualColor )
00047     Q_PROPERTY( QColor foreground READ foreground WRITE setForeground )
00048     Q_PROPERTY( QColor background READ background WRITE setBackground )
00049     Q_PROPERTY( QColor currentColor READ currentColor WRITE setCurrentColor STORED false DESIGNABLE false )
00050     Q_PROPERTY( DualColor current READ current WRITE setCurrent )
00051 
00052 public:
00053     
00054     enum DualColor { Foreground, Background };
00060     KDualColorButton(QWidget *parent=0, const char *name=0, QWidget* dialogParent=0);
00061 
00066     KDualColorButton(const QColor &fgColor, const QColor &bgColor,
00067                      QWidget *parent=0, const char *name=0, QWidget* dialogParent=0);
00068 
00069     ~KDualColorButton();
00073     QColor foreground() const;
00077     QColor background() const;
00081     DualColor current() const;
00085     QColor currentColor() const;
00090     virtual QSize sizeHint() const;
00091 public slots:
00095     void setForeground(const QColor &c);
00099     void setBackground(const QColor &c);
00103     void setCurrent(DualColor s);
00107     void setCurrentColor(const QColor &c);
00108 signals:
00112     void fgChanged(const QColor &c);
00116     void bgChanged(const QColor &c);
00120     void currentChanged(KDualColorButton::DualColor s);
00121 protected:
00129     virtual void metrics(QRect &fgRect, QRect &bgRect);
00130     virtual void paintEvent(QPaintEvent *ev);
00131     virtual void mousePressEvent(QMouseEvent *ev);
00132     virtual void mouseMoveEvent(QMouseEvent *ev);
00133     virtual void mouseReleaseEvent(QMouseEvent *ev);
00134     // Dnd
00135     virtual void dragEnterEvent(QDragEnterEvent *ev);
00136     virtual void dropEvent(QDropEvent *ev);
00137 private:
00138     QBitmap *arrowBitmap;
00139     QPixmap *resetPixmap;
00140     QBrush fg, bg;
00141     QPoint mPos;
00142     bool dragFlag, miniCtlFlag;
00143     DualColor curColor, tmpColor;
00144 
00145 protected:
00146     virtual void virtual_hook( int id, void* data );
00147 private:
00148     class KDualColorPrivate;
00149     KDualColorPrivate *d;
00150 };
00151 
00152 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:56:42 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001