kdualcolorbutton.h
/* This file is part of the KDE libraries
Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __KDUALCOLORBTN_H
#define __KDUALCOLORBTN_H
class QBitmap;
#include <qbrush.h>
#include <qwidget.h>
#include <kdelibs_export.h>
class KDEUI_EXPORT KDualColorButton : public QWidget
{
Q_OBJECT
Q_ENUMS( DualColor )
Q_PROPERTY( QColor foreground READ foreground WRITE setForeground )
Q_PROPERTY( QColor background READ background WRITE setBackground )
Q_PROPERTY( QColor currentColor READ currentColor WRITE setCurrentColor STORED false DESIGNABLE false )
Q_PROPERTY( DualColor current READ current WRITE setCurrent )
public:
enum DualColor { Foreground, Background };
KDualColorButton(QWidget *parent=0, const char *name=0, QWidget* dialogParent=0);
KDualColorButton(const QColor &fgColor, const QColor &bgColor,
QWidget *parent=0, const char *name=0, QWidget* dialogParent=0);
~KDualColorButton();
QColor foreground() const;
QColor background() const;
DualColor current() const;
QColor currentColor() const;
virtual QSize sizeHint() const;
public slots:
void setForeground(const QColor &c);
void setBackground(const QColor &c);
void setCurrent(DualColor s);
void setCurrentColor(const QColor &c);
signals:
void fgChanged(const QColor &c);
void bgChanged(const QColor &c);
void currentChanged(KDualColorButton::DualColor s);
protected:
virtual void metrics(QRect &fgRect, QRect &bgRect);
virtual void paintEvent(QPaintEvent *ev);
virtual void mousePressEvent(QMouseEvent *ev);
virtual void mouseMoveEvent(QMouseEvent *ev);
virtual void mouseReleaseEvent(QMouseEvent *ev);
// Dnd
virtual void dragEnterEvent(QDragEnterEvent *ev);
virtual void dropEvent(QDropEvent *ev);
private:
QBitmap *arrowBitmap;
QPixmap *resetPixmap;
QBrush fg, bg;
QPoint mPos;
bool dragFlag, miniCtlFlag;
DualColor curColor, tmpColor;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KDualColorPrivate;
KDualColorPrivate *d;
};
#endif
KDualColorButton
A widget for selecting two related colors.
Definition: kdualcolorbutton.h:48

KDE Home | KDE Accessibility Home | Description of Access Keys