]> git.sur5r.net Git - minitube/blob - src/segmentedcontrol.h
Imported Upstream version 2.1.3
[minitube] / src / segmentedcontrol.h
1 /* $BEGIN_LICENSE
2
3 This file is part of Minitube.
4 Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
5
6 Minitube is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 Minitube 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 Minitube.  If not, see <http://www.gnu.org/licenses/>.
18
19 $END_LICENSE */
20
21 #ifndef SEGMENTEDCONTROL_H
22 #define SEGMENTEDCONTROL_H
23
24 #include <QtGui>
25
26 class SegmentedControl : public QWidget {
27
28     Q_OBJECT
29
30 public:
31     SegmentedControl(QWidget *parent = 0);
32     ~SegmentedControl();
33     QAction *addAction(QAction *action);
34     bool setCheckedAction(int index);
35     bool setCheckedAction(QAction *action);
36     QSize minimumSizeHint(void) const;
37
38 signals:
39     void checkedActionChanged(QAction & action);
40
41 protected:
42     void paintEvent(QPaintEvent *event);
43     void mouseMoveEvent(QMouseEvent *event);
44     void mousePressEvent(QMouseEvent *event);
45     void mouseReleaseEvent(QMouseEvent *event);
46     void leaveEvent(QEvent *event);
47
48 private:
49     void drawButton(QPainter *painter,
50                     const QRect& rect,
51                     const QAction *action);
52     void drawUnselectedButton(QPainter *painter,
53                               const QRect& rect,
54                               const QAction *action);
55     void drawSelectedButton(QPainter *painter,
56                             const QRect& rect,
57                             const QAction *action);
58     void paintButton(QPainter *painter,
59                     const QRect& rect,
60                     const QAction *action);
61     QAction *hoveredAction(const QPoint& pos) const;
62     int calculateButtonWidth(void) const;
63
64     class Private;
65     Private *d;
66
67 };
68
69 #endif /* !SEGMENTEDCONTROL_H */