keduca
kradioeduca.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 "kradioeduca.h"
00019 #include "kradioeduca.moc"
00020 #include <qstyle.h>
00021 #include <kaccelmanager.h>
00022
00023 KRadioEduca::KRadioEduca(QWidget *parent, const char *name) : QRadioButton(parent,name)
00024 {
00025 _doc=0;
00026 KAcceleratorManager::setNoAccel(this);
00027 }
00028
00029 KRadioEduca::~KRadioEduca()
00030 {
00031 delete _doc;
00032 }
00033
00035 void KRadioEduca::drawButtonLabel( QPainter *p)
00036 {
00037 int x, y, w, h;
00038 int extra_width, indicator_width;
00039 extra_width = 8;
00040 indicator_width = style().pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, 0);
00041
00042 y = 0;
00043 x = indicator_width + extra_width;
00044 w = width() - x;
00045 h = height();
00046
00047 QRect cr(x,y,w,h);
00048
00049 _doc = new QSimpleRichText( text(), font() );
00050 _doc->setWidth( 10 );
00051
00052 _doc->setWidth(p, cr.width() );
00053 int rw = _doc->widthUsed() + extra_width;
00054 int rh = _doc->height();
00055 int xo = 0;
00056 int yo = 0;
00057
00058 resize( width(), rh);
00059
00060 yo = (cr.height()-rh)/2;
00061
00062 if (!isEnabled() ) {
00063 QColorGroup cg = colorGroup();
00064 cg.setColor( QColorGroup::Text, cg.light() );
00065 _doc->draw(p, cr.x()+xo+1, cr.y()+yo+1, cr, cg, 0);
00066 }
00067 _doc->draw(p, cr.x()+xo, cr.y()+yo, cr, colorGroup(), 0);
00068
00069 if ( hasFocus() ) {
00070
00071
00072
00073
00074 QRect br(x,y,rw,rh+yo);
00075
00076 br.setLeft( br.left()-3 );
00077 br.setRight( br.right()+2 );
00078 br.setTop( br.top()-2 );
00079 br.setBottom( br.bottom()+2);
00080 br = br.intersect( QRect(0,0,rw, rh+yo ) );
00081 style().drawPrimitive( QStyle::PE_FocusRect, p, br, colorGroup());
00082 }
00083 }