| 1 | /* |
|---|
| 2 | * Hydrogen |
|---|
| 3 | * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net] |
|---|
| 4 | * |
|---|
| 5 | * http://www.hydrogen-music.org |
|---|
| 6 | * |
|---|
| 7 | * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | * it under the terms of the GNU General Public License as published by |
|---|
| 9 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | * (at your option) any later version. |
|---|
| 11 | * |
|---|
| 12 | * This program is distributed in the hope that it will be useful, |
|---|
| 13 | * but WITHOUT ANY WARRANTY, without even the implied warranty of |
|---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | * GNU General Public License for more details. |
|---|
| 16 | * |
|---|
| 17 | * You should have received a copy of the GNU General Public License |
|---|
| 18 | * along with this program; if not, write to the Free Software |
|---|
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 20 | * |
|---|
| 21 | */ |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | #ifndef BUTTON_H |
|---|
| 25 | #define BUTTON_H |
|---|
| 26 | |
|---|
| 27 | #include "config.h" |
|---|
| 28 | |
|---|
| 29 | #include <hydrogen/Object.h> |
|---|
| 30 | #include <hydrogen/action.h> |
|---|
| 31 | |
|---|
| 32 | #include "MidiLearnable.h" |
|---|
| 33 | |
|---|
| 34 | #include <QtGui> |
|---|
| 35 | |
|---|
| 36 | class PixmapWidget; |
|---|
| 37 | |
|---|
| 38 | /** |
|---|
| 39 | * Generic Button with pixmaps and text. |
|---|
| 40 | */ |
|---|
| 41 | class Button : public QWidget, public Object, public MidiLearnable |
|---|
| 42 | { |
|---|
| 43 | Q_OBJECT |
|---|
| 44 | |
|---|
| 45 | public: |
|---|
| 46 | Button( |
|---|
| 47 | QWidget *pParent, |
|---|
| 48 | const QString& sOnImg, |
|---|
| 49 | const QString& sOffImg, |
|---|
| 50 | const QString& sOverImg, |
|---|
| 51 | QSize size, |
|---|
| 52 | bool use_skin_style = false |
|---|
| 53 | ); |
|---|
| 54 | virtual ~Button(); |
|---|
| 55 | |
|---|
| 56 | bool isPressed() { return m_bPressed; } |
|---|
| 57 | void setPressed(bool pressed); |
|---|
| 58 | |
|---|
| 59 | void setText( const QString& sText ); |
|---|
| 60 | void setFontSize( int size ); |
|---|
| 61 | |
|---|
| 62 | signals: |
|---|
| 63 | void clicked(Button *pBtn); |
|---|
| 64 | void rightClicked(Button *pBtn); |
|---|
| 65 | void mousePress(Button *pBtn); |
|---|
| 66 | |
|---|
| 67 | protected: |
|---|
| 68 | bool m_bPressed; |
|---|
| 69 | |
|---|
| 70 | QFont m_textFont; |
|---|
| 71 | QString m_sText; |
|---|
| 72 | |
|---|
| 73 | QPixmap m_onPixmap; |
|---|
| 74 | QPixmap m_offPixmap; |
|---|
| 75 | QPixmap m_overPixmap; |
|---|
| 76 | |
|---|
| 77 | private: |
|---|
| 78 | bool m_bMouseOver; |
|---|
| 79 | bool __use_skin_style; |
|---|
| 80 | |
|---|
| 81 | void mousePressEvent(QMouseEvent *ev); |
|---|
| 82 | void mouseReleaseEvent(QMouseEvent *ev); |
|---|
| 83 | void enterEvent(QEvent *ev); |
|---|
| 84 | void leaveEvent(QEvent *ev); |
|---|
| 85 | void paintEvent( QPaintEvent* ev); |
|---|
| 86 | |
|---|
| 87 | bool loadImage( const QString& sFilename, QPixmap& pixmap ); |
|---|
| 88 | }; |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | /** |
|---|
| 94 | * A ToggleButton (On/Off). |
|---|
| 95 | */ |
|---|
| 96 | class ToggleButton : public Button |
|---|
| 97 | { |
|---|
| 98 | Q_OBJECT |
|---|
| 99 | |
|---|
| 100 | public: |
|---|
| 101 | ToggleButton( QWidget *pParent, const QString& sOnImg, const QString& sOffImg, const QString& sOverImg, QSize size, bool use_skin_style = false ); |
|---|
| 102 | ~ToggleButton(); |
|---|
| 103 | |
|---|
| 104 | private: |
|---|
| 105 | void mousePressEvent( QMouseEvent *ev ); |
|---|
| 106 | void mouseReleaseEvent( QMouseEvent *ev ); |
|---|
| 107 | }; |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | #endif |
|---|