~ubuntu-branches/ubuntu/hoary/kvirc/hoary

« back to all changes in this revision

Viewing changes to src/kvilib/qt/kvi_toolbarbutton_qt.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Robin Verduijn
  • Date: 2004-12-14 15:32:19 UTC
  • mfrom: (0.2.1 upstream) (1.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20041214153219-fdink3gyp2s20b6g
Tags: 2:2.1.3.1-2
* Change Recommends on xmms to a Suggests.
* Rebuild against KDE 3.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// =============================================================================
 
2
//
 
3
//      --- kvi_toolbarbutton_qt.cpp ---
 
4
//
 
5
//   This file is part of the KVIrc IRC client distribution
 
6
//   Copyright (C) 1999-2000 Szymon Stefanek (stefanek@tin.it)
 
7
//   Copyright (C) 1999-2000 Till Busch (buti@geocities.com)
 
8
//
 
9
//   This program is FREE software. You can redistribute it and/or
 
10
//   modify it under the terms of the GNU General Public License
 
11
//   as published by the Free Software Foundation; either version 2
 
12
//   of the License, or (at your opinion) any later version.
 
13
//
 
14
//   This program is distributed in the HOPE that it will be USEFUL,
 
15
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
17
//   See the GNU General Public License for more details.
 
18
//
 
19
//   You should have received a copy of the GNU General Public License
 
20
//   along with this program. If not, write to the Free Software Foundation,
 
21
//   Inc, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
22
//
 
23
// =============================================================================
 
24
 
 
25
#define _KVI_DEBUG_CHECK_RANGE_
 
26
#define _KVI_DEBUG_CLASS_NAME_ "KviToolBarButton"
 
27
 
 
28
#include <qpainter.h>
 
29
#include <qstyle.h>
 
30
 
 
31
#include "kvi_iconloader.h"
 
32
#include "kvi_string.h"
 
33
#include "kvi_toolbar.h"
 
34
#include "kvi_toolbarbutton_qt.h"
 
35
 
 
36
KviToolBarButton::KviToolBarButton(QWidget *parent, const char *name)
 
37
        : QToolButton(parent, name)
 
38
{
 
39
        // Nothing here
 
40
}
 
41
 
 
42
KviToolBarButton::KviToolBarButton(
 
43
        const QString &icon, const char *textLabel, const char *groupText,
 
44
        QObject *receiver, const char *slot, KviToolBar *parent, const char *name)
 
45
        : QToolButton(
 
46
                KviIconLoader::loadIcon(icon), _CHAR_2_QSTRING(textLabel), _CHAR_2_QSTRING(groupText), receiver, slot, parent, name
 
47
        )
 
48
{
 
49
        setFocusPolicy(NoFocus);
 
50
}
 
51
 
 
52
KviToolBarButton::KviToolBarButton(
 
53
        const QPixmap &pm, const char *textLabel, const char *groupText,
 
54
        QObject *receiver, const char *slot, KviToolBar *parent, const char *name)
 
55
        : QToolButton(pm, _CHAR_2_QSTRING(textLabel), _CHAR_2_QSTRING(groupText), receiver, slot, parent, name)
 
56
{
 
57
        setFocusPolicy(NoFocus);
 
58
}
 
59
 
 
60
KviToolBarButton::~KviToolBarButton()
 
61
{
 
62
        // Nothing here
 
63
}
 
64
 
 
65
void KviToolBarButton::drawButton(QPainter *p)
 
66
{
 
67
        // Allow setting a background pixmap to the toolbar
 
68
        const QPixmap *pix = ((KviToolBar *) parent())->backgroundPixmap();
 
69
        if( pix ) {
 
70
                if( !pix->isNull() ) {
 
71
                        p->drawTiledPixmap(0, 0, width(), height(), *pix, x() % pix->width(), y() % pix->height());
 
72
                        if( uses3D() || isDown() || isOn() ) {
 
73
                                style().drawPrimitive(
 
74
                                        QStyle::PE_ButtonBevel, p, rect(), colorGroup(),
 
75
                                        (isOn() || isDown()) ? QStyle::Style_Sunken : QStyle::Style_Default
 
76
                                );
 
77
                        }
 
78
                        drawButtonLabel(p);
 
79
                        return;
 
80
                }
 
81
        }
 
82
        QToolButton::drawButton(p);
 
83
}
 
84
 
 
85
void KviToolBarButton::setIcon(const QString &icon)
 
86
{
 
87
        setPixmap(KviIconLoader::loadIcon(icon));
 
88
}
 
89
 
 
90
#include "m_kvi_toolbarbutton_qt.moc"