1 /****************************************************************************
2 **
3 ** DQt - D bindings for the Qt Toolkit
4 **
5 ** GNU Lesser General Public License Usage
6 ** This file may be used under the terms of the GNU Lesser
7 ** General Public License version 3 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
9 ** packaging of this file. Please review the following information to
10 ** ensure the GNU Lesser General Public License version 3 requirements
11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
12 **
13 ****************************************************************************/
14 module qt.widgets.abstractbutton;
15 extern(C++):
16 
17 import qt.config;
18 import qt.core.coreevent;
19 import qt.core.point;
20 import qt.core.size;
21 import qt.core.string;
22 import qt.gui.event;
23 import qt.gui.icon;
24 import qt.helpers;
25 import qt.widgets.buttongroup;
26 import qt.widgets.widget;
27 version(QT_NO_SHORTCUT){}else
28     import qt.gui.keysequence;
29 
30 /+ QT_REQUIRE_CONFIG(abstractbutton);
31 
32 
33 
34 class QButtonGroup; +/
35 extern(C++, class) struct QAbstractButtonPrivate;
36 
37 class /+ Q_WIDGETS_EXPORT +/ QAbstractButton : QWidget
38 {
39     mixin(Q_OBJECT);
40 
41     /+ Q_PROPERTY(QString text READ text WRITE setText)
42     Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
43     Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
44 #ifndef QT_NO_SHORTCUT
45     Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut)
46 #endif
47     Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable)
48     Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY toggled USER true)
49     Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat)
50     Q_PROPERTY(bool autoExclusive READ autoExclusive WRITE setAutoExclusive)
51     Q_PROPERTY(int autoRepeatDelay READ autoRepeatDelay WRITE setAutoRepeatDelay)
52     Q_PROPERTY(int autoRepeatInterval READ autoRepeatInterval WRITE setAutoRepeatInterval)
53     Q_PROPERTY(bool down READ isDown WRITE setDown DESIGNABLE false) +/
54 
55 public:
56     /+ explicit +/this(QWidget parent = null);
57     ~this();
58 
59     final void setText(ref const(QString) text);
60     final void setText(const QString s){setText(s);}
61     final QString text() const;
62 
63     final void setIcon(ref const(QIcon) icon);
64     final QIcon icon() const;
65 
66     final QSize iconSize() const;
67 
68     version(QT_NO_SHORTCUT){}else
69     {
70         final void setShortcut(ref const(QKeySequence) key);
71         final QKeySequence shortcut() const;
72     }
73 
74     final void setCheckable(bool);
75     final bool isCheckable() const;
76 
77     final bool isChecked() const;
78 
79     final void setDown(bool);
80     final bool isDown() const;
81 
82     final void setAutoRepeat(bool);
83     final bool autoRepeat() const;
84 
85     final void setAutoRepeatDelay(int);
86     final int autoRepeatDelay() const;
87 
88     final void setAutoRepeatInterval(int);
89     final int autoRepeatInterval() const;
90 
91     final void setAutoExclusive(bool);
92     final bool autoExclusive() const;
93 
94 /+ #if QT_CONFIG(buttongroup) +/
95     final QButtonGroup group() const;
96 /+ #endif +/
97 
98 public /+ Q_SLOTS +/:
99     @QSlot final void setIconSize(ref const(QSize) size);
100     @QSlot final void animateClick(int msec = 100);
101     @QSlot final void click();
102     @QSlot final void toggle();
103     @QSlot final void setChecked(bool);
104 
105 /+ Q_SIGNALS +/public:
106     @QSignal final void pressed();
107     @QSignal final void released();
108     @QSignal final void clicked(bool checked = false);
109     @QSignal final void toggled(bool checked);
110 
111 protected:
112     abstract override void paintEvent(QPaintEvent e);
113     /+ virtual +/ bool hitButton(ref const(QPoint) pos) const;
114     /+ virtual +/ void checkStateSet();
115     /+ virtual +/ void nextCheckState();
116 
117     override bool event(QEvent e);
118     override void keyPressEvent(QKeyEvent e);
119     override void keyReleaseEvent(QKeyEvent e);
120     override void mousePressEvent(QMouseEvent e);
121     override void mouseReleaseEvent(QMouseEvent e);
122     override void mouseMoveEvent(QMouseEvent e);
123     override void focusInEvent(QFocusEvent e);
124     override void focusOutEvent(QFocusEvent e);
125     override void changeEvent(QEvent e);
126     override void timerEvent(QTimerEvent e);
127 
128 
129 protected:
130     this(ref QAbstractButtonPrivate dd, QWidget parent = null);
131 
132 private:
133     /+ Q_DECLARE_PRIVATE(QAbstractButton) +/
134     /+ Q_DISABLE_COPY(QAbstractButton) +/
135     /+ friend class QButtonGroup; +/
136 }
137