moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / keduca / keduca / kradioeduca.cpp
blob94f26eebd45ca2c0ae317b89ca51c888b10e5e87
1 /***************************************************************************
2 kradioeduca.cpp - description
3 -------------------
4 begin : Wed Sep 6 2000
5 copyright : (C) 2000 by Javier Campos Morales
6 email : javi@asyris.org
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #include "kradioeduca.h"
19 #include "kradioeduca.moc"
20 #include <qstyle.h>
21 #include <kaccelmanager.h>
23 KRadioEduca::KRadioEduca(QWidget *parent, const char *name) : QRadioButton(parent,name)
25 _doc=0;
26 KAcceleratorManager::setNoAccel(this);
29 KRadioEduca::~KRadioEduca()
31 delete _doc;
34 /** reimpl */
35 void KRadioEduca::drawButtonLabel( QPainter *p)
37 int x, y, w, h;
38 int extra_width, indicator_width;
39 extra_width = 8;
40 indicator_width = style().pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, 0);
42 y = 0;
43 x = indicator_width + extra_width; //###
44 w = width() - x;
45 h = height();
47 QRect cr(x,y,w,h);
49 _doc = new QSimpleRichText( text(), font() );
50 _doc->setWidth( 10 );
52 _doc->setWidth(p, cr.width() );
53 int rw = _doc->widthUsed() + extra_width;
54 int rh = _doc->height();
55 int xo = 0;
56 int yo = 0;
58 resize( width(), rh);
60 yo = (cr.height()-rh)/2;
62 if (!isEnabled() ) {
63 QColorGroup cg = colorGroup();
64 cg.setColor( QColorGroup::Text, cg.light() );
65 _doc->draw(p, cr.x()+xo+1, cr.y()+yo+1, cr, cg, 0);
67 _doc->draw(p, cr.x()+xo, cr.y()+yo, cr, colorGroup(), 0);
69 if ( hasFocus() ) {
70 // QRect br = style().itemRect( p, x, y, rw, rh+yo,
71 // AlignLeft|AlignVCenter|ShowPrefix,
72 // isEnabled(),
73 // pixmap(), text().visual() );
74 QRect br(x,y,rw,rh+yo);
76 br.setLeft( br.left()-3 );
77 br.setRight( br.right()+2 );
78 br.setTop( br.top()-2 );
79 br.setBottom( br.bottom()+2);
80 br = br.intersect( QRect(0,0,rw, rh+yo ) );
81 style().drawPrimitive( QStyle::PE_FocusRect, p, br, colorGroup());