kdeui Library API Documentation

KDualColorButton Class Reference

KDualColorButton allows the user to select two cascaded colors (usually a foreground and background color). A widget for selecting two related colors. More...

#include <kdualcolorbutton.h>

Inheritance diagram for KDualColorButton:

QWidget List of all members.

Public Types

enum  DualColor { Foreground, Background }

Public Slots

void setForeground (const QColor &c)
 Sets the foreground color.

void setBackground (const QColor &c)
 Sets the background color.

void setCurrent (DualColor s)
 Sets the current selected color item.

void setCurrentColor (const QColor &c)
 Sets the color of the selected item.


Signals

void fgChanged (const QColor &c)
 Emitted when the foreground color is changed.

void bgChanged (const QColor &c)
 Emitted when the background color is changed.

void currentChanged (KDualColorButton::DualColor s)
 Emitted when the user changes the current color selection.


Public Member Functions

 KDualColorButton (QWidget *parent=0, const char *name=0, QWidget *dialogParent=0)
 Constructs a new KDualColorButton using the default black and white colors.

 KDualColorButton (const QColor &fgColor, const QColor &bgColor, QWidget *parent=0, const char *name=0, QWidget *dialogParent=0)
 Constructs a new KDualColorButton with the supplied foreground and background colors.

QColor foreground () const
 Returns the current foreground color.

QColor background () const
 Returns the current background color.

DualColor current () const
 Returns the current color item selected by the user.

QColor currentColor () const
 Returns the color of the selected item.

virtual QSize sizeHint () const
 Returns the minimum size needed to display the widget and all its controls.


Protected Member Functions

virtual void metrics (QRect &fgRect, QRect &bgRect)
 Sets the supplied rectangles to the proper size and position for the current widget size.

virtual void paintEvent (QPaintEvent *ev)
virtual void mousePressEvent (QMouseEvent *ev)
virtual void mouseMoveEvent (QMouseEvent *ev)
virtual void mouseReleaseEvent (QMouseEvent *ev)
virtual void dragEnterEvent (QDragEnterEvent *ev)
virtual void dropEvent (QDropEvent *ev)
virtual void virtual_hook (int id, void *data)

Detailed Description

KDualColorButton allows the user to select two cascaded colors (usually a foreground and background color). A widget for selecting two related colors.

Other features include drag and drop from other KDE color widgets, a reset to black and white control, and a swap colors control.

When the user clicks on the foreground or background rectangle the rectangle is first sunken and the currentChanged() signal is emitted. Further clicks will present a color dialog and emit either the fgChanged() or bgChanged() if a new color is selected.

Note: With drag and drop when dropping a color the current selected color will be set, while when dragging a color it will use whatever color rectangle the mouse was pressed inside.

Author:
Daniel M. Duley <mosfet@kde.org>

Definition at line 43 of file kdualcolorbutton.h.


Constructor & Destructor Documentation

KDualColorButton::KDualColorButton QWidget parent = 0,
const char *  name = 0,
QWidget dialogParent = 0
 

Constructs a new KDualColorButton using the default black and white colors.

Definition at line 35 of file kdualcolorbutton.cpp.

References QSize::isValid(), KStdAccel::name(), QWidget::setAcceptDrops(), QWidget::setMinimumSize(), and sizeHint().

KDualColorButton::KDualColorButton const QColor fgColor,
const QColor bgColor,
QWidget parent = 0,
const char *  name = 0,
QWidget dialogParent = 0
 

Constructs a new KDualColorButton with the supplied foreground and background colors.

Definition at line 55 of file kdualcolorbutton.cpp.

References QSize::isValid(), KStdAccel::name(), QWidget::setAcceptDrops(), QWidget::setMinimumSize(), and sizeHint().


Member Function Documentation

QColor KDualColorButton::foreground  )  const
 

Returns the current foreground color.

Definition at line 83 of file kdualcolorbutton.cpp.

References QBrush::color().

QColor KDualColorButton::background  )  const
 

Returns the current background color.

Definition at line 88 of file kdualcolorbutton.cpp.

References QBrush::color().

KDualColorButton::DualColor KDualColorButton::current  )  const
 

Returns the current color item selected by the user.

Definition at line 93 of file kdualcolorbutton.cpp.

QColor KDualColorButton::currentColor  )  const
 

Returns the color of the selected item.

Definition at line 98 of file kdualcolorbutton.cpp.

References QBrush::color().

QSize KDualColorButton::sizeHint  )  const [virtual]
 

Returns the minimum size needed to display the widget and all its controls.

Reimplemented from QWidget.

Definition at line 103 of file kdualcolorbutton.cpp.

Referenced by KDualColorButton().

void KDualColorButton::setForeground const QColor c  )  [slot]
 

Sets the foreground color.

Definition at line 108 of file kdualcolorbutton.cpp.

References QBrush::color(), fgChanged(), and QWidget::repaint().

void KDualColorButton::setBackground const QColor c  )  [slot]
 

Sets the background color.

Definition at line 116 of file kdualcolorbutton.cpp.

References bgChanged(), QBrush::color(), and QWidget::repaint().

void KDualColorButton::setCurrent DualColor  s  )  [slot]
 

Sets the current selected color item.

Definition at line 133 of file kdualcolorbutton.cpp.

References QWidget::repaint().

void KDualColorButton::setCurrentColor const QColor c  )  [slot]
 

Sets the color of the selected item.

Definition at line 124 of file kdualcolorbutton.cpp.

References QWidget::repaint().

void KDualColorButton::fgChanged const QColor c  )  [signal]
 

Emitted when the foreground color is changed.

Referenced by setForeground().

void KDualColorButton::bgChanged const QColor c  )  [signal]
 

Emitted when the background color is changed.

Referenced by setBackground().

void KDualColorButton::currentChanged KDualColorButton::DualColor  s  )  [signal]
 

Emitted when the user changes the current color selection.

void KDualColorButton::metrics QRect fgRect,
QRect bgRect
[protected, virtual]
 

Sets the supplied rectangles to the proper size and position for the current widget size.

You can reimplement this to change the layout of the widget. Restrictions are that the swap control will always be at the top right, the reset control will always be at the bottom left, and you must leave at least a 14x14 space in those corners.

Definition at line 139 of file kdualcolorbutton.cpp.

References QWidget::height(), and QWidget::width().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 27 22:15:08 2005 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001