summaryrefslogtreecommitdiffstats
path: root/keduca/keduca/kradioeduca.cpp
blob: 94f26eebd45ca2c0ae317b89ca51c888b10e5e87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/***************************************************************************
                          kradioeduca.cpp  -  description
                             -------------------
    begin                : Wed Sep 6 2000
    copyright            : (C) 2000 by Javier Campos Morales
    email                : javi@asyris.org
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "kradioeduca.h"
#include "kradioeduca.moc"
#include <qstyle.h>
#include <kaccelmanager.h>

KRadioEduca::KRadioEduca(QWidget *parent, const char *name) : QRadioButton(parent,name)
{
    _doc=0;
    KAcceleratorManager::setNoAccel(this);
}

KRadioEduca::~KRadioEduca()
{
    delete _doc;
}

/** reimpl */
void KRadioEduca::drawButtonLabel( QPainter *p)
{
    int x, y, w, h;
    int extra_width, indicator_width;
    extra_width = 8;
    indicator_width = style().pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, 0);

    y = 0;
    x = indicator_width + extra_width; //###
    w = width() - x;
    h = height();

    QRect cr(x,y,w,h);

    _doc = new QSimpleRichText( text(), font() );
    _doc->setWidth( 10 );

    _doc->setWidth(p, cr.width() );
    int rw = _doc->widthUsed() + extra_width;
    int rh = _doc->height();
    int xo = 0;
    int yo = 0;

    resize( width(), rh);

    yo = (cr.height()-rh)/2;

    if (!isEnabled() ) {
        QColorGroup cg = colorGroup();
        cg.setColor( QColorGroup::Text, cg.light() );
        _doc->draw(p, cr.x()+xo+1, cr.y()+yo+1, cr, cg, 0);
    }
    _doc->draw(p, cr.x()+xo, cr.y()+yo, cr, colorGroup(), 0);

    if ( hasFocus() ) {
//	QRect br = style().itemRect( p, x, y, rw, rh+yo,
//				   AlignLeft|AlignVCenter|ShowPrefix,
//				   isEnabled(),
//				   pixmap(), text().visual() );
        QRect br(x,y,rw,rh+yo);

        br.setLeft( br.left()-3 );
        br.setRight( br.right()+2 );
        br.setTop( br.top()-2 );
        br.setBottom( br.bottom()+2);
        br = br.intersect( QRect(0,0,rw, rh+yo ) );
        style().drawPrimitive( QStyle::PE_FocusRect, p, br, colorGroup());
    }
}