moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / keduca / keduca / kcheckeduca.cpp
blob8fe6b557882e7903f403a0893cbcc3a3d3ee2ad3
1 /***************************************************************************
2 kcheckeduca.cpp - description
3 -------------------
4 begin : Tue Sep 5 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 "kcheckeduca.h"
19 #include "kcheckeduca.moc"
21 #include <qstyle.h>
22 #include <kaccelmanager.h>
24 KCheckEduca::KCheckEduca(QWidget *parent, const char *name ) : QCheckBox(parent,name)
26 _doc = 0;
27 KAcceleratorManager::setNoAccel( this );
30 KCheckEduca::~KCheckEduca()
32 delete _doc;
35 /** */
36 void KCheckEduca::drawButtonLabel( QPainter *p){
37 int x, y, w, h;
38 int extra_width, indicator_width;
40 extra_width = 8;
41 indicator_width = style().pixelMetric(QStyle::PM_IndicatorWidth, 0);
43 y = 0;
44 x = indicator_width + extra_width; //###
45 w = width() - x;
46 h = height();
48 QRect cr(x,y,w,h);
50 _doc = new QSimpleRichText( text(), font() );
51 _doc->setWidth( 10 );
53 _doc->setWidth(p, cr.width() );
54 int rw = _doc->widthUsed() + extra_width;
55 int rh = _doc->height();
56 int xo = 0;
57 int yo = 0;
59 resize( width(), rh);
61 yo = (cr.height()-rh)/2;
63 if ( !isEnabled() ) {
64 QColorGroup cg = colorGroup();
65 cg.setColor( QColorGroup::Text, cg.light() );
66 _doc->draw(p, cr.x()+xo+1, cr.y()+yo+1, cr, cg, 0);
68 _doc->draw(p, cr.x()+xo, cr.y()+yo, cr, colorGroup(), 0);
70 if ( hasFocus() ) {
71 // QRect br = style().itemRect( p, x, y, rw, rh+yo,
72 // AlignLeft|AlignVCenter|ShowPrefix,
73 // isEnabled(),
74 // pixmap(), text().visual() );
75 QRect br(x,y,rw,rh+yo);
77 br.setLeft( br.left()-3 );
78 br.setRight( br.right()+2 );
79 br.setTop( br.top()-2 );
80 br.setBottom( br.bottom()+2);
81 br = br.intersect( QRect(0,0,rw, rh+yo ) );
83 style().drawPrimitive( QStyle::PE_FocusRect, p, br, colorGroup());