1
/****************************************************************************
3
** This file is part of a Qt Solutions component.
5
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
7
** Contact: Qt Software Information (qt-info@nokia.com)
10
** Licensees holding valid Qt Commercial licenses may use this file in
11
** accordance with the Qt Solutions Commercial License Agreement provided
12
** with the Software or, alternatively, in accordance with the terms
13
** contained in a written agreement between you and Nokia.
15
** GNU Lesser General Public License Usage
16
** Alternatively, this file may be used under the terms of the GNU Lesser
17
** General Public License version 2.1 as published by the Free Software
18
** Foundation and appearing in the file LICENSE.LGPL included in the
19
** packaging of this file. Please review the following information to
20
** ensure the GNU Lesser General Public License version 2.1 requirements
21
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23
** In addition, as a special exception, Nokia gives you certain
24
** additional rights. These rights are described in the Nokia Qt LGPL
25
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
28
** GNU General Public License Usage
29
** Alternatively, this file may be used under the terms of the GNU
30
** General Public License version 3.0 as published by the Free Software
31
** Foundation and appearing in the file LICENSE.GPL included in the
32
** packaging of this file. Please review the following information to
33
** ensure the GNU General Public License version 3.0 requirements will be
34
** met: http://www.gnu.org/copyleft/gpl.html.
36
** Please note Third Party Software included with Qt Solutions may impose
37
** additional restrictions and it is the user's responsibility to ensure
38
** that they have met the licensing requirements of the GPL, LGPL, or Qt
39
** Solutions Commercial license and the relevant license of the Third
40
** Party Software they are using.
42
** If you are unsure which license is appropriate for your use, please
43
** contact the sales department at qt-sales@nokia.com.
45
****************************************************************************/
47
#include <QtGui/QApplication>
48
#include <QtGui/QDesktopWidget>
49
#include <QtGui/QPainter>
50
#include <QtGui/QPushButton>
51
#include <QtGui/QColorDialog>
52
#include <QtCore/QMap>
53
#include <QtGui/QLayout>
54
#include <QtGui/QStyle>
55
#include <QtGui/QLabel>
56
#include <QtGui/QToolTip>
57
#include <QtGui/QPixmap>
58
#include <QtGui/QFocusEvent>
59
#include <QtGui/QPaintEvent>
60
#include <QtGui/QGridLayout>
61
#include <QtGui/QHideEvent>
62
#include <QtGui/QKeyEvent>
63
#include <QtGui/QShowEvent>
64
#include <QtGui/QMouseEvent>
67
#include "qtcolorpicker.h"
69
/*! \class QtColorPicker
71
\brief The QtColorPicker class provides a widget for selecting
72
colors from a popup color grid.
74
Users can invoke the color picker by clicking on it, or by
75
navigating to it and pressing Space. They can use the mouse or
76
arrow keys to navigate between colors on the grid, and select a
77
color by clicking or by pressing Enter or Space. The
78
colorChanged() signal is emitted whenever the color picker's color
81
The widget also supports negative selection: Users can click and
82
hold the mouse button on the QtColorPicker widget, then move the
83
mouse over the color grid and release the mouse button over the
84
color they wish to select.
86
The color grid shows a customized selection of colors. An optional
87
ellipsis "..." button (signifying "more") can be added at the
88
bottom of the grid; if the user presses this, a QColorDialog pops
89
up and lets them choose any color they like. This button is made
90
available by using setColorDialogEnabled().
92
When a color is selected, the QtColorPicker widget shows the color
93
and its name. If the name cannot be determined, the translatable
94
name "Custom" is used.
96
The QtColorPicker object is optionally initialized with the number
97
of columns in the color grid. Colors are then added left to right,
98
top to bottom using insertColor(). If the number of columns is not
99
set, QtColorPicker calculates the number of columns and rows that
100
will make the grid as square as possible.
103
DrawWidget::DrawWidget(QWidget *parent, const char *name)
105
QtColorPicker *picker = new QtColorPicker(this);
106
picker->insertColor(red, "Red"));
107
picker->insertColor(QColor("green"), "Green"));
108
picker->insertColor(QColor(0, 0, 255), "Blue"));
109
picker->insertColor(white);
111
connect(colors, SIGNAL(colorChanged(const QColor &)), SLOT(setCurrentColor(const QColor &)));
115
An alternative to adding colors manually is to initialize the grid
116
with QColorDialog's standard colors using setStandardColors().
118
QtColorPicker also provides a the static function getColor(),
119
which pops up the grid of standard colors at any given point.
121
\img colorpicker1.png
122
\img colorpicker2.png
127
/*! \fn QtColorPicker::colorChanged(const QColor &color)
129
This signal is emitted when the QtColorPicker's color is changed.
130
\a color is the new color.
132
To obtain the color's name, use text().
136
A class that acts very much like a QPushButton. It's not styled,
137
so we can expect the exact same look, feel and geometry
138
everywhere. Also, this button always emits clicked on
139
mouseRelease, even if the mouse button was not pressed inside the
142
class ColorPickerButton : public QFrame
147
ColorPickerButton(QWidget *parent);
153
void mousePressEvent(QMouseEvent *e);
154
void mouseMoveEvent(QMouseEvent *e);
155
void mouseReleaseEvent(QMouseEvent *e);
156
void keyPressEvent(QKeyEvent *e);
157
void keyReleaseEvent(QKeyEvent *e);
158
void paintEvent(QPaintEvent *e);
159
void focusInEvent(QFocusEvent *e);
160
void focusOutEvent(QFocusEvent *e);
164
This class represents each "color" or item in the color grid.
166
class ColorPickerItem : public QFrame
171
ColorPickerItem(const QColor &color = Qt::white, const QString &text = QString::null,
172
QWidget *parent = 0);
175
QColor color() const;
176
QString text() const;
178
void setSelected(bool);
179
bool isSelected() const;
185
void setColor(const QColor &color, const QString &text = QString());
188
void mousePressEvent(QMouseEvent *e);
189
void mouseReleaseEvent(QMouseEvent *e);
190
void mouseMoveEvent(QMouseEvent *e);
191
void paintEvent(QPaintEvent *e);
202
class ColorPickerPopup : public QFrame
207
ColorPickerPopup(int width, bool withColorDialog,
208
QWidget *parent = 0);
211
void insertColor(const QColor &col, const QString &text, int index);
216
QColor lastSelected() const;
218
ColorPickerItem *find(const QColor &col) const;
219
QColor color(int index) const;
222
void selected(const QColor &);
226
void getColorFromDialog();
229
void updateSelected();
232
void keyPressEvent(QKeyEvent *e);
233
void showEvent(QShowEvent *e);
234
void hideEvent(QHideEvent *e);
235
void mouseReleaseEvent(QMouseEvent *e);
237
void regenerateGrid();
240
QMap<int, QMap<int, QWidget *> > widgetAt;
241
QList<ColorPickerItem *> items;
243
ColorPickerButton *moreButton;
244
QEventLoop *eventLoop;
252
Constructs a QtColorPicker widget. The popup will display a grid
253
with \a cols columns, or if \a cols is -1, the number of columns
254
will be calculated automatically.
256
If \a enableColorDialog is true, the popup will also have a "More"
257
button (signified by an ellipsis "...") that presents a
258
QColorDialog when clicked.
260
After constructing a QtColorPicker, call insertColor() to add
261
individual colors to the popup grid, or call setStandardColors()
262
to add all the standard colors in one go.
264
The \a parent argument is passed to QFrame's constructor.
268
QtColorPicker::QtColorPicker(QWidget *parent,
269
int cols, bool enableColorDialog)
270
: QPushButton(parent), popup(0), withColorDialog(enableColorDialog)
272
setFocusPolicy(Qt::StrongFocus);
273
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
274
setAutoDefault(false);
275
setAutoFillBackground(true);
279
setText(tr("Black"));
280
firstInserted = false;
282
// Create and set icon
286
// Create color grid popup and connect to it.
287
popup = new ColorPickerPopup(cols, withColorDialog, this);
288
connect(popup, SIGNAL(selected(const QColor &)),
289
SLOT(setCurrentColor(const QColor &)));
290
connect(popup, SIGNAL(hid()), SLOT(popupClosed()));
292
// Connect this push button's pressed() signal.
293
connect(this, SIGNAL(toggled(bool)), SLOT(buttonPressed(bool)));
297
Destructs the QtColorPicker.
299
QtColorPicker::~QtColorPicker()
305
Pops up the color grid, and makes sure the status of
306
QtColorPicker's button is right.
308
void QtColorPicker::buttonPressed(bool toggled)
313
const QRect desktop = QApplication::desktop()->geometry();
314
// Make sure the popup is inside the desktop.
315
QPoint pos = mapToGlobal(rect().bottomLeft());
316
if (pos.x() < desktop.left())
317
pos.setX(desktop.left());
318
if (pos.y() < desktop.top())
319
pos.setY(desktop.top());
321
if ((pos.x() + popup->sizeHint().width()) > desktop.width())
322
pos.setX(desktop.width() - popup->sizeHint().width());
323
if ((pos.y() + popup->sizeHint().height()) > desktop.bottom())
324
pos.setY(desktop.bottom() - popup->sizeHint().height());
327
if (ColorPickerItem *item = popup->find(col))
328
item->setSelected(true);
330
// Remove focus from this widget, preventing the focus rect
331
// from showing when the popup is shown. Order an update to
332
// make sure the focus rect is cleared.
336
// Allow keyboard navigation as soon as the popup shows.
339
// Execute the popup. The popup will enter the event loop.
346
void QtColorPicker::paintEvent(QPaintEvent *e)
349
int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize);
350
QPixmap pix(iconSize, iconSize);
351
pix.fill(palette().button().color());
355
int w = pix.width(); // width of cell in pixels
356
int h = pix.height(); // height of cell in pixels
357
p.setPen(QPen(Qt::gray));
359
p.drawRect(2, 2, w - 5, h - 5);
364
QPushButton::paintEvent(e);
369
Makes sure the button isn't pressed when the popup hides.
371
void QtColorPicker::popupClosed()
378
Returns the currently selected color.
382
QColor QtColorPicker::currentColor() const
388
Returns the color at position \a index.
390
QColor QtColorPicker::color(int index) const
392
return popup->color(index);
396
Adds the 17 predefined colors from the Qt namespace.
398
(The names given to the colors, "Black", "White", "Red", etc., are
403
void QtColorPicker::setStandardColors()
405
insertColor(Qt::black, tr("Black"));
406
insertColor(Qt::white, tr("White"));
407
insertColor(Qt::red, tr("Red"));
408
insertColor(Qt::darkRed, tr("Dark red"));
409
insertColor(Qt::green, tr("Green"));
410
insertColor(Qt::darkGreen, tr("Dark green"));
411
insertColor(Qt::blue, tr("Blue"));
412
insertColor(Qt::darkBlue, tr("Dark blue"));
413
insertColor(Qt::cyan, tr("Cyan"));
414
insertColor(Qt::darkCyan, tr("Dark cyan"));
415
insertColor(Qt::magenta, tr("Magenta"));
416
insertColor(Qt::darkMagenta, tr("Dark magenta"));
417
insertColor(Qt::yellow, tr("Yellow"));
418
insertColor(Qt::darkYellow, tr("Dark yellow"));
419
insertColor(Qt::gray, tr("Gray"));
420
insertColor(Qt::darkGray, tr("Dark gray"));
421
insertColor(Qt::lightGray, tr("Light gray"));
426
Makes \a color current. If \a color is not already in the color grid, it
427
is inserted with the text "Custom".
429
This function emits the colorChanged() signal if the new color is
430
valid, and different from the old one.
432
void QtColorPicker::setCurrentColor(const QColor &color)
434
if (col == color || !color.isValid())
437
ColorPickerItem *item = popup->find(color);
439
insertColor(color, tr("Custom"));
440
item = popup->find(color);
444
setText(item->text());
451
item->setSelected(true);
452
emit colorChanged(color);
456
Adds the color \a color with the name \a text to the color grid,
457
at position \a index. If index is -1, the color is assigned
458
automatically assigned a position, starting from left to right,
461
void QtColorPicker::insertColor(const QColor &color, const QString &text, int index)
463
popup->insertColor(color, text, index);
464
if (!firstInserted) {
467
firstInserted = true;
471
/*! \property QtColorPicker::colorDialog
472
\brief Whether the ellipsis "..." (more) button is available.
474
If this property is set to TRUE, the color grid popup will include
475
a "More" button (signified by an ellipsis, "...") which pops up a
476
QColorDialog when clicked. The user will then be able to select
477
any custom color they like.
479
void QtColorPicker::setColorDialogEnabled(bool enabled)
481
withColorDialog = enabled;
483
bool QtColorPicker::colorDialogEnabled() const
485
return withColorDialog;
489
Pops up a color grid with Qt default colors at \a point, using
490
global coordinates. If \a allowCustomColors is true, there will
491
also be a button on the popup that invokes QColorDialog.
496
void Drawer::mouseReleaseEvent(QMouseEvent *e)
498
if (e->button() & RightButton) {
499
QColor color = QtColorPicker::getColor(mapToGlobal(e->pos()));
504
QColor QtColorPicker::getColor(const QPoint &point, bool allowCustomColors)
506
ColorPickerPopup popup(-1, allowCustomColors);
508
popup.insertColor(Qt::black, tr("Black"), 0);
509
popup.insertColor(Qt::white, tr("White"), 1);
510
popup.insertColor(Qt::red, tr("Red"), 2);
511
popup.insertColor(Qt::darkRed, tr("Dark red"), 3);
512
popup.insertColor(Qt::green, tr("Green"), 4);
513
popup.insertColor(Qt::darkGreen, tr("Dark green"), 5);
514
popup.insertColor(Qt::blue, tr("Blue"), 6);
515
popup.insertColor(Qt::darkBlue, tr("Dark blue"), 7);
516
popup.insertColor(Qt::cyan, tr("Cyan"), 8);
517
popup.insertColor(Qt::darkCyan, tr("Dark cyan"), 9);
518
popup.insertColor(Qt::magenta, tr("Magenta"), 10);
519
popup.insertColor(Qt::darkMagenta, tr("Dark magenta"), 11);
520
popup.insertColor(Qt::yellow, tr("Yellow"), 12);
521
popup.insertColor(Qt::darkYellow, tr("Dark yellow"), 13);
522
popup.insertColor(Qt::gray, tr("Gray"), 14);
523
popup.insertColor(Qt::darkGray, tr("Dark gray"), 15);
524
popup.insertColor(Qt::lightGray, tr("Light gray"), 16);
528
return popup.lastSelected();
533
Constructs the popup widget.
535
ColorPickerPopup::ColorPickerPopup(int width, bool withColorDialog,
537
: QFrame(parent, Qt::Popup)
539
setFrameStyle(QFrame::StyledPanel);
540
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
542
setFocusPolicy(Qt::StrongFocus);
543
setMouseTracking(true);
546
if (withColorDialog) {
547
moreButton = new ColorPickerButton(this);
548
moreButton->setFixedWidth(24);
549
moreButton->setFixedHeight(21);
550
moreButton->setFrameRect(QRect(2, 2, 20, 17));
551
connect(moreButton, SIGNAL(clicked()), SLOT(getColorFromDialog()));
564
Destructs the popup widget.
566
ColorPickerPopup::~ColorPickerPopup()
574
If there is an item whole color is equal to \a col, returns a
575
pointer to this item; otherwise returns 0.
577
ColorPickerItem *ColorPickerPopup::find(const QColor &col) const
579
for (int i = 0; i < items.size(); ++i) {
580
if (items.at(i) && items.at(i)->color() == col)
589
Adds \a item to the grid. The items are added from top-left to
592
void ColorPickerPopup::insertColor(const QColor &col, const QString &text, int index)
594
// Don't add colors that we have already.
595
ColorPickerItem *existingItem = find(col);
596
ColorPickerItem *lastSelectedItem = find(lastSelected());
599
if (lastSelectedItem && existingItem != lastSelectedItem)
600
lastSelectedItem->setSelected(false);
601
existingItem->setFocus();
602
existingItem->setSelected(true);
606
ColorPickerItem *item = new ColorPickerItem(col, text, this);
608
if (lastSelectedItem) {
609
lastSelectedItem->setSelected(false);
612
item->setSelected(true);
617
connect(item, SIGNAL(selected()), SLOT(updateSelected()));
620
index = items.count();
622
items.insert((unsigned int)index, item);
631
QColor ColorPickerPopup::color(int index) const
633
if (index < 0 || index > (int) items.count() - 1)
636
ColorPickerPopup *that = (ColorPickerPopup *)this;
637
return that->items.at(index)->color();
643
void ColorPickerPopup::exec()
656
void ColorPickerPopup::updateSelected()
658
QLayoutItem *layoutItem;
660
while ((layoutItem = grid->itemAt(i)) != 0) {
661
QWidget *w = layoutItem->widget();
662
if (w && w->inherits("ColorPickerItem")) {
663
ColorPickerItem *litem = reinterpret_cast<ColorPickerItem *>(layoutItem->widget());
664
if (litem != sender())
665
litem->setSelected(false);
670
if (sender() && sender()->inherits("ColorPickerItem")) {
671
ColorPickerItem *item = (ColorPickerItem *)sender();
672
lastSel = item->color();
673
emit selected(item->color());
682
void ColorPickerPopup::mouseReleaseEvent(QMouseEvent *e)
684
if (!rect().contains(e->pos()))
690
Controls keyboard navigation and selection on the color grid.
692
void ColorPickerPopup::keyPressEvent(QKeyEvent *e)
697
bool foundFocus = false;
698
for (int j = 0; !foundFocus && j < grid->rowCount(); ++j) {
699
for (int i = 0; !foundFocus && i < grid->columnCount(); ++i) {
700
if (widgetAt[j][i] && widgetAt[j][i]->hasFocus()) {
711
if (curCol > 0) --curCol;
712
else if (curRow > 0) { --curRow; curCol = grid->columnCount() - 1; }
715
if (curCol < grid->columnCount() - 1 && widgetAt[curRow][curCol + 1]) ++curCol;
716
else if (curRow < grid->rowCount() - 1) { ++curRow; curCol = 0; }
719
if (curRow > 0) --curRow;
723
if (curRow < grid->rowCount() - 1) {
724
QWidget *w = widgetAt[curRow + 1][curCol];
727
} else for (int i = 1; i < grid->columnCount(); ++i) {
728
if (!widgetAt[curRow + 1][i]) {
738
case Qt::Key_Enter: {
739
QWidget *w = widgetAt[curRow][curCol];
740
if (w && w->inherits("ColorPickerItem")) {
741
ColorPickerItem *wi = reinterpret_cast<ColorPickerItem *>(w);
742
wi->setSelected(true);
744
QLayoutItem *layoutItem;
746
while ((layoutItem = grid->itemAt(i)) != 0) {
747
QWidget *w = layoutItem->widget();
748
if (w && w->inherits("ColorPickerItem")) {
749
ColorPickerItem *litem
750
= reinterpret_cast<ColorPickerItem *>(layoutItem->widget());
752
litem->setSelected(false);
757
lastSel = wi->color();
758
emit selected(wi->color());
760
} else if (w && w->inherits("QPushButton")) {
761
ColorPickerItem *wi = reinterpret_cast<ColorPickerItem *>(w);
762
wi->setSelected(true);
764
QLayoutItem *layoutItem;
766
while ((layoutItem = grid->itemAt(i)) != 0) {
767
QWidget *w = layoutItem->widget();
768
if (w && w->inherits("ColorPickerItem")) {
769
ColorPickerItem *litem
770
= reinterpret_cast<ColorPickerItem *>(layoutItem->widget());
772
litem->setSelected(false);
777
lastSel = wi->color();
778
emit selected(wi->color());
791
widgetAt[curRow][curCol]->setFocus();
797
void ColorPickerPopup::hideEvent(QHideEvent *e)
806
QFrame::hideEvent(e);
812
QColor ColorPickerPopup::lastSelected() const
819
Sets focus on the popup to enable keyboard navigation. Draws
820
focusRect and selection rect.
822
void ColorPickerPopup::showEvent(QShowEvent *)
824
bool foundSelected = false;
825
for (int i = 0; i < grid->columnCount(); ++i) {
826
for (int j = 0; j < grid->rowCount(); ++j) {
827
QWidget *w = widgetAt[j][i];
828
if (w && w->inherits("ColorPickerItem")) {
829
if (((ColorPickerItem *)w)->isSelected()) {
831
foundSelected = true;
838
if (!foundSelected) {
839
if (items.count() == 0)
842
widgetAt[0][0]->setFocus();
849
void ColorPickerPopup::regenerateGrid()
855
columns = (int) ceil(sqrt((float) items.count()));
857
// When the number of columns grows, the number of rows will
858
// fall. There's no way to shrink a grid, so we create a new
860
if (grid) delete grid;
861
grid = new QGridLayout(this);
865
int ccol = 0, crow = 0;
866
for (int i = 0; i < items.size(); ++i) {
868
widgetAt[crow][ccol] = items.at(i);
869
grid->addWidget(items.at(i), crow, ccol++);
870
if (ccol == columns) {
878
grid->addWidget(moreButton, crow, ccol);
879
widgetAt[crow][ccol] = moreButton;
886
Copies the color dialog's currently selected item and emits
889
void ColorPickerPopup::getColorFromDialog()
892
QRgb rgb = QColorDialog::getRgba(lastSel.rgba(), &ok, parentWidget());
896
QColor col = QColor::fromRgba(rgb);
897
insertColor(col, tr("Custom"), -1);
903
Constructs a ColorPickerItem whose color is set to \a color, and
904
whose name is set to \a text.
906
ColorPickerItem::ColorPickerItem(const QColor &color, const QString &text,
908
: QFrame(parent), c(color), t(text), sel(false)
916
Destructs a ColorPickerItem.
918
ColorPickerItem::~ColorPickerItem()
923
Returns the item's color.
927
QColor ColorPickerItem::color() const
933
Returns the item's text.
937
QString ColorPickerItem::text() const
945
bool ColorPickerItem::isSelected() const
953
void ColorPickerItem::setSelected(bool selected)
960
Sets the item's color to \a color, and its name to \a text.
962
void ColorPickerItem::setColor(const QColor &color, const QString &text)
973
void ColorPickerItem::mouseMoveEvent(QMouseEvent *)
982
void ColorPickerItem::mouseReleaseEvent(QMouseEvent *)
991
void ColorPickerItem::mousePressEvent(QMouseEvent *)
1000
void ColorPickerItem::paintEvent(QPaintEvent *)
1003
int w = width(); // width of cell in pixels
1004
int h = height(); // height of cell in pixels
1006
p.setPen( QPen( Qt::gray, 0, Qt::SolidLine ) );
1009
p.drawRect(1, 1, w - 3, h - 3);
1011
p.setPen( QPen( Qt::black, 0, Qt::SolidLine ) );
1012
p.drawRect(3, 3, w - 7, h - 7);
1013
p.fillRect(QRect(4, 4, w - 8, h - 8), QBrush(c));
1016
p.drawRect(0, 0, w - 1, h - 1);
1022
ColorPickerButton::ColorPickerButton(QWidget *parent)
1025
setFrameStyle(StyledPanel);
1031
void ColorPickerButton::mousePressEvent(QMouseEvent *)
1033
setFrameShadow(Sunken);
1040
void ColorPickerButton::mouseMoveEvent(QMouseEvent *)
1049
void ColorPickerButton::mouseReleaseEvent(QMouseEvent *)
1051
setFrameShadow(Raised);
1059
void ColorPickerButton::keyPressEvent(QKeyEvent *e)
1061
if (e->key() == Qt::Key_Up
1062
|| e->key() == Qt::Key_Down
1063
|| e->key() == Qt::Key_Left
1064
|| e->key() == Qt::Key_Right) {
1065
qApp->sendEvent(parent(), e);
1066
} else if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Space || e->key() == Qt::Key_Return) {
1067
setFrameShadow(Sunken);
1070
QFrame::keyPressEvent(e);
1077
void ColorPickerButton::keyReleaseEvent(QKeyEvent *e)
1079
if (e->key() == Qt::Key_Up
1080
|| e->key() == Qt::Key_Down
1081
|| e->key() == Qt::Key_Left
1082
|| e->key() == Qt::Key_Right) {
1083
qApp->sendEvent(parent(), e);
1084
} else if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Space || e->key() == Qt::Key_Return) {
1085
setFrameShadow(Raised);
1089
QFrame::keyReleaseEvent(e);
1097
void ColorPickerButton::focusInEvent(QFocusEvent *e)
1099
setFrameShadow(Raised);
1101
QFrame::focusOutEvent(e);
1107
void ColorPickerButton::focusOutEvent(QFocusEvent *e)
1109
setFrameShadow(Raised);
1111
QFrame::focusOutEvent(e);
1117
void ColorPickerButton::paintEvent(QPaintEvent *e)
1119
QFrame::paintEvent(e);
1122
p.fillRect(contentsRect(), palette().button());
1126
int offset = frameShadow() == Sunken ? 1 : 0;
1128
QPen pen(palette().buttonText(), 1);
1131
p.drawRect(r.center().x() + offset - 4, r.center().y() + offset, 1, 1);
1132
p.drawRect(r.center().x() + offset , r.center().y() + offset, 1, 1);
1133
p.drawRect(r.center().x() + offset + 4, r.center().y() + offset, 1, 1);
1135
p.setPen( QPen( Qt::black, 0, Qt::SolidLine ) );
1136
p.drawRect(0, 0, width() - 1, height() - 1);
1143
#include "qtcolorpicker.moc"