~ubuntu-branches/ubuntu/dapper/lmms/dapper

« back to all changes in this revision

Viewing changes to src/widgets/led_checkbox.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ragwitz
  • Date: 2005-12-22 16:22:50 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051222162250-key3p7x0212jy6dn
Tags: 0.1.2-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * led_checkbox.cpp - class ledCheckBox, an improved QCheckBox
3
3
 *
4
 
 * Linux MultiMedia Studio
5
 
 * Copyright (c) 2004-2005 Tobias Doerffel <tobydox@users.sourceforge.net>
 
4
 * Copyright (c) 2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
 
5
 * 
 
6
 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
6
7
 *
7
8
 * This program is free software; you can redistribute it and/or
8
9
 * modify it under the terms of the GNU General Public
35
36
#include <qfontmetrics.h>
36
37
#include <qpainter.h>
37
38
 
38
 
#define setChecked setOn
39
 
#define isChecked isOn
40
 
 
41
39
#endif
42
40
 
43
41
 
44
42
#include "led_checkbox.h"
45
43
#include "embed.h"
46
 
#include "templates.h"
 
44
#include "gui_templates.h"
47
45
#include "spc_bg_hndl_widget.h"
48
46
 
49
47
 
56
54
 
57
55
ledCheckBox::ledCheckBox( const QString & _text, QWidget * _parent,
58
56
                                                        ledColors _color ) :
59
 
        QCheckBox( _text, _parent )
 
57
        QWidget( _parent ),
 
58
        m_checked( FALSE ),
 
59
        m_text( _text )
60
60
{
61
61
        if( _color >= TOTAL_COLORS || _color < YELLOW )
62
62
        {
70
70
        m_ledOffPixmap = new QPixmap( embed::getIconPixmap( "led_off" ) );
71
71
 
72
72
#ifndef QT4
73
 
        setBackgroundMode( Qt::NoBackground );
 
73
        setBackgroundMode( Qt::PaletteBackground );
74
74
#endif
75
75
 
76
76
        setFont( pointSize<7>( font() ) );
91
91
 
92
92
 
93
93
 
 
94
void ledCheckBox::mousePressEvent( QMouseEvent * _me )
 
95
{
 
96
        if( _me->button() == Qt::LeftButton )
 
97
        {
 
98
                toggle();
 
99
        }
 
100
}
 
101
        
 
102
        
 
103
        
 
104
        
 
105
void ledCheckBox::toggle( void )
 
106
{
 
107
        m_checked = !m_checked;
 
108
        update();
 
109
        emit( toggled( m_checked ) );
 
110
}
 
111
 
 
112
 
 
113
 
 
114
 
 
115
void ledCheckBox::setChecked( bool _on )
 
116
{
 
117
        if( _on != isChecked() )
 
118
        {
 
119
                toggle();
 
120
        }
 
121
        else
 
122
        {
 
123
                emit( toggled( m_checked ) );
 
124
        }
 
125
}
 
126
 
 
127
 
 
128
 
 
129
 
94
130
void ledCheckBox::paintEvent( QPaintEvent * )
95
131
{
96
132
#ifdef QT4
97
133
        QPainter p( this );
98
134
#else
99
135
        QPixmap draw_pm( rect().size() );
100
 
        draw_pm.fill( this, rect().topLeft() );
 
136
        //draw_pm.fill( this, rect().topLeft() );
101
137
 
102
138
        QPainter p( &draw_pm, this );
103
139
#endif
104
140
        p.drawPixmap( 0, 0, specialBgHandlingWidget::getBackground( this ) );
105
141
 
106
 
#ifdef QT4
107
 
        if( checkState() == Qt::Checked )
108
 
#else
109
 
        if( state() == On )
110
 
#endif
 
142
        if( isChecked() == TRUE )
111
143
        {
112
144
                p.drawPixmap( 0, 0, *m_ledOnPixmap );
113
145
        }
125
157
}
126
158
 
127
159
 
128
 
#undef setChecked
129
 
#undef isChecked
130
160
 
 
161
#include "led_checkbox.moc"