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