Cleaned up code and moved the new ZoomButtonPanel into master branch.
[situare] / src / ui / imagebutton.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Pekka Nissinen - pekka.nissinen@ixonos.com
6
7    Situare is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License
9    version 2 as published by the Free Software Foundation.
10
11    Situare is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with Situare; if not, write to the Free Software
18    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19    USA.
20 */
21
22 #ifndef IMAGEBUTTON_H
23 #define IMAGEBUTTON_H
24
25 #include <QIcon>
26 #include <QSize>
27 #include <QString>
28 #include <QPushButton>
29 #include <QMouseEvent>
30 #include <QPaintEvent>
31
32 /**
33  * @brief A simple class for icon button
34  *
35  * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
36  */
37 class ImageButton : public QPushButton
38 {
39     Q_OBJECT
40
41 public:
42     /**
43      * @brief Constructor
44      *
45      * @param parent Parent
46      * @param normalIconPictureFileName Normal state Icon image file name
47      * @param selectedIconPictureFileName Selected state Icon image file name (optional)
48      */
49     ImageButton(QWidget *parent = 0, QString normalIconPictureFileName = "",
50                 QString selectedIconPictureFileName = "");
51
52 /*******************************************************************************
53  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
54  ******************************************************************************/
55 protected:
56     /**
57      * @brief Event handler for mouse press events
58      *
59      * @param event Mouse event
60      */
61     void mousePressEvent(QMouseEvent *event);
62
63     /**
64      * @brief Event handler for mouse release events
65      *
66      * @param event Mouse event
67      */
68     void mouseReleaseEvent(QMouseEvent *event);
69
70     /**
71      * @brief Event handler for paint events
72      *
73      * Paints the button and its icon
74      * @param event Paint event
75      */
76     void paintEvent(QPaintEvent *event);
77
78 /*******************************************************************************
79  * MEMBER FUNCTIONS AND SLOTS
80  ******************************************************************************/
81 public:
82     /**
83      * @brief Sets the button icon mode
84      *
85      * @param mode Button icon mode
86      */
87     void setMode(QIcon::Mode mode);
88
89 /*******************************************************************************
90  * DATA MEMBERS
91  ******************************************************************************/
92 private:
93     QIcon::Mode m_buttonMode; ///< Button mode (Normal, Selected etc...)
94     QSize m_buttonSize; ///< Button size
95 };
96
97 #endif // IMAGEBUTTON_H