ocheckitem.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <qpainter.h>
00014
00015 #include "ocheckitem.h"
00016
00024 OCheckItem::OCheckItem( QTable *t, const QString &key )
00025 : QTableItem( t, Never, "" ), m_checked( FALSE ), m_sortKey( key )
00026 {
00027 }
00028
00034 QString OCheckItem::key() const
00035 {
00036 return m_sortKey;
00037 }
00038
00045 void OCheckItem::setChecked( bool b )
00046 {
00047 m_checked = b;
00048 table()->updateCell( row(), col() );
00049 }
00050
00055 void OCheckItem::toggle()
00056 {
00057 m_checked = !m_checked;
00058 }
00059
00065 bool OCheckItem::isChecked() const
00066 {
00067 return m_checked;
00068 }
00069
00074 void OCheckItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr,
00075 bool )
00076 {
00077 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
00078
00079 int marg = ( cr.width() - BoxSize ) / 2;
00080 int x = 0;
00081 int y = ( cr.height() - BoxSize ) / 2;
00082 p->setPen( QPen( cg.text() ) );
00083 p->drawRect( x + marg, y, BoxSize, BoxSize );
00084 p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 );
00085 p->setPen( darkGreen );
00086 x += 1;
00087 y += 1;
00088 if ( m_checked ) {
00089 QPointArray a( 7*2 );
00090 int i, xx, yy;
00091 xx = x+1+marg;
00092 yy = y+2;
00093 for ( i=0; i<3; i++ ) {
00094 a.setPoint( 2*i, xx, yy );
00095 a.setPoint( 2*i+1, xx, yy+2 );
00096 xx++; yy++;
00097 }
00098 yy -= 2;
00099 for ( i=3; i<7; i++ ) {
00100 a.setPoint( 2*i, xx, yy );
00101 a.setPoint( 2*i+1, xx, yy+2 );
00102 xx++; yy--;
00103 }
00104 p->drawLineSegments( a );
00105 }
00106 }
This file is part of the documentation for OPIE Version 1.1.