1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the widgets module of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
29
#ifndef QABSTRACTBUTTON_H
30
#define QABSTRACTBUTTON_H
32
#include "QtGui/qicon.h"
33
#include "QtGui/qkeysequence.h"
34
#include "QtGui/qwidget.h"
37
class QAbstractButtonPrivate;
39
class Q_GUI_EXPORT QAbstractButton : public QWidget
43
Q_PROPERTY(QString text READ text WRITE setText)
44
Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
45
Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
46
Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut)
47
Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable)
48
Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY toggled)
49
Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat)
50
Q_PROPERTY(bool autoExclusive READ autoExclusive WRITE setAutoExclusive)
51
Q_PROPERTY(bool down READ isDown WRITE setDown DESIGNABLE false)
54
explicit QAbstractButton(QWidget* parent=0);
57
void setText(const QString &text);
60
void setIcon(const QIcon &icon);
63
QSize iconSize() const;
65
void setShortcut(const QKeySequence &key);
66
QKeySequence shortcut() const;
68
void setCheckable(bool);
69
bool isCheckable() const;
71
bool isChecked() const;
76
void setAutoRepeat(bool);
77
bool autoRepeat() const;
79
void setAutoExclusive(bool);
80
bool autoExclusive() const;
82
QButtonGroup *group() const;
85
void setIconSize(const QSize &size);
86
void animateClick(int msec = 100);
89
void setChecked(bool);
94
void clicked(bool checked = false);
95
void toggled(bool checked);
98
virtual void paintEvent(QPaintEvent *e) = 0;
99
virtual bool hitButton(const QPoint &pos) const;
100
virtual void checkStateSet();
101
virtual void nextCheckState();
103
bool event(QEvent *e);
104
void keyPressEvent(QKeyEvent *e);
105
void keyReleaseEvent(QKeyEvent *e);
106
void mousePressEvent(QMouseEvent *e);
107
void mouseReleaseEvent(QMouseEvent *e);
108
void mouseMoveEvent(QMouseEvent *e);
109
void focusInEvent(QFocusEvent *e);
110
void focusOutEvent(QFocusEvent *e);
111
void changeEvent(QEvent *e);
112
void timerEvent(QTimerEvent *e);
116
QT3_SUPPORT_CONSTRUCTOR QAbstractButton(QWidget *parent, const char *name, Qt::WFlags f=0);
117
inline QT3_SUPPORT bool isOn() const { return isChecked(); }
118
inline QT3_SUPPORT const QPixmap *pixmap() const { return 0; } // help styles compile
119
inline QT3_SUPPORT void setPixmap( const QPixmap &p ) { setIcon(QIcon(p)); }
120
QT3_SUPPORT QIcon *iconSet() const;
121
inline QT3_SUPPORT void setIconSet(const QIcon &icon) { setIcon(icon); }
122
inline QT3_SUPPORT bool isToggleButton() const { return isCheckable(); }
123
inline QT3_SUPPORT void setToggleButton(bool b) { setCheckable(b); }
124
inline QT3_SUPPORT void setAccel(const QKeySequence &key) { setShortcut(key); }
125
inline QT3_SUPPORT QKeySequence accel() const { return shortcut(); }
128
inline QT_MOC_COMPAT void setOn(bool b) { setChecked(b); }
132
QAbstractButton(QAbstractButtonPrivate &dd, QWidget* parent = 0);
135
Q_DECLARE_PRIVATE(QAbstractButton)
136
Q_DISABLE_COPY(QAbstractButton)
137
friend class QButtonGroup;
140
#endif // QABSTRACTBUTTON_H