Debian Codegraph @

HercStudio/PanelButton.cpp

raw symbols SCIP
1 /*
2 * File: PanelButton.cpp
3 *
4 * Author: Jacob Dekel
5 * Created on: Aug 7, 2009
6 *
7 * Copyright (c) 2009-2013 Jacob Dekel
8 * $Id$
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24
25 #include "PanelButton.h"
26 #include "HerculesStudio.h"
27 #include "Environment.h"
28
29 #include <iostream>
30 #include <QPainter>
31 #include <QPixmap>
32
33
34 PanelButton::PanelButton(const QString& upButtonName, const QString& downButtonName, QWidget * parent) :
35 QPushButton(parent), mDown(false), mUpButtonName(upButtonName), mDownButtonName(downButtonName)
36
37 {
38 connect(this,SIGNAL(pressed()), this, SLOT(pressedSignal()));
39 connect(this,SIGNAL(released()), this, SLOT(releasedSignal()));
40 }
41
42 PanelButton::~PanelButton()
43 {
44
45 }
46
47 void PanelButton::replaceButton(const QString& upButtonName, const QString& downButtonName)
48 {
49 mUpButtonName = upButtonName;
50 mDownButtonName = downButtonName;
51 repaint();
52 }
53 void PanelButton::paintEvent(QPaintEvent *)
54 {
55 QString filename = mUpButtonName;
56 if (mDown)
57 filename = mDownButtonName;
58 QPixmap newPix(filename);
59 QPainter painter(this);
60 painter.drawPixmap(0, 0, newPix);
61 resize(33,25);
62 }
63
64 void PanelButton::pressedSignal()
65 {
66 mDown = true;
67 repaint();
68 }
69
70 void PanelButton::releasedSignal()
71 {
72 mDown = false;
73 repaint();
74 }
75
76