Public Slots | Signals | Public Member Functions | Protected Member Functions

ColorPickerItem Class Reference

Inheritance diagram for ColorPickerItem:
Inheritance graph
[legend]
Collaboration diagram for ColorPickerItem:
Collaboration graph
[legend]

List of all members.

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)

Constructor & Destructor Documentation

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.

{
}


Member Function Documentation

void ColorPickerItem::clicked (  )  [signal]
QColor ColorPickerItem::color (  )  const

Returns the item's color.

See also:
text()

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().

void ColorPickerItem::setColor ( const QColor color,
const QString text = QString() 
) [slot]

Sets the item's color to color, and its name to text.

{
    c = color;
    t = text;
    setToolTip(t);
    update();
}

void ColorPickerItem::setSelected ( bool  selected  ) 
QString ColorPickerItem::text (  )  const

Returns the item's text.

See also:
color()

Referenced by QtColorPicker::setCurrentColor().

{
    return t;
}


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