~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/gui/widgets/qabstractbutton.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the widgets module of the Qt Toolkit.
 
6
**
 
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.
 
10
**
 
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.
 
15
**
 
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.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
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.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef QABSTRACTBUTTON_H
 
30
#define QABSTRACTBUTTON_H
 
31
 
 
32
#include "QtGui/qicon.h"
 
33
#include "QtGui/qkeysequence.h"
 
34
#include "QtGui/qwidget.h"
 
35
 
 
36
class QButtonGroup;
 
37
class QAbstractButtonPrivate;
 
38
 
 
39
class Q_GUI_EXPORT QAbstractButton : public QWidget
 
40
{
 
41
    Q_OBJECT
 
42
 
 
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)
 
52
 
 
53
public:
 
54
    explicit QAbstractButton(QWidget* parent=0);
 
55
    ~QAbstractButton();
 
56
 
 
57
    void setText(const QString &text);
 
58
    QString text() const;
 
59
 
 
60
    void setIcon(const QIcon &icon);
 
61
    QIcon icon() const;
 
62
 
 
63
    QSize iconSize() const;
 
64
 
 
65
    void setShortcut(const QKeySequence &key);
 
66
    QKeySequence shortcut() const;
 
67
 
 
68
    void setCheckable(bool);
 
69
    bool isCheckable() const;
 
70
 
 
71
    bool isChecked() const;
 
72
 
 
73
    void setDown(bool);
 
74
    bool isDown() const;
 
75
 
 
76
    void setAutoRepeat(bool);
 
77
    bool autoRepeat() const;
 
78
 
 
79
    void setAutoExclusive(bool);
 
80
    bool autoExclusive() const;
 
81
 
 
82
    QButtonGroup *group() const;
 
83
 
 
84
public slots:
 
85
    void setIconSize(const QSize &size);
 
86
    void animateClick(int msec = 100);
 
87
    void click();
 
88
    void toggle();
 
89
    void setChecked(bool);
 
90
 
 
91
signals:
 
92
    void pressed();
 
93
    void released();
 
94
    void clicked(bool checked = false);
 
95
    void toggled(bool checked);
 
96
 
 
97
protected:
 
98
    virtual void paintEvent(QPaintEvent *e) = 0;
 
99
    virtual bool hitButton(const QPoint &pos) const;
 
100
    virtual void checkStateSet();
 
101
    virtual void nextCheckState();
 
102
 
 
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);
 
113
 
 
114
#ifdef QT3_SUPPORT
 
115
public:
 
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(); }
 
126
 
 
127
public slots:
 
128
    inline QT_MOC_COMPAT void setOn(bool b) { setChecked(b); }
 
129
#endif
 
130
 
 
131
protected:
 
132
    QAbstractButton(QAbstractButtonPrivate &dd, QWidget* parent = 0);
 
133
 
 
134
private:
 
135
    Q_DECLARE_PRIVATE(QAbstractButton)
 
136
    Q_DISABLE_COPY(QAbstractButton)
 
137
    friend class QButtonGroup;
 
138
};
 
139
 
 
140
#endif // QABSTRACTBUTTON_H