keduca
kcheckeduca.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "kcheckeduca.h"
00019 #include "kcheckeduca.moc"
00020
00021 #include <qstyle.h>
00022 #include <kaccelmanager.h>
00023
00024 KCheckEduca::KCheckEduca(QWidget *parent, const char *name ) : QCheckBox(parent,name)
00025 {
00026 _doc = 0;
00027 KAcceleratorManager::setNoAccel( this );
00028 }
00029
00030 KCheckEduca::~KCheckEduca()
00031 {
00032 delete _doc;
00033 }
00034
00036 void KCheckEduca::drawButtonLabel( QPainter *p){
00037 int x, y, w, h;
00038 int extra_width, indicator_width;
00039
00040 extra_width = 8;
00041 indicator_width = style().pixelMetric(QStyle::PM_IndicatorWidth, 0);
00042
00043 y = 0;
00044 x = indicator_width + extra_width;
00045 w = width() - x;
00046 h = height();
00047
00048 QRect cr(x,y,w,h);
00049
00050 _doc = new QSimpleRichText( text(), font() );
00051 _doc->setWidth( 10 );
00052
00053 _doc->setWidth(p, cr.width() );
00054 int rw = _doc->widthUsed() + extra_width;
00055 int rh = _doc->height();
00056 int xo = 0;
00057 int yo = 0;
00058
00059 resize( width(), rh);
00060
00061 yo = (cr.height()-rh)/2;
00062
00063 if ( !isEnabled() ) {
00064 QColorGroup cg = colorGroup();
00065 cg.setColor( QColorGroup::Text, cg.light() );
00066 _doc->draw(p, cr.x()+xo+1, cr.y()+yo+1, cr, cg, 0);
00067 }
00068 _doc->draw(p, cr.x()+xo, cr.y()+yo, cr, colorGroup(), 0);
00069
00070 if ( hasFocus() ) {
00071
00072
00073
00074
00075 QRect br(x,y,rw,rh+yo);
00076
00077 br.setLeft( br.left()-3 );
00078 br.setRight( br.right()+2 );
00079 br.setTop( br.top()-2 );
00080 br.setBottom( br.bottom()+2);
00081 br = br.intersect( QRect(0,0,rw, rh+yo ) );
00082
00083 style().drawPrimitive( QStyle::PE_FocusRect, p, br, colorGroup());
00084 }
00085 }