Source Code (Use browser search to find items of interest.)
Class Index
kmix'QceStateLED (./kdemultimedia/kmix/QceStateLED.h:36)
class QceStateLED : public QFrame
{
Q_OBJECT
public:
/**
* Construct a QceStateLED widget
*/
QceStateLED(QWidget *parent=0);
/**
* Possible states of a QceStateLED
*/
enum State { On, Off };
/**
* Retrieve the state of the QceStateLED
*/
State state() const { return s; }
/**
* Set the state of the QceStateLED
*/
void setState(State state) { s= state; repaint(FALSE); }
void setColor(QColor);
/**
* Toggle the state of the QceStateLED
*/
void toggleState() { if (s == On) s= Off; else if (s == Off) s= On; repaint(FALSE); }
public slots:
void toggle() { toggleState(); };
void on() { setState(On); };
void off() { setState(Off); };
protected:
void drawContents(QPainter *);
private:
const int dx;
State s;
QColor i_QColor_base;
};
kmix'QceStateLED::QceStateLED() (./kdemultimedia/kmix/QceStateLED.cpp:30)
QceStateLED::QceStateLED(QWidget *parent) : QFrame(parent), dx( 4 )
{
// Make sure we're in a sane state
s= Off;
// Set the frame style
setFrameStyle(Sunken | Box);
setGeometry(0,0,28,7);
}
kmix'QceStateLED::setColor() (./kdemultimedia/kmix/QceStateLED.cpp:40)
void QceStateLED::setColor(QColor val_QColor_state)
{
// Set new color internally and post a redraw request
i_QColor_base = val_QColor_state;
update();
}
kmix'QceStateLED::drawContents() (./kdemultimedia/kmix/QceStateLED.cpp:47)
void QceStateLED::drawContents(QPainter *painter)
{
QBrush lightBrush(i_QColor_base);
QBrush darkBrush(QColor(60,60,0));
QPen pen(QColor(40,40,0));
switch(s) {
case On:
painter->setBrush(i_QColor_base);
painter->drawRect(1,1,QFrame::width()-2, QFrame::height()-2);
break;
case Off:
painter->setBrush(i_QColor_base.dark(300));
painter->drawRect(1,1,QFrame::width()-2, QFrame::height()-2);
painter->setPen(i_QColor_base.dark(400));
painter->drawLine(2,2,QFrame::width()-2, 2);
painter->drawLine(2,QFrame::height()-2,QFrame::width()-2,QFrame::height()-2);
// Draw verticals
int i;
for (i= 2; i < QFrame::width()-1; i+= dx)
painter->drawLine(i,2,i,QFrame::height()-2);
break;
}
}