author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 21 Apr 2010 20:15:53 +0300 | |
branch | RCL_3 |
changeset 14 | c0432d11811c |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#ifndef QABSTRACTBUTTON_H |
|
43 |
#define QABSTRACTBUTTON_H |
|
44 |
||
45 |
#include <QtGui/qicon.h> |
|
46 |
#include <QtGui/qkeysequence.h> |
|
47 |
#include <QtGui/qwidget.h> |
|
48 |
||
49 |
QT_BEGIN_HEADER |
|
50 |
||
51 |
QT_BEGIN_NAMESPACE |
|
52 |
||
53 |
QT_MODULE(Gui) |
|
54 |
||
55 |
class QButtonGroup; |
|
56 |
class QAbstractButtonPrivate; |
|
57 |
||
58 |
class Q_GUI_EXPORT QAbstractButton : public QWidget |
|
59 |
{ |
|
60 |
Q_OBJECT |
|
61 |
||
62 |
Q_PROPERTY(QString text READ text WRITE setText) |
|
63 |
Q_PROPERTY(QIcon icon READ icon WRITE setIcon) |
|
64 |
Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize) |
|
65 |
#ifndef QT_NO_SHORTCUT |
|
66 |
Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut) |
|
67 |
#endif |
|
68 |
Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable) |
|
69 |
Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled USER true) |
|
70 |
Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat) |
|
71 |
Q_PROPERTY(bool autoExclusive READ autoExclusive WRITE setAutoExclusive) |
|
72 |
Q_PROPERTY(int autoRepeatDelay READ autoRepeatDelay WRITE setAutoRepeatDelay) |
|
73 |
Q_PROPERTY(int autoRepeatInterval READ autoRepeatInterval WRITE setAutoRepeatInterval) |
|
74 |
Q_PROPERTY(bool down READ isDown WRITE setDown DESIGNABLE false) |
|
75 |
||
76 |
public: |
|
77 |
explicit QAbstractButton(QWidget* parent=0); |
|
78 |
~QAbstractButton(); |
|
79 |
||
80 |
void setText(const QString &text); |
|
81 |
QString text() const; |
|
82 |
||
83 |
void setIcon(const QIcon &icon); |
|
84 |
QIcon icon() const; |
|
85 |
||
86 |
QSize iconSize() const; |
|
87 |
||
88 |
#ifndef QT_NO_SHORTCUT |
|
89 |
void setShortcut(const QKeySequence &key); |
|
90 |
QKeySequence shortcut() const; |
|
91 |
#endif |
|
92 |
||
93 |
void setCheckable(bool); |
|
94 |
bool isCheckable() const; |
|
95 |
||
96 |
bool isChecked() const; |
|
97 |
||
98 |
void setDown(bool); |
|
99 |
bool isDown() const; |
|
100 |
||
101 |
void setAutoRepeat(bool); |
|
102 |
bool autoRepeat() const; |
|
103 |
||
104 |
void setAutoRepeatDelay(int); |
|
105 |
int autoRepeatDelay() const; |
|
106 |
||
107 |
void setAutoRepeatInterval(int); |
|
108 |
int autoRepeatInterval() const; |
|
109 |
||
110 |
void setAutoExclusive(bool); |
|
111 |
bool autoExclusive() const; |
|
112 |
||
113 |
#ifndef QT_NO_BUTTONGROUP |
|
114 |
QButtonGroup *group() const; |
|
115 |
#endif |
|
116 |
||
117 |
public Q_SLOTS: |
|
118 |
void setIconSize(const QSize &size); |
|
119 |
void animateClick(int msec = 100); |
|
120 |
void click(); |
|
121 |
void toggle(); |
|
122 |
void setChecked(bool); |
|
123 |
||
124 |
Q_SIGNALS: |
|
125 |
void pressed(); |
|
126 |
void released(); |
|
127 |
void clicked(bool checked = false); |
|
128 |
void toggled(bool checked); |
|
129 |
||
130 |
protected: |
|
131 |
virtual void paintEvent(QPaintEvent *e) = 0; |
|
132 |
virtual bool hitButton(const QPoint &pos) const; |
|
133 |
virtual void checkStateSet(); |
|
134 |
virtual void nextCheckState(); |
|
135 |
||
136 |
bool event(QEvent *e); |
|
137 |
void keyPressEvent(QKeyEvent *e); |
|
138 |
void keyReleaseEvent(QKeyEvent *e); |
|
139 |
void mousePressEvent(QMouseEvent *e); |
|
140 |
void mouseReleaseEvent(QMouseEvent *e); |
|
141 |
void mouseMoveEvent(QMouseEvent *e); |
|
142 |
void focusInEvent(QFocusEvent *e); |
|
143 |
void focusOutEvent(QFocusEvent *e); |
|
144 |
void changeEvent(QEvent *e); |
|
145 |
void timerEvent(QTimerEvent *e); |
|
146 |
||
147 |
#ifdef QT3_SUPPORT |
|
148 |
public: |
|
149 |
QT3_SUPPORT_CONSTRUCTOR QAbstractButton(QWidget *parent, const char *name, Qt::WindowFlags f=0); |
|
150 |
inline QT3_SUPPORT bool isOn() const { return isChecked(); } |
|
151 |
inline QT3_SUPPORT const QPixmap *pixmap() const { return 0; } // help styles compile |
|
152 |
inline QT3_SUPPORT void setPixmap( const QPixmap &p ) { |
|
153 |
setIcon(QIcon(p)); |
|
154 |
setIconSize(p.size()); |
|
155 |
} |
|
156 |
QT3_SUPPORT QIcon *iconSet() const; |
|
157 |
inline QT3_SUPPORT void setIconSet(const QIcon &icon) { setIcon(icon); } |
|
158 |
inline QT3_SUPPORT bool isToggleButton() const { return isCheckable(); } |
|
159 |
inline QT3_SUPPORT void setToggleButton(bool b) { setCheckable(b); } |
|
160 |
inline QT3_SUPPORT void setAccel(const QKeySequence &key) { setShortcut(key); } |
|
161 |
inline QT3_SUPPORT QKeySequence accel() const { return shortcut(); } |
|
162 |
||
163 |
public Q_SLOTS: |
|
164 |
inline QT_MOC_COMPAT void setOn(bool b) { setChecked(b); } |
|
165 |
#endif |
|
166 |
||
167 |
protected: |
|
168 |
QAbstractButton(QAbstractButtonPrivate &dd, QWidget* parent = 0); |
|
169 |
||
170 |
private: |
|
171 |
Q_DECLARE_PRIVATE(QAbstractButton) |
|
172 |
Q_DISABLE_COPY(QAbstractButton) |
|
173 |
friend class QButtonGroup; |
|
174 |
}; |
|
175 |
||
176 |
QT_END_NAMESPACE |
|
177 |
||
178 |
QT_END_HEADER |
|
179 |
||
180 |
#endif // QABSTRACTBUTTON_H |