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