| # kdeui Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# KColorDialog Class Reference

A color selection dialog. More...

`#include <kcolordialog.h>`

Inheritance diagram for KColorDialog:

[legend]
Collaboration diagram for KColorDialog:

[legend]
List of all members.

## Public Slots
void | setColor (const QColor &col)
## Signals
void | colorSelected (const QColor &col)
## Public Member Functions
| KColorDialog (QWidget *parent=0L, const char *name=0L, bool modal=false)
| ~KColorDialog ()
QColor | color () const
void | setDefaultColor (const QColor &defaultCol)
QColor | defaultColor () const
## Static Public Member Functions
static int | getColor (QColor &theColor, QWidget *parent=0L)
static int | getColor (QColor &theColor, const QColor &defaultColor, QWidget *parent=0L)
static QColor | grabColor (const QPoint &p)
## Protected Member Functions
virtual void | mouseReleaseEvent (QMouseEvent *)
virtual void | keyPressEvent (QKeyEvent *)
virtual bool | eventFilter (QObject *obj, QEvent *ev)
virtual void | virtual_hook (int id, void *data)

## Detailed Description

A color selection dialog.

Features:

- Color selection from a wide range of palettes.
- Color selection from a palette of H vs S and V selectors (similar to windoze).
- Direct input of HSV or RGB values.
- Saving of custom colors

In most cases, you will want to use the static method KColorDialog::getColor(). This pops up the dialog (with an initial selection provided by you), lets the user choose a color, and returns.

Example:

        QColor myColor;
        int result = KColorDialog::getColor( myColor );
             if ( result == KColorDialog::Accepted )
                ...

KDE Color Dialog

The color dialog is really a collection of several widgets which can you can also use separately: the quadratic plane in the top left of the dialog is a KXYSelector. Right next to it is a KHSSelector for choosing hue/saturation.

On the right side of the dialog you see a KPaletteTable showing up to 40 colors with a combo box which offers several predefined palettes or a palette configured by the user. The small field showing the currently selected color is a KColorPatch.

Definition at line 375 of file kcolordialog.h.

## Constructor & Destructor Documentation

KColorDialog::KColorDialog | ( | QWidget * | parent = `0L`,
|  | const char * | name = `0L`,
|  | bool | modal = `false`
| ) |

| Constructs a color selection dialog. Definition at line 915 of file kcolordialog.cpp. References QGridLayout::addLayout(), QGridLayout::addMultiCellWidget(), QGridLayout::addWidget(), KDialogBase::closeClicked(), colorSelected(), KDialogBase::disableResize(), KDialogBase::okClicked(), setColor(), QGridLayout::setColStretch(), KDialogBase::setHelp(), KColor::setHsv(), KDialogBase::setMainWidget(), QWidget::setMinimumSize(), QPushButton::setPixmap(), QPushButton::setText(), QWidget::sizeHint(), and KDialog::spacingHint().

KColorDialog::~KColorDialog | ( |  | ) |

| Destroys the color selection dialog. Definition at line 1155 of file kcolordialog.cpp.

## Member Function Documentation

QColor KColorDialog::color | ( |  | ) | const

| Returns the currently selected color. Definition at line 1262 of file kcolordialog.cpp. Referenced by getColor().

int KColorDialog::getColor | ( | QColor & | theColor,
|  | QWidget * | parent = `0L`
| ) | `[static]`

| Creates a modal color dialog, let the user choose a color, and returns when the dialog is closed. The selected color is returned in the argument `theColor`. Returns: QDialog::result(). Definition at line 1279 of file kcolordialog.cpp. References color(), QDialog::exec(), and setColor().

int KColorDialog::getColor | ( | QColor & | theColor,
|  | const QColor & | defaultColor,
|  | QWidget * | parent = `0L`
| ) | `[static]`

| Creates a modal color dialog, lets the user choose a color, and returns when the dialog is closed. The selected color is returned in the argument `theColor`. This version takes a `defaultColor` argument, which sets the color selected by the "default color" checkbox. When this checkbox is checked, the invalid color (QColor()) is returned into `theColor`. Returns: QDialog::result(). Definition at line 1297 of file kcolordialog.cpp. References color(), QDialog::exec(), setColor(), and setDefaultColor().

QColor KColorDialog::grabColor | ( | const QPoint & | p | ) | `[static]`

| Gets the color from the pixel at point p on the screen. Definition at line 1514 of file kcolordialog.cpp. References QPixmap::convertToImage(), QApplication::desktop(), QPixmap::grabWindow(), QImage::pixel(), QWidget::winId(), QWidget::x(), and QWidget::y().

void KColorDialog::setDefaultColor | ( | const QColor & | defaultCol | ) |

| Call this to make the dialog show a "Default Color" checkbox. If this checkbox is selected, the dialog will return an "invalid" color (QColor()). This can be used to mean "the default text color", for instance, the one with the KDE text color on screen, but black when printing. Definition at line 1184 of file kcolordialog.cpp. References KDialogBase::disableResize(), KDialogBase::mainWidget(), QWidget::setMaximumSize(), and QWidget::setMinimumSize(). Referenced by getColor().

QColor KColorDialog::defaultColor | ( |  | ) | const

| Returns: the value passed to setDefaultColor Definition at line 1214 of file kcolordialog.cpp.

void KColorDialog::setColor | ( | const QColor & | col | ) | `[slot]`

| Preselects a color. Definition at line 1271 of file kcolordialog.cpp. Referenced by getColor(), and KColorDialog().

void KColorDialog::colorSelected | ( | const QColor & | col | ) | `[signal]`

| Emitted when a color is selected. Connect to this to monitor the color as it as selected if you are not running modal. Referenced by KColorDialog().

void KColorDialog::keyPressEvent | ( | QKeyEvent * |  | ) | `[protected, virtual]`

| Maps some keys to the actions buttons. F1 is mapped to the Help button if present and Escape to the Cancel or Close if present. The button action event is animated. Reimplemented from KDialogBase. Definition at line 1523 of file kcolordialog.cpp. References KDialogBase::keyPressEvent().

The documentation for this class was generated from the following files:

- kcolordialog.h
- kcolordialog.cpp

This file is part of the documentation for kdeui Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:20:45 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003