Public Slots | |
void | setColor (const QColor &color, const QString &text=QString()) |
Signals | |
void | clicked () |
void | selected () |
Public Member Functions | |
ColorPickerItem (const QColor &color=Qt::white, const QString &text=QString::null, QWidget *parent=0) | |
~ColorPickerItem () | |
QColor | color () const |
QString | text () const |
void | setSelected (bool) |
bool | isSelected () const |
Protected Member Functions | |
void | mousePressEvent (QMouseEvent *e) |
void | mouseReleaseEvent (QMouseEvent *e) |
void | mouseMoveEvent (QMouseEvent *e) |
void | paintEvent (QPaintEvent *e) |
ColorPickerItem::ColorPickerItem | ( | const QColor & | color = Qt::white , |
|
const QString & | text = QString::null , |
|||
QWidget * | parent = 0 | |||
) |
Constructs a ColorPickerItem whose color is set to color, and whose name is set to text.
: QFrame(parent), c(color), t(text), sel(false) { setToolTip(t); setFixedWidth(24); setFixedHeight(21); }
ColorPickerItem::~ColorPickerItem | ( | ) |
Destructs a ColorPickerItem.
{ }
void ColorPickerItem::clicked | ( | ) | [signal] |
QColor ColorPickerItem::color | ( | ) | const |
Returns the item's color.
Referenced by ColorPickerPopup::keyPressEvent(), and ColorPickerPopup::updateSelected().
{
return c;
}
bool ColorPickerItem::isSelected | ( | ) | const |
{
return sel;
}
void ColorPickerItem::mouseMoveEvent | ( | QMouseEvent * | e | ) | [protected] |
{ setFocus(); update(); }
void ColorPickerItem::mousePressEvent | ( | QMouseEvent * | e | ) | [protected] |
{ setFocus(); update(); }
void ColorPickerItem::mouseReleaseEvent | ( | QMouseEvent * | e | ) | [protected] |
{ sel = true; emit selected(); }
void ColorPickerItem::paintEvent | ( | QPaintEvent * | e | ) | [protected] |
Reimplemented from QFrame.
{ QPainter p(this); int w = width(); // width of cell in pixels int h = height(); // height of cell in pixels p.setPen( QPen( Qt::gray, 0, Qt::SolidLine ) ); if (sel) p.drawRect(1, 1, w - 3, h - 3); p.setPen( QPen( Qt::black, 0, Qt::SolidLine ) ); p.drawRect(3, 3, w - 7, h - 7); p.fillRect(QRect(4, 4, w - 8, h - 8), QBrush(c)); if (hasFocus()) p.drawRect(0, 0, w - 1, h - 1); }
void ColorPickerItem::selected | ( | ) | [signal] |
Referenced by mouseReleaseEvent().
Sets the item's color to color, and its name to text.
{ c = color; t = text; setToolTip(t); update(); }
void ColorPickerItem::setSelected | ( | bool | selected | ) |
Referenced by ColorPickerPopup::insertColor(), ColorPickerPopup::keyPressEvent(), QtColorPicker::setCurrentColor(), and ColorPickerPopup::updateSelected().
{ sel = selected; update(); }
QString ColorPickerItem::text | ( | ) | const |
Returns the item's text.
Referenced by QtColorPicker::setCurrentColor().
{
return t;
}