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.toolbutton; 15 extern(C++): 16 17 import qt.config; 18 import qt.core.coreevent; 19 import qt.core.namespace; 20 import qt.core.point; 21 import qt.core.size; 22 import qt.gui.event; 23 import qt.helpers; 24 import qt.widgets.abstractbutton; 25 import qt.widgets.action; 26 import qt.widgets.menu; 27 import qt.widgets.styleoption; 28 import qt.widgets.widget; 29 version(QT_NO_ACTION){}else 30 import qt.widgets.event; 31 32 /+ QT_REQUIRE_CONFIG(toolbutton); +/ 33 34 35 extern(C++, class) struct QToolButtonPrivate; 36 /+ class QMenu; 37 class QStyleOptionToolButton; +/ 38 39 class /+ Q_WIDGETS_EXPORT +/ QToolButton : QAbstractButton 40 { 41 mixin(Q_OBJECT); 42 /+ Q_ENUMS(Qt::ToolButtonStyle Qt::ArrowType) 43 #if QT_CONFIG(menu) 44 Q_PROPERTY(ToolButtonPopupMode popupMode READ popupMode WRITE setPopupMode) 45 #endif 46 Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle) 47 Q_PROPERTY(bool autoRaise READ autoRaise WRITE setAutoRaise) 48 Q_PROPERTY(Qt::ArrowType arrowType READ arrowType WRITE setArrowType) +/ 49 50 public: 51 enum ToolButtonPopupMode { 52 DelayedPopup, 53 MenuButtonPopup, 54 InstantPopup 55 } 56 /+ Q_ENUM(ToolButtonPopupMode) +/ 57 58 /+ explicit +/this(QWidget parent = null); 59 ~this(); 60 61 override QSize sizeHint() const; 62 override QSize minimumSizeHint() const; 63 64 final /+ Qt:: +/qt.core.namespace.ToolButtonStyle toolButtonStyle() const; 65 66 final /+ Qt:: +/qt.core.namespace.ArrowType arrowType() const; 67 final void setArrowType(/+ Qt:: +/qt.core.namespace.ArrowType type); 68 69 /+ #if QT_CONFIG(menu) +/ 70 final void setMenu(QMenu menu); 71 final QMenu menu() const; 72 73 final void setPopupMode(ToolButtonPopupMode mode); 74 final ToolButtonPopupMode popupMode() const; 75 /+ #endif +/ 76 77 final QAction defaultAction() const; 78 79 final void setAutoRaise(bool enable); 80 final bool autoRaise() const; 81 82 public /+ Q_SLOTS +/: 83 /+ #if QT_CONFIG(menu) +/ 84 @QSlot final void showMenu(); 85 /+ #endif +/ 86 @QSlot final void setToolButtonStyle(/+ Qt:: +/qt.core.namespace.ToolButtonStyle style); 87 @QSlot final void setDefaultAction(QAction ); 88 89 /+ Q_SIGNALS +/public: 90 @QSignal final void triggered(QAction ); 91 92 protected: 93 override bool event(QEvent e); 94 override void mousePressEvent(QMouseEvent ); 95 override void mouseReleaseEvent(QMouseEvent ); 96 override void paintEvent(QPaintEvent ); 97 override void actionEvent(QActionEvent ); 98 99 override void enterEvent(QEvent ); 100 override void leaveEvent(QEvent ); 101 override void timerEvent(QTimerEvent ); 102 override void changeEvent(QEvent ); 103 104 override bool hitButton(ref const(QPoint) pos) const; 105 override void nextCheckState(); 106 final void initStyleOption(QStyleOptionToolButton* option) const; 107 108 private: 109 /+ Q_DISABLE_COPY(QToolButton) +/ 110 /+ Q_DECLARE_PRIVATE(QToolButton) +/ 111 /+ #if QT_CONFIG(menu) 112 Q_PRIVATE_SLOT(d_func(), void _q_buttonPressed()) 113 Q_PRIVATE_SLOT(d_func(), void _q_buttonReleased()) 114 Q_PRIVATE_SLOT(d_func(), void _q_updateButtonDown()) 115 Q_PRIVATE_SLOT(d_func(), void _q_menuTriggered(QAction*)) 116 #endif 117 Q_PRIVATE_SLOT(d_func(), void _q_actionTriggered()) +/ 118 119 } 120