source: trunk/src/gui/widgets/qabstractbutton.h@ 858

Last change on this file since 858 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 5.8 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
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** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
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
49QT_BEGIN_HEADER
50
51QT_BEGIN_NAMESPACE
52
53QT_MODULE(Gui)
54
55class QButtonGroup;
56class QAbstractButtonPrivate;
57
58class 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
76public:
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
117public 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
124Q_SIGNALS:
125 void pressed();
126 void released();
127 void clicked(bool checked = false);
128 void toggled(bool checked);
129
130protected:
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
148public:
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
163public Q_SLOTS:
164 inline QT_MOC_COMPAT void setOn(bool b) { setChecked(b); }
165#endif
166
167protected:
168 QAbstractButton(QAbstractButtonPrivate &dd, QWidget* parent = 0);
169
170private:
171 Q_DECLARE_PRIVATE(QAbstractButton)
172 Q_DISABLE_COPY(QAbstractButton)
173 friend class QButtonGroup;
174};
175
176QT_END_NAMESPACE
177
178QT_END_HEADER
179
180#endif // QABSTRACTBUTTON_H
Note: See TracBrowser for help on using the repository browser.